-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64][TargetParser] Move extension aliases into tablegen #91970
Merged
tmatheson-arm
merged 4 commits into
llvm:main
from
tmatheson-arm:targetparser_extension_aliases
May 14, 2024
Merged
[AArch64][TargetParser] Move extension aliases into tablegen #91970
tmatheson-arm
merged 4 commits into
llvm:main
from
tmatheson-arm:targetparser_extension_aliases
May 14, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allow only one alias.
@llvm/pr-subscribers-backend-aarch64 Author: Tomas Matheson (tmatheson-arm) ChangesAllow only one alias. Full diff: https://github.com/llvm/llvm-project/pull/91970.diff 4 Files Affected:
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..32db865f1feb3 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/TargetParser/AArch64TargetParser.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
@@ -74,13 +75,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 +114,11 @@ 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) {
+ assert(!ArchExt.empty());
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"
|
jroelofs
approved these changes
May 13, 2024
Turns out that this is called many times with an empty string.
fc5dda8
to
24c1614
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow only one alias.