[llvm] 12c0024 - [AArch64][TargetParser] Move extension aliases into tablegen (#91970)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 23:04:34 PDT 2024
Author: Tomas Matheson
Date: 2024-05-14T07:04:29+01:00
New Revision: 12c0024d196189bd38a140512c0bfbda85d8d75e
URL: https://github.com/llvm/llvm-project/commit/12c0024d196189bd38a140512c0bfbda85d8d75e
DIFF: https://github.com/llvm/llvm-project/commit/12c0024d196189bd38a140512c0bfbda85d8d75e.diff
LOG: [AArch64][TargetParser] Move extension aliases into tablegen (#91970)
Added:
Modified:
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64Features.td
llvm/lib/TargetParser/AArch64TargetParser.cpp
llvm/utils/TableGen/ARMTargetDefEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 20c3f95173c28..b662a74e5fc68 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -114,11 +114,12 @@ using ExtensionBitset = Bitset<AEK_NUM_EXTENSIONS>;
// SubtargetFeature which may represent either an actual extension or some
// internal LLVM property.
struct ExtensionInfo {
- StringRef Name; // Human readable name, e.g. "profile".
- ArchExtKind ID; // Corresponding to the ArchExtKind, this
- // extensions representation in the bitfield.
- StringRef Feature; // -mattr enable string, e.g. "+spe"
- StringRef NegFeature; // -mattr disable string, e.g. "-spe"
+ StringRef Name; // Human readable name, e.g. "profile".
+ std::optional<StringRef> Alias; // An alias for this extension, if one exists.
+ ArchExtKind ID; // Corresponding to the ArchExtKind, this
+ // extensions representation in the bitfield.
+ StringRef Feature; // -mattr enable string, e.g. "+spe"
+ StringRef NegFeature; // -mattr disable string, e.g. "-spe"
CPUFeatures CPUFeature; // Function Multi Versioning (FMV) bitfield value
// set in __aarch64_cpu_features
StringRef DependentFeatures; // FMV enabled features string,
@@ -674,8 +675,6 @@ struct Alias {
inline constexpr Alias CpuAliases[] = {{"cobalt-100", "neoverse-n2"},
{"grace", "neoverse-v2"}};
-inline constexpr Alias ExtAliases[] = {{"rdma", "rdm"}};
-
const ExtensionInfo &getExtensionByID(ArchExtKind(ExtID));
bool getExtensionFeatures(
@@ -684,7 +683,6 @@ bool getExtensionFeatures(
StringRef getArchExtFeature(StringRef ArchExt);
StringRef resolveCPUAlias(StringRef CPU);
-StringRef resolveExtAlias(StringRef ArchExt);
// Information by Name
const ArchInfo *getArchForCpu(StringRef CPU);
diff --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td
index 920ca7f4fbfcb..b9c26e99ae034 100644
--- a/llvm/lib/Target/AArch64/AArch64Features.td
+++ b/llvm/lib/Target/AArch64/AArch64Features.td
@@ -39,6 +39,10 @@ class Extension<
// not doing so.
string MArchName = TargetFeatureName;
+ // An alias that can be used on the command line, if the extension has one.
+ // Used for correcting historical names while remaining backwards compatible.
+ string MArchAlias = "";
+
// Function MultiVersioning (FMV) properties
// A C++ expression giving the number of the bit in the FMV ABI.
@@ -163,6 +167,7 @@ def FeatureOutlineAtomics : SubtargetFeature<"outline-atomics", "OutlineAtomics"
def FeatureFMV : SubtargetFeature<"fmv", "HasFMV", "true",
"Enable Function Multi Versioning support.">;
+let MArchAlias = "rdma" in
def FeatureRDM : Extension<"rdm", "RDM",
"Enable ARMv8.1 Rounding Double Multiply Add/Subtract instructions (FEAT_RDM)",
[FeatureNEON],
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index 026214e7e2eac..c10b4be4eded9 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -74,13 +74,6 @@ StringRef AArch64::resolveCPUAlias(StringRef Name) {
return Name;
}
-StringRef AArch64::resolveExtAlias(StringRef Name) {
- for (const auto &A : ExtAliases)
- if (A.AltName == Name)
- return A.Name;
- return Name;
-}
-
StringRef AArch64::getArchExtFeature(StringRef ArchExt) {
bool IsNegated = ArchExt.starts_with("no");
StringRef ArchExtBase = IsNegated ? ArchExt.drop_front(2) : ArchExt;
@@ -120,13 +113,10 @@ const AArch64::ArchInfo *AArch64::parseArch(StringRef Arch) {
return {};
}
-std::optional<AArch64::ExtensionInfo> AArch64::parseArchExtension(StringRef ArchExt) {
- // Resolve aliases first.
- ArchExt = resolveExtAlias(ArchExt);
-
- // Then find the Extension name.
+std::optional<AArch64::ExtensionInfo>
+AArch64::parseArchExtension(StringRef ArchExt) {
for (const auto &A : Extensions) {
- if (ArchExt == A.Name)
+ if (ArchExt == A.Name || ArchExt == A.Alias)
return A;
}
return {};
diff --git a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
index 4a46f2ea95869..0e90f57af4938 100644
--- a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
+++ b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
@@ -89,6 +89,10 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
auto AEK = Rec->getValueAsString("ArchExtKindSpelling").upper();
OS << " ";
OS << "{\"" << Rec->getValueAsString("MArchName") << "\"";
+ if (auto Alias = Rec->getValueAsString("MArchAlias"); Alias.empty())
+ OS << ", {}";
+ else
+ OS << ", \"" << Alias << "\"";
OS << ", AArch64::" << AEK;
if (AEK == "AEK_NONE") {
// HACK: don't emit posfeat/negfeat strings for FMVOnlyExtensions.
@@ -102,7 +106,7 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
OS << ", " << (uint64_t)Rec->getValueAsInt("FMVPriority");
OS << "},\n";
};
- OS << " {\"none\", AArch64::AEK_NONE, {}, {}, FEAT_INIT, \"\", "
+ OS << " {\"none\", {}, AArch64::AEK_NONE, {}, {}, FEAT_INIT, \"\", "
"ExtensionInfo::MaxFMVPriority},\n";
OS << "};\n"
<< "#undef EMIT_EXTENSIONS\n"
More information about the llvm-commits
mailing list