Skip to content

Commit 64851d9

Browse files
committed
[AArch64][TargetParser][NFC] Use parseArchExtension in parseModifier.
This allows making changes in parseArchExtension to make their way in the command line as well, not only in target attributes.
1 parent 319f4c0 commit 64851d9

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,18 @@ 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-
}
263+
bool IsNegated = Modifier.starts_with("no");
264+
StringRef ArchExt = IsNegated ? Modifier.drop_front(2) : Modifier;
273265

274-
// Positive modifiers
275-
for (const auto &AE : Extensions) {
276-
if (!AE.Feature.empty() && Modifier == AE.Name) {
277-
enable(AE.ID);
266+
if (auto AE = parseArchExtension(ArchExt)) {
267+
if (IsNegated && !AE->NegFeature.empty()) {
268+
disable(AE->ID);
269+
return true;
270+
}
271+
if (!AE->Feature.empty()) {
272+
enable(AE->ID);
278273
return true;
279274
}
280275
}
281-
282276
return false;
283277
}

0 commit comments

Comments
 (0)