Skip to content

Commit 0c00fc2

Browse files
committed
[AArch64] Merge duplicate extension information.
When we moved the extension information into tablegen in llvm#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. As a result these features are no longer AEK_NONE, which means they would become available to the command line. Since we don't want that I added a new field in ExtensionInfo to indicate whether a feature IsFMVOnly. That made the class FMVOnlyExtension redundant so I have removed it from tablegen. To reject such features on the command line but have them accepted in attribute strings we need two different parsing functions. I made parseArchExtension skip over IsFMVOnly entries and created a new one called parseFMVExtension which doesn't skip them. Making all extensions have ArchExtKind != AEK_NONE is a stepping stone towards deprecating DependentFeatures from ExtensionInfo completely, since we will be able to express them through ExtensionDependency.
1 parent c7c5666 commit 0c00fc2

File tree

8 files changed

+159
-77
lines changed

8 files changed

+159
-77
lines changed

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
659659
unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const {
660660
if (Name == "default")
661661
return 0;
662-
if (auto Ext = llvm::AArch64::parseArchExtension(Name))
662+
if (auto Ext = llvm::AArch64::parseFMVExtension(Name))
663663
return Ext->FmvPriority;
664664
return 0;
665665
}
@@ -670,13 +670,13 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const {
670670
}
671671

672672
bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const {
673-
if (auto Ext = llvm::AArch64::parseArchExtension(Name))
673+
if (auto Ext = llvm::AArch64::parseFMVExtension(Name))
674674
return !Ext->DependentFeatures.empty();
675675
return false;
676676
}
677677

