[PATCH] D68764: [ARM][AsmParser] handles offset expression in parentheses
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 00:02:18 PDT 2019
jcai19 updated this revision to Diff 224263.
jcai19 added a comment.
Remove typos.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68764/new/
https://reviews.llvm.org/D68764
Files:
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/test/MC/ARM/gas-compl.s
Index: llvm/test/MC/ARM/gas-compl.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ARM/gas-compl.s
@@ -0,0 +1,8 @@
+@ RUN: llvm-mc -triple=arm < %s | FileCheck %s
+
+@ CHECK: ldr r12, [sp, #15]
+.syntax unified
+ ldr r12, [sp, #(15)]
+@ CHECK: ldr r12, [sp, #40]
+.syntax unified
+ ldr r12, [sp, #(15+5*5)]
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -5734,13 +5734,17 @@
}
// 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 '$'.
+ bool StartsWithParen = false;
+ if (Parser.getTok().isNot(AsmToken::Integer)) {
+ StartsWithParen = Parser.getTok().is(AsmToken::LParen);
+ Parser.Lex(); // Eat '#' or '$' or '('
+ }
E = Parser.getTok().getLoc();
bool isNegative = getParser().getTok().is(AsmToken::Minus);
@@ -5762,6 +5766,10 @@
CE = MCConstantExpr::create(std::numeric_limits<int32_t>::min(),
getContext());
+ // Check if the offset is surrounded by parentheses
+ if (StartsWithParen && Parser.getTok().isNot(AsmToken::RParen))
+ return Error(Parser.getTok().getLoc(), "')' expected");
+
// Now we should have the closing ']'
if (Parser.getTok().isNot(AsmToken::RBrac))
return Error(Parser.getTok().getLoc(), "']' expected");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68764.224263.patch
Type: text/x-patch
Size: 2009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/85405890/attachment-0001.bin>
More information about the llvm-commits
mailing list