[clang] [SYCL] Allow neon attributes for ARM host (PR #94229)
Harald van Dijk via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 23 05:20:51 PST 2024
https://github.com/hvdijk updated https://github.com/llvm/llvm-project/pull/94229
>From b1a53997e9378954da353ea1f0d8f03a8f19736f Mon Sep 17 00:00:00 2001
From: Harald van Dijk <harald.vandijk at codeplay.com>
Date: Mon, 23 Dec 2024 13:19:56 +0000
Subject: [PATCH] [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.
---
clang/lib/Sema/SemaType.cpp | 8 ++++----
clang/test/SemaSYCL/neon-attrs.cpp | 10 ++++++++++
2 files changed, 14 insertions(+), 4 deletions(-)
create mode 100644 clang/test/SemaSYCL/neon-attrs.cpp
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 83464c50b4b238..266f047b1a6836 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8287,10 +8287,10 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
/// match one of the standard Neon vector types.
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
Sema &S, VectorKind VecKind) {
- bool IsTargetCUDAAndHostARM = false;
- if (S.getLangOpts().CUDAIsDevice) {
+ bool IsTargetDeviceAndHostARM = false;
+ if (S.getLangOpts().CUDAIsDevice || S.getLangOpts().SYCLIsDevice) {
const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
- IsTargetCUDAAndHostARM =
+ IsTargetDeviceAndHostARM =
AuxTI && (AuxTI->getTriple().isAArch64() || AuxTI->getTriple().isARM());
}
@@ -8327,7 +8327,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
// Only certain element types are supported for Neon vectors.
if (!isPermittedNeonBaseType(CurType, VecKind, S) &&
- !IsTargetCUDAAndHostARM) {
+ !IsTargetDeviceAndHostARM) {
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
Attr.setInvalid();
return;
diff --git a/clang/test/SemaSYCL/neon-attrs.cpp b/clang/test/SemaSYCL/neon-attrs.cpp
new file mode 100644
index 00000000000000..fa9282e08947cf
--- /dev/null
+++ b/clang/test/SemaSYCL/neon-attrs.cpp
@@ -0,0 +1,10 @@
+// Host compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fsyntax-only -verify=quiet %s
+
+// Device compilation on ARM (no errors expected).
+// RUN: %clang_cc1 -triple spirv64 -aux-triple aarch64-linux-gnu -fsycl-is-device -fsyntax-only -verify=quiet %s
+
+// quiet-no-diagnostics
+typedef __attribute__((neon_vector_type(4))) float float32x4_t;
+typedef unsigned char poly8_t;
+typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t;
More information about the cfe-commits
mailing list