[clang] 7d40baa - [AArch64] Add __ARM_FEATURE_BTI and __ARM_FEATURE_PAUTH
Daniel Kiss via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 7 07:30:22 PST 2022
Author: Daniel Kiss
Date: 2022-12-07T16:30:16+01:00
New Revision: 7d40baa82b1f272f68de63f3c4f68d970bdcd6ed
URL: https://github.com/llvm/llvm-project/commit/7d40baa82b1f272f68de63f3c4f68d970bdcd6ed
DIFF: https://github.com/llvm/llvm-project/commit/7d40baa82b1f272f68de63f3c4f68d970bdcd6ed.diff
LOG: [AArch64] Add __ARM_FEATURE_BTI and __ARM_FEATURE_PAUTH
Macros are added to ACLE[1] and already added to ARM but these two are missing from AArch64.
[1] https://github.com/ARM-software/acle/blob/main/main/acle.md#changes-between-acle-q3-2021-and-acle-q4-2021
Reviewed By: chill
Differential Revision: https://reviews.llvm.org/D139445
Added:
Modified:
clang/lib/Basic/Targets/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index c5fce62bc501f..89ad602b591f5 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -199,6 +199,7 @@ void AArch64TargetInfo::getTargetDefinesARMV83A(const LangOptions &Opts,
MacroBuilder &Builder) const {
Builder.defineMacro("__ARM_FEATURE_COMPLEX", "1");
Builder.defineMacro("__ARM_FEATURE_JCVT", "1");
+ Builder.defineMacro("__ARM_FEATURE_PAUTH", "1");
// Also include the Armv8.2 defines
getTargetDefinesARMV82A(Opts, Builder);
}
@@ -212,6 +213,7 @@ void AArch64TargetInfo::getTargetDefinesARMV84A(const LangOptions &Opts,
void AArch64TargetInfo::getTargetDefinesARMV85A(const LangOptions &Opts,
MacroBuilder &Builder) const {
Builder.defineMacro("__ARM_FEATURE_FRINT", "1");
+ Builder.defineMacro("__ARM_FEATURE_BTI", "1");
// Also include the Armv8.4 defines
getTargetDefinesARMV84A(Opts, Builder);
}
@@ -385,6 +387,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__ARM_FEATURE_SM4", "1");
}
+ if (HasPAuth)
+ Builder.defineMacro("__ARM_FEATURE_PAUTH", "1");
+
if (HasUnaligned)
Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
@@ -601,6 +606,7 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasMOPS = false;
HasD128 = false;
HasRCPC = false;
+ HasPAuth = false;
ArchKind = llvm::AArch64::ArchKind::INVALID;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c
index 40ea003a85848..53b6644ef12e6 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -461,6 +461,7 @@
// ================== Check Pointer Authentication Extension (PAuth).
// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s
// RUN: %clang -target arm64-none-linux-gnu -march=armv8.5-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+pauth -mbranch-protection=none -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-ON %s
// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=none -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s
// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=bti -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH-OFF %s
// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -mbranch-protection=standard -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-PAUTH %s
@@ -473,6 +474,7 @@
// CHECK-PAUTH-BKEY: #define __ARM_FEATURE_PAC_DEFAULT 2
// CHECK-PAUTH-ALL: #define __ARM_FEATURE_PAC_DEFAULT 5
// CHECK-PAUTH-BKEY-ALL: #define __ARM_FEATURE_PAC_DEFAULT 6
+// CHECK-PAUTH-ON: #define __ARM_FEATURE_PAUTH 1
// ================== Check Branch Target Identification (BTI).
// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-BTI-OFF %s
@@ -560,10 +562,12 @@
// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER,CHECK-V85-OR-LATER %s
// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER,CHECK-V85-OR-LATER %s
// CHECK-V81-OR-LATER: __ARM_FEATURE_ATOMICS 1
+// CHECK-V85-OR-LATER: __ARM_FEATURE_BTI 1
// CHECK-V83-OR-LATER: __ARM_FEATURE_COMPLEX 1
// CHECK-V81-OR-LATER: __ARM_FEATURE_CRC32 1
// CHECK-V85-OR-LATER: __ARM_FEATURE_FRINT 1
// CHECK-V83-OR-LATER: __ARM_FEATURE_JCVT 1
+// CHECK-V83-OR-LATER: __ARM_FEATURE_PAUTH 1
// CHECK-V81-OR-LATER: __ARM_FEATURE_QRDMX 1
// CHECK-BEFORE-V83-NOT: __ARM_FEATURE_COMPLEX 1
// CHECK-BEFORE-V83-NOT: __ARM_FEATURE_JCVT 1
More information about the cfe-commits
mailing list