[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 17:04:15 PDT 2019
jcai19 updated this revision to Diff 224503.
jcai19 added a comment.
Expand test cases and rename test file.
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-mem-offset-paren.s
Index: llvm/test/MC/ARM/gas-compl-mem-offset-paren.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ARM/gas-compl-mem-offset-paren.s
@@ -0,0 +1,26 @@
+@ RUN: llvm-mc -triple=arm < %s | FileCheck %s
+
+.syntax unified
+
+@ CHECK: ldr r12, [sp, #15]
+ldr r12, [sp, (15)]
+
+@ CHECK: ldr r12, [sp, #15]
+ldr r12, [sp, #(15)]
+
+@ CHECK: ldr r12, [sp, #15]
+.syntax unified
+ldr r12, [sp, $(15)]
+
+@ CHECK: ldr r12, [sp, #100]
+.syntax unified
+ldr r12, [sp, (((15+5)*5))]
+
+@ CHECK: ldr r12, [sp, #100]
+.syntax unified
+ldr r12, [sp, #(((15+5)*5))]
+
+
+@ CHECK: ldr r12, [sp, #100]
+.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,14 @@
}
// 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().isNot(AsmToken::Integer) && Parser.getTok().isNot(AsmToken::LParen))
+ Parser.Lex(); // Eat '#' or '$'
E = Parser.getTok().getLoc();
bool isNegative = getParser().getTok().is(AsmToken::Minus);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68764.224503.patch
Type: text/x-patch
Size: 1768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191011/cc787759/attachment.bin>
More information about the llvm-commits
mailing list