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

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 02:06:41 PDT 2024


================
@@ -6991,11 +6991,12 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) {
       if (Extension.Features.none())
         report_fatal_error("unsupported architectural extension: " + Name);
 
-      FeatureBitset ToggleFeatures =
-          EnableFeature
-              ? STI.SetFeatureBitsTransitively(~Features & Extension.Features)
-              : STI.ToggleFeature(Features & Extension.Features);
-      setAvailableFeatures(ComputeAvailableFeatures(ToggleFeatures));
+      if (EnableFeature)
+        STI.SetFeatureBitsTransitively(Extension.Features);
+      else
+        STI.ClearFeatureBitsTransitively(Extension.Features);
+      FeatureBitset Features = ComputeAvailableFeatures(STI.getFeatureBits());
+      setAvailableFeatures(Features);
----------------
sdesmalen-arm wrote:

You can move the `setAvailableFeatures` after the nested for-loop, and remove the similar lines on lines 6982-6983. `STI.getFeatureBits()` gets the bits that are set by `STI.Set/ClearBitsTransitively()`, so the result should be the same.

While you're modifying this code, replacing the double-nested loop with a `llvm::find_if` makes it easier to emit an error diagnostic for the case that is currently silently ignored (see my comment above) and simplifies the logic a bit.

Similar suggestions apply to the loop-nest in `parseDirectiveCPU`.

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


More information about the llvm-commits mailing list