diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc index e296c73350f1..e47b6a870e20 100644 --- a/gcc/config/aarch64/aarch64-c.cc +++ b/gcc/config/aarch64/aarch64-c.cc @@ -195,6 +195,8 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v); } + aarch64_def_or_undef (TARGET_PAUTH, "__ARM_FEATURE_PAUTH", pfile); + aarch64_def_or_undef (TARGET_BTI, "__ARM_FEATURE_BTI", pfile); aarch64_def_or_undef (TARGET_I8MM, "__ARM_FEATURE_MATMUL_INT8", pfile); aarch64_def_or_undef (TARGET_BF16_SIMD, "__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile); diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index dcb1ecef71a9..db6ec5c48d8f 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -312,6 +312,11 @@ enum class aarch64_feature : unsigned char { /* PAUTH instructions are enabled through +pauth. */ #define TARGET_PAUTH (AARCH64_ISA_PAUTH) +/* BTI instructions exist from Armv8.5-a onwards. Their automatic use is + enabled through -mbranch-protection by using NOP-space instructions, + but this TARGET_ is used for defining BTI-related ACLE things. */ +#define TARGET_BTI (AARCH64_ISA_V8_5A) + /* MOPS instructions are enabled through +mops. */ #define TARGET_MOPS (AARCH64_ISA_MOPS) diff --git a/gcc/testsuite/gcc.target/aarch64/acle/bti_def.c b/gcc/testsuite/gcc.target/aarch64/acle/bti_def.c new file mode 100644 index 000000000000..db94769ec8b9 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/bti_def.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +#pragma GCC target "arch=armv8.5-a" +#ifndef __ARM_FEATURE_BTI +#error "__ARM_FEATURE_BTI is not defined but should be!" +#endif + +void +foo (void) {} + diff --git a/gcc/testsuite/gcc.target/aarch64/acle/pauth_def.c b/gcc/testsuite/gcc.target/aarch64/acle/pauth_def.c new file mode 100644 index 000000000000..400a0f61deb0 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/pauth_def.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +#pragma GCC target "+pauth" +#ifndef __ARM_FEATURE_PAUTH +#error "__ARM_FEATURE_PAUTH is not defined but should be!" +#endif + +void +foo (void) {} +