[clang] [AArch64][Clang] Define __ARM_NEON_SVE_BRIDGE unconditionally (PR #118272)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 01:24:36 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: None (SpencerAbson)

<details>
<summary>Changes</summary>

The meaning of `__ARM_NEON_SVE_BRIDGE` was changed here:
https://github.com/ARM-software/acle/pull/362

Such that it should be defined to `1` if the `arm_neon_sve_bridge.h` header file is available, which is the case for Clang. 

---
Full diff: https://github.com/llvm/llvm-project/pull/118272.diff


4 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+3-3) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+1) 
- (modified) clang/test/Preprocessor/init-aarch64.c (+1) 
- (added) clang/test/Sema/aarch64-sve-intrinsics/acle_neon_sve_bridge.cpp (+15) 


``````````diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 4efc1841c836d0..b7d374c67f33ef 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -447,6 +447,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
   Builder.defineMacro("__ARM_FP16_FORMAT_IEEE", "1");
   Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
+  // Clang supports arm_neon_sve_bridge.h
+  Builder.defineMacro("__ARM_NEON_SVE_BRIDGE", "1");
+
   if (Opts.UnsafeFPMath)
     Builder.defineMacro("__ARM_FP_FAST", "1");
 
@@ -464,9 +467,6 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
   if (FPU & SveMode)
     Builder.defineMacro("__ARM_FEATURE_SVE", "1");
 
-  if ((FPU & NeonMode) && (FPU & SveMode))
-    Builder.defineMacro("__ARM_NEON_SVE_BRIDGE", "1");
-
   if (HasSVE2)
     Builder.defineMacro("__ARM_FEATURE_SVE2", "1");
 
diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c
index 037a3e186ee559..86265f630296c3 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -39,6 +39,7 @@
 // CHECK-NOT: __ARM_FP_FAST 1
 // CHECK: __ARM_NEON 1
 // CHECK: __ARM_NEON_FP 0xE
+// CHECK: __ARM_NEON_SVE_BRIDGE 1
 // CHECK: __ARM_PCS_AAPCS64 1
 // CHECK-NOT: __ARM_PCS 1
 // CHECK-NOT: __ARM_PCS_VFP 1
diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
index 8ee6c6ba60af43..3d2f4b83abcb88 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -30,6 +30,7 @@
 // AARCH64-NEXT: #define __ARM_FP 0xE
 // AARCH64-NEXT: #define __ARM_FP16_ARGS 1
 // AARCH64-NEXT: #define __ARM_FP16_FORMAT_IEEE 1
+// AARCH64-NEXT: #define __ARM_NEON_SVE_BRIDGE 1
 // AARCH64-NEXT: #define __ARM_PCS_AAPCS64 1
 // AARCH64-NEXT: #define __ARM_SIZEOF_MINIMAL_ENUM 4
 // AARCH64-NEXT: #define __ARM_SIZEOF_WCHAR_T 4
diff --git a/clang/test/Sema/aarch64-sve-intrinsics/acle_neon_sve_bridge.cpp b/clang/test/Sema/aarch64-sve-intrinsics/acle_neon_sve_bridge.cpp
new file mode 100644
index 00000000000000..a3f3764939156f
--- /dev/null
+++ b/clang/test/Sema/aarch64-sve-intrinsics/acle_neon_sve_bridge.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu  -verify -emit-llvm -o - %s
+// REQUIRES: aarch64-registered-target
+
+// Test that we can use __ARM_NEON_SVE_BRIDGE to guard to inclusion of arm_neon_sve_bridge.h,
+// and use the associated intrinsics via a target() attribute.
+
+// expected-no-diagnostics
+
+#ifdef __ARM_NEON_SVE_BRIDGE
+#include <arm_neon_sve_bridge.h>
+#endif
+
+uint32x4_t __attribute__((target("+sve"))) foo(svuint32_t a) {
+    return svget_neonq_u32(a);
+}
\ No newline at end of file

``````````

</details>


https://github.com/llvm/llvm-project/pull/118272


More information about the cfe-commits mailing list