[PATCH] D96304: [Thumb2] support `movs pc, lr` alias for `subs pc, lr, #0`/`eret`
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 8 17:13:41 PST 2021
nickdesaulniers created this revision.
nickdesaulniers added reviewers: rengolin, ostannard, psmith, rovka.
Herald added a subscriber: hiraditya.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is used by the Linux kernel.
Forked from D95586 <https://reviews.llvm.org/D95586>.
Signed-off-by: Nick Desaulniers <ndesaulniers at google.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96304
Files:
llvm/lib/Target/ARM/ARMInstrThumb2.td
llvm/test/MC/ARM/lsl-zero-errors.s
llvm/test/MC/ARM/thumb-mov.s
Index: llvm/test/MC/ARM/thumb-mov.s
===================================================================
--- llvm/test/MC/ARM/thumb-mov.s
+++ llvm/test/MC/ARM/thumb-mov.s
@@ -13,13 +13,11 @@
movs pc, r0
movs r0, pc
movs pc, pc
-// CHECK: error: operand must be a register in range [r0, r14]
+// CHECK: error: invalid instruction, any one of the following would fix this:
// CHECK-NEXT: movs pc, r0
-// CHECK: note: operand must be a register in range [r0, r14]
-// CHECK-NEXT: movs r0, pc
-// CHECK: note: invalid operand for instruction
+// CHECK: error: invalid instruction, any one of the following would fix this:
// CHECK-NEXT: movs r0, pc
-// CHECK: error: invalid instruction
+// CHECK: error: invalid operand for instruction
// CHECK-NEXT: movs pc, pc
// mov.w selects t2MOVr
@@ -39,13 +37,11 @@
movs.w pc, r0
movs.w r0, pc
movs.w pc, pc
-// CHECK: error: operand must be a register in range [r0, r14]
+// CHECK: error: invalid instruction, any one of the following would fix this:
// CHECK-NEXT: movs.w pc, r0
-// CHECK: note: operand must be a register in range [r0, r14]
-// CHECK-NEXT: movs.w r0, pc
-// CHECK: note: invalid operand for instruction
+// CHECK: error: invalid instruction, any one of the following would fix this:
// CHECK-NEXT: movs.w r0, pc
-// CHECK: error: invalid instruction
+// CHECK: error: invalid operand for instruction
// CHECK-NEXT: movs.w pc, pc
@@ -104,3 +100,11 @@
mov.w r0, sp
// CHECK: mov.w sp, r0 @ encoding: [0x4f,0xea,0x00,0x0d]
// CHECK: mov.w r0, sp @ encoding: [0x4f,0xea,0x0d,0x00]
+
+ // `movs pc, lr` is an alias for `subs pc, lr, #0`.
+ movs pc, lr
+ movs.w pc, lr
+// CHECK-V7: subs pc, lr, #0 @ encoding: [0xde,0xf3,0x00,0x8f]
+// CHECK-V7: subs pc, lr, #0 @ encoding: [0xde,0xf3,0x00,0x8f]
+// CHECK-V8: eret @ encoding: [0xde,0xf3,0x00,0x8f]
+// CHECK-V8: eret @ encoding: [0xde,0xf3,0x00,0x8f]
Index: llvm/test/MC/ARM/lsl-zero-errors.s
===================================================================
--- llvm/test/MC/ARM/lsl-zero-errors.s
+++ llvm/test/MC/ARM/lsl-zero-errors.s
@@ -72,8 +72,7 @@
// CHECK-THUMBV7: note: operand must be a register in range [r0, r12] or r14
// CHECK-THUMBV8: note: operand must be a register in range [r0, r14]
-// CHECK-THUMBV7: error: operand must be a register in range [r0, r12] or r14
-// CHECK-THUMBV8: error: operand must be a register in range [r0, r14]
+// CHECK-NONARM: error: invalid instruction, any one of the following would fix this:
// CHECK-NONARM-NEXT: movs pc, r0, lsl #0
// CHECK-NONARM: error: invalid instruction, any one of the following would fix this:
@@ -82,8 +81,7 @@
// CHECK-NONARM: note: invalid operand for instruction
// CHECK-NONARM: note: invalid operand for instruction
-// CHECK-THUMBV7: error: operand must be a register in range [r0, r12] or r14
-// CHECK-THUMBV8: error: operand must be a register in range [r0, r14]
+// CHECK-NONARM: error: invalid instruction, any one of the following would fix this:
// CHECK-NONARM-NEXT: movs pc, pc, lsl #0
// CHECK-ARM: mov pc, r0 @ encoding: [0x00,0xf0,0xa0,0xe1]
Index: llvm/lib/Target/ARM/ARMInstrThumb2.td
===================================================================
--- llvm/lib/Target/ARM/ARMInstrThumb2.td
+++ llvm/lib/Target/ARM/ARMInstrThumb2.td
@@ -4144,6 +4144,8 @@
bits<8> imm;
let Inst{7-0} = imm;
}
+def : t2InstAlias<"movs{$p}\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>;
+def : t2InstAlias<"movs{$p}.w\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>;
// Hypervisor Call is a system instruction.
let isCall = 1 in {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96304.322246.patch
Type: text/x-patch
Size: 3746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210209/283ef4d2/attachment.bin>
More information about the llvm-commits
mailing list