Skip to content

Commit 12c0024

Browse files
[AArch64][TargetParser] Move extension aliases into tablegen (llvm#91970)
1 parent f3b8d91 commit 12c0024

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

llvm/include/llvm/TargetParser/AArch64TargetParser.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ using ExtensionBitset = Bitset<AEK_NUM_EXTENSIONS>;
114114
// SubtargetFeature which may represent either an actual extension or some
115115
// internal LLVM property.
116116
struct ExtensionInfo {
117-
StringRef Name; // Human readable name, e.g. "profile".
118-
ArchExtKind ID; // Corresponding to the ArchExtKind, this
119-
// extensions representation in the bitfield.
120-
StringRef Feature; // -mattr enable string, e.g. "+spe"
121-
StringRef NegFeature; // -mattr disable string, e.g. "-spe"
117+
StringRef Name; // Human readable name, e.g. "profile".
118+
std::optional<StringRef> Alias; // An alias for this extension, if one exists.
119+
ArchExtKind ID; // Corresponding to the ArchExtKind, this
120+
// extensions representation in the bitfield.
121+
StringRef Feature; // -mattr enable string, e.g. "+spe"
122+
StringRef NegFeature; // -mattr disable string, e.g. "-spe"
122123
CPUFeatures CPUFeature; // Function Multi Versioning (FMV) bitfield value
123124
// set in __aarch64_cpu_features
124125
StringRef DependentFeatures; // FMV enabled features string,
@@ -674,8 +675,6 @@ struct Alias {
674675
inline constexpr Alias CpuAliases[] = {{"cobalt-100", "neoverse-n2"},
675676
{"grace", "neoverse-v2"}};
676677

677-
inline constexpr Alias ExtAliases[] = {{"rdma", "rdm"}};
678-
679678
const ExtensionInfo &getExtensionByID(ArchExtKind(ExtID));
680679

681680
bool getExtensionFeatures(
@@ -684,7 +683,6 @@ bool getExtensionFeatures(
684683

685684
StringRef getArchExtFeature(StringRef ArchExt);
686685
StringRef resolveCPUAlias(StringRef CPU);
687-
StringRef resolveExtAlias(StringRef ArchExt);
688686

689687
// Information by Name
690688
const ArchInfo *getArchForCpu(StringRef CPU);

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class Extension<
3939
// not doing so.
4040
string MArchName = TargetFeatureName;
4141

42+
// An alias that can be used on the command line, if the extension has one.
43+
// Used for correcting historical names while remaining backwards compatible.
44+
string MArchAlias = "";
45+
4246
// Function MultiVersioning (FMV) properties
4347

4448
// A C++ expression giving the number of the bit in the FMV ABI.
@@ -163,6 +167,7 @@ def FeatureOutlineAtomics : SubtargetFeature<"outline-atomics", "OutlineAtomics"
163167
def FeatureFMV : SubtargetFeature<"fmv", "HasFMV", "true",
164168
"Enable Function Multi Versioning support.">;
165169

170+
let MArchAlias = "rdma" in
166171
def FeatureRDM : Extension<"rdm", "RDM",
167172
"Enable ARMv8.1 Rounding Double Multiply Add/Subtract instructions (FEAT_RDM)",
168173
[FeatureNEON],

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ StringRef AArch64::resolveCPUAlias(StringRef Name) {
7474
return Name;
7575
}
7676

77-
StringRef AArch64::resolveExtAlias(StringRef Name) {
78-
for (const auto &A : ExtAliases)
79-
if (A.AltName == Name)
80-
return A.Name;
81-
return Name;
82-
}
83-
8477
StringRef AArch64::getArchExtFeature(StringRef ArchExt) {
8578
bool IsNegated = ArchExt.starts_with("no");
8679
StringRef ArchExtBase = IsNegated ? ArchExt.drop_front(2) : ArchExt;
@@ -120,13 +113,10 @@ const AArch64::ArchInfo *AArch64::parseArch(StringRef Arch) {
120113
return {};
121114
}
122115

123-
std::optional<AArch64::ExtensionInfo> AArch64::parseArchExtension(StringRef ArchExt) {
124-
// Resolve aliases first.
125-
ArchExt = resolveExtAlias(ArchExt);
126-
127-
// Then find the Extension name.
116+
std::optional<AArch64::ExtensionInfo>
117+
AArch64::parseArchExtension(StringRef ArchExt) {
128118
for (const auto &A : Extensions) {
129-
if (ArchExt == A.Name)
119+
if (ArchExt == A.Name || ArchExt == A.Alias)
130120
return A;
131121
}
132122
return {};

llvm/utils/TableGen/ARMTargetDefEmitter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
8989
auto AEK = Rec->getValueAsString("ArchExtKindSpelling").upper();
9090
OS << " ";
9191
OS << "{\"" << Rec->getValueAsString("MArchName") << "\"";
92+
if (auto Alias = Rec->getValueAsString("MArchAlias"); Alias.empty())
93+
OS << ", {}";
94+
else
95+
OS << ", \"" << Alias << "\"";
9296
OS << ", AArch64::" << AEK;
9397
if (AEK == "AEK_NONE") {
9498
// HACK: don't emit posfeat/negfeat strings for FMVOnlyExtensions.
@@ -102,7 +106,7 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
102106
OS << ", " << (uint64_t)Rec->getValueAsInt("FMVPriority");
103107
OS << "},\n";
104108
};
105-
OS << " {\"none\", AArch64::AEK_NONE, {}, {}, FEAT_INIT, \"\", "
109+
OS << " {\"none\", {}, AArch64::AEK_NONE, {}, {}, FEAT_INIT, \"\", "
106110
"ExtensionInfo::MaxFMVPriority},\n";
107111
OS << "};\n"
108112
<< "#undef EMIT_EXTENSIONS\n"

0 commit comments

Comments
 (0)