[llvm] Reland [AArch64][AsmParser] Directives should clear transitively implied features (#106625) (PR #106850)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 07:17:14 PDT 2024


================
@@ -7075,30 +7075,22 @@ bool AArch64AsmParser::parseDirectiveCPU(SMLoc L) {
 
     bool EnableFeature = !Name.consume_front_insensitive("no");
 
-    bool FoundExtension = false;
-    for (const auto &Extension : ExtensionMap) {
-      if (Extension.Name != Name)
-        continue;
+    auto It = llvm::find_if(ExtensionMap, [&Name](const auto &Extension) {
+      return Extension.Name == Name;
+    });
 
-      if (Extension.Features.none())
-        report_fatal_error("unsupported architectural extension: " + Name);
-
-      FeatureBitset Features = STI.getFeatureBits();
-      FeatureBitset ToggleFeatures =
-          EnableFeature
-              ? STI.SetFeatureBitsTransitively(~Features & Extension.Features)
-              : STI.ToggleFeature(Features & Extension.Features);
-      setAvailableFeatures(ComputeAvailableFeatures(ToggleFeatures));
-      FoundExtension = true;
-
-      break;
+    if (It != std::end(ExtensionMap)) {
+      if (EnableFeature)
+        STI.SetFeatureBitsTransitively(It->Features);
+      else
+        STI.ClearFeatureBitsTransitively(It->Features);
+    } else {
+      Error(CurLoc, "unsupported architectural extension: " + Name);
----------------
labrinea wrote:

I don't mind. I originally tried to keep it nfc in that regard, happy to change it as well as the tests but I have no strong opinion either way. Lemme know

https://github.com/llvm/llvm-project/pull/106850


More information about the llvm-commits mailing list