[llvm-commits] [llvm] r122530 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmLexer.cpp
Jim Grosbach
grosbach at apple.com
Thu Dec 23 16:03:39 PST 2010
Author: grosbach
Date: Thu Dec 23 18:03:39 2010
New Revision: 122530
URL: http://llvm.org/viewvc/llvm-project?rev=122530&view=rev
Log:
Use a StringSwitch<> instead of a manually constructed string matcher.
Modified:
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmLexer.cpp
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmLexer.cpp?rev=122530&r1=122529&r2=122530&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmLexer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmLexer.cpp Thu Dec 23 18:03:39 2010
@@ -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 @@
// 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) {
More information about the llvm-commits
mailing list