mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
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:
parent
a13f3cdb01
commit
580f9c85fd
@ -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
|
||||
|
5
test/MC/ARM/2013-03-18-Br-to-label-named-like-reg.s
Normal file
5
test/MC/ARM/2013-03-18-Br-to-label-named-like-reg.s
Normal file
@ -0,0 +1,5 @@
|
||||
@ RUN: llvm-mc -arch arm %s
|
||||
@ CHECK: test:
|
||||
@ CHECK: br r1
|
||||
test:
|
||||
bl r1
|
Loading…
Reference in New Issue
Block a user