[llvm] r269761 - [ARM] ARM mov InstAlias for MOVW lacks HasV6T2

Renato Golin via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 06:05:28 PDT 2016


Author: rengolin
Date: Tue May 17 08:05:28 2016
New Revision: 269761

URL: http://llvm.org/viewvc/llvm-project?rev=269761&view=rev
Log:
[ARM] ARM mov InstAlias for MOVW lacks HasV6T2

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.

Patch by Peter Smith.

Modified:
    llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
    llvm/trunk/test/MC/ARM/not-armv4.s

Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=269761&r1=269760&r2=269761&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue May 17 08:05:28 2016
@@ -3334,7 +3334,7 @@ def MOVi16 : AI1<0b1000, (outs GPR:$Rd),
 
 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, []>,

Modified: llvm/trunk/test/MC/ARM/not-armv4.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/not-armv4.s?rev=269761&r1=269760&r2=269761&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/not-armv4.s (original)
+++ llvm/trunk/test/MC/ARM/not-armv4.s Tue May 17 08:05:28 2016
@@ -6,3 +6,8 @@ clz r4,r9
 
 @ CHECK: error: instruction requires: armv6t2
 rbit r4,r9
+
+@ CHECK: error: instruction requires: armv6t2
+movw r4,#0x1234
+@ CHECK: error: instruction requires: armv6t2
+mov  r4,#0x1234




More information about the llvm-commits mailing list