llvm.org GIT mirror llvm / 0c9f250
Recognize alternative register names like ip -> r12. Fixes <rdar://problem/8857982>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123409 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 9 years ago
1 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2323 #include "llvm/Support/SourceMgr.h"
2424 #include "llvm/Support/raw_ostream.h"
2525 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/StringExtras.h"
2627 #include "llvm/ADT/StringSwitch.h"
2728 #include "llvm/ADT/Twine.h"
2829 using namespace llvm;
494495
495496 // FIXME: Validate register for the current architecture; we have to do
496497 // validation later, so maybe there is no need for this here.
497 unsigned RegNum = MatchRegisterName(Tok.getString());
498 if (RegNum == 0)
499 return -1;
498 std::string upperCase = Tok.getString().str();
499 std::string lowerCase = LowercaseString(upperCase);
500 unsigned RegNum = MatchRegisterName(lowerCase);
501 if (!RegNum) {
502 RegNum = StringSwitch(lowerCase)
503 .Case("r13", ARM::SP)
504 .Case("r14", ARM::LR)
505 .Case("r15", ARM::PC)
506 .Case("ip", ARM::R12)
507 .Default(0);
508 }
509 if (!RegNum) return -1;
510
500511 Parser.Lex(); // Eat identifier token.
501512 return RegNum;
502513 }