aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Goodwin <david_goodwin@apple.com>2009-06-26 16:10:07 +0000
committerDavid Goodwin <david_goodwin@apple.com>2009-06-26 16:10:07 +0000
commit2dbffd44a6d2bdc31f6f24a44e98c3dbaca3bea6 (patch)
treebe9a0ca7a0ec94157c4f966f4d68d0b38998af79
parentdeb5adead1c7ccad508b3de9fc528fc0e08980ad (diff)
downloadexternal_llvm-2dbffd44a6d2bdc31f6f24a44e98c3dbaca3bea6.tar.gz
external_llvm-2dbffd44a6d2bdc31f6f24a44e98c3dbaca3bea6.tar.bz2
external_llvm-2dbffd44a6d2bdc31f6f24a44e98c3dbaca3bea6.zip
Currently there is a pattern for the thumb-2 MOV 16-bit immediate instruction. That instruction cannot write the flags so it should use T2I instead of T2sI.
Also, added a pattern for the thumb-2 MOV of shifted immediate since that can encode immediates not encodable by the 16-bit immediate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74288 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/ARMInstrThumb2.td11
-rw-r--r--test/CodeGen/Thumb2/thumb2-mov3.ll33
-rw-r--r--test/CodeGen/Thumb2/thumb2-mov4.ll8
3 files changed, 49 insertions, 3 deletions
diff --git a/lib/Target/ARM/ARMInstrThumb2.td b/lib/Target/ARM/ARMInstrThumb2.td
index ec46df890e..4736711926 100644
--- a/lib/Target/ARM/ARMInstrThumb2.td
+++ b/lib/Target/ARM/ARMInstrThumb2.td
@@ -409,9 +409,14 @@ def t2MOVr : T2sI<(outs GPR:$dst), (ins GPR:$src),
"mov", " $dst, $src", []>;
let isReMaterializable = 1, isAsCheapAsAMove = 1 in
-def t2MOVi16 : T2sI<(outs GPR:$dst), (ins i32imm:$src),
- "movw", " $dst, $src",
- [(set GPR:$dst, imm0_65535:$src)]>;
+def t2MOVi : T2sI<(outs GPR:$dst), (ins t2_so_imm:$src),
+ "mov", " $dst, $src",
+ [(set GPR:$dst, t2_so_imm:$src)]>;
+
+let isReMaterializable = 1, isAsCheapAsAMove = 1 in
+def t2MOVi16 : T2I<(outs GPR:$dst), (ins i32imm:$src),
+ "movw", " $dst, $src",
+ [(set GPR:$dst, imm0_65535:$src)]>;
// FIXME: Also available in ARM mode.
let Constraints = "$src = $dst" in
diff --git a/test/CodeGen/Thumb2/thumb2-mov3.ll b/test/CodeGen/Thumb2/thumb2-mov3.ll
new file mode 100644
index 0000000000..f8f06af487
--- /dev/null
+++ b/test/CodeGen/Thumb2/thumb2-mov3.ll
@@ -0,0 +1,33 @@
+; RUN: llvm-as < %s | llc | grep {mov\\W*r\[0-9\],\\W*#\[0-9\]*} | grep {#171\\|#1179666\\|#872428544\\|#1448498774\\|#66846720} | Count 5
+
+target triple = "thumbv7-apple-darwin"
+
+; 171 = 0x000000ab
+define i32 @f1(i32 %a) {
+ %tmp = add i32 0, 171
+ ret i32 %tmp
+}
+
+; 1179666 = 0x00120012
+define i32 @f2(i32 %a) {
+ %tmp = add i32 0, 1179666
+ ret i32 %tmp
+}
+
+; 872428544 = 0x34003400
+define i32 @f3(i32 %a) {
+ %tmp = add i32 0, 872428544
+ ret i32 %tmp
+}
+
+; 1448498774 = 0x56565656
+define i32 @f4(i32 %a) {
+ %tmp = add i32 0, 1448498774
+ ret i32 %tmp
+}
+
+; 66846720 = 0x03fc0000
+define i32 @f5(i32 %a) {
+ %tmp = add i32 0, 66846720
+ ret i32 %tmp
+}
diff --git a/test/CodeGen/Thumb2/thumb2-mov4.ll b/test/CodeGen/Thumb2/thumb2-mov4.ll
new file mode 100644
index 0000000000..e905b530f1
--- /dev/null
+++ b/test/CodeGen/Thumb2/thumb2-mov4.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | llc | grep {movw\\W*r\[0-9\],\\W*#\[0-9\]*} | grep {#65535} | Count 1
+
+target triple = "thumbv7-apple-darwin"
+
+define i32 @f6(i32 %a) {
+ %tmp = add i32 0, 65535
+ ret i32 %tmp
+}