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,6 +4593,11 @@ bool ARMAsmParser::parseOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands,
Error(Parser.getTok().getLoc(), "unexpected token in operand");
return true;
case AsmToken::Identifier: {
// 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);
@@ -4608,6 +4613,7 @@ bool ARMAsmParser::parseOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands,
Operands.push_back(ARMOperand::CreateToken("APSR_nzcv", S));
return false;
}
}
// Fall though for the Identifier case that is not a register or a
// special name.

View File

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