[PATCH] D97501: [ARM] support symbolic expressions as branch target
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 16:40:16 PST 2021
jcai19 updated this revision to Diff 326841.
jcai19 added a comment.
Skip range check of MCBinaryExpr instead of any non-constant expressions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97501/new/
https://reviews.llvm.org/D97501
Files:
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/test/MC/ARM/thumb2-b.w-target.s
llvm/test/MC/ARM/thumb2-branch-ranges.s
Index: llvm/test/MC/ARM/thumb2-branch-ranges.s
===================================================================
--- llvm/test/MC/ARM/thumb2-branch-ranges.s
+++ llvm/test/MC/ARM/thumb2-branch-ranges.s
@@ -94,3 +94,10 @@
// CHECK: [[@LINE+2]]:{{[0-9]}}: error: Relocation out of range
// CHECK-LABEL: beq.w start6
beq.w start6
+
+start7:
+// branch to thumb function resolved at assembly time
+// CHECK-NOT: error
+// CHECK: [[@LINE+1]]:{{[0-9]}}: error: Relocation out of range
+ b.w start8 - start7 + 0x1000000
+start8:
Index: llvm/test/MC/ARM/thumb2-b.w-target.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ARM/thumb2-b.w-target.s
@@ -0,0 +1,12 @@
+// RUN: llvm-mc -triple=thumbv7 -filetype=obj %s | llvm-objdump --triple=thumbv7 -d - | FileCheck %s
+
+.syntax unified
+
+// CHECK-LABEL: start
+// CHECK-NEXT: b.w #16777208
+// CHECK-NEXT: b.w #2
+start:
+ b.w start - 1f + 0x1000000
+1:
+ b.w . + (2f - 1b + 2)
+2:
Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -1069,7 +1069,6 @@
template<unsigned width, unsigned scale>
bool isSignedOffset() const {
if (!isImm()) return false;
- if (isa<MCSymbolRefExpr>(Imm.Val)) return true;
if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Imm.Val)) {
int64_t Val = CE->getValue();
int64_t Align = 1LL << scale;
@@ -1077,6 +1076,9 @@
int64_t Min = -Align * (1LL << (width-1));
return ((Val % Align) == 0) && (Val >= Min) && (Val <= Max);
}
+ // Delay the checks of symbolic values until they are resolved
+ if (isa<MCSymbolRefExpr>(Imm.Val) || isa<MCBinaryExpr>(Imm.Val))
+ return true;
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97501.326841.patch
Type: text/x-patch
Size: 1883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210227/71651043/attachment.bin>
More information about the llvm-commits
mailing list