[clang] [AArch64] Add missing ACLE predefined macros and update __ARM_ACLE. (PR #108857)
Alexandros Lamprineas via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 16 11:26:35 PDT 2024
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/108857
>From cc3f72918aadab7df7397c25de280e713d1257f2 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas <alexandros.lamprineas at arm.com>
Date: Mon, 16 Sep 2024 17:39:07 +0100
Subject: [PATCH 1/2] [AArch64] Add missing ACLE predefined macros and update
__ARM_ACLE.
Adds __ARM_ACLE_VERSION and __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL
as defined here https://github.com/ARM-software/acle/pull/301 and
here https://github.com/ARM-software/acle/pull/302.
Also bumps __ARM_ACLE to 202420.
---
clang/lib/Basic/Targets/AArch64.cpp | 9 ++++++++-
clang/test/Preprocessor/aarch64-target-features.c | 1 -
clang/test/Preprocessor/init-aarch64.c | 15 ++++++++++++---
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 63fc15f916c558..9c7fb5d475ef45 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -399,7 +399,14 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__AARCH64_CMODEL_" + CodeModel + "__");
// ACLE predefines. Many can only have one possible value on v8 AArch64.
- Builder.defineMacro("__ARM_ACLE", "200");
+ Builder.defineMacro("__ARM_ACLE_VERSION(year, quarter, patch)",
+ "100 * (year) + 10 * (quarter) + (patch)");
+#define __ARM_ACLE_VERSION(Y, Q, P) 100 * (Y) + 10 * (Q) + (P)
+ Builder.defineMacro("__ARM_ACLE",
+ std::to_string(__ARM_ACLE_VERSION(2024, 2, 0)));
+ Builder.defineMacro("__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL",
+ std::to_string(__ARM_ACLE_VERSION(2024, 2, 0)));
+#undef __ARM_ACLE_VERSION
Builder.defineMacro("__ARM_ARCH",
std::to_string(ArchInfo->Version.getMajor()));
Builder.defineMacro("__ARM_ARCH_PROFILE",
diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c
index ae2bdda6f536c5..bcc0640c55e35a 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -4,7 +4,6 @@
// CHECK: __AARCH64EL__ 1
// CHECK: __ARM_64BIT_STATE 1
// CHECK-NOT: __ARM_32BIT_STATE
-// CHECK: __ARM_ACLE 200
// CHECK: __ARM_ALIGN_MAX_STACK_PWR 4
// CHECK: __ARM_ARCH 8
// CHECK: __ARM_ARCH_ISA_A64 1
diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
index 81c9a66f137512..e4fde357b83f92 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -12,7 +12,8 @@
// AARCH64_LE-NEXT: #define __AARCH64EL__ 1
// AARCH64_LE-NEXT: #define __AARCH64_CMODEL_SMALL__ 1
// AARCH64-NEXT: #define __ARM_64BIT_STATE 1
-// AARCH64-NEXT: #define __ARM_ACLE 200
+// AARCH64-NEXT: #define __ARM_ACLE 202420
+// AARCH64-NEXT: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
// AARCH64-NEXT: #define __ARM_ALIGN_MAX_STACK_PWR 4
// AARCH64-NEXT: #define __ARM_ARCH 8
// AARCH64-NEXT: #define __ARM_ARCH_ISA_A64 1
@@ -121,6 +122,7 @@
// AARCH64-NEXT: #define __FPCLASS_SNAN 0x0001
// AARCH64-NEXT: #define __FP_FAST_FMA 1
// AARCH64-NEXT: #define __FP_FAST_FMAF 1
+// AARCH64-NEXT: #define __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL 202420
// AARCH64-NEXT: #define __GCC_ASM_FLAG_OUTPUTS__ 1
// AARCH64-NEXT: #define __GCC_CONSTRUCTIVE_SIZE {{.+}}
// AARCH64-NEXT: #define __GCC_DESTRUCTIVE_SIZE {{.+}}
@@ -393,6 +395,8 @@
// AARCH64-DARWIN: #define __AARCH64EL__ 1
// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
// AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
+// AARCH64-DARWIN: #define __ARM_ACLE 202420
+// AARCH64-DARWIN: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
// AARCH64-DARWIN: #define __ARM_ARCH 8
// AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
@@ -429,6 +433,7 @@
// AARCH64-DARWIN: #define __FLT_MIN_EXP__ (-125)
// AARCH64-DARWIN: #define __FLT_MIN__ 1.17549435e-38F
// AARCH64-DARWIN: #define __FLT_RADIX__ 2
+// AARCH64-DARWIN: #define __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL 202420
// AARCH64-DARWIN: #define __INT16_C_SUFFIX__
// AARCH64-DARWIN: #define __INT16_FMTd__ "hd"
// AARCH64-DARWIN: #define __INT16_FMTi__ "hi"
@@ -588,7 +593,8 @@
// AARCH64-MSVC: #define _WIN64 1
// AARCH64-MSVC: #define __AARCH64EL__ 1
// AARCH64-MSVC: #define __ARM_64BIT_STATE 1
-// AARCH64-MSVC: #define __ARM_ACLE 200
+// AARCH64-MSVC: #define __ARM_ACLE 202420
+// AARCH64-MSVC: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
// AARCH64-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
// AARCH64-MSVC: #define __ARM_ARCH 8
// AARCH64-MSVC: #define __ARM_ARCH_ISA_A64 1
@@ -644,6 +650,7 @@
// AARCH64-MSVC: #define __FLT_MIN_EXP__ (-125)
// AARCH64-MSVC: #define __FLT_MIN__ 1.17549435e-38F
// AARCH64-MSVC: #define __FLT_RADIX__ 2
+// AARCH64-MSVC: #define __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL 202420
// AARCH64-MSVC: #define __INT_MAX__ 2147483647
// AARCH64-MSVC: #define __LDBL_DECIMAL_DIG__ 17
// AARCH64-MSVC: #define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
@@ -750,7 +757,8 @@
// ARM64EC-MSVC: #define __AARCH64EL__ 1
// ARM64EC-MSVC: #define __AARCH64_CMODEL_SMALL__ 1
// ARM64EC-MSVC: #define __ARM_64BIT_STATE 1
-// ARM64EC-MSVC: #define __ARM_ACLE 200
+// ARM64EC-MSVC: #define __ARM_ACLE 202420
+// ARM64EC-MSVC: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
// ARM64EC-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
// ARM64EC-MSVC: #define __ARM_ARCH 8
// ARM64EC-MSVC: #define __ARM_ARCH_ISA_A64 1
@@ -850,6 +858,7 @@
// ARM64EC-MSVC: #define __FPCLASS_SNAN 0x0001
// ARM64EC-MSVC: #define __FP_FAST_FMA 1
// ARM64EC-MSVC: #define __FP_FAST_FMAF 1
+// ARM64EC-MSVC: #define __FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL 202420
// ARM64EC-MSVC: #define __GCC_ASM_FLAG_OUTPUTS__ 1
// ARM64EC-MSVC: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
// ARM64EC-MSVC: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1
>From b46b5cfa653a5e11b7870817101267122a8c3d52 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas <alexandros.lamprineas at arm.com>
Date: Mon, 16 Sep 2024 19:17:23 +0100
Subject: [PATCH 2/2] Changes from last revision
Added missing parenthesis around the macro
---
clang/lib/Basic/Targets/AArch64.cpp | 4 ++--
clang/test/Preprocessor/init-aarch64.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 9c7fb5d475ef45..586e4dd2a21b4e 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -400,8 +400,8 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
// ACLE predefines. Many can only have one possible value on v8 AArch64.
Builder.defineMacro("__ARM_ACLE_VERSION(year, quarter, patch)",
- "100 * (year) + 10 * (quarter) + (patch)");
-#define __ARM_ACLE_VERSION(Y, Q, P) 100 * (Y) + 10 * (Q) + (P)
+ "(100 * (year) + 10 * (quarter) + (patch))");
+#define __ARM_ACLE_VERSION(Y, Q, P) (100 * (Y) + 10 * (Q) + (P))
Builder.defineMacro("__ARM_ACLE",
std::to_string(__ARM_ACLE_VERSION(2024, 2, 0)));
Builder.defineMacro("__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL",
diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
index e4fde357b83f92..c52c49a94e016e 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -13,7 +13,7 @@
// AARCH64_LE-NEXT: #define __AARCH64_CMODEL_SMALL__ 1
// AARCH64-NEXT: #define __ARM_64BIT_STATE 1
// AARCH64-NEXT: #define __ARM_ACLE 202420
-// AARCH64-NEXT: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
+// AARCH64-NEXT: #define __ARM_ACLE_VERSION(year,quarter,patch) (100 * (year) + 10 * (quarter) + (patch))
// AARCH64-NEXT: #define __ARM_ALIGN_MAX_STACK_PWR 4
// AARCH64-NEXT: #define __ARM_ARCH 8
// AARCH64-NEXT: #define __ARM_ARCH_ISA_A64 1
@@ -396,7 +396,7 @@
// AARCH64-DARWIN-NOT: #define __AARCH_BIG_ENDIAN 1
// AARCH64-DARWIN: #define __ARM_64BIT_STATE 1
// AARCH64-DARWIN: #define __ARM_ACLE 202420
-// AARCH64-DARWIN: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
+// AARCH64-DARWIN: #define __ARM_ACLE_VERSION(year,quarter,patch) (100 * (year) + 10 * (quarter) + (patch))
// AARCH64-DARWIN: #define __ARM_ARCH 8
// AARCH64-DARWIN: #define __ARM_ARCH_ISA_A64 1
// AARCH64-DARWIN-NOT: #define __ARM_BIG_ENDIAN 1
@@ -594,7 +594,7 @@
// AARCH64-MSVC: #define __AARCH64EL__ 1
// AARCH64-MSVC: #define __ARM_64BIT_STATE 1
// AARCH64-MSVC: #define __ARM_ACLE 202420
-// AARCH64-MSVC: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
+// AARCH64-MSVC: #define __ARM_ACLE_VERSION(year,quarter,patch) (100 * (year) + 10 * (quarter) + (patch))
// AARCH64-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
// AARCH64-MSVC: #define __ARM_ARCH 8
// AARCH64-MSVC: #define __ARM_ARCH_ISA_A64 1
@@ -758,7 +758,7 @@
// ARM64EC-MSVC: #define __AARCH64_CMODEL_SMALL__ 1
// ARM64EC-MSVC: #define __ARM_64BIT_STATE 1
// ARM64EC-MSVC: #define __ARM_ACLE 202420
-// ARM64EC-MSVC: #define __ARM_ACLE_VERSION(year,quarter,patch) 100 * (year) + 10 * (quarter) + (patch)
+// ARM64EC-MSVC: #define __ARM_ACLE_VERSION(year,quarter,patch) (100 * (year) + 10 * (quarter) + (patch))
// ARM64EC-MSVC: #define __ARM_ALIGN_MAX_STACK_PWR 4
// ARM64EC-MSVC: #define __ARM_ARCH 8
// ARM64EC-MSVC: #define __ARM_ARCH_ISA_A64 1
More information about the cfe-commits
mailing list