[PATCH] D20163: [ARM] ARM mov InstAlias for MOVW lacks HasV6T2

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 06:12:15 PDT 2016


peter.smith created this revision.
peter.smith added reviewers: rengolin, olista01, t.p.northover.
peter.smith added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

The movw instruction is only available in ARM state for V6T2 and above. The MOVi16 instruction has requirement HasV6T2 but the InstAlias for mov rd, imm where the operand is imm0_65535_expr:$imm does not. This means that movw can incorrectly be used in ARMv4 and ARMv5 by writing mov rd, 0x1234. The simple fix is to the requirement HasV6T2 to the InstAlias. Tests added to not-armv4.s.

http://reviews.llvm.org/D20163

Files:
  lib/Target/ARM/ARMInstrInfo.td
  test/MC/ARM/not-armv4.s

Index: test/MC/ARM/not-armv4.s
===================================================================
--- test/MC/ARM/not-armv4.s
+++ test/MC/ARM/not-armv4.s
@@ -6,3 +6,8 @@
 
 @ CHECK: error: instruction requires: armv6t2
 rbit r4,r9
+
+@ CHECK: error: instruction requires: armv6t2
+movw r4,#0x1234
+@ CHECK: error: instruction requires: armv6t2
+mov  r4,#0x1234
Index: lib/Target/ARM/ARMInstrInfo.td
===================================================================
--- lib/Target/ARM/ARMInstrInfo.td
+++ lib/Target/ARM/ARMInstrInfo.td
@@ -3328,7 +3328,7 @@
 
 def : InstAlias<"mov${p} $Rd, $imm",
                 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
-        Requires<[IsARM]>;
+        Requires<[IsARM, HasV6T2]>;
 
 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
                                 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20163.56893.patch
Type: text/x-patch
Size: 866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160511/dccb2ca5/attachment.bin>


More information about the llvm-commits mailing list