1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00

Recognize alternative register names like ip -> r12.

Fixes <rdar://problem/8857982>.

llvm-svn: 123409
This commit is contained in:
Owen Anderson 2011-01-13 22:50:36 +00:00
parent 918de3a3b8
commit 58bcb5d7f2

View File

@ -24,6 +24,7 @@
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
using namespace llvm;
@ -495,9 +496,19 @@ int ARMAsmParser::TryParseRegister() {
// FIXME: Validate register for the current architecture; we have to do
// validation later, so maybe there is no need for this here.
unsigned RegNum = MatchRegisterName(Tok.getString());
if (RegNum == 0)
return -1;
std::string upperCase = Tok.getString().str();
std::string lowerCase = LowercaseString(upperCase);
unsigned RegNum = MatchRegisterName(lowerCase);
if (!RegNum) {
RegNum = StringSwitch<unsigned>(lowerCase)
.Case("r13", ARM::SP)
.Case("r14", ARM::LR)
.Case("r15", ARM::PC)
.Case("ip", ARM::R12)
.Default(0);
}
if (!RegNum) return -1;
Parser.Lex(); // Eat identifier token.
return RegNum;
}