forked from OSchip/llvm-project
[ARM][AsmParser] handles offset expression in parentheses
Summary: Integrated assembler does not accept offset expressions surrounded by parenthesis. Handle this case for GAS compability. https://bugs.llvm.org/show_bug.cgi?id=43631 Subscribers: kristof.beyls, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68764 llvm-svn: 374832
This commit is contained in:
parent
be744ea54f
commit
e9089c223c
|
@ -5733,14 +5733,16 @@ bool ARMAsmParser::parseMemory(OperandVector &Operands) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a '#', it's an immediate offset, else assume it's a register
|
// If we have a '#' or '$', it's an immediate offset, else assume it's a
|
||||||
// offset. Be friendly and also accept a plain integer (without a leading
|
// register offset. Be friendly and also accept a plain integer or expression
|
||||||
// hash) for gas compatibility.
|
// (without a leading hash) for gas compatibility.
|
||||||
if (Parser.getTok().is(AsmToken::Hash) ||
|
if (Parser.getTok().is(AsmToken::Hash) ||
|
||||||
Parser.getTok().is(AsmToken::Dollar) ||
|
Parser.getTok().is(AsmToken::Dollar) ||
|
||||||
|
Parser.getTok().is(AsmToken::LParen) ||
|
||||||
Parser.getTok().is(AsmToken::Integer)) {
|
Parser.getTok().is(AsmToken::Integer)) {
|
||||||
if (Parser.getTok().isNot(AsmToken::Integer))
|
if (Parser.getTok().is(AsmToken::Hash) ||
|
||||||
Parser.Lex(); // Eat '#' or '$'.
|
Parser.getTok().is(AsmToken::Dollar))
|
||||||
|
Parser.Lex(); // Eat '#' or '$'
|
||||||
E = Parser.getTok().getLoc();
|
E = Parser.getTok().getLoc();
|
||||||
|
|
||||||
bool isNegative = getParser().getTok().is(AsmToken::Minus);
|
bool isNegative = getParser().getTok().is(AsmToken::Minus);
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
@ RUN: llvm-mc -triple=arm-linux-gnueabi < %s | FileCheck %s
|
||||||
|
|
||||||
|
@ CHECK: ldr r12, [sp, #15]
|
||||||
|
ldr r12, [sp, (15)]
|
||||||
|
|
||||||
|
@ CHECK: ldr r12, [sp, #15]
|
||||||
|
ldr r12, [sp, #(15)]
|
||||||
|
|
||||||
|
@ CHECK: ldr r12, [sp, #15]
|
||||||
|
ldr r12, [sp, $(15)]
|
||||||
|
|
||||||
|
@ CHECK: ldr r12, [sp, #100]
|
||||||
|
ldr r12, [sp, (((15+5)*5))]
|
||||||
|
|
||||||
|
@ CHECK: ldr r12, [sp, #100]
|
||||||
|
ldr r12, [sp, #(((15+5)*5))]
|
||||||
|
|
||||||
|
|
||||||
|
@ CHECK: ldr r12, [sp, #100]
|
||||||
|
ldr r12, [sp, $(((15+5)*5))]
|
Loading…
Reference in New Issue