Skip to content

Commit 9798e21

Browse files
committed
[AArch64] Reduce +sve2-aes to an alias of +sve-aes+sve2
- Introduce the ammended feature flag for FEAT_SVE_AES, 'sve-aes' - Make the existing sve2-aes flag as an alias of +sve2+sve-aes - The exising __ARM_FEATURE_SVE2_AES macro must not be effected by this change, so an effort has been made to ensure it is defined when we have supplied target features +sve-aes and +sve2 by any method.
1 parent ea050ab commit 9798e21

File tree

8 files changed

+61
-19
lines changed

8 files changed

+61
-19
lines changed

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
473473
if (HasSVE2p1)
474474
Builder.defineMacro("__ARM_FEATURE_SVE2p1", "1");
475475

476-
if (HasSVE2 && HasSVE2AES)
476+
if (HasSVE2 && HasSVEAES)
477477
Builder.defineMacro("__ARM_FEATURE_SVE2_AES", "1");
478478

479479
if (HasSVE2 && HasSVE2BitPerm)
@@ -769,7 +769,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
769769
.Case("f32mm", FPU & SveMode && HasMatmulFP32)
770770
.Case("f64mm", FPU & SveMode && HasMatmulFP64)
771771
.Case("sve2", FPU & SveMode && HasSVE2)
772-
.Case("sve2-pmull128", FPU & SveMode && HasSVE2AES)
772+
.Case("sve2-pmull128", FPU & SveMode && HasSVEAES && HasSVE2)
773773
.Case("sve2-bitperm", FPU & SveMode && HasSVE2BitPerm)
774774
.Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
775775
.Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
@@ -861,12 +861,17 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
861861
HasSVE2 = true;
862862
HasSVE2p1 = true;
863863
}
864+
if (Feature == "+sve-aes") {
865+
FPU |= NeonMode;
866+
HasAES = true;
867+
HasSVEAES = true;
868+
}
864869
if (Feature == "+sve2-aes") {
865870
FPU |= NeonMode;
866871
FPU |= SveMode;
867872
HasFullFP16 = true;
868873
HasSVE2 = true;
869-
HasSVE2AES = true;
874+
HasSVEAES = true;
870875
}
871876
if (Feature == "+sve2-sha3") {
872877
FPU |= NeonMode;

clang/lib/Basic/Targets/AArch64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
7878
bool HasBFloat16 = false;
7979
bool HasSVE2 = false;
8080
bool HasSVE2p1 = false;
81-
bool HasSVE2AES = false;
81+
bool HasSVEAES = false;
8282
bool HasSVE2SHA3 = false;
8383
bool HasSVE2SM4 = false;
8484
bool HasSVEB16B16 = false;

clang/test/Driver/aarch64-implied-sve-features.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// SVE2-BITPERM-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "-sve2-bitperm"
3737

3838
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-aes+nosve2-aes %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-AES-REVERT
39-
// SVE2-AES-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "-sve2-aes"
39+
// SVE2-AES-REVERT: "-target-feature" "+sve" "-target-feature" "+sve-aes" "-target-feature" "+sve2" "-target-feature" "-sve2-aes"
4040

4141
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sha3+nosve2-sha3 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SHA3-REVERT
4242
// SVE2-SHA3-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "-sve2-sha3"
@@ -47,8 +47,11 @@
4747
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sha3 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SHA3
4848
// SVE2-SHA3: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+sve2-sha3"
4949

50+
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve-aes %s -### 2>&1 | FileCheck %s --check-prefix=SVE-AES
51+
// SVE-AES: "-target-feature" "+aes"{{.*}} "-target-feature" "+sve-aes"
52+
5053
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-aes %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-AES
51-
// SVE2-AES: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+sve2-aes"
54+
// SVE2-AES: "-target-feature" "+sve" "-target-feature" "+sve-aes" "-target-feature" "+sve2" "-target-feature" "+sve2-aes"
5255

5356
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sm4 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SM4
5457
// SVE2-SM4: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+sve2-sm4"
@@ -65,8 +68,8 @@
6568
// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve2"
6669
// SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve"
6770

68-
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+nosve+sve2-aes %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT-REV
69-
// SVE-SUBFEATURE-CONFLICT-REV: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+sve2-aes"
71+
// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+nosve+sve2-bitperm %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT-REV
72+
// SVE-SUBFEATURE-CONFLICT-REV: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+sve2-bitperm"
7073

7174
// RUN: %clang --target=aarch64-linux-gnu -mcpu=neoverse-n2+nosve2 %s -### 2>&1 | FileCheck %s --check-prefix=SVE-MCPU-FEATURES
7275
// SVE-MCPU-FEATURES-NOT: "-target-feature" "+sve2-bitperm"

clang/test/Driver/print-supported-extensions-aarch64.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@
7777
// CHECK-NEXT: profile FEAT_SPE Enable Statistical Profiling extension
7878
// CHECK-NEXT: predres2 FEAT_SPECRES2 Enable Speculation Restriction Instruction
7979
// CHECK-NEXT: ssbs FEAT_SSBS, FEAT_SSBS2 Enable Speculative Store Bypass Safe bit
80-
// CHECK-NEXT: ssve-aes FEAT_SSVE_AES Enable Armv9.6-A SVE2 AES support in streaming SVE mode
80+
// CHECK-NEXT: ssve-aes FEAT_SSVE_AES Enable Armv9.6-A SVE AES support in streaming SVE mode
8181
// CHECK-NEXT: ssve-fp8dot2 FEAT_SSVE_FP8DOT2 Enable SVE2 FP8 2-way dot product instructions
8282
// CHECK-NEXT: ssve-fp8dot4 FEAT_SSVE_FP8DOT4 Enable SVE2 FP8 4-way dot product instructions
8383
// CHECK-NEXT: ssve-fp8fma FEAT_SSVE_FP8FMA Enable SVE2 FP8 multiply-add instructions
8484
// CHECK-NEXT: sve FEAT_SVE Enable Scalable Vector Extension (SVE) instructions
85+
// CHECK-NEXT: sve-aes FEAT_SVE_AES, FEAT_SVE_PMULL128 Enable SVE AES and 128-bit PMULL instructions
8586
// CHECK-NEXT: sve-aes2 FEAT_SVE_AES2 Enable Armv9.6-A SVE multi-vector AES and 128-bit PMULL instructions
8687
// CHECK-NEXT: sve-b16b16 FEAT_SVE_B16B16 Enable SVE2 non-widening and SME2 Z-targeting non-widening BFloat16 instructions
8788
// CHECK-NEXT: sve-bfscale FEAT_SVE_BFSCALE Enable Armv9.6-A SVE BFloat16 scaling instructions
8889
// CHECK-NEXT: sve-f16f32mm FEAT_SVE_F16F32MM Enable Armv9.6-A FP16 to FP32 Matrix Multiply
8990
// CHECK-NEXT: sve2 FEAT_SVE2 Enable Scalable Vector Extension 2 (SVE2) instructions
90-
// CHECK-NEXT: sve2-aes FEAT_SVE_AES, FEAT_SVE_PMULL128 Enable AES SVE2 instructions
91+
// CHECK-NEXT: sve2-aes An alias of +sve2+sve-aes
9192
// CHECK-NEXT: sve2-bitperm FEAT_SVE_BitPerm Enable bit permutation SVE2 instructions
9293
// CHECK-NEXT: sve2-sha3 FEAT_SVE_SHA3 Enable SHA3 SVE2 instructions
9394
// CHECK-NEXT: sve2-sm4 FEAT_SVE_SM4 Enable SM4 SVE2 instructions

clang/test/Preprocessor/aarch64-target-features.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,20 @@
227227
// CHECK-NONEON-NOT: __ARM_FEATURE_SVE 1
228228
// CHECK-NONEON-NOT: __ARM_NEON 1
229229

230+
// RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve-aes -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVEAES %s
231+
// CHECK-SVEAES: __ARM_FEATURE_AES 1
232+
230233
// RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve2-aes -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2AES %s
234+
// CHECK-SVE2AES: __ARM_FEATURE_AES 1
235+
// CHECK-SVE2AES: __ARM_FEATURE_SVE2 1
231236
// CHECK-SVE2AES: __ARM_FEATURE_SVE2_AES 1
237+
238+
// RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve-aes+sve2 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVEAES-SVE2 %s
239+
// CHECK-SVEAES-SVE2: __ARM_FEATURE_AES 1
240+
// CHECK-SVEAES-SVE2: __ARM_FEATURE_SVE2 1
241+
// CHECK-SVEAES-SVE2: __ARM_FEATURE_SVE2_AES 1
242+
243+
232244
// RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve2-sha3 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2SHA3 %s
233245
// CHECK-SVE2SHA3: __ARM_FEATURE_SVE2_SHA3 1
234246
// RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve2-sm4 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2SM4 %s

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,12 @@ def FeatureSVE2 : ExtensionWithMArch<"sve2", "SVE2", "FEAT_SVE2",
369369
"Enable Scalable Vector Extension 2 (SVE2) instructions",
370370
[FeatureSVE, FeatureUseScalarIncVL]>;
371371

372-
def FeatureSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES",
372+
def FeatureSVEAES : ExtensionWithMArch<"sve-aes", "SVEAES",
373373
"FEAT_SVE_AES, FEAT_SVE_PMULL128",
374-
"Enable AES SVE2 instructions", [FeatureSVE2, FeatureAES]>;
374+
"Enable SVE AES and 128-bit PMULL instructions", [FeatureAES]>;
375+
376+
def FeatureSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES", "",
377+
"An alias of +sve2+sve-aes", [FeatureSVE2, FeatureSVEAES]>;
375378

376379
def FeatureSVE2SM4 : ExtensionWithMArch<"sve2-sm4", "SVE2SM4", "FEAT_SVE_SM4",
377380
"Enable SM4 SVE2 instructions", [FeatureSVE2, FeatureSM4]>;
@@ -542,7 +545,7 @@ def FeatureSME2p2: ExtensionWithMArch<"sme2p2", "SME2p2", "FEAT_SME2p2",
542545
"Enable Armv9.6-A Scalable Matrix Extension 2.2 instructions", [FeatureSME2p1]>;
543546

544547
def FeatureSSVE_AES : ExtensionWithMArch<"ssve-aes", "SSVE_AES", "FEAT_SSVE_AES",
545-
"Enable Armv9.6-A SVE2 AES support in streaming SVE mode", [FeatureSME2, FeatureSVE2AES]>;
548+
"Enable Armv9.6-A SVE AES support in streaming SVE mode", [FeatureSME2, FeatureSVEAES]>;
546549

547550
def FeatureSVE2p2 : ExtensionWithMArch<"sve2p2", "SVE2p2", "FEAT_SVE2p2",
548551
"Enable Armv9.6-A Scalable Vector Extension 2.2 instructions", [FeatureSVE2p1]>;

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,6 +3734,7 @@ static const struct Extension {
37343734
{"rng", {AArch64::FeatureRandGen}},
37353735
{"sve", {AArch64::FeatureSVE}},
37363736
{"sve-b16b16", {AArch64::FeatureSVEB16B16}},
3737+
{"sve-aes", {AArch64::FeatureSVEAES}},
37373738
{"sve2", {AArch64::FeatureSVE2}},
37383739
{"sve2-aes", {AArch64::FeatureSVE2AES}},
37393740
{"sve2-sm4", {AArch64::FeatureSVE2SM4}},

llvm/unittests/TargetParser/TargetParserTest.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ TEST(TargetParserTest, AArch64ExtensionFeatures) {
13341334
AArch64::AEK_FPRCVT, AArch64::AEK_CMPBR,
13351335
AArch64::AEK_LSUI, AArch64::AEK_OCCMO,
13361336
AArch64::AEK_PCDPHINT, AArch64::AEK_POPS,
1337+
AArch64::AEK_SVEAES
13371338
};
13381339

13391340
std::vector<StringRef> Features;
@@ -1369,6 +1370,7 @@ TEST(TargetParserTest, AArch64ExtensionFeatures) {
13691370
EXPECT_TRUE(llvm::is_contained(Features, "+sve-bfscale"));
13701371
EXPECT_TRUE(llvm::is_contained(Features, "+sve-f16f32mm"));
13711372
EXPECT_TRUE(llvm::is_contained(Features, "+sve2"));
1373+
EXPECT_TRUE(llvm::is_contained(Features, "+sve-aes"));
13721374
EXPECT_TRUE(llvm::is_contained(Features, "+sve2-aes"));
13731375
EXPECT_TRUE(llvm::is_contained(Features, "+sve2-sm4"));
13741376
EXPECT_TRUE(llvm::is_contained(Features, "+sve2-sha3"));
@@ -1538,6 +1540,7 @@ TEST(TargetParserTest, AArch64ArchExtFeature) {
15381540
{"sve-bfscale", "nosve-bfscale", "+sve-bfscale", "-sve-bfscale"},
15391541
{"sve-f16f32mm", "nosve-f16f32mm", "+sve-f16f32mm", "-sve-f16f32mm"},
15401542
{"sve2", "nosve2", "+sve2", "-sve2"},
1543+
{"sve-aes", "nosve-aes", "+sve-aes", "-sve-aes"},
15411544
{"sve2-aes", "nosve2-aes", "+sve2-aes", "-sve2-aes"},
15421545
{"sve2-sm4", "nosve2-sm4", "+sve2-sm4", "-sve2-sm4"},
15431546
{"sve2-sha3", "nosve2-sha3", "+sve2-sha3", "-sve2-sha3"},
@@ -1840,7 +1843,11 @@ AArch64ExtensionDependenciesBaseArchTestParams
18401843
{},
18411844
{"sve", "sve-f16f32mm"}},
18421845

1843-
// sve2 -> {sve2p1, sve2-bitperm, sve2-sha3, sve2-sm4}
1846+
// aes -> {sve-aes}
1847+
{AArch64::ARMV8A, {"noaes", "sve-aes"}, {"aes", "sve-aes"}, {}},
1848+
{AArch64::ARMV8A, {"sve-aes", "noaes"}, {}, {"aes", "sve-aes"}},
1849+
1850+
// sve2 -> {sve2p1, sve2-bitperm, sve2-sha3, sve2-sm4, sve2-aes}
18441851
{AArch64::ARMV8A, {"nosve2", "sve2p1"}, {"sve2", "sve2p1"}, {}},
18451852
{AArch64::ARMV8A, {"sve2p1", "nosve2"}, {}, {"sve2", "sve2p1"}},
18461853
{AArch64::ARMV8A,
@@ -1855,6 +1862,8 @@ AArch64ExtensionDependenciesBaseArchTestParams
18551862
{AArch64::ARMV8A, {"sve2-sha3", "nosve2"}, {}, {"sve2", "sve2-sha3"}},
18561863
{AArch64::ARMV8A, {"nosve2", "sve2-sm4"}, {"sve2", "sve2-sm4"}, {}},
18571864
{AArch64::ARMV8A, {"sve2-sm4", "nosve2"}, {}, {"sve2", "sve2-sm4"}},
1865+
{AArch64::ARMV8A, {"nosve2", "sve2-aes"}, {"sve2", "sve2-aes"}, {}},
1866+
{AArch64::ARMV8A, {"sve2-aes", "nosve2"}, {}, {"sve2", "sve2-aes"}},
18581867

18591868
// sve-b16b16 -> {sme-b16b16}
18601869
{AArch64::ARMV9_4A,
@@ -1955,15 +1964,23 @@ AArch64ExtensionDependenciesBaseArchTestParams
19551964
{AArch64::ARMV8A, {"norcpc", "rcpc3"}, {"rcpc", "rcpc3"}, {}},
19561965
{AArch64::ARMV8A, {"rcpc3", "norcpc"}, {}, {"rcpc", "rcpc3"}},
19571966

1958-
// sve2-aes -> ssve-aes
1967+
// sve-aes -> {ssve-aes, sve2-aes}
1968+
{AArch64::ARMV9_6A,
1969+
{"nosve-aes", "ssve-aes"},
1970+
{"sve-aes", "ssve-aes"},
1971+
{}},
1972+
{AArch64::ARMV9_6A,
1973+
{"ssve-aes", "nosve-aes"},
1974+
{},
1975+
{"ssve-aes", "sve-aes"}},
19591976
{AArch64::ARMV9_6A,
1960-
{"nosve2-aes", "ssve-aes"},
1961-
{"sve2-aes", "ssve-aes"},
1977+
{"nosve-aes", "sve2-aes"},
1978+
{"sve2-aes", "sve-aes"},
19621979
{}},
19631980
{AArch64::ARMV9_6A,
1964-
{"ssve-aes", "nosve2-aes"},
1981+
{"sve2-aes", "nosve-aes"},
19651982
{},
1966-
{"ssve-aes", "sve2-aes"}},
1983+
{"sve2-aes", "sve-aes"}}
19671984
};
19681985

19691986
INSTANTIATE_TEST_SUITE_P(

0 commit comments

Comments
 (0)