ARM: correct toggling behaviour
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 17 Aug 2014 19:20:38 +0000 (19:20 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 17 Aug 2014 19:20:38 +0000 (19:20 +0000)
This was a thinko.  The intent was to flip the explicit bits that need toggling
rather than all bits.  This would result in incorrect behaviour (which now is
tested).

Thanks to Nico Weber for pointing this out!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215846 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/directive-arch_extension-toggle.s [new file with mode: 0644]

index e4b59aedb3a3d8db5a42142d65f123e84a4b2c22..db6dfe235aa6eac601912bbf3d05a41c8a5ed18a 100644 (file)
@@ -9580,14 +9580,12 @@ bool ARMAsmParser::parseDirectiveArchExtension(SMLoc L) {
       return false;
     }
 
       return false;
     }
 
-    bool ToggleFeatures = EnableFeature
-                              ? (~STI.getFeatureBits() & Extension.Features)
-                              : ( STI.getFeatureBits() & Extension.Features);
-    if (ToggleFeatures) {
-      unsigned Features =
-          ComputeAvailableFeatures(STI.ToggleFeature(Extension.Features));
-      setAvailableFeatures(Features);
-    }
+    unsigned ToggleFeatures = EnableFeature
+                                  ? (~STI.getFeatureBits() & Extension.Features)
+                                  : ( STI.getFeatureBits() & Extension.Features);
+    unsigned Features =
+        ComputeAvailableFeatures(STI.ToggleFeature(ToggleFeatures));
+    setAvailableFeatures(Features);
     return false;
   }
 
     return false;
   }
 
diff --git a/test/MC/ARM/directive-arch_extension-toggle.s b/test/MC/ARM/directive-arch_extension-toggle.s
new file mode 100644 (file)
index 0000000..c3fb901
--- /dev/null
@@ -0,0 +1,8 @@
+@ RUN: llvm-mc -triple armv7-eabi -mattr hwdiv -filetype asm -o /dev/null %s
+
+       .syntax unified
+       .thumb
+
+       udiv r0, r1, r2
+       .arch_extension idiv
+       udiv r0, r1, r2