Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang] Remove preprocessor guards and global feature checks for NEON #95224

Merged
merged 7 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3246,6 +3246,9 @@ def warn_unsupported_target_attribute
def err_attribute_unsupported
: Error<"%0 attribute is not supported on targets missing %1;"
" specify an appropriate -march= or -mcpu=">;
def err_attribute_unsupported_m_profile
: Error<"on M-profile architectures %0 attribute is not supported on targets missing %1;"
" specify an appropriate -march= or -mcpu=">;
def err_duplicate_target_attribute
: Error<"%select{unsupported|duplicate|unknown}0%select{| CPU|"
" tune CPU}1 '%2' in the '%select{target|target_clones|target_version}3' "
Expand Down
24 changes: 10 additions & 14 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8203,23 +8203,19 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,

// Target must have NEON (or MVE, whose vectors are similar enough
// not to need a separate attribute)
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
S.Context.getTargetInfo().hasFeature("mve") ||
S.Context.getTargetInfo().hasFeature("sve") ||
S.Context.getTargetInfo().hasFeature("sme") ||
IsTargetCUDAAndHostARM) &&
VecKind == VectorKind::Neon) {
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
<< Attr << "'neon', 'mve', 'sve' or 'sme'";
if (!S.Context.getTargetInfo().hasFeature("mve") &&
VecKind == VectorKind::Neon &&
S.Context.getTargetInfo().getTriple().isArmMClass()) {
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile)
<< Attr << "'mve'";
Attr.setInvalid();
return;
}
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
S.Context.getTargetInfo().hasFeature("mve") ||
IsTargetCUDAAndHostARM) &&
VecKind == VectorKind::NeonPoly) {
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
<< Attr << "'neon' or 'mve'";
if (!S.Context.getTargetInfo().hasFeature("mve") &&
VecKind == VectorKind::NeonPoly &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wha happens if we have the original test(git show ed2d497), but without the neon check:
if (!(S.Context.getTargetInfo().hasFeature("mve") || IsTargetCUDAAndHostARM)){

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that wouldn't work as we would still get missing attribute error on aarch64 targets, as they don't have mve enabled.

S.Context.getTargetInfo().getTriple().isArmMClass()) {
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile)
<< Attr << "'mve'";
Attr.setInvalid();
return;
}
Expand Down
11 changes: 6 additions & 5 deletions clang/test/Sema/arm-vector-types-support.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify
// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify
// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify
// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type
// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type

typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}}
typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{on M-profile architectures 'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}}
typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // expected-error{{on M-profile architectures 'neon_polyvector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}}
typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}}
// sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}}
22 changes: 0 additions & 22 deletions clang/test/SemaCUDA/neon-attrs.cu

This file was deleted.

5 changes: 0 additions & 5 deletions clang/utils/TableGen/NeonEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2370,10 +2370,6 @@ void NeonEmitter::run(raw_ostream &OS) {
"Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";
OS << "#else\n\n";

OS << "#if !defined(__ARM_NEON)\n";
OS << "#error \"NEON support not enabled\"\n";
OS << "#else\n\n";

OS << "#include <stdint.h>\n\n";

OS << "#include <arm_bf16.h>\n";
Expand Down Expand Up @@ -2450,7 +2446,6 @@ void NeonEmitter::run(raw_ostream &OS) {
OS << "#undef __ai\n\n";
OS << "#endif /* if !defined(__ARM_NEON) */\n";
OS << "#endif /* ifndef __ARM_FP */\n";
OS << "#endif /* __ARM_NEON_H */\n";
}

/// run - Read the records in arm_fp16.td and output arm_fp16.h. arm_fp16.h
Expand Down
Loading