Skip to content
Snippets Groups Projects
Commit 688f4eb2 authored by Kyrylo Tkachov's avatar Kyrylo Tkachov
Browse files

aarch64: Add __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI ACLE defines

Recent ACLE additions specified the __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI macros [1] that the compiler
should define when the pointer authentication and BTI instructions are available (and don't act as NOPs).
We've received requests to enable them in GCC for aarch64, similar to clang [2].
It's a fairly simple patch and should be non-intrusive at this stage.
Pointer authentication has its own "pauth" feature flag, whereas BTI depends on an architecture level
of Armv8.5-a or later.

Bootstrapped and tested on aarch64-none-linux-gnu.

[1] https://github.com/ARM-software/acle/blob/main/main/acle.md#pointer-authentication
[2] https://reviews.llvm.org/rG7d40baa82b1f272f68de63f3c4f68d970bdcd6ed

gcc/ChangeLog:

	* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define
	__ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI when appropriate.
	* config/aarch64/aarch64.h (TARGET_BTI): Define.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/acle/bti_def.c: New test.
	* gcc.target/aarch64/acle/pauth_def.c: New test.
parent 49bf49bb
No related branches found
No related tags found
No related merge requests found
...@@ -195,6 +195,8 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) ...@@ -195,6 +195,8 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v); 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_I8MM, "__ARM_FEATURE_MATMUL_INT8", pfile);
aarch64_def_or_undef (TARGET_BF16_SIMD, aarch64_def_or_undef (TARGET_BF16_SIMD,
"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile); "__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile);
......
...@@ -312,6 +312,11 @@ enum class aarch64_feature : unsigned char { ...@@ -312,6 +312,11 @@ enum class aarch64_feature : unsigned char {
/* PAUTH instructions are enabled through +pauth. */ /* PAUTH instructions are enabled through +pauth. */
#define TARGET_PAUTH (AARCH64_ISA_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. */ /* MOPS instructions are enabled through +mops. */
#define TARGET_MOPS (AARCH64_ISA_MOPS) #define TARGET_MOPS (AARCH64_ISA_MOPS)
......
/* { 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) {}
/* { 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) {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment