diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5734,13 +5734,15 @@ } // If we have a '#', it's an immediate offset, else assume it's a register - // offset. Be friendly and also accept a plain integer (without a leading - // hash) for gas compatibility. + // offset. Be friendly and also accept a plain integer or expression (without + // a leading hash) for gas compatibility. if (Parser.getTok().is(AsmToken::Hash) || Parser.getTok().is(AsmToken::Dollar) || + Parser.getTok().is(AsmToken::LParen) || Parser.getTok().is(AsmToken::Integer)) { if (Parser.getTok().isNot(AsmToken::Integer)) - Parser.Lex(); // Eat '#' or '$'. + if (!Parser.getTok().is(AsmToken::LParen)) + Parser.Lex(); // Eat '#' or '$' E = Parser.getTok().getLoc(); bool isNegative = getParser().getTok().is(AsmToken::Minus); diff --git a/llvm/test/MC/ARM/gas-compl.s b/llvm/test/MC/ARM/gas-compl.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/ARM/gas-compl.s @@ -0,0 +1,26 @@ +@ RUN: llvm-mc -triple=arm < %s | FileCheck %s + +@ CHECK: ldr r12, [sp, #15] +.syntax unified + ldr r12, [sp, (15)] + +@ CHECK: ldr r12, [sp, #15] +.syntax unified + ldr r12, [sp, #(15)] + +@ CHECK: ldr r12, [sp, #15] +.syntax unified + ldr r12, [sp, $(15)] + +@ CHECK: ldr r12, [sp, #40] +.syntax unified + ldr r12, [sp, (15+5*5)] + +@ CHECK: ldr r12, [sp, #40] +.syntax unified + ldr r12, [sp, #(15+5*5)] + + +@ CHECK: ldr r12, [sp, #40] +.syntax unified + ldr r12, [sp, $(15+5*5)]