[llvm] [AArch64][TargetParser][NFC] Use parseArchExtension in parseModifier. (PR #80427)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 2 04:54:22 PST 2024
https://github.com/labrinea created https://github.com/llvm/llvm-project/pull/80427
This allows making changes in parseArchExtension to make their way in the command line as well, not only in target attributes.
>From 64851d9898b1a42632d16bc9c606fc2c2f7b7fca Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas <alexandros.lamprineas at arm.com>
Date: Fri, 2 Feb 2024 12:11:03 +0000
Subject: [PATCH] [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.
---
llvm/lib/TargetParser/AArch64TargetParser.cpp | 24 +++++++------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index fd47f786a46ef..f730232c5022a 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -260,24 +260,18 @@ void AArch64::ExtensionSet::addArchDefaults(const ArchInfo &Arch) {
bool AArch64::ExtensionSet::parseModifier(StringRef Modifier) {
LLVM_DEBUG(llvm::dbgs() << "parseModifier(" << Modifier << ")\n");
- // Negative modifiers, with the syntax "no<feat>"
- if (Modifier.starts_with("no")) {
- StringRef ModifierBase(Modifier.substr(2));
- for (const auto &AE : Extensions) {
- if (!AE.NegFeature.empty() && ModifierBase == AE.Name) {
- disable(AE.ID);
- return true;
- }
- }
- }
+ bool IsNegated = Modifier.starts_with("no");
+ StringRef ArchExt = IsNegated ? Modifier.drop_front(2) : Modifier;
- // Positive modifiers
- for (const auto &AE : Extensions) {
- if (!AE.Feature.empty() && Modifier == AE.Name) {
- enable(AE.ID);
+ if (auto AE = parseArchExtension(ArchExt)) {
+ if (IsNegated && !AE->NegFeature.empty()) {
+ disable(AE->ID);
+ return true;
+ }
+ if (!AE->Feature.empty()) {
+ enable(AE->ID);
return true;
}
}
-
return false;
}
More information about the llvm-commits
mailing list