Fix pr13145 - Naming a function like a register name confuses the asm parser.

Patch by Stepan Dyatkovskiy <stpworld@narod.ru>
rdar://13457826

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177463 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier 2013-03-19 23:44:03 +00:00
parent a13f3cdb01
commit 580f9c85fd
2 changed files with 25 additions and 14 deletions

View File

@ -4593,20 +4593,26 @@ bool ARMAsmParser::parseOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands,
Error(Parser.getTok().getLoc(), "unexpected token in operand");
return true;
case AsmToken::Identifier: {
if (!tryParseRegisterWithWriteBack(Operands))
return false;
int Res = tryParseShiftRegister(Operands);
if (Res == 0) // success
return false;
else if (Res == -1) // irrecoverable error
return true;
// If this is VMRS, check for the apsr_nzcv operand.
if (Mnemonic == "vmrs" &&
Parser.getTok().getString().equals_lower("apsr_nzcv")) {
S = Parser.getTok().getLoc();
Parser.Lex();
Operands.push_back(ARMOperand::CreateToken("APSR_nzcv", S));
return false;
// If we've seen a branch mnemonic, the next operand must be a label. This
// is true even if the label is a register name. So "br r1" means branch to
// label "r1".
bool ExpectLabel = Mnemonic == "b" || Mnemonic == "bl";
if (!ExpectLabel) {
if (!tryParseRegisterWithWriteBack(Operands))
return false;
int Res = tryParseShiftRegister(Operands);
if (Res == 0) // success
return false;
else if (Res == -1) // irrecoverable error
return true;
// If this is VMRS, check for the apsr_nzcv operand.
if (Mnemonic == "vmrs" &&
Parser.getTok().getString().equals_lower("apsr_nzcv")) {
S = Parser.getTok().getLoc();
Parser.Lex();
Operands.push_back(ARMOperand::CreateToken("APSR_nzcv", S));
return false;
}
}
// Fall though for the Identifier case that is not a register or a

View File

@ -0,0 +1,5 @@
@ RUN: llvm-mc -arch arm %s
@ CHECK: test:
@ CHECK: br r1
test:
bl r1