Skip to content

Commit 0a95ea6

Browse files
committed
[NFC][AArch64] Rename TargetParser's ExtensionInfo fields
This renames some of the fields in AArchte64TargetParser's ExtensionInfo struct to better reflect their use cases and improve readability.
1 parent 524a4ae commit 0a95ea6

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,8 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef AttrStr,
966966
llvm::SmallDenseSet<StringRef, 8> UniqueFeats;
967967
for (auto &Feat : Features)
968968
if (auto Ext = llvm::AArch64::parseArchExtension(Feat))
969-
if (UniqueFeats.insert(Ext->Name).second)
970-
Out << 'M' << Ext->Name;
969+
if (UniqueFeats.insert(Ext->UserVisibleName).second)
970+
Out << 'M' << Ext->UserVisibleName;
971971
}
972972

973973
std::unique_ptr<TargetCodeGenInfo>

clang/lib/Driver/ToolChain.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ static void getAArch64MultilibFlags(const Driver &D,
195195
UnifiedFeatures.end());
196196
std::vector<std::string> MArch;
197197
for (const auto &Ext : AArch64::Extensions)
198-
if (FeatureSet.contains(Ext.Feature))
199-
MArch.push_back(Ext.Name.str());
198+
if (FeatureSet.contains(Ext.TargetFeature))
199+
MArch.push_back(Ext.UserVisibleName.str());
200200
for (const auto &Ext : AArch64::Extensions)
201-
if (FeatureSet.contains(Ext.NegFeature))
202-
MArch.push_back(("no" + Ext.Name).str());
201+
if (FeatureSet.contains(Ext.NegTargetFeature))
202+
MArch.push_back(("no" + Ext.UserVisibleName).str());
203203
StringRef ArchName;
204204
for (const auto &ArchInfo : AArch64::ArchInfos)
205205
if (FeatureSet.contains(ArchInfo->ArchFeature))

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
15231523
auto isPAuthLR = [](const char *member) {
15241524
llvm::AArch64::ExtensionInfo pauthlr_extension =
15251525
llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR);
1526-
return pauthlr_extension.Feature == member;
1526+
return pauthlr_extension.TargetFeature == member;
15271527
};
15281528

15291529
if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR))

llvm/include/llvm/TargetParser/AArch64TargetParser.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +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".
117+
StringRef UserVisibleName; // Human readable name used in -march/-cpu, 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.
121-
StringRef Feature; // -mattr enable string, e.g. "+spe"
122-
StringRef NegFeature; // -mattr disable string, e.g. "-spe"
121+
StringRef TargetFeature; // -target-feature/-mattr enable string, e.g. "+spe"
122+
StringRef NegTargetFeature; // -target-feature/-mattr disable string, e.g. "-spe"
123123
CPUFeatures CPUFeature; // Function Multi Versioning (FMV) bitfield value
124124
// set in __aarch64_cpu_features
125125
StringRef DependentFeatures; // FMV enabled features string,
@@ -273,12 +273,12 @@ struct ExtensionSet {
273273
Features.emplace_back(T(BaseArch->ArchFeature));
274274

275275
for (const auto &E : Extensions) {
276-
if (E.Feature.empty() || !Touched.test(E.ID))
276+
if (E.TargetFeature.empty() || !Touched.test(E.ID))
277277
continue;
278278
if (Enabled.test(E.ID))
279-
Features.emplace_back(T(E.Feature));
279+
Features.emplace_back(T(E.TargetFeature));
280280
else
281-
Features.emplace_back(T(E.NegFeature));
281+
Features.emplace_back(T(E.NegTargetFeature));
282282
}
283283
}
284284
};

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ bool AArch64::getExtensionFeatures(
5858
std::vector<StringRef> &Features) {
5959
for (const auto &E : Extensions)
6060
/* INVALID and NONE have no feature name. */
61-
if (InputExts.test(E.ID) && !E.Feature.empty())
62-
Features.push_back(E.Feature);
61+
if (InputExts.test(E.ID) && !E.TargetFeature.empty())
62+
Features.push_back(E.TargetFeature);
6363

6464
return true;
6565
}
@@ -77,7 +77,7 @@ StringRef AArch64::getArchExtFeature(StringRef ArchExt) {
7777

7878
if (auto AE = parseArchExtension(ArchExtBase)) {
7979
// Note: the returned string can be empty.
80-
return IsNegated ? AE->NegFeature : AE->Feature;
80+
return IsNegated ? AE->NegTargetFeature : AE->TargetFeature;
8181
}
8282

8383
return StringRef();
@@ -113,9 +113,9 @@ const AArch64::ArchInfo *AArch64::parseArch(StringRef Arch) {
113113
std::optional<AArch64::ExtensionInfo>
114114
AArch64::parseArchExtension(StringRef ArchExt) {
115115
for (const auto &A : Extensions) {
116-
if (A.Name.empty() && !A.Alias)
116+
if (A.UserVisibleName.empty() && !A.Alias)
117117
continue;
118-
if (ArchExt == A.Name || ArchExt == A.Alias)
118+
if (ArchExt == A.UserVisibleName || ArchExt == A.Alias)
119119
return A;
120120
}
121121
return {};
@@ -124,7 +124,7 @@ AArch64::parseArchExtension(StringRef ArchExt) {
124124
std::optional<AArch64::ExtensionInfo>
125125
AArch64::targetFeatureToExtension(StringRef TargetFeature) {
126126
for (const auto &E : Extensions)
127-
if (TargetFeature == E.Feature)
127+
if (TargetFeature == E.TargetFeature)
128128
return E;
129129
return {};
130130
}
@@ -147,11 +147,11 @@ void AArch64::PrintSupportedExtensions(StringMap<StringRef> DescMap) {
147147
<< (DescMap.empty() ? "\n" : "Description\n");
148148
for (const auto &Ext : Extensions) {
149149
// Extensions without a feature cannot be used with -march.
150-
if (!Ext.Name.empty() && !Ext.Feature.empty()) {
151-
std::string Description = DescMap[Ext.Name].str();
150+
if (!Ext.UserVisibleName.empty() && !Ext.TargetFeature.empty()) {
151+
std::string Description = DescMap[Ext.UserVisibleName].str();
152152
outs() << " "
153153
<< format(Description.empty() ? "%s\n" : "%-20s%s\n",
154-
Ext.Name.str().c_str(), Description.c_str());
154+
Ext.UserVisibleName.str().c_str(), Description.c_str());
155155
}
156156
}
157157
}
@@ -253,7 +253,7 @@ bool AArch64::ExtensionSet::parseModifier(StringRef Modifier,
253253
StringRef ArchExt = Modifier.drop_front(NChars);
254254

255255
if (auto AE = parseArchExtension(ArchExt)) {
256-
if (AE->Feature.empty() || AE->NegFeature.empty())
256+
if (AE->TargetFeature.empty() || AE->NegTargetFeature.empty())
257257
return false;
258258
if (IsNegated)
259259
disable(AE->ID);

0 commit comments

Comments
 (0)