Skip to content

Commit 260fe03

Browse files
authored
[llvm][AArch64][TargetParser][NFC] Use parseArchExtension in parseModifier. (#80427)
This allows making changes in parseArchExtension to make their way in the command line as well, not only in target attributes.
1 parent cba1b64 commit 260fe03

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,17 @@ void AArch64::ExtensionSet::addArchDefaults(const ArchInfo &Arch) {
260260
bool AArch64::ExtensionSet::parseModifier(StringRef Modifier) {
261261
LLVM_DEBUG(llvm::dbgs() << "parseModifier(" << Modifier << ")\n");
262262

263-
// Negative modifiers, with the syntax "no<feat>"
264-
if (Modifier.starts_with("no")) {
265-
StringRef ModifierBase(Modifier.substr(2));
266-
for (const auto &AE : Extensions) {
267-
if (!AE.NegFeature.empty() && ModifierBase == AE.Name) {
268-
disable(AE.ID);
269-
return true;
270-
}
271-
}
272-
}
273-
274-
// Positive modifiers
275-
for (const auto &AE : Extensions) {
276-
if (!AE.Feature.empty() && Modifier == AE.Name) {
277-
enable(AE.ID);
278-
return true;
279-
}
263+
bool IsNegated = Modifier.starts_with("no");
264+
StringRef ArchExt = IsNegated ? Modifier.drop_front(2) : Modifier;
265+
266+
if (auto AE = parseArchExtension(ArchExt)) {
267+
if (AE->Feature.empty() || AE->NegFeature.empty())
268+
return false;
269+
if (IsNegated)
270+
disable(AE->ID);
271+
else
272+
enable(AE->ID);
273+
return true;
280274
}
281-
282275
return false;
283276
}

0 commit comments

Comments
 (0)