Skip to content

Commit

Permalink
[AArch64][Clang] Define __ARM_NEON_SVE_BRIDGE unconditionally (#118272)
Browse files Browse the repository at this point in the history
The meaning of `__ARM_NEON_SVE_BRIDGE` was changed here:
ARM-software/acle#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.
  • Loading branch information
SpencerAbson authored Dec 4, 2024
1 parent 04b26f0 commit 0adab6b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");

Expand Down
1 change: 1 addition & 0 deletions clang/test/Preprocessor/aarch64-target-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions clang/test/Preprocessor/init-aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions clang/test/Sema/aarch64-sve-intrinsics/acle_neon_sve_bridge.cpp
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 0adab6b

Please sign in to comment.