llvm/lib/Support/TargetParser.cpp: Rework llvm::ARM::getArchExtFeature() to avoid...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Thu, 19 Nov 2015 15:03:11 +0000 (15:03 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Thu, 19 Nov 2015 15:03:11 +0000 (15:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253566 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/TargetParser.cpp

index 213275a..371ae35 100644 (file)
@@ -87,7 +87,6 @@ static const struct {
   const char *NegFeature;
 
   StringRef getName() const { return StringRef(NameCStr, NameLength); }
-  StringRef getNegName() const { return (Twine("no") + getName()).str(); }
 } ARCHExtNames[] = {
 #define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
   { NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE },
@@ -332,11 +331,16 @@ StringRef llvm::ARM::getArchExtName(unsigned ArchExtKind) {
 }
 
 const char *llvm::ARM::getArchExtFeature(StringRef ArchExt) {
+  if (ArchExt.substr(0, 2) == "no") {
+    StringRef ArchExtBase(ArchExt.substr(2));
+    for (const auto AE : ARCHExtNames) {
+      if (AE.NegFeature && ArchExtBase == AE.getName())
+        return AE.NegFeature;
+    }
+  }
   for (const auto AE : ARCHExtNames) {
     if (AE.Feature && ArchExt == AE.getName())
       return AE.Feature;
-    else if (AE.NegFeature && ArchExt == AE.getNegName())
-      return AE.NegFeature;
   }
 
   return nullptr;