Use a StringSwitch<> instead of a manually constructed string matcher.
authorJim Grosbach <grosbach@apple.com>
Fri, 24 Dec 2010 00:03:39 +0000 (00:03 +0000)
committerJim Grosbach <grosbach@apple.com>
Fri, 24 Dec 2010 00:03:39 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122530 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmParser/ARMAsmLexer.cpp

index c93fb248e7a0dd8d82394d0b6ac40f3dcef6c25c..0cc607941092fdb2cc748a2ef2b8258d3c281901 100644 (file)
@@ -13,6 +13,7 @@
 #include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSwitch.h"
 
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCParser/MCAsmLexer.h"
@@ -128,16 +129,12 @@ AsmToken ARMBaseAsmLexer::LexTokenUAL() {
     //   ip  -> r12
     //   FIXME: Some assemblers support lots of others. Do we want them all?
     if (!regID) {
-     if (lowerCase.size() == 3 && lowerCase[0] == 'r'
-        && lowerCase[1] == '1') {
-       switch (lowerCase[2]) {
-       default: break;
-       case '3': regID = ARM::SP;
-       case '4': regID = ARM::LR;
-       case '5': regID = ARM::PC;
-       }
-     } else if (lowerCase == "ip")
-       regID = ARM::R12;
+      regID = StringSwitch<unsigned>(lowerCase)
+        .Case("r13", ARM::SP)
+        .Case("r14", ARM::LR)
+        .Case("r15", ARM::PC)
+        .Case("ip", ARM::R12)
+        .Default(0);
     }
 
     if (regID) {