678678
StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const {
679-
if (auto Ext = llvm::AArch64::parseArchExtension(Name))
679+
if (auto Ext = llvm::AArch64::parseFMVExtension(Name))
680680
return Ext->DependentFeatures;
681681
return StringRef();
682682
}
@@ -686,7 +686,7 @@ bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
686686
llvm::SmallVector<StringRef, 8> Features;
687687
FeatureStr.split(Features, "+");
688688
for (auto &Feature : Features)
689-
if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value())
689+
if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value())
690690
return false;
691691
return true;
692692
}

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14259,7 +14259,7 @@ Value *CodeGenFunction::EmitAArch64CpuSupports(const CallExpr *E) {
1425914259
ArgStr.split(Features, "+");
1426014260
for (auto &Feature : Features) {
1426114261
Feature = Feature.trim();
14262-
if (!llvm::AArch64::parseArchExtension(Feature))
14262+
if (!llvm::AArch64::parseFMVExtension(Feature))
1426314263
return Builder.getFalse();
1426414264
if (Feature != "default")
1426514265
Features.push_back(Feature);

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef AttrStr,
973973

974974
llvm::SmallDenseSet<StringRef, 8> UniqueFeats;
975975
for (auto &Feat : Features)
976-
if (auto Ext = llvm::AArch64::parseArchExtension(Feat))
976+
if (auto Ext = llvm::AArch64::parseFMVExtension(Feat))
977977
if (UniqueFeats.insert(Ext->Name).second)
978978
Out << 'M' << Ext->Name;
979979
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Test that features which are meaningful only for Function Multiversioning are rejected from the command line.
2+
3+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+dgh %s 2>&1 | FileCheck %s --check-prefix=DGH
4+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+ebf16 %s 2>&1 | FileCheck %s --check-prefix=EBF16
5+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+ls64_accdata %s 2>&1 | FileCheck %s --check-prefix=LS64_ACCDATA
6+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+ls64_v %s 2>&1 | FileCheck %s --check-prefix=LS64_V
7+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+memtag2 %s 2>&1 | FileCheck %s --check-prefix=MEMTAG2
8+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+memtag3 %s 2>&1 | FileCheck %s --check-prefix=MEMTAG3
9+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+pmull %s 2>&1 | FileCheck %s --check-prefix=PMULL
10+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+rpres %s 2>&1 | FileCheck %s --check-prefix=RPRES
11+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+sha1 %s 2>&1 | FileCheck %s --check-prefix=SHA1
12+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+ssbs2 %s 2>&1 | FileCheck %s --check-prefix=SSBS2
13+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+sve-bf16 %s 2>&1 | FileCheck %s --check-prefix=SVE_BF16
14+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+sve-ebf16 %s 2>&1 | FileCheck %s --check-prefix=SVE_EBF16
15+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+sve-i8mm %s 2>&1 | FileCheck %s --check-prefix=SVE_I8MM
16+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-pmull128 %s 2>&1 | FileCheck %s --check-prefix=SVE2_PMULL128
17+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+dpb %s 2>&1 | FileCheck %s --check-prefix=DPB
18+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+rcpc2 %s 2>&1 | FileCheck %s --check-prefix=RCPC2
19+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+flagm2 %s 2>&1 | FileCheck %s --check-prefix=FLAGM2
20+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+frintts %s 2>&1 | FileCheck %s --check-prefix=FRINTTS
21+
// RUN: not %clang --target=aarch64-linux-gnu -march=armv8-a+dpb2 %s 2>&1 | FileCheck %s --check-prefix=DPB2
22+
23+
// DGH: error: unsupported argument 'armv8-a+dgh' to option '-march='
24+
// EBF16: error: unsupported argument 'armv8-a+ebf16' to option '-march='
25+
// LS64_ACCDATA: error: unsupported argument 'armv8-a+ls64_accdata' to option '-march='
26+
// LS64_V: error: unsupported argument 'armv8-a+ls64_v' to option '-march='
27+
// MEMTAG2: error: unsupported argument 'armv8-a+memtag2' to option '-march='
28+
// MEMTAG3: error: unsupported argument 'armv8-a+memtag3' to option '-march='
29+
// PMULL: error: unsupported argument 'armv8-a+pmull' to option '-march='
30+
// RPRES: error: unsupported argument 'armv8-a+rpres' to option '-march='
31+
// SHA1: error: unsupported argument 'armv8-a+sha1' to option '-march='
32+
// SSBS2: error: unsupported argument 'armv8-a+ssbs2' to option '-march='
33+
// SVE_BF16: error: unsupported argument 'armv8-a+sve-bf16' to option '-march='
34+
// SVE_EBF16: error: unsupported argument 'armv8-a+sve-ebf16' to option '-march='
35+
// SVE_I8MM: error: unsupported argument 'armv8-a+sve-i8mm' to option '-march='
36+
// SVE2_PMULL128: error: unsupported argument 'armv8-a+sve2-pmull128' to option '-march='
37+
// DPB: error: unsupported argument 'armv8-a+dpb' to option '-march='
38+
// RCPC2: error: unsupported argument 'armv8-a+rcpc2' to option '-march='
39+
// FLAGM2: error: unsupported argument 'armv8-a+flagm2' to option '-march='
40+
// FRINTTS: error: unsupported argument 'armv8-a+frintts' to option '-march='
41+
// DPB2: error: unsupported argument 'armv8-a+dpb2' to option '-march='

llvm/include/llvm/TargetParser/AArch64TargetParser.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,24 @@ static_assert(FEAT_MAX < 62,
109109

110110
using ExtensionBitset = Bitset<AEK_NUM_EXTENSIONS>;
111111

112-
// Represents an extension that can be enabled with -march=<arch>+<extension>.
113-
// Typically these correspond to Arm Architecture extensions, unlike
114-
// SubtargetFeature which may represent either an actual extension or some
115-
// internal LLVM property.
112+
// Represents an extension that can be enabled with -march=<arch>+<extension>,
113+
// or via a Function Multiversion (FMV) attribute. Typically these correspond
114+
// to Arm Architecture extensions, unlike SubtargetFeature which may represent
115+
// either an actual extension or some internal LLVM property.
116116
struct ExtensionInfo {
117117
StringRef Name; // Human readable name, e.g. "profile".
118118
std::optional<StringRef> Alias; // An alias for this extension, if one exists.
119119
ArchExtKind ID; // Corresponding to the ArchExtKind, this
120120
// extensions representation in the bitfield.
121121
StringRef Feature; // -mattr enable string, e.g. "+spe"
122122
StringRef NegFeature; // -mattr disable string, e.g. "-spe"
123-
CPUFeatures CPUFeature; // Function Multi Versioning (FMV) bitfield value
124-
// set in __aarch64_cpu_features
125-
StringRef DependentFeatures; // FMV enabled features string,
126-
// e.g. "+dotprod,+fp-armv8,+neon"
127-
unsigned FmvPriority; // FMV feature priority
123+
bool IsFMVOnly; // Flag indicating whether the extension is
124+
// available on the command line or not.
125+
CPUFeatures CPUFeature; // FMV bitfield value set in
126+
// __aarch64_cpu_features
127+
StringRef DependentFeatures; // FMV enabled features string,
128+
// e.g. "+dotprod,+fp-armv8,+neon"
129+
unsigned FmvPriority; // FMV feature priority
128130
static constexpr unsigned MaxFMVPriority =
129131
1000; // Maximum priority for FMV feature
130132
};
@@ -690,6 +692,7 @@ const ArchInfo *getArchForCpu(StringRef CPU);
690692
// Parser
691693
const ArchInfo *parseArch(StringRef Arch);
692694
std::optional<ExtensionInfo> parseArchExtension(StringRef Extension);
695+
std::optional<ExtensionInfo> parseFMVExtension(StringRef Extension);
693696
// Given the name of a CPU or alias, return the correponding CpuInfo.
694697
std::optional<CpuInfo> parseCpu(StringRef Name);
695698
// Used by target parser tests

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12-
// A SubtargetFeature that can be toggled from the command line, and therefore
13-
// has an AEK_* entry in ArmExtKind.
12+
// A SubtargetFeature that can be toggled from the command line, or be part of
13+
// a Function Multiversioning (FMV) attribute string.
1414
//
15-
// If Function MultiVersioning (FMV) properties are left at their defaults
16-
// (FEAT_INIT, no dependencies, priority 0) it indiates that this extension is
17-
// not an FMV feature, but can be enabled via the command line (-march, -mcpu,
18-
// etc).
19-
//
20-
// Conversely if the ArchExtKindSpelling is set to AEK_NONE, this indicates
21-
// that a feature is FMV-only, and can not be selected on the command line.
22-
// Such extensions should be added via FMVOnlyExtension.
15+
// If FMV properties are left at their defaults (FEAT_INIT, no dependencies,
16+
// priority 0) it indiates that this extension is not an FMV feature, but can
17+
// be enabled via the command line (-march, -mcpu, etc).
2318
class Extension<
2419
string TargetFeatureName, // String used for -target-feature and -march, unless overridden.
2520
string Spelling, // The XYZ in HasXYZ and AEK_XYZ.
@@ -28,7 +23,8 @@ class Extension<
2823
// FMV properties
2924
string _FMVBit = "FEAT_INIT", // FEAT_INIT is repurposed to indicate "not an FMV feature"
3025
string _FMVDependencies = "",
31-
int _FMVPriority = 0
26+
int _FMVPriority = 0,
27+
string _IsFMVOnly = "false" // Indicates if the extension is available on the command line.
3228
> : SubtargetFeature<TargetFeatureName, "Has" # Spelling, "true", Desc, Implies>
3329
{
3430
string ArchExtKindSpelling = "AEK_" # Spelling; // ArchExtKind enum name.
@@ -43,7 +39,7 @@ class Extension<
4339
// Used for correcting historical names while remaining backwards compatible.
4440
string MArchAlias = "";
4541

46-
// Function MultiVersioning (FMV) properties
42+
// Function Multiversioning (FMV) properties
4743

4844
// A C++ expression giving the number of the bit in the FMV ABI.
4945
// Currently this is given as a value from the enum "CPUFeatures".
@@ -56,43 +52,64 @@ class Extension<
5652

5753
// The FMV priority
5854
int FMVPriority = _FMVPriority;
55+
56+
// Indicates if the extension is available on the command line.
57+
string IsFMVOnly = _IsFMVOnly;
5958
}
6059

6160
// Some extensions are available for FMV but can not be controlled via the
62-
// command line. These entries:
63-
// - are SubtargetFeatures, so they have (unused) FieldNames on the subtarget
64-
// e.g. HasFMVOnlyFEAT_XYZ
65-
// - have incorrect (empty) Implies fields, because the code that handles FMV
66-
// ignores these dependencies and looks only at FMVDependencies.
67-
// - have no description.
68-
//
69-
// In the generated data structures for extensions (ExtensionInfo), AEK_NONE is
70-
// used to indicate that a feature is FMV only. Therefore ArchExtKindSpelling is
71-
// manually overridden here.
72-
class FMVOnlyExtension<string FMVBit, string Name, string Deps, int Priority>
73-
: Extension<Name, "FMVOnly"#FMVBit, "", [], FMVBit, Deps, Priority> {
74-
let ArchExtKindSpelling = "AEK_NONE"; // AEK_NONE indicates FMV-only feature
75-
}
61+
// command line, neither have a TargetFeatureName. Since they have no effect
62+
// on their own, their description is left empty. However they can have side
63+
// effects by implying other Subtarget Features. These extensions are used
64+
// in FMV for detection purposes.
65+
66+
let MArchName = "dgh" in
67+
def : Extension<"", "DGH", "", [], "FEAT_DGH", "", 260, "true">;
68+
69+
let MArchName = "ebf16" in
70+
def : Extension<"", "EBF16", "", [], "FEAT_EBF16", "+bf16", 290, "true">;
71+
72+
let MArchName = "ls64_accdata" in
73+
def : Extension<"", "LS64_ACCDATA", "", [], "FEAT_LS64_ACCDATA",
74+
"+ls64", 540, "true">;
75+
76+
let MArchName = "ls64_v" in
77+
def : Extension<"", "LS64_V", "", [], "FEAT_LS64_V", "", 530, "true">;
78+
79+
let MArchName = "memtag2" in
80+
def : Extension<"", "MEMTAG2", "", [], "FEAT_MEMTAG2", "+mte", 450, "true">;
81+
82+
let MArchName = "memtag3" in
83+
def : Extension<"", "MEMTAG3", "", [], "FEAT_MEMTAG3", "+mte", 460, "true">;
84+
85+
let MArchName = "pmull" in
86+
def : Extension<"", "PMULL", "", [], "FEAT_PMULL",
87+
"+aes,+fp-armv8,+neon", 160, "true">;
88+
89+
let MArchName = "rpres" in
90+
def : Extension<"", "RPRES", "", [], "FEAT_RPRES", "", 300, "true">;
91+
92+
let MArchName = "sha1" in
93+
def : Extension<"", "SHA1", "", [], "FEAT_SHA1", "+fp-armv8,+neon", 120, "true">;
94+
95+
let MArchName = "ssbs2" in
96+
def : Extension<"", "SSBS2", "", [], "FEAT_SSBS2", "+ssbs", 500, "true">;
97+
98+
let MArchName = "sve-bf16" in
99+
def : Extension<"", "SVE_BF16", "", [], "FEAT_SVE_BF16",
100+
"+sve,+bf16,+fullfp16,+fp-armv8,+neon", 320, "true">;
101+
102+
let MArchName = "sve-ebf16" in
103+
def : Extension<"", "SVE_EBF16", "", [], "FEAT_SVE_EBF16",
104+
"+sve,+bf16,+fullfp16,+fp-armv8,+neon", 330, "true">;
105+
106+
let MArchName = "sve-i8mm" in
107+
def : Extension<"", "SVE_I8MM", "", [], "FEAT_SVE_I8MM",
108+
"+sve,+i8mm,+fullfp16,+fp-armv8,+neon", 340, "true">;
76109

77-
def : FMVOnlyExtension<"FEAT_DGH", "dgh", "", 260>;
78-
def : FMVOnlyExtension<"FEAT_DPB", "dpb", "+ccpp", 190>;
79-
def : FMVOnlyExtension<"FEAT_DPB2", "dpb2", "+ccpp,+ccdp", 200>;
80-
def : FMVOnlyExtension<"FEAT_EBF16", "ebf16", "+bf16", 290>;
81-
def : FMVOnlyExtension<"FEAT_FLAGM2", "flagm2", "+flagm,+altnzcv", 30>;
82-
def : FMVOnlyExtension<"FEAT_FRINTTS", "frintts", "+fptoint", 250>;
83-
def : FMVOnlyExtension<"FEAT_LS64_ACCDATA", "ls64_accdata", "+ls64", 540>;
84-
def : FMVOnlyExtension<"FEAT_LS64_V", "ls64_v", "", 530>;
85-
def : FMVOnlyExtension<"FEAT_MEMTAG2", "memtag2", "+mte", 450>;
86-
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>;
89-
def : FMVOnlyExtension<"FEAT_RPRES", "rpres", "", 300>;
90-
def : FMVOnlyExtension<"FEAT_SHA1", "sha1", "+fp-armv8,+neon", 120>;
91-
def : FMVOnlyExtension<"FEAT_SSBS2", "ssbs2", "+ssbs", 500>;
92-
def : FMVOnlyExtension<"FEAT_SVE_BF16", "sve-bf16", "+sve,+bf16,+fullfp16,+fp-armv8,+neon", 320>;
93-
def : FMVOnlyExtension<"FEAT_SVE_EBF16", "sve-ebf16", "+sve,+bf16,+fullfp16,+fp-armv8,+neon", 330>;
94-
def : FMVOnlyExtension<"FEAT_SVE_I8MM", "sve-i8mm", "+sve,+i8mm,+fullfp16,+fp-armv8,+neon", 340>;
95-
def : FMVOnlyExtension<"FEAT_SVE_PMULL128", "sve2-pmull128", "+sve2,+sve,+sve2-aes,+fullfp16,+fp-armv8,+neon", 390>;
110+
let MArchName = "sve2-pmull128" in
111+
def : Extension<"", "SVE_PMULL128", "", [], "FEAT_SVE_PMULL128",
112+
"+sve2,+sve,+sve2-aes,+fullfp16,+fp-armv8,+neon", 390, "true">;
96113

97114

98115
// Each SubtargetFeature which corresponds to an Arm Architecture feature should
@@ -216,8 +233,10 @@ def FeaturePAN_RWV : SubtargetFeature<
216233
def FeaturePsUAO : SubtargetFeature< "uaops", "HasPsUAO", "true",
217234
"Enable v8.2 UAO PState (FEAT_UAO)">;
218235

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

222241
def FeatureSVE : Extension<"sve", "SVE",
223242
"Enable Scalable Vector Extension (SVE) instructions (FEAT_SVE)", [FeatureFullFP16],
@@ -491,9 +510,10 @@ def FeatureFlagM : Extension<
491510
"FEAT_FLAGM", "+flagm", 20>;
492511

493512
// 8.4 RCPC enchancements: LDAPR & STLR instructions with Immediate Offset
494-
def FeatureRCPC_IMMO : SubtargetFeature<"rcpc-immo", "HasRCPC_IMMO", "true",
513+
let MArchName = "rcpc2" in
514+
def FeatureRCPC_IMMO : Extension<"rcpc-immo", "RCPC_IMMO",
495515
"Enable v8.4-A RCPC instructions with Immediate Offsets (FEAT_LRCPC2)",
496-
[FeatureRCPC]>;
516+
[FeatureRCPC], "FEAT_RCPC2", "+rcpc", 240, "true">;
497517

498518
def FeatureNoNegativeImmediates : SubtargetFeature<"no-neg-immediates",
499519
"NegativeImmediates", "false",
@@ -525,12 +545,16 @@ def FeatureAggressiveFMA :
525545
"true",
526546
"Enable Aggressive FMA for floating-point.">;
527547

528-
def FeatureAltFPCmp : SubtargetFeature<"altnzcv", "HasAlternativeNZCV", "true",
529-
"Enable alternative NZCV format for floating point comparisons (FEAT_FlagM2)">;
548+
let MArchName = "flagm2" in
549+
def FeatureAltFPCmp : Extension<"altnzcv", "AlternativeNZCV",
550+
"Enable alternative NZCV format for floating point comparisons (FEAT_FlagM2)",
551+
[], "FEAT_FLAGM2", "+flagm,+altnzcv", 30, "true">;
530552

531-
def FeatureFRInt3264 : SubtargetFeature<"fptoint", "HasFRInt3264", "true",
553+
let MArchName = "frintts" in
554+
def FeatureFRInt3264 : Extension<"fptoint", "FRInt3264",
532555
"Enable FRInt[32|64][Z|X] instructions that round a floating-point number to "
533-
"an integer (in FP format) forcing it to fit into a 32- or 64-bit int (FEAT_FRINTTS)" >;
556+
"an integer (in FP format) forcing it to fit into a 32- or 64-bit int (FEAT_FRINTTS)",
557+
[], "FEAT_FRINTTS", "+fptoint", 250, "true">;
534558

535559
def FeatureSpecRestrict : SubtargetFeature<"specrestrict", "HasSpecRestrict",
536560
"true", "Enable architectural speculation restriction (FEAT_CSV2_2)">;
@@ -547,13 +571,14 @@ def FeaturePredRes : Extension<"predres", "PredRes",
547571
"Enable v8.5a execution and data prediction invalidation instructions (FEAT_SPECRES)", [],
548572
"FEAT_PREDRES", "+predres", 480>;
549573

550-
def FeatureCacheDeepPersist : SubtargetFeature<"ccdp", "CCDP", "true",
551-
"Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)" >;
574+
let MArchName = "dpb2" in
575+
def FeatureCacheDeepPersist : Extension<"ccdp", "CCDP",
576+
"Enable v8.5 Cache Clean to Point of Deep Persistence (FEAT_DPB2)", [],
577+
"FEAT_DPB2", "+ccpp,+ccdp", 200, "true">;
552578

553-
let ArchExtKindSpelling = "AEK_NONE" in
554579
def FeatureBranchTargetId : Extension<"bti", "BTI",
555580
"Enable Branch Target Identification (FEAT_BTI)", [],
556-
"FEAT_BTI", "+bti", 510>;
581+
"FEAT_BTI", "+bti", 510, "true">;
557582

558583
let ArchExtKindSpelling = "AEK_RAND", MArchName = "rng" in
559584
def FeatureRandGen : Extension<"rand", "RandGen",

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ std::optional<AArch64::ArchInfo> AArch64::ArchInfo::findBySubArch(StringRef SubA
5050
uint64_t AArch64::getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs) {
5151
uint64_t FeaturesMask = 0;
5252
for (const StringRef &FeatureStr : FeatureStrs) {
53-
if (auto Ext = parseArchExtension(FeatureStr))
53+
if (auto Ext = parseFMVExtension(FeatureStr))
5454
FeaturesMask |= (1ULL << Ext->CPUFeature);
5555
}
5656
return FeaturesMask;
@@ -116,12 +116,23 @@ const AArch64::ArchInfo *AArch64::parseArch(StringRef Arch) {
116116
std::optional<AArch64::ExtensionInfo>
117117
AArch64::parseArchExtension(StringRef ArchExt) {
118118
for (const auto &A : Extensions) {
119+
if (A.IsFMVOnly)
120+
continue;
119121
if (ArchExt == A.Name || ArchExt == A.Alias)
120122
return A;
121123
}
122124
return {};
123125
}
124126

127+
std::optional<AArch64::ExtensionInfo>
128+
AArch64::parseFMVExtension(StringRef FMVExt) {
129+
for (const auto &E : Extensions) {
130+
if (FMVExt == E.Name || FMVExt == E.Alias)
131+
return E;
132+
}
133+
return {};
134+
}
135+
125136
std::optional<AArch64::CpuInfo> AArch64::parseCpu(StringRef Name) {
126137
// Resolve aliases first.
127138
Name = resolveCPUAlias(Name);

0 commit comments

Comments
 (0)