[clang] [llvm] [TargetParser] Define AEK_FCMA and AEK_JSCVT for tsv110 (PR #75516)
Qi Hu via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 14 13:12:20 PST 2023
https://github.com/Qi-Hu updated https://github.com/llvm/llvm-project/pull/75516
>From dce3b66e2c55c81fe9e950b29d1da15e5e7a3f9f Mon Sep 17 00:00:00 2001
From: Qi Hu <qi.hu at huawei.com>
Date: Thu, 14 Dec 2023 13:35:52 -0500
Subject: [PATCH] [TargetParser] Define AEK_FCMA and AEK_JSCVT for tsv110
We define AEK_JSCVT and AEK_FCMA for CPU features FEAT_JSCVT and FEAT_FCMA
respectively, and add them to the CpuInfo of tsv110.
---
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | 9 +++++++++
clang/test/Driver/aarch64-complxnum.c | 11 +++++++++++
clang/test/Driver/aarch64-jsconv.c | 11 +++++++++++
clang/test/Preprocessor/aarch64-target-features.c | 4 ++--
llvm/include/llvm/TargetParser/AArch64TargetParser.h | 9 ++++++---
llvm/unittests/TargetParser/TargetParserTest.cpp | 6 ++++--
6 files changed, 43 insertions(+), 7 deletions(-)
create mode 100644 clang/test/Driver/aarch64-complxnum.c
create mode 100644 clang/test/Driver/aarch64-jsconv.c
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 912df79417ae21..2c26a12994ee1e 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -81,6 +81,15 @@ static bool DecodeAArch64Features(const Driver &D, StringRef text,
else
return false;
+ // +jsconv and +complxnum implies +neon and +fp-armv8
+ if (Feature == "jscvt" || Feature == "fcma") {
+ Features.push_back("+neon");
+ Features.push_back("+fp-armv8");
+ } else if (Feature == "nosimd" || Feature == "nofp") {
+ Features.push_back("-jsconv");
+ Features.push_back("-complxnum");
+ }
+
// +sme implies +bf16.
// +sme-f64f64 and +sme-i16i64 both imply +sme.
if (Feature == "sme") {
diff --git a/clang/test/Driver/aarch64-complxnum.c b/clang/test/Driver/aarch64-complxnum.c
new file mode 100644
index 00000000000000..484e26ca8494ec
--- /dev/null
+++ b/clang/test/Driver/aarch64-complxnum.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.3-a+fcma -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-COMPLXNUM %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+fcma -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-COMPLXNUM %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=tsv110 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-COMPLXNUM %s
+// CHECK-COMPLXNUM: "-target-feature" "+complxnum"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.3-a+nofcma -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOCOMPLXNUM %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+nofcma -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOCOMPLXNUM %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=tsv110+nofcma -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOCOMPLXNUM %s
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.2-a+fcma+nofp -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOCOMPLXNUM %s
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.2-a+fcma+nosimd -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOCOMPLXNUM %s
+// CHECK-NOCOMPLXNUM: "-target-feature" "-complxnum"
diff --git a/clang/test/Driver/aarch64-jsconv.c b/clang/test/Driver/aarch64-jsconv.c
new file mode 100644
index 00000000000000..71cc7c9f4aee93
--- /dev/null
+++ b/clang/test/Driver/aarch64-jsconv.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.3-a+jscvt -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-JSCONV %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+jscvt -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-JSCONV %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=tsv110 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-JSCONV %s
+// CHECK-JSCONV: "-target-feature" "+jsconv"
+
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.3-a+nojscvt -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOJSCONV %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=generic+nojscvt -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOJSCONV %s
+// RUN: %clang -target aarch64-none-none-eabi -mcpu=tsv110+nojscvt -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOJSCONV %s
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.2-a+jscvt+nofp -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOJSCONV %s
+// RUN: %clang -target aarch64-none-none-eabi -march=armv8.2-a+jscvt+nosimd -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-NOJSCONV %s
+// CHECK-NOJSCONV: "-target-feature" "-jsconv"
diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c
index db89aa7b608ad5..e5fe5592616c33 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -340,7 +340,7 @@
// RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto+nofp+nosimd+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-2 %s
// RUN: %clang -target aarch64 -march=armv8-a+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-3 %s
// CHECK-MARCH-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-crc" "-target-feature" "-crypto"
+// CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-jsconv" "-target-feature" "-complxnum" "-target-feature" "-crc" "-target-feature" "-crypto"
// CHECK-MARCH-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon"
// While we're checking +nofp, also make sure it stops defining __ARM_FP
@@ -461,7 +461,7 @@
// RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-3 %s
// CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "-sha2" "-target-feature" "-aes"
// CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc"
-// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8a" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" "-neon" "-target-feature" "-sha2" "-target-feature" "-aes"
+// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8a" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" "-neon" "-target-feature" "-jsconv" "-target-feature" "-complxnum" "-target-feature" "-sha2" "-target-feature" "-aes"
// RUN: %clang -target aarch64 -mcpu=cyclone+nocrc+nocrypto -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
// RUN: %clang -target aarch64 -march=armv8-a -mcpu=cyclone+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 56c32fae712cef..276bdf10751118 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,6 +173,8 @@ enum ArchExtKind : unsigned {
AEK_SMEF8F16 = 69, // FEAT_SME_F8F16
AEK_SMEF8F32 = 70, // FEAT_SME_F8F32
AEK_SMEFA64 = 71, // FEAT_SME_FA64
+ AEK_JSCVT = 72, // FEAT_JSCVT
+ AEK_FCMA = 73, // FEAT_FCMA
AEK_NUM_EXTENSIONS
};
using ExtensionBitset = Bitset<AEK_NUM_EXTENSIONS>;
@@ -218,7 +220,7 @@ inline constexpr ExtensionInfo Extensions[] = {
{"ebf16", AArch64::AEK_NONE, {}, {}, FEAT_EBF16, "+bf16", 290},
{"f32mm", AArch64::AEK_F32MM, "+f32mm", "-f32mm", FEAT_SVE_F32MM, "+sve,+f32mm,+fullfp16,+fp-armv8,+neon", 350},
{"f64mm", AArch64::AEK_F64MM, "+f64mm", "-f64mm", FEAT_SVE_F64MM, "+sve,+f64mm,+fullfp16,+fp-armv8,+neon", 360},
- {"fcma", AArch64::AEK_NONE, {}, {}, FEAT_FCMA, "+fp-armv8,+neon,+complxnum", 220},
+ {"fcma", AArch64::AEK_FCMA, "+complxnum", "-complxnum", FEAT_FCMA, "+fp-armv8,+neon,+complxnum", 220},
{"flagm", AArch64::AEK_FLAGM, "+flagm", "-flagm", FEAT_FLAGM, "+flagm", 20},
{"flagm2", AArch64::AEK_NONE, {}, {}, FEAT_FLAGM2, "+flagm,+altnzcv", 30},
{"fp", AArch64::AEK_FP, "+fp-armv8", "-fp-armv8", FEAT_FP, "+fp-armv8,+neon", 90},
@@ -228,7 +230,7 @@ inline constexpr ExtensionInfo Extensions[] = {
{"hbc", AArch64::AEK_HBC, "+hbc", "-hbc", FEAT_INIT, "", 0},
{"i8mm", AArch64::AEK_I8MM, "+i8mm", "-i8mm", FEAT_I8MM, "+i8mm", 270},
{"ite", AArch64::AEK_ITE, "+ite", "-ite", FEAT_INIT, "", 0},
- {"jscvt", AArch64::AEK_NONE, {}, {}, FEAT_JSCVT, "+fp-armv8,+neon,+jsconv", 210},
+ {"jscvt", AArch64::AEK_JSCVT, "+jsconv", "-jsconv", FEAT_JSCVT, "+fp-armv8,+neon,+jsconv", 210},
{"ls64_accdata", AArch64::AEK_NONE, {}, {}, FEAT_LS64_ACCDATA, "+ls64", 540},
{"ls64_v", AArch64::AEK_NONE, {}, {}, FEAT_LS64_V, "", 530},
{"ls64", AArch64::AEK_LS64, "+ls64", "-ls64", FEAT_LS64, "", 520},
@@ -666,7 +668,8 @@ inline constexpr CpuInfo CpuInfos[] = {
{"tsv110", ARMV8_2A,
(AArch64::ExtensionBitset(
{AArch64::AEK_AES, AArch64::AEK_SHA2, AArch64::AEK_DOTPROD,
- AArch64::AEK_FP16, AArch64::AEK_FP16FML, AArch64::AEK_PROFILE}))},
+ AArch64::AEK_FP16, AArch64::AEK_FP16FML, AArch64::AEK_PROFILE,
+ AArch64::AEK_JSCVT, AArch64::AEK_FCMA}))},
{"a64fx", ARMV8_2A,
(AArch64::ExtensionBitset({AArch64::AEK_AES, AArch64::AEK_SHA2,
AArch64::AEK_FP16,
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp
index e2b9712b511eca..1181083ad41ffd 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -1610,8 +1610,8 @@ INSTANTIATE_TEST_SUITE_P(
{AArch64::AEK_CRC, AArch64::AEK_AES, AArch64::AEK_SHA2,
AArch64::AEK_FP, AArch64::AEK_SIMD, AArch64::AEK_RAS,
AArch64::AEK_LSE, AArch64::AEK_RDM, AArch64::AEK_PROFILE,
- AArch64::AEK_FP16, AArch64::AEK_FP16FML,
- AArch64::AEK_DOTPROD})),
+ AArch64::AEK_JSCVT, AArch64::AEK_FCMA, AArch64::AEK_FP16,
+ AArch64::AEK_FP16FML, AArch64::AEK_DOTPROD})),
"8.2-A"),
ARMCPUTestParams<AArch64::ExtensionBitset>(
"a64fx", "armv8.2-a", "crypto-neon-fp-armv8",
@@ -1757,6 +1757,8 @@ TEST(TargetParserTest, testAArch64Extension) {
EXPECT_TRUE(testAArch64Extension("tsv110", "fp16"));
EXPECT_TRUE(testAArch64Extension("tsv110", "fp16fml"));
EXPECT_TRUE(testAArch64Extension("tsv110", "dotprod"));
+ EXPECT_TRUE(testAArch64Extension("tsv110", "jscvt"));
+ EXPECT_TRUE(testAArch64Extension("tsv110", "fcma"));
EXPECT_TRUE(testAArch64Extension("a64fx", "fp16"));
EXPECT_TRUE(testAArch64Extension("a64fx", "sve"));
EXPECT_FALSE(testAArch64Extension("a64fx", "sve2"));
More information about the cfe-commits
mailing list