[PATCH] D15746: Normalize the features string in SubtargetFeatures::getFeatureBits

A. Skrobov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 5 03:39:27 PST 2016


tyomitch updated this revision to Diff 43980.
tyomitch added a comment.

Thank you Michael and Eric for your comments!
I've now committed the non-controversial changes as r256823.

> How are you getting the feature strings that you're showing here?


We have a sort of testing script which runs LLVM with different
combinations of enabled features, pasting together chunks of
feature strings, each such chunk enabling a different subset
of test cases.

The existing implementation of getFeatureBits lets us "cancel out"
a `+feature` in a later chunk by appending a `-feature`; but
it doesn't allow to cancel out a `-feature`, which is what my
patch tries to achieve.


http://reviews.llvm.org/D15746

Files:
  lib/MC/SubtargetFeature.cpp
  test/MC/ARM/fullfp16-neon.s

Index: test/MC/ARM/fullfp16-neon.s
===================================================================
--- test/MC/ARM/fullfp16-neon.s
+++ test/MC/ARM/fullfp16-neon.s
@@ -1,4 +1,4 @@
-@ RUN: llvm-mc -triple armv8a-none-eabi -mattr=+fullfp16,+neon -show-encoding < %s | FileCheck %s --check-prefix=ARM
+@ RUN: llvm-mc -triple armv8a-none-eabi -mattr=+fullfp16,-fp-armv8,+fp-armv8,+neon -show-encoding < %s | FileCheck %s --check-prefix=ARM
 @ RUN: llvm-mc -triple thumbv8a-none-eabi -mattr=+fullfp16,+neon -show-encoding < %s | FileCheck %s --check-prefix=THUMB
 
   vadd.f16 d0, d1, d2
Index: lib/MC/SubtargetFeature.cpp
===================================================================
--- lib/MC/SubtargetFeature.cpp
+++ lib/MC/SubtargetFeature.cpp
@@ -261,6 +261,21 @@
     }
   }
 
+  // Cancel out the disabled features which are explicitly re-enabled later on.
+  FeatureBitset ExplicitlyEnabled;
+  for (auto Feature  = Features.rbegin();
+            Feature != Features.rend();
+          ++Feature) {
+    const SubtargetFeatureKV *FeatureEntry =
+        Find(StripFlag(*Feature), FeatureTable);
+    if (FeatureEntry) {
+      if ((ExplicitlyEnabled & FeatureEntry->Value).any())
+        Features.erase(std::next(Feature).base());
+      else if (isEnabled(*Feature))
+        ExplicitlyEnabled |= FeatureEntry->Value;
+    }
+  }
+
   // Iterate through each feature
   for (auto &Feature : Features) {
     // Check for help


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15746.43980.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160105/2036e26f/attachment.bin>


More information about the llvm-commits mailing list