Skip to content

Commit 895f71d

Browse files
committed
[SYCL] Allow neon attributes for ARM host
We permit neon attributes in CUDA device code, but this permission was only for CUDA device code. The same permission makes sense for SYCL device code as well, especially now that neon attributes are used in glibc headers.
1 parent 875e911 commit 895f71d

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

clang/lib/Sema/SemaType.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8077,10 +8077,10 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
80778077
/// match one of the standard Neon vector types.
80788078
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
80798079
Sema &S, VectorKind VecKind) {
8080-
bool IsTargetCUDAAndHostARM = false;
8081-
if (S.getLangOpts().CUDAIsDevice) {
8080+
bool IsTargetDeviceAndHostARM = false;
8081+
if (S.getLangOpts().CUDAIsDevice || S.getLangOpts().SYCLIsDevice) {
80828082
const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
8083-
IsTargetCUDAAndHostARM =
8083+
IsTargetDeviceAndHostARM =
80848084
AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM());
80858085
}
80868086

@@ -8090,7 +8090,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
80908090
S.Context.getTargetInfo().hasFeature("mve") ||
80918091
S.Context.getTargetInfo().hasFeature("sve") ||
80928092
S.Context.getTargetInfo().hasFeature("sme") ||
8093-
IsTargetCUDAAndHostARM) &&
8093+
IsTargetDeviceAndHostARM) &&
80948094
VecKind == VectorKind::Neon) {
80958095
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
80968096
<< Attr << "'neon', 'mve', 'sve' or 'sme'";
@@ -8099,7 +8099,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
80998099
}
81008100
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
81018101
S.Context.getTargetInfo().hasFeature("mve") ||
8102-
IsTargetCUDAAndHostARM) &&
8102+
IsTargetDeviceAndHostARM) &&
81038103
VecKind == VectorKind::NeonPoly) {
81048104
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
81058105
<< Attr << "'neon' or 'mve'";
@@ -8121,7 +8121,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
81218121

81228122
// Only certain element types are supported for Neon vectors.
81238123
if (!isPermittedNeonBaseType(CurType, VecKind, S) &&
8124-
!IsTargetCUDAAndHostARM) {
8124+
!IsTargetDeviceAndHostARM) {
81258125
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
81268126
Attr.setInvalid();
81278127
return;

clang/test/SemaSYCL/neon-attrs.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Host compilation on ARM with neon enabled (no errors expected).
2+
// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fsyntax-only -verify=quiet %s
3+
4+
// Host compilation on ARM with neon disabled.
5+
// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature -neon -fsyntax-only -verify %s
6+
7+
// Device compilation on ARM (no errors expected).
8+
// RUN: %clang_cc1 -triple spirv64 -aux-triple aarch64-linux-gnu -fsycl-is-device -fsyntax-only -verify=quiet %s
9+
10+
// quiet-no-diagnostics
11+
typedef __attribute__((neon_vector_type(4))) float float32x4_t;
12+
// expected-error@-1 {{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'}}
13+
typedef unsigned char poly8_t;
14+
typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t;
15+
// expected-error@-1 {{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'}}

0 commit comments

Comments
 (0)