From: David Green Date: Wed, 4 Jan 2023 13:09:26 +0000 (+0000) Subject: [AArch64] Alter arm_neon_sve_bridge.h to be target-based, not preprocessor based. X-Git-Tag: upstream/17.0.6~22187 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=997852920d52442242fca9173a7b003b1164e26d;p=platform%2Fupstream%2Fllvm.git [AArch64] Alter arm_neon_sve_bridge.h to be target-based, not preprocessor based. Similar to D131064, this alters the arm_neon_sve_bridge.h header to use target-based intrinsics that give an error if used in a function that does not have the sve features, but are not preprocessed out. This header is simpler than the arm_sve.h and other headers, not including any tablegen'd content. The main change is altering the builtin definitions from using BUILTIN to TARGET_BUILTIN. Differential Revision: https://reviews.llvm.org/D132639 --- diff --git a/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def b/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def index 8e32299..b8bb054 100644 --- a/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def +++ b/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def @@ -1,39 +1,39 @@ #ifdef GET_SVE_BUILTINS -BUILTIN(__builtin_sve_svget_neonq_s8, "V16Scq16Sc", "n") -BUILTIN(__builtin_sve_svget_neonq_s16, "V8sq8s", "n") -BUILTIN(__builtin_sve_svget_neonq_s32, "V4iq4i", "n") -BUILTIN(__builtin_sve_svget_neonq_s64, "V2Wiq2Wi", "n") -BUILTIN(__builtin_sve_svget_neonq_u8, "V16Ucq16Uc", "n") -BUILTIN(__builtin_sve_svget_neonq_u16, "V16Usq16Us", "n") -BUILTIN(__builtin_sve_svget_neonq_u32, "V4Uiq4Ui", "n") -BUILTIN(__builtin_sve_svget_neonq_u64, "V2UWiq2UWi", "n") -BUILTIN(__builtin_sve_svget_neonq_f16, "V8hq8h", "n") -BUILTIN(__builtin_sve_svget_neonq_f32, "V4fq4f", "n") -BUILTIN(__builtin_sve_svget_neonq_f64, "V2dq2d", "n") -BUILTIN(__builtin_sve_svget_neonq_bf16, "V8yq8y", "n") -BUILTIN(__builtin_sve_svset_neonq_s8, "q16Scq16ScV16Sc", "n") -BUILTIN(__builtin_sve_svset_neonq_s16, "q8sq8sV8s", "n") -BUILTIN(__builtin_sve_svset_neonq_s32, "q4iq4iV4i", "n") -BUILTIN(__builtin_sve_svset_neonq_s64, "q2Wiq2WiV2Wi", "n") -BUILTIN(__builtin_sve_svset_neonq_u8, "q16Ucq16UcV16Uc", "n") -BUILTIN(__builtin_sve_svset_neonq_u16, "q8Usq8UsV8s", "n") -BUILTIN(__builtin_sve_svset_neonq_u32, "q4Uiq4UiV4Ui", "n") -BUILTIN(__builtin_sve_svset_neonq_u64, "q2UWiq2UWiV2UWi", "n") -BUILTIN(__builtin_sve_svset_neonq_f16, "q8hq8hV8h", "n") -BUILTIN(__builtin_sve_svset_neonq_f32, "q4fq4fV4f", "n") -BUILTIN(__builtin_sve_svset_neonq_f64, "q2dq2dV2d", "n") -BUILTIN(__builtin_sve_svset_neonq_bf16, "q8yq8yV8y", "n") -BUILTIN(__builtin_sve_svdup_neonq_s8, "q16ScV16Sc", "n") -BUILTIN(__builtin_sve_svdup_neonq_s16, "q8sV8s", "n") -BUILTIN(__builtin_sve_svdup_neonq_s32, "q4iV4i", "n") -BUILTIN(__builtin_sve_svdup_neonq_s64, "q4iV4i", "n") -BUILTIN(__builtin_sve_svdup_neonq_u8, "q16UcV16Uc", "n") -BUILTIN(__builtin_sve_svdup_neonq_u16, "q8UsV8Us", "n") -BUILTIN(__builtin_sve_svdup_neonq_u32, "q4UiV4Ui", "n") -BUILTIN(__builtin_sve_svdup_neonq_u64, "q2UWiV2UWi", "n") -BUILTIN(__builtin_sve_svdup_neonq_f16, "q8hV8h", "n") -BUILTIN(__builtin_sve_svdup_neonq_f32, "q4fV4f", "n") -BUILTIN(__builtin_sve_svdup_neonq_f64, "q2dV2d", "n") -BUILTIN(__builtin_sve_svdup_neonq_bf16, "q8yV8y", "n") +TARGET_BUILTIN(__builtin_sve_svget_neonq_s8, "V16Scq16Sc", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_s16, "V8sq8s", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_s32, "V4iq4i", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_s64, "V2Wiq2Wi", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_u8, "V16Ucq16Uc", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_u16, "V16Usq16Us", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_u32, "V4Uiq4Ui", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_u64, "V2UWiq2UWi", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_f16, "V8hq8h", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_f32, "V4fq4f", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_f64, "V2dq2d", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svget_neonq_bf16, "V8yq8y", "n", "sve,bf16") +TARGET_BUILTIN(__builtin_sve_svset_neonq_s8, "q16Scq16ScV16Sc", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_s16, "q8sq8sV8s", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_s32, "q4iq4iV4i", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_s64, "q2Wiq2WiV2Wi", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_u8, "q16Ucq16UcV16Uc", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_u16, "q8Usq8UsV8s", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_u32, "q4Uiq4UiV4Ui", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_u64, "q2UWiq2UWiV2UWi", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_f16, "q8hq8hV8h", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_f32, "q4fq4fV4f", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_f64, "q2dq2dV2d", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svset_neonq_bf16, "q8yq8yV8y", "n", "sve,bf16") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_s8, "q16ScV16Sc", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_s16, "q8sV8s", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_s32, "q4iV4i", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_s64, "q4iV4i", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_u8, "q16UcV16Uc", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_u16, "q8UsV8Us", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_u32, "q4UiV4Ui", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_u64, "q2UWiV2UWi", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_f16, "q8hV8h", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_f32, "q4fV4f", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_f64, "q2dV2d", "n", "sve") +TARGET_BUILTIN(__builtin_sve_svdup_neonq_bf16, "q8yV8y", "n", "sve,bf16") #endif diff --git a/clang/lib/Headers/arm_neon_sve_bridge.h b/clang/lib/Headers/arm_neon_sve_bridge.h index 17699d8..a9fbdba 100644 --- a/clang/lib/Headers/arm_neon_sve_bridge.h +++ b/clang/lib/Headers/arm_neon_sve_bridge.h @@ -159,7 +159,6 @@ svfloat32_t svdup_neonq_f32(float32x4_t); __ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f64))) svfloat64_t svdup_neonq_f64(float64x2_t); -#if defined(__ARM_FEATURE_SVE_BF16) __aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_bf16))) svbfloat16_t svset_neonq(svbfloat16_t, bfloat16x8_t); __ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_bf16))) @@ -172,7 +171,6 @@ __aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_bf16))) svbfloat16_t svdup_neonq(bfloat16x8_t); __ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_bf16))) svbfloat16_t svdup_neonq_bf16(bfloat16x8_t); -#endif // defined(__ARM_FEATURE_SVE_BF16) #undef __ai #undef __aio diff --git a/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c b/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c new file mode 100644 index 0000000..b5cbd24 --- /dev/null +++ b/clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/target.c @@ -0,0 +1,32 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon -S -verify -emit-llvm -o - %s + +#include + +__attribute__((target("sve"))) +void target_sve(svint8_t s, int8x16_t n) { + svset_neonq_s8(s, n); + svget_neonq_s8(s); + svdup_neonq_s8(n); +} + +__attribute__((target("sve,bf16"))) +void target_svebf16(svbfloat16_t t, bfloat16x8_t m) { + svset_neonq_bf16(t, m); + svget_neonq_bf16(t); + svdup_neonq_bf16(m); +} + +void base(int8x16_t n, bfloat16x8_t m) { + // expected-error@+1 {{'svundef_s8' needs target feature sve}} + svset_neonq_s8(svundef_s8(), n); // expected-error {{'svset_neonq_s8' needs target feature sve}} + // expected-error@+1 {{'svundef_s8' needs target feature sve}} + svget_neonq_s8(svundef_s8()); // expected-error {{'svget_neonq_s8' needs target feature sve}} + svdup_neonq_s8(n); // expected-error {{'svdup_neonq_s8' needs target feature sve}} + + // expected-error@+1 {{'svundef_bf16' needs target feature sve}} + svset_neonq_bf16(svundef_bf16(), m); // expected-error {{'svset_neonq_bf16' needs target feature sve,bf16}} + // expected-error@+1 {{'svundef_bf16' needs target feature sve}} + svget_neonq_bf16(svundef_bf16()); // expected-error {{'svget_neonq_bf16' needs target feature sve,bf16}} + svdup_neonq_bf16(m); // expected-error {{'svdup_neonq_bf16' needs target feature sve,bf16}} +}