Skip to content

Commit a174440

Browse files
LukacmaAlexisPerry
authored andcommitted
[Clang] Remove preprocessor guards and global feature checks for NEON (llvm#95224)
To enable function multi-versioning (FMV), current checks which rely on cmd line options or global macros to see if target feature is present need to be removed. This patch removes those for NEON and also implements changes to NEON header file as proposed in [ACLE](ARM-software/acle#321).
1 parent df04efa commit a174440

File tree

5 files changed

+19
-46
lines changed

5 files changed

+19
-46
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,6 +3246,9 @@ def warn_unsupported_target_attribute
32463246
def err_attribute_unsupported
32473247
: Error<"%0 attribute is not supported on targets missing %1;"
32483248
" specify an appropriate -march= or -mcpu=">;
3249+
def err_attribute_unsupported_m_profile
3250+
: Error<"on M-profile architectures %0 attribute is not supported on targets missing %1;"
3251+
" specify an appropriate -march= or -mcpu=">;
32493252
def err_duplicate_target_attribute
32503253
: Error<"%select{unsupported|duplicate|unknown}0%select{| CPU|"
32513254
" tune CPU}1 '%2' in the '%select{target|target_clones|target_version}3' "

clang/lib/Sema/SemaType.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8203,23 +8203,19 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
82038203

82048204
// Target must have NEON (or MVE, whose vectors are similar enough
82058205
// not to need a separate attribute)
8206-
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
8207-
S.Context.getTargetInfo().hasFeature("mve") ||
8208-
S.Context.getTargetInfo().hasFeature("sve") ||
8209-
S.Context.getTargetInfo().hasFeature("sme") ||
8210-
IsTargetCUDAAndHostARM) &&
8211-
VecKind == VectorKind::Neon) {
8212-
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
8213-
<< Attr << "'neon', 'mve', 'sve' or 'sme'";
8206+
if (!S.Context.getTargetInfo().hasFeature("mve") &&
8207+
VecKind == VectorKind::Neon &&
8208+
S.Context.getTargetInfo().getTriple().isArmMClass()) {
8209+
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile)
8210+
<< Attr << "'mve'";
82148211
Attr.setInvalid();
82158212
return;
82168213
}
8217-
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
8218-
S.Context.getTargetInfo().hasFeature("mve") ||
8219-
IsTargetCUDAAndHostARM) &&
8220-
VecKind == VectorKind::NeonPoly) {
8221-
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
8222-
<< Attr << "'neon' or 'mve'";
8214+
if (!S.Context.getTargetInfo().hasFeature("mve") &&
8215+
VecKind == VectorKind::NeonPoly &&
8216+
S.Context.getTargetInfo().getTriple().isArmMClass()) {
8217+
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported_m_profile)
8218+
<< Attr << "'mve'";
82238219
Attr.setInvalid();
82248220
return;
82258221
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
2-
// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify
3-
// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify
1+
// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify
2+
// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type
3+
// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type
44

5-
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=}}
6-
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=}}
5+
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=}}
6+
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=}}
77
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=}}
8+
// sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}}

clang/test/SemaCUDA/neon-attrs.cu

Lines changed: 0 additions & 22 deletions
This file was deleted.

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,10 +2370,6 @@ void NeonEmitter::run(raw_ostream &OS) {
23702370
"Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";
23712371
OS << "#else\n\n";
23722372

2373-
OS << "#if !defined(__ARM_NEON)\n";
2374-
OS << "#error \"NEON support not enabled\"\n";
2375-
OS << "#else\n\n";
2376-
23772373
OS << "#include <stdint.h>\n\n";
23782374

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

24562451
/// run - Read the records in arm_fp16.td and output arm_fp16.h. arm_fp16.h

0 commit comments

Comments
 (0)