Skip to content

Commit 5e4b981

Browse files
committed
[AArch64] Merge duplicate extension information.
When we moved the extension information into tablegen in #90987, some features (FEAT_DPB, FEAT_DPB2, FEAT_FLAGM2, FEAT_FRINTTS, FEAT_RCPC2) were defined as FMVOnlyExtension despite already having an equivalent SubtargetFeature in place. This patch is fusing these duplications. Moreover my reverted attempt to decouple feature dependency expansion (see #95056) made it evident that some features are still using the FMV dependencies in the target attribute. FEAT_PMULL and FEAT_SSBS2 are such examples. I have rectified those to reland the mentioned patch.
1 parent b1fe03f commit 5e4b981

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

clang/test/CodeGen/attr-target-version.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ int caller(void) { return used_def_without_default_decl() + used_decl_without_de
11551155
// CHECK: attributes #[[ATTR23]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+complxnum,+fullfp16,+neon,+rdm,+sme,-fp-armv8,-v9.5a" }
11561156
// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+f32mm,+fullfp16,+i8mm,+neon,+sha2,+sha3,+sve,-fp-armv8,-v9.5a" }
11571157
// CHECK: attributes #[[ATTR25]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+dit,+fullfp16,+neon,+sve,-fp-armv8,-v9.5a" }
1158-
// CHECK: attributes #[[ATTR26]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ccpp,+rcpc,-fp-armv8,-v9.5a" }
1158+
// CHECK: attributes #[[ATTR26]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ccpp,+rcpc,+rcpc-immo,-fp-armv8,-v9.5a" }
11591159
// CHECK: attributes #[[ATTR27]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ccdp,+ccpp,+jsconv,+neon,-fp-armv8,-v9.5a" }
11601160
// CHECK: attributes #[[ATTR28]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fptoint,+rcpc,-fp-armv8,-v9.5a" }
11611161
// CHECK: attributes #[[ATTR29]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+bf16,+fullfp16,+neon,+sve,-fp-armv8,-v9.5a" }

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,13 @@ class FMVOnlyExtension<string FMVBit, string Name, string Deps, int Priority>
7575
}
7676

7777
def : FMVOnlyExtension<"FEAT_DGH", "dgh", "", 260>;
78-
def : FMVOnlyExtension<"FEAT_DPB", "dpb", "+ccpp", 190>;
79-
def : FMVOnlyExtension<"FEAT_DPB2", "dpb2", "+ccpp,+ccdp", 200>;
8078
def : FMVOnlyExtension<"FEAT_EBF16", "ebf16", "+bf16", 290>;
81-
def : FMVOnlyExtension<"FEAT_FLAGM2", "flagm2", "+flagm,+altnzcv", 30>;
82-
def : FMVOnlyExtension<"FEAT_FRINTTS", "frintts", "+fptoint", 250>;
8379
def : FMVOnlyExtension<"FEAT_LS64_ACCDATA", "ls64_accdata", "+ls64", 540>;
8480
def : FMVOnlyExtension<"FEAT_LS64_V", "ls64_v", "", 530>;
8581
def : FMVOnlyExtension<"FEAT_MEMTAG2", "memtag2", "+mte", 450>;
8682
def : FMVOnlyExtension<"FEAT_MEMTAG3", "memtag3", "+mte", 460>;
87-
def : FMVOnlyExtension<"FEAT_PMULL", "pmull", "+aes,+fp-armv8,+neon", 160>;
88-
def : FMVOnlyExtension<"FEAT_RCPC2", "rcpc2", "+rcpc", 240>;
8983
def : FMVOnlyExtension<"FEAT_RPRES", "rpres", "", 300>;
9084
def : FMVOnlyExtension<"FEAT_SHA1", "sha1", "+fp-armv8,+neon", 120>;
91-
def : FMVOnlyExtension<"FEAT_SSBS2", "ssbs2", "+ssbs", 500>;
9285
def : FMVOnlyExtension<"FEAT_SVE_BF16", "sve-bf16", "+sve,+bf16,+fullfp16,+fp-armv8,+neon", 320>;
9386
def : FMVOnlyExtension<"FEAT_SVE_EBF16", "sve-ebf16", "+sve,+bf16,+fullfp16,+fp-armv8,+neon", 330>;
9487
def : FMVOnlyExtension<"FEAT_SVE_I8MM", "sve-i8mm", "+sve,+i8mm,+fullfp16,+fp-armv8,+neon", 340>;
@@ -131,6 +124,9 @@ def FeatureAES : Extension<
131124
"Enable AES support (FEAT_AES, FEAT_PMULL)", [FeatureNEON],
132125
"FEAT_AES", "+fp-armv8,+neon", 150>;
133126

127+
let ArchExtKindSpelling = "AEK_PMULL", Implies = [FeatureAES] in
128+
def : FMVOnlyExtension<"FEAT_PMULL", "pmull", "+aes,+fp-armv8,+neon", 160>;
129+
134130
// Crypto has been split up and any combination is now valid (see the
135131
// crypto definitions above). Also, crypto is now context sensitive:
136132
// it has a different meaning for e.g. Armv8.4 than it has for Armv8.2.
@@ -216,8 +212,10 @@ def FeaturePAN_RWV : SubtargetFeature<
216212
def FeaturePsUAO : SubtargetFeature< "uaops", "HasPsUAO", "true",
217213
"Enable v8.2 UAO PState (FEAT_UAO)">;
218214

