blob: fc271ba40b087c361ac1657b662b86685a8d389f [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===- ARMInstrThumb.td - Thumb support for ARM ---------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the Thumb instruction set.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Thumb specific DAG Nodes.
16//
17
18def ARMtcall : SDNode<"ARMISD::tCALL", SDT_ARMcall,
19 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
20
Evan Chenga8e29892007-01-19 07:51:42 +000021def imm_neg_XFORM : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000022 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
Evan Chenga8e29892007-01-19 07:51:42 +000023}]>;
24def imm_comp_XFORM : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000025 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
Evan Chenga8e29892007-01-19 07:51:42 +000026}]>;
27
28
29/// imm0_7 predicate - True if the 32-bit immediate is in the range [0,7].
30def imm0_7 : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000031 return (uint32_t)N->getZExtValue() < 8;
Evan Chenga8e29892007-01-19 07:51:42 +000032}]>;
33def imm0_7_neg : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000034 return (uint32_t)-N->getZExtValue() < 8;
Evan Chenga8e29892007-01-19 07:51:42 +000035}], imm_neg_XFORM>;
36
37def imm0_255 : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000038 return (uint32_t)N->getZExtValue() < 256;
Evan Chenga8e29892007-01-19 07:51:42 +000039}]>;
40def imm0_255_comp : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000041 return ~((uint32_t)N->getZExtValue()) < 256;
Evan Chenga8e29892007-01-19 07:51:42 +000042}]>;
43
44def imm8_255 : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000045 return (uint32_t)N->getZExtValue() >= 8 && (uint32_t)N->getZExtValue() < 256;
Evan Chenga8e29892007-01-19 07:51:42 +000046}]>;
47def imm8_255_neg : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000048 unsigned Val = -N->getZExtValue();
Evan Chenga8e29892007-01-19 07:51:42 +000049 return Val >= 8 && Val < 256;
50}], imm_neg_XFORM>;
51
52// Break imm's up into two pieces: an immediate + a left shift.
53// This uses thumb_immshifted to match and thumb_immshifted_val and
54// thumb_immshifted_shamt to get the val/shift pieces.
55def thumb_immshifted : PatLeaf<(imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000056 return ARM_AM::isThumbImmShiftedVal((unsigned)N->getZExtValue());
Evan Chenga8e29892007-01-19 07:51:42 +000057}]>;
58
59def thumb_immshifted_val : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000060 unsigned V = ARM_AM::getThumbImmNonShiftedVal((unsigned)N->getZExtValue());
Evan Chenga8e29892007-01-19 07:51:42 +000061 return CurDAG->getTargetConstant(V, MVT::i32);
62}]>;
63
64def thumb_immshifted_shamt : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000065 unsigned V = ARM_AM::getThumbImmValShift((unsigned)N->getZExtValue());
Evan Chenga8e29892007-01-19 07:51:42 +000066 return CurDAG->getTargetConstant(V, MVT::i32);
67}]>;
68
69// Define Thumb specific addressing modes.
70
71// t_addrmode_rr := reg + reg
72//
73def t_addrmode_rr : Operand<i32>,
74 ComplexPattern<i32, 2, "SelectThumbAddrModeRR", []> {
75 let PrintMethod = "printThumbAddrModeRROperand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +000076 let MIOperandInfo = (ops tGPR:$base, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +000077}
78
Evan Chengc38f2bc2007-01-23 22:59:13 +000079// t_addrmode_s4 := reg + reg
80// reg + imm5 * 4
Evan Chenga8e29892007-01-19 07:51:42 +000081//
Evan Chengc38f2bc2007-01-23 22:59:13 +000082def t_addrmode_s4 : Operand<i32>,
83 ComplexPattern<i32, 3, "SelectThumbAddrModeS4", []> {
84 let PrintMethod = "printThumbAddrModeS4Operand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +000085 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +000086}
Evan Chengc38f2bc2007-01-23 22:59:13 +000087
88// t_addrmode_s2 := reg + reg
89// reg + imm5 * 2
90//
91def t_addrmode_s2 : Operand<i32>,
92 ComplexPattern<i32, 3, "SelectThumbAddrModeS2", []> {
93 let PrintMethod = "printThumbAddrModeS2Operand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +000094 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +000095}
Evan Chengc38f2bc2007-01-23 22:59:13 +000096
97// t_addrmode_s1 := reg + reg
98// reg + imm5
99//
100def t_addrmode_s1 : Operand<i32>,
101 ComplexPattern<i32, 3, "SelectThumbAddrModeS1", []> {
102 let PrintMethod = "printThumbAddrModeS1Operand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000103 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +0000104}
105
106// t_addrmode_sp := sp + imm8 * 4
107//
108def t_addrmode_sp : Operand<i32>,
109 ComplexPattern<i32, 2, "SelectThumbAddrModeSP", []> {
110 let PrintMethod = "printThumbAddrModeSPOperand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000111 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
Evan Chenga8e29892007-01-19 07:51:42 +0000112}
113
114//===----------------------------------------------------------------------===//
115// Miscellaneous Instructions.
116//
117
Evan Cheng071a2792007-09-11 19:55:27 +0000118let Defs = [SP], Uses = [SP] in {
Evan Cheng44bec522007-05-15 01:29:07 +0000119def tADJCALLSTACKUP :
Bill Wendling0f8d9c02007-11-13 00:44:25 +0000120PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
121 "@ tADJCALLSTACKUP $amt1",
122 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>, Requires<[IsThumb]>;
Evan Cheng44bec522007-05-15 01:29:07 +0000123
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000124def tADJCALLSTACKDOWN :
Evan Cheng64d80e32007-07-19 01:14:50 +0000125PseudoInst<(outs), (ins i32imm:$amt),
Evan Cheng44bec522007-05-15 01:29:07 +0000126 "@ tADJCALLSTACKDOWN $amt",
Evan Cheng071a2792007-09-11 19:55:27 +0000127 [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb]>;
128}
Evan Cheng44bec522007-05-15 01:29:07 +0000129
Evan Chengeaa91b02007-06-19 01:26:51 +0000130let isNotDuplicable = 1 in
Evan Chenga09b9ca2009-06-24 23:47:58 +0000131def tPICADD : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, pclabel:$cp),
Evan Chengc60e76d2007-01-30 20:37:08 +0000132 "$cp:\n\tadd $dst, pc",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000133 [(set tGPR:$dst, (ARMpic_add tGPR:$lhs, imm:$cp))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000134
Evan Cheng7dcf4a82009-06-25 01:05:06 +0000135// PC relative add.
136def tADDrPCi : T1I<(outs tGPR:$dst), (ins i32imm:$rhs),
137 "add $dst, pc, $rhs * 4", []>;
138
139// ADD rd, sp, #imm8
140// FIXME: hard code sp?
141def tADDrSPi : T1I<(outs tGPR:$dst), (ins GPR:$sp, i32imm:$rhs),
142 "add $dst, $sp, $rhs * 4 @ addrspi", []>;
143
144// ADD sp, sp, #imm7
145// FIXME: hard code sp?
146def tADDspi : T1It<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs),
147 "add $dst, $rhs * 4", []>;
148
149// FIXME: Make use of the following?
150// ADD rm, sp, rm
151// ADD sp, rm
152
Evan Chenga8e29892007-01-19 07:51:42 +0000153//===----------------------------------------------------------------------===//
154// Control Flow Instructions.
155//
156
Evan Cheng9d945f72007-02-01 01:49:46 +0000157let isReturn = 1, isTerminator = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000158 def tBX_RET : TI<(outs), (ins), "bx lr", [(ARMretflag)]>;
Evan Cheng9d945f72007-02-01 01:49:46 +0000159 // Alternative return instruction used by vararg functions.
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000160 def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), "bx $target", []>;
Evan Cheng9d945f72007-02-01 01:49:46 +0000161}
Evan Chenga8e29892007-01-19 07:51:42 +0000162
163// FIXME: remove when we have a way to marking a MI with these properties.
Evan Cheng325474e2008-01-07 23:56:57 +0000164let isReturn = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000165def tPOP_RET : TI<(outs reglist:$dst1, variable_ops), (ins),
Evan Chenga8e29892007-01-19 07:51:42 +0000166 "pop $dst1", []>;
167
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000168let isCall = 1,
Evan Chenga8e29892007-01-19 07:51:42 +0000169 Defs = [R0, R1, R2, R3, LR,
170 D0, D1, D2, D3, D4, D5, D6, D7] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000171 def tBL : TIx2<(outs), (ins i32imm:$func, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000172 "bl ${func:call}",
173 [(ARMtcall tglobaladdr:$func)]>;
174 // ARMv5T and above
Evan Cheng64d80e32007-07-19 01:14:50 +0000175 def tBLXi : TIx2<(outs), (ins i32imm:$func, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000176 "blx ${func:call}",
177 [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>;
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000178 def tBLXr : TI<(outs), (ins tGPR:$func, variable_ops),
Evan Cheng64d80e32007-07-19 01:14:50 +0000179 "blx $func",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000180 [(ARMtcall tGPR:$func)]>, Requires<[HasV5T]>;
Lauro Ramos Venanciob8a93a42007-03-27 16:19:21 +0000181 // ARMv4T
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000182 def tBX : TIx2<(outs), (ins tGPR:$func, variable_ops),
Evan Cheng64d80e32007-07-19 01:14:50 +0000183 "cpy lr, pc\n\tbx $func",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000184 [(ARMcall_nolink tGPR:$func)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000185}
186
Evan Chengffbacca2007-07-21 00:34:19 +0000187let isBranch = 1, isTerminator = 1 in {
Evan Cheng3f8602c2007-05-16 21:53:43 +0000188 let isBarrier = 1 in {
189 let isPredicable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000190 def tB : TI<(outs), (ins brtarget:$target), "b $target",
191 [(br bb:$target)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000192
Evan Cheng225dfe92007-01-30 01:13:37 +0000193 // Far jump
Evan Cheng64d80e32007-07-19 01:14:50 +0000194 def tBfar : TIx2<(outs), (ins brtarget:$target), "bl $target\t@ far jump",[]>;
Evan Cheng225dfe92007-01-30 01:13:37 +0000195
Evan Cheng64d80e32007-07-19 01:14:50 +0000196 def tBR_JTr : TJTI<(outs),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000197 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Cheng64d80e32007-07-19 01:14:50 +0000198 "cpy pc, $target \n\t.align\t2\n$jt",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000199 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
Evan Cheng3f8602c2007-05-16 21:53:43 +0000200 }
Evan Chengd85ac4d2007-01-27 02:29:45 +0000201}
202
Evan Chengc85e8322007-07-05 07:13:32 +0000203// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000204// a two-value operand where a dag node expects two operands. :(
Evan Chengffbacca2007-07-21 00:34:19 +0000205let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000206 def tBcc : TI<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
207 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000208
209//===----------------------------------------------------------------------===//
210// Load Store Instructions.
211//
212
Dan Gohman15511cf2008-12-03 18:15:48 +0000213let canFoldAsLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000214def tLDR : TI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000215 "ldr $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000216 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000217
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000218def tLDRB : TI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000219 "ldrb $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000220 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000221
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000222def tLDRH : TI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000223 "ldrh $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000224 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000225
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000226def tLDRSB : TI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000227 "ldrsb $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000228 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000229
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000230def tLDRSH : TI2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000231 "ldrsh $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000232 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000233
Dan Gohman15511cf2008-12-03 18:15:48 +0000234let canFoldAsLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000235def tLDRspi : TIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
Evan Chenga8e29892007-01-19 07:51:42 +0000236 "ldr $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000237 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
Evan Cheng012f2d92007-01-24 08:53:17 +0000238
Evan Cheng8e59ea92007-02-07 00:06:56 +0000239// Special instruction for restore. It cannot clobber condition register
240// when it's expanded by eliminateCallFramePseudoInstr().
Dan Gohman15511cf2008-12-03 18:15:48 +0000241let canFoldAsLoad = 1, mayLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000242def tRestore : TIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
Evan Cheng8e59ea92007-02-07 00:06:56 +0000243 "ldr $dst, $addr", []>;
244
Evan Cheng012f2d92007-01-24 08:53:17 +0000245// Load tconstpool
Dan Gohman15511cf2008-12-03 18:15:48 +0000246let canFoldAsLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000247def tLDRpci : TIs<(outs tGPR:$dst), (ins i32imm:$addr),
Evan Cheng012f2d92007-01-24 08:53:17 +0000248 "ldr $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000249 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
Evan Chengfa775d02007-03-19 07:20:03 +0000250
251// Special LDR for loads from non-pc-relative constpools.
Dan Gohman15511cf2008-12-03 18:15:48 +0000252let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000253def tLDRcp : TIs<(outs tGPR:$dst), (ins i32imm:$addr),
Evan Chengfa775d02007-03-19 07:20:03 +0000254 "ldr $dst, $addr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000255
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000256def tSTR : TI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000257 "str $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000258 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000259
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000260def tSTRB : TI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000261 "strb $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000262 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000263
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000264def tSTRH : TI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000265 "strh $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000266 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000267
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000268def tSTRspi : TIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
Evan Chenga8e29892007-01-19 07:51:42 +0000269 "str $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000270 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
Evan Cheng8e59ea92007-02-07 00:06:56 +0000271
Chris Lattner2e48a702008-01-06 08:36:04 +0000272let mayStore = 1 in {
Evan Cheng8e59ea92007-02-07 00:06:56 +0000273// Special instruction for spill. It cannot clobber condition register
274// when it's expanded by eliminateCallFramePseudoInstr().
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000275def tSpill : TIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
Evan Cheng8e59ea92007-02-07 00:06:56 +0000276 "str $src, $addr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000277}
278
279//===----------------------------------------------------------------------===//
280// Load / store multiple Instructions.
281//
282
283// TODO: A7-44: LDMIA - load multiple
284
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000285let mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000286def tPOP : TI<(outs reglist:$dst1, variable_ops), (ins),
Evan Chenga8e29892007-01-19 07:51:42 +0000287 "pop $dst1", []>;
288
Chris Lattner2e48a702008-01-06 08:36:04 +0000289let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000290def tPUSH : TI<(outs), (ins reglist:$src1, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000291 "push $src1", []>;
292
293//===----------------------------------------------------------------------===//
294// Arithmetic Instructions.
295//
296
Evan Cheng53d7dba2007-01-27 00:07:15 +0000297// Add with carry
Eli Friedman6b7bb422009-06-19 01:43:08 +0000298let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000299def tADC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Cheng53d7dba2007-01-27 00:07:15 +0000300 "adc $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000301 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000302
Evan Cheng09c39fc2009-06-23 19:38:13 +0000303def tADDS : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Cheng3471b602007-01-31 20:12:31 +0000304 "add $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000305 [(set tGPR:$dst, (addc tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000306
307
Evan Cheng09c39fc2009-06-23 19:38:13 +0000308def tADDi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000309 "add $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000310 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000311
Evan Cheng09c39fc2009-06-23 19:38:13 +0000312def tADDi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000313 "add $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000314 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000315
Evan Cheng09c39fc2009-06-23 19:38:13 +0000316def tADDrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000317 "add $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000318 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000319
Evan Chengcd799b92009-06-12 20:46:18 +0000320let neverHasSideEffects = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000321def tADDhirr : T1It<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000322 "add $dst, $rhs @ addhirr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000323
Eli Friedman6b7bb422009-06-19 01:43:08 +0000324let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000325def tAND : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000326 "and $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000327 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000328
Evan Cheng09c39fc2009-06-23 19:38:13 +0000329def tASRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000330 "asr $dst, $lhs, $rhs",
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000331 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000332
Evan Cheng09c39fc2009-06-23 19:38:13 +0000333def tASRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000334 "asr $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000335 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000336
Evan Cheng09c39fc2009-06-23 19:38:13 +0000337def tBIC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000338 "bic $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000339 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000340
341
Evan Cheng09c39fc2009-06-23 19:38:13 +0000342def tCMN : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000343 "cmn $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000344 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000345
Evan Cheng09c39fc2009-06-23 19:38:13 +0000346def tCMPi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000347 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000348 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000349
Evan Cheng09c39fc2009-06-23 19:38:13 +0000350def tCMPr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000351 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000352 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000353
Evan Cheng09c39fc2009-06-23 19:38:13 +0000354def tTST : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000355 "tst $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000356 [(ARMcmpNZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000357
Evan Cheng09c39fc2009-06-23 19:38:13 +0000358def tCMNNZ : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000359 "cmn $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000360 [(ARMcmpNZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000361
Evan Cheng09c39fc2009-06-23 19:38:13 +0000362def tCMPNZi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000363 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000364 [(ARMcmpNZ tGPR:$lhs, imm0_255:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000365
Evan Cheng09c39fc2009-06-23 19:38:13 +0000366def tCMPNZr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000367 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000368 [(ARMcmpNZ tGPR:$lhs, tGPR:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000369
Evan Chenga8e29892007-01-19 07:51:42 +0000370// TODO: A7-37: CMP(3) - cmp hi regs
371
Eli Friedman6b7bb422009-06-19 01:43:08 +0000372let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000373def tEOR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000374 "eor $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000375 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000376
Evan Cheng09c39fc2009-06-23 19:38:13 +0000377def tLSLri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000378 "lsl $dst, $lhs, $rhs",
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000379 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000380
Evan Cheng09c39fc2009-06-23 19:38:13 +0000381def tLSLrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000382 "lsl $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000383 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000384
Evan Cheng09c39fc2009-06-23 19:38:13 +0000385def tLSRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000386 "lsr $dst, $lhs, $rhs",
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000387 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000388
Evan Cheng09c39fc2009-06-23 19:38:13 +0000389def tLSRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000390 "lsr $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000391 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000392
Evan Cheng5e3c2032007-03-29 21:38:31 +0000393// FIXME: This is not rematerializable because mov changes the condition code.
Evan Cheng09c39fc2009-06-23 19:38:13 +0000394def tMOVi8 : T1I<(outs tGPR:$dst), (ins i32imm:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000395 "mov $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000396 [(set tGPR:$dst, imm0_255:$src)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000397
398// TODO: A7-73: MOV(2) - mov setting flag.
399
400
401// Note: MOV(2) of two low regs updates the flags, so we emit this as 'cpy',
402// which is MOV(3). This also supports high registers.
Evan Chengcd799b92009-06-12 20:46:18 +0000403let neverHasSideEffects = 1 in {
Evan Cheng09c39fc2009-06-23 19:38:13 +0000404def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000405 "cpy $dst, $src", []>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000406def tMOVhir2lor : T1I<(outs tGPR:$dst), (ins GPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000407 "cpy $dst, $src\t@ hir2lor", []>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000408def tMOVlor2hir : T1I<(outs GPR:$dst), (ins tGPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000409 "cpy $dst, $src\t@ lor2hir", []>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000410def tMOVhir2hir : T1I<(outs GPR:$dst), (ins GPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000411 "cpy $dst, $src\t@ hir2hir", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000412} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000413
Eli Friedman6b7bb422009-06-19 01:43:08 +0000414let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000415def tMUL : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000416 "mul $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000417 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000418
Evan Cheng09c39fc2009-06-23 19:38:13 +0000419def tMVN : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000420 "mvn $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000421 [(set tGPR:$dst, (not tGPR:$src))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000422
Evan Cheng09c39fc2009-06-23 19:38:13 +0000423def tNEG : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000424 "neg $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000425 [(set tGPR:$dst, (ineg tGPR:$src))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000426
Eli Friedman6b7bb422009-06-19 01:43:08 +0000427let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000428def tORR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000429 "orr $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000430 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000431
432
Evan Cheng09c39fc2009-06-23 19:38:13 +0000433def tREV : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000434 "rev $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000435 [(set tGPR:$dst, (bswap tGPR:$src))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000436 Requires<[IsThumb, HasV6]>;
437
Evan Cheng09c39fc2009-06-23 19:38:13 +0000438def tREV16 : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000439 "rev16 $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000440 [(set tGPR:$dst,
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000441 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
442 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
443 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
444 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000445 Requires<[IsThumb, HasV6]>;
446
Evan Cheng09c39fc2009-06-23 19:38:13 +0000447def tREVSH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000448 "revsh $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000449 [(set tGPR:$dst,
Evan Chenga8e29892007-01-19 07:51:42 +0000450 (sext_inreg
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000451 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
452 (shl tGPR:$src, (i32 8))), i16))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000453 Requires<[IsThumb, HasV6]>;
454
Evan Cheng09c39fc2009-06-23 19:38:13 +0000455def tROR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000456 "ror $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000457 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000458
Evan Cheng53d7dba2007-01-27 00:07:15 +0000459
460// Subtract with carry
Evan Cheng09c39fc2009-06-23 19:38:13 +0000461def tSBC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000462 "sbc $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000463 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000464
Evan Cheng09c39fc2009-06-23 19:38:13 +0000465def tSUBS : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Cheng3471b602007-01-31 20:12:31 +0000466 "sub $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000467 [(set tGPR:$dst, (subc tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000468
469
Evan Chenga8e29892007-01-19 07:51:42 +0000470// TODO: A7-96: STMIA - store multiple.
471
Evan Cheng09c39fc2009-06-23 19:38:13 +0000472def tSUBi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000473 "sub $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000474 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000475
Evan Cheng09c39fc2009-06-23 19:38:13 +0000476def tSUBi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000477 "sub $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000478 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000479
Evan Cheng09c39fc2009-06-23 19:38:13 +0000480def tSUBrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000481 "sub $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000482 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000483
Evan Cheng09c39fc2009-06-23 19:38:13 +0000484def tSUBspi : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Cheng3fdadfc2007-01-26 21:33:19 +0000485 "sub $dst, $rhs * 4", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000486
Evan Cheng09c39fc2009-06-23 19:38:13 +0000487def tSXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000488 "sxtb $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000489 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000490 Requires<[IsThumb, HasV6]>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000491def tSXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000492 "sxth $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000493 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000494 Requires<[IsThumb, HasV6]>;
495
Evan Chenga8e29892007-01-19 07:51:42 +0000496
Evan Cheng09c39fc2009-06-23 19:38:13 +0000497def tUXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000498 "uxtb $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000499 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000500 Requires<[IsThumb, HasV6]>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000501def tUXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000502 "uxth $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000503 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000504 Requires<[IsThumb, HasV6]>;
505
506
507// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
508// Expanded by the scheduler into a branch sequence.
509let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
510 def tMOVCCr :
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000511 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
Evan Chenga8e29892007-01-19 07:51:42 +0000512 "@ tMOVCCr $cc",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000513 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000514
515// tLEApcrel - Load a pc-relative address into a register without offending the
516// assembler.
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000517def tLEApcrel : TIx2<(outs tGPR:$dst), (ins i32imm:$label),
Evan Chenga8e29892007-01-19 07:51:42 +0000518 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
Evan Cheng1b201682007-05-01 20:27:19 +0000519 "${:private}PCRELL${:uid}+4))\n"),
Evan Chenge0c2b6b2007-02-01 03:04:49 +0000520 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
521 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
Evan Chenga8e29892007-01-19 07:51:42 +0000522 []>;
523
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000524def tLEApcrelJT : TIx2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
Evan Chengd85ac4d2007-01-27 02:29:45 +0000525 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
526 "${:private}PCRELL${:uid}+4))\n"),
Evan Chenge0c2b6b2007-02-01 03:04:49 +0000527 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
528 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
529 []>;
Evan Chengd85ac4d2007-01-27 02:29:45 +0000530
Evan Chenga8e29892007-01-19 07:51:42 +0000531//===----------------------------------------------------------------------===//
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000532// TLS Instructions
533//
534
535// __aeabi_read_tp preserves the registers r1-r3.
536let isCall = 1,
537 Defs = [R0, LR] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000538 def tTPsoft : TIx2<(outs), (ins),
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000539 "bl __aeabi_read_tp",
540 [(set R0, ARMthread_pointer)]>;
541}
542
543//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +0000544// Non-Instruction Patterns
545//
546
547// ConstantPool, GlobalAddress
548def : ThumbPat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
549def : ThumbPat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
Evan Chenga8e29892007-01-19 07:51:42 +0000550
Evan Chengd85ac4d2007-01-27 02:29:45 +0000551// JumpTable
552def : ThumbPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
553 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
554
Evan Chenga8e29892007-01-19 07:51:42 +0000555// Direct calls
556def : ThumbPat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>;
557def : ThumbV5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>;
558
559// Indirect calls to ARM routines
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000560def : ThumbV5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>;
Evan Chenga8e29892007-01-19 07:51:42 +0000561
562// zextload i1 -> zextload i8
Evan Chengc38f2bc2007-01-23 22:59:13 +0000563def : ThumbPat<(zextloadi1 t_addrmode_s1:$addr),
564 (tLDRB t_addrmode_s1:$addr)>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000565
Evan Chengb60c02e2007-01-26 19:13:16 +0000566// extload -> zextload
567def : ThumbPat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
568def : ThumbPat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
569def : ThumbPat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
570
Evan Chenga8e29892007-01-19 07:51:42 +0000571// Large immediate handling.
572
573// Two piece imms.
Evan Cheng09c39fc2009-06-23 19:38:13 +0000574def : Thumb1Pat<(i32 thumb_immshifted:$src),
575 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
576 (thumb_immshifted_shamt imm:$src))>;
Evan Chenga8e29892007-01-19 07:51:42 +0000577
Evan Cheng09c39fc2009-06-23 19:38:13 +0000578def : Thumb1Pat<(i32 imm0_255_comp:$src),
579 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;