219-
def FeatureCCPP : SubtargetFeature<"ccpp", "HasCCPP",
220-
"true", "Enable v8.2 data Cache Clean to Point of Persistence (FEAT_DPB)" >;
215+
let MArchName = "dpb" in
216+
def FeatureCCPP : Extension<"ccpp", "CCPP",
217+
"Enable v8.2 data Cache Clean to Point of Persistence (FEAT_DPB)", [],
218+
"FEAT_DPB", "+ccpp", 190>;
221219

222220
def FeatureSVE : Extension<"sve", "SVE",
223221
"Enable Scalable Vector Extension (SVE) instructions (FEAT_SVE)", [FeatureFullFP16],
@@ -484,9 +482,10 @@ def FeatureFlagM : Extension<
484482
"FEAT_FLAGM", "+flagm", 20>;
485483

486484
// 8.4 RCPC enchancements: LDAPR & STLR instructions with Immediate Offset
487-
def FeatureRCPC_IMMO : SubtargetFeature<"rcpc-immo", "HasRCPC_IMMO", "true",
485+
let MArchName = "rcpc2" in
486+
def FeatureRCPC_IMMO : Extension<"rcpc-immo", "RCPC_IMMO",
488487
"Enable v8.4-A RCPC instructions with Immediate Offsets (FEAT_LRCPC2)",
489-
[FeatureRCPC]>;
488+
[FeatureRCPC], "FEAT_RCPC2", "+rcpc,+rcpc-immo", 240>;
490489

491490
def FeatureNoNegativeImmediates : SubtargetFeature<"no-neg-immediates",
492491
"NegativeImmediates", "false",
@@ -518,12 +517,16 @@ def FeatureAggressiveFMA :
518517
"true",
519518
"Enable Aggressive FMA for floating-point.">;
520519

521-
def FeatureAltFPCmp : SubtargetFeature<"altnzcv", "HasAlternativeNZCV", "true",
522-
"Enable alternative NZCV format for floating point comparisons (FEAT_FlagM2)">;
520+
let MArchName = "flagm2" in
521+
def FeatureAltFPCmp : Extension<"altnzcv", "AlternativeNZCV",
522+
"Enable alternative NZCV format for floating point comparisons (FEAT_FlagM2)",
523+
[FeatureFlagM], "FEAT_FLAGM2", "+flagm,+altnzcv", 30>;
523524

524-
def FeatureFRInt3264 : SubtargetFeature<"fptoint", "HasFRInt3264", "true",
525+
let MArchName = "frintts" in
526+
def FeatureFRInt3264 : Extension<"fptoint", "FRInt3264",
525527
"Enable FRInt[32|64][Z|X] instructions that round a floating-point number to "
526-
"an integer (in FP format) forcing it to fit into a 32- or 64-bit int (FEAT_FRINTTS)" >;
528+
"an integer (in FP format) forcing it to fit into a 32- or 64-bit int (FEAT_FRINTTS)",
529+
[], "FEAT_FRINTTS", "+fptoint", 250>;
527530

528531
def FeatureSpecRestrict : SubtargetFeature<"specrestrict", "HasSpecRestrict",
529532
"true", "Enable architectural speculation restriction (FEAT_CSV2_2)">;
@@ -536,14 +539,18 @@ def FeatureSSBS : Extension<"ssbs", "SSBS",
536539
"Enable Speculative Store Bypass Safe bit (FEAT_SSBS, FEAT_SSBS2)", [],
537540
"FEAT_SSBS", "", 490>;
538541

542+
let ArchExtKindSpelling = "AEK_SSBS2", Implies = [FeatureSSBS] in
543+
def : FMVOnlyExtension<"FEAT_SSBS2", "ssbs2", "+ssbs", 500>;
544+
539545
def FeaturePredRes : Extension<"predres", "PredRes",
540546
"Enable v8.5a execution and data prediction invalidation instructions (FEAT_SPECRES)", [],
541547
"FEAT_PREDRES", "+predres", 480>;
542548

543-
def FeatureCacheDeepPersist : SubtargetFeature<"ccdp", "CCDP", "true",
544-
"Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)" >;
549+
let MArchName = "dpb2" in
550+
def FeatureCacheDeepPersist : Extension<"ccdp", "CCDP",
551+
"Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)", [FeatureCCPP],
552+
"FEAT_DPB2", "+ccpp,+ccdp", 200>;
545553

546-
let ArchExtKindSpelling = "AEK_NONE" in
547554
def FeatureBranchTargetId : Extension<"bti", "BTI",
548555
"Enable Branch Target Identification (FEAT_BTI)", [],
549556
"FEAT_BTI", "+bti", 510>;

llvm/unittests/TargetParser/TargetParserTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,6 @@ TEST(TargetParserTest, AArch64PrintSupportedExtensions) {
22902290
// but not all as if one is hidden correctly the rest should be.
22912291
EXPECT_EQ(std::string::npos, captured.find("memtag3"));
22922292
EXPECT_EQ(std::string::npos, captured.find("sha1"));
2293-
EXPECT_EQ(std::string::npos, captured.find("ssbs2"));
22942293
}
22952294

22962295
struct AArch64ExtensionDependenciesBaseArchTestParams {

0 commit comments

Comments
 (0)