blob: b7aa94143107ca5249967ec2a0c9b60092700963 [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",
David Goodwinf1daf7d2009-07-08 23:10:31 +0000122 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>, Requires<[IsThumb1Only]>;
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",
David Goodwinf1daf7d2009-07-08 23:10:31 +0000127 [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb1Only]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000128}
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 Cheng446c4282009-07-11 06:43:01 +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.
Evan Cheng446c4282009-07-11 06:43:01 +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
David Goodwin334c2642009-07-08 16:09:28 +0000165def tPOP_RET : T1I<(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 Cheng756da122009-07-22 06:46:53 +0000169 Defs = [R0, R1, R2, R3, R12, LR,
170 D0, D1, D2, D3, D4, D5, D6, D7,
171 D16, D17, D18, D19, D20, D21, D22, D23,
Evan Cheng0531d042009-07-29 20:10:36 +0000172 D24, D25, D26, D27, D28, D29, D30, D31, CPSR] in {
David Goodwin334c2642009-07-08 16:09:28 +0000173 def tBL : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000174 "bl ${func:call}",
Evan Cheng20a2a0a2009-07-29 21:26:42 +0000175 [(ARMtcall tglobaladdr:$func)]>,
176 Requires<[IsThumb1Only, IsNotDarwin]>;
177
Evan Chenga8e29892007-01-19 07:51:42 +0000178 // ARMv5T and above
David Goodwin334c2642009-07-08 16:09:28 +0000179 def tBLXi : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000180 "blx ${func:call}",
Evan Cheng20a2a0a2009-07-29 21:26:42 +0000181 [(ARMcall tglobaladdr:$func)]>,
182 Requires<[IsThumb1Only, HasV5T, IsNotDarwin]>;
183
David Goodwin334c2642009-07-08 16:09:28 +0000184 def tBLXr : T1I<(outs), (ins tGPR:$func, variable_ops),
Evan Cheng64d80e32007-07-19 01:14:50 +0000185 "blx $func",
Evan Cheng20a2a0a2009-07-29 21:26:42 +0000186 [(ARMtcall tGPR:$func)]>,
187 Requires<[IsThumb1Only, HasV5T, IsNotDarwin]>;
188
Lauro Ramos Venanciob8a93a42007-03-27 16:19:21 +0000189 // ARMv4T
David Goodwin334c2642009-07-08 16:09:28 +0000190 def tBX : T1Ix2<(outs), (ins tGPR:$func, variable_ops),
Evan Chengf6bc4ae2009-07-14 01:49:27 +0000191 "mov lr, pc\n\tbx $func",
Evan Cheng20a2a0a2009-07-29 21:26:42 +0000192 [(ARMcall_nolink tGPR:$func)]>,
193 Requires<[IsThumb1Only, IsNotDarwin]>;
194}
195
196// On Darwin R9 is call-clobbered.
197let isCall = 1,
198 Defs = [R0, R1, R2, R3, R9, R12, LR,
199 D0, D1, D2, D3, D4, D5, D6, D7,
200 D16, D17, D18, D19, D20, D21, D22, D23,
201 D24, D25, D26, D27, D28, D29, D30, D31, CPSR] in {
202 def tBLr9 : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
203 "bl ${func:call}",
204 [(ARMtcall tglobaladdr:$func)]>,
205 Requires<[IsThumb1Only, IsDarwin]>;
206
207 // ARMv5T and above
208 def tBLXi_r9 : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
209 "blx ${func:call}",
210 [(ARMcall tglobaladdr:$func)]>,
211 Requires<[IsThumb1Only, HasV5T, IsDarwin]>;
212
213 def tBLXr_r9 : T1I<(outs), (ins tGPR:$func, variable_ops),
214 "blx $func",
215 [(ARMtcall tGPR:$func)]>,
216 Requires<[IsThumb1Only, HasV5T, IsDarwin]>;
217
218 // ARMv4T
219 def tBXr9 : T1Ix2<(outs), (ins tGPR:$func, variable_ops),
220 "mov lr, pc\n\tbx $func",
221 [(ARMcall_nolink tGPR:$func)]>,
222 Requires<[IsThumb1Only, IsDarwin]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000223}
224
Evan Chengffbacca2007-07-21 00:34:19 +0000225let isBranch = 1, isTerminator = 1 in {
Evan Cheng3f8602c2007-05-16 21:53:43 +0000226 let isBarrier = 1 in {
227 let isPredicable = 1 in
David Goodwin5e47a9a2009-06-30 18:04:13 +0000228 def tB : T1I<(outs), (ins brtarget:$target), "b $target",
229 [(br bb:$target)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000230
Evan Cheng225dfe92007-01-30 01:13:37 +0000231 // Far jump
David Goodwin5e47a9a2009-06-30 18:04:13 +0000232 def tBfar : T1Ix2<(outs), (ins brtarget:$target),
233 "bl $target\t@ far jump",[]>;
Evan Cheng225dfe92007-01-30 01:13:37 +0000234
David Goodwin5e47a9a2009-06-30 18:04:13 +0000235 def tBR_JTr : T1JTI<(outs),
236 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chenge7c329b2009-07-28 20:53:24 +0000237 "mov pc, $target\n\t.align\t2\n$jt",
David Goodwin5e47a9a2009-06-30 18:04:13 +0000238 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
Evan Cheng3f8602c2007-05-16 21:53:43 +0000239 }
Evan Chengd85ac4d2007-01-27 02:29:45 +0000240}
241
Evan Chengc85e8322007-07-05 07:13:32 +0000242// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000243// a two-value operand where a dag node expects two operands. :(
Evan Chengffbacca2007-07-21 00:34:19 +0000244let isBranch = 1, isTerminator = 1 in
David Goodwin5e47a9a2009-06-30 18:04:13 +0000245 def tBcc : T1I<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
Evan Cheng64d80e32007-07-19 01:14:50 +0000246 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000247
248//===----------------------------------------------------------------------===//
249// Load Store Instructions.
250//
251
Dan Gohman15511cf2008-12-03 18:15:48 +0000252let canFoldAsLoad = 1 in
Evan Cheng446c4282009-07-11 06:43:01 +0000253def tLDR : T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
254 "ldr", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000255 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000256
Evan Cheng446c4282009-07-11 06:43:01 +0000257def tLDRB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
258 "ldrb", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000259 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000260
Evan Cheng446c4282009-07-11 06:43:01 +0000261def tLDRH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
262 "ldrh", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000263 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000264
Evan Cheng2f297df2009-07-11 07:08:13 +0000265let AddedComplexity = 10 in
Evan Cheng446c4282009-07-11 06:43:01 +0000266def tLDRSB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
267 "ldrsb", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000268 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000269
Evan Cheng2f297df2009-07-11 07:08:13 +0000270let AddedComplexity = 10 in
Evan Cheng446c4282009-07-11 06:43:01 +0000271def tLDRSH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
272 "ldrsh", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000273 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000274
Dan Gohman15511cf2008-12-03 18:15:48 +0000275let canFoldAsLoad = 1 in
Evan Cheng446c4282009-07-11 06:43:01 +0000276def tLDRspi : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
277 "ldr", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000278 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
Evan Cheng012f2d92007-01-24 08:53:17 +0000279
Evan Cheng8e59ea92007-02-07 00:06:56 +0000280// Special instruction for restore. It cannot clobber condition register
281// when it's expanded by eliminateCallFramePseudoInstr().
Dan Gohman15511cf2008-12-03 18:15:48 +0000282let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng446c4282009-07-11 06:43:01 +0000283def tRestore : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
284 "ldr", " $dst, $addr", []>;
Evan Cheng8e59ea92007-02-07 00:06:56 +0000285
Evan Cheng012f2d92007-01-24 08:53:17 +0000286// Load tconstpool
Dan Gohman15511cf2008-12-03 18:15:48 +0000287let canFoldAsLoad = 1 in
Evan Cheng446c4282009-07-11 06:43:01 +0000288def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr),
289 "ldr", " $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000290 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
Evan Chengfa775d02007-03-19 07:20:03 +0000291
292// Special LDR for loads from non-pc-relative constpools.
Dan Gohman15511cf2008-12-03 18:15:48 +0000293let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Evan Cheng446c4282009-07-11 06:43:01 +0000294def tLDRcp : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr),
295 "ldr", " $dst, $addr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000296
Evan Cheng446c4282009-07-11 06:43:01 +0000297def tSTR : T1pI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
298 "str", " $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000299 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000300
Evan Cheng446c4282009-07-11 06:43:01 +0000301def tSTRB : T1pI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
302 "strb", " $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000303 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000304
Evan Cheng446c4282009-07-11 06:43:01 +0000305def tSTRH : T1pI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
306 "strh", " $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000307 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000308
Evan Cheng446c4282009-07-11 06:43:01 +0000309def tSTRspi : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
310 "str", " $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000311 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
Evan Cheng8e59ea92007-02-07 00:06:56 +0000312
Chris Lattner2e48a702008-01-06 08:36:04 +0000313let mayStore = 1 in {
Evan Cheng8e59ea92007-02-07 00:06:56 +0000314// Special instruction for spill. It cannot clobber condition register
315// when it's expanded by eliminateCallFramePseudoInstr().
Evan Cheng446c4282009-07-11 06:43:01 +0000316def tSpill : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
317 "str", " $src, $addr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000318}
319
320//===----------------------------------------------------------------------===//
321// Load / store multiple Instructions.
322//
323
324// TODO: A7-44: LDMIA - load multiple
Evan Cheng446c4282009-07-11 06:43:01 +0000325// TODO: Allow these to be predicated
Evan Chenga8e29892007-01-19 07:51:42 +0000326
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000327let mayLoad = 1 in
David Goodwin334c2642009-07-08 16:09:28 +0000328def tPOP : T1I<(outs reglist:$dst1, variable_ops), (ins),
Evan Chenga8e29892007-01-19 07:51:42 +0000329 "pop $dst1", []>;
330
Chris Lattner2e48a702008-01-06 08:36:04 +0000331let mayStore = 1 in
David Goodwin334c2642009-07-08 16:09:28 +0000332def tPUSH : T1I<(outs), (ins reglist:$src1, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000333 "push $src1", []>;
334
335//===----------------------------------------------------------------------===//
336// Arithmetic Instructions.
337//
338
David Goodwinc9ee1182009-06-25 22:49:55 +0000339// Add with carry register
Evan Cheng446c4282009-07-11 06:43:01 +0000340let isCommutable = 1, Uses = [CPSR] in
341def tADC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
342 "adc", " $dst, $rhs",
Evan Cheng892837a2009-07-10 02:09:04 +0000343 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000344
David Goodwinc9ee1182009-06-25 22:49:55 +0000345// Add immediate
Evan Cheng446c4282009-07-11 06:43:01 +0000346def tADDi3 : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
347 "add", " $dst, $lhs, $rhs",
348 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000349
Evan Cheng446c4282009-07-11 06:43:01 +0000350def tADDi8 : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
351 "add", " $dst, $rhs",
352 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000353
David Goodwinc9ee1182009-06-25 22:49:55 +0000354// Add register
Evan Cheng446c4282009-07-11 06:43:01 +0000355let isCommutable = 1 in
356def tADDrr : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
357 "add", " $dst, $lhs, $rhs",
358 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000359
Evan Chengcd799b92009-06-12 20:46:18 +0000360let neverHasSideEffects = 1 in
Evan Cheng446c4282009-07-11 06:43:01 +0000361def tADDhirr : T1pIt<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
362 "add", " $dst, $rhs @ addhirr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000363
David Goodwinc9ee1182009-06-25 22:49:55 +0000364// And register
Evan Cheng446c4282009-07-11 06:43:01 +0000365let isCommutable = 1 in
366def tAND : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
367 "and", " $dst, $rhs",
368 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000369
David Goodwinc9ee1182009-06-25 22:49:55 +0000370// ASR immediate
Evan Cheng446c4282009-07-11 06:43:01 +0000371def tASRri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
372 "asr", " $dst, $lhs, $rhs",
373 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000374
David Goodwinc9ee1182009-06-25 22:49:55 +0000375// ASR register
Evan Cheng446c4282009-07-11 06:43:01 +0000376def tASRrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
377 "asr", " $dst, $rhs",
378 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000379
David Goodwinc9ee1182009-06-25 22:49:55 +0000380// BIC register
Evan Cheng446c4282009-07-11 06:43:01 +0000381def tBIC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
382 "bic", " $dst, $rhs",
383 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000384
David Goodwinc9ee1182009-06-25 22:49:55 +0000385// CMN register
386let Defs = [CPSR] in {
Evan Cheng446c4282009-07-11 06:43:01 +0000387def tCMN : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
388 "cmn", " $lhs, $rhs",
389 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
390def tCMNZ : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
391 "cmn", " $lhs, $rhs",
392 [(ARMcmpZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
David Goodwinc9ee1182009-06-25 22:49:55 +0000393}
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000394
David Goodwinc9ee1182009-06-25 22:49:55 +0000395// CMP immediate
396let Defs = [CPSR] in {
Evan Cheng446c4282009-07-11 06:43:01 +0000397def tCMPi8 : T1pI<(outs), (ins tGPR:$lhs, i32imm:$rhs),
398 "cmp", " $lhs, $rhs",
399 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
400def tCMPZi8 : T1pI<(outs), (ins tGPR:$lhs, i32imm:$rhs),
401 "cmp", " $lhs, $rhs",
402 [(ARMcmpZ tGPR:$lhs, imm0_255:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000403
David Goodwinc9ee1182009-06-25 22:49:55 +0000404}
405
406// CMP register
407let Defs = [CPSR] in {
Evan Cheng446c4282009-07-11 06:43:01 +0000408def tCMPr : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
409 "cmp", " $lhs, $rhs",
410 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
411def tCMPZr : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
412 "cmp", " $lhs, $rhs",
413 [(ARMcmpZ tGPR:$lhs, tGPR:$rhs)]>;
414
415// TODO: Make use of the followings cmp hi regs
416def tCMPhir : T1pI<(outs), (ins GPR:$lhs, GPR:$rhs),
417 "cmp", " $lhs, $rhs", []>;
418def tCMPZhir : T1pI<(outs), (ins GPR:$lhs, GPR:$rhs),
419 "cmp", " $lhs, $rhs", []>;
David Goodwinc9ee1182009-06-25 22:49:55 +0000420}
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000421
Evan Chenga8e29892007-01-19 07:51:42 +0000422
David Goodwinc9ee1182009-06-25 22:49:55 +0000423// XOR register
Evan Cheng446c4282009-07-11 06:43:01 +0000424let isCommutable = 1 in
425def tEOR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
426 "eor", " $dst, $rhs",
427 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000428
David Goodwinc9ee1182009-06-25 22:49:55 +0000429// LSL immediate
Evan Cheng446c4282009-07-11 06:43:01 +0000430def tLSLri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
431 "lsl", " $dst, $lhs, $rhs",
432 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000433
David Goodwinc9ee1182009-06-25 22:49:55 +0000434// LSL register
Evan Cheng446c4282009-07-11 06:43:01 +0000435def tLSLrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
436 "lsl", " $dst, $rhs",
437 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000438
David Goodwinc9ee1182009-06-25 22:49:55 +0000439// LSR immediate
Evan Cheng446c4282009-07-11 06:43:01 +0000440def tLSRri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
441 "lsr", " $dst, $lhs, $rhs",
442 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000443
David Goodwinc9ee1182009-06-25 22:49:55 +0000444// LSR register
Evan Cheng446c4282009-07-11 06:43:01 +0000445def tLSRrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
446 "lsr", " $dst, $rhs",
447 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000448
David Goodwinc9ee1182009-06-25 22:49:55 +0000449// move register
Evan Cheng446c4282009-07-11 06:43:01 +0000450def tMOVi8 : T1sI<(outs tGPR:$dst), (ins i32imm:$src),
451 "mov", " $dst, $src",
452 [(set tGPR:$dst, imm0_255:$src)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000453
454// TODO: A7-73: MOV(2) - mov setting flag.
455
456
Evan Chengcd799b92009-06-12 20:46:18 +0000457let neverHasSideEffects = 1 in {
Evan Cheng446c4282009-07-11 06:43:01 +0000458// FIXME: Make this predicable.
Evan Cheng09c39fc2009-06-23 19:38:13 +0000459def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Cheng446c4282009-07-11 06:43:01 +0000460 "mov $dst, $src", []>;
461let Defs = [CPSR] in
462def tMOVSr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
463 "movs $dst, $src", []>;
464
465// FIXME: Make these predicable.
Evan Chengd8336062009-07-26 23:59:01 +0000466def tMOVgpr2tgpr : T1I<(outs tGPR:$dst), (ins GPR:$src),
Evan Cheng446c4282009-07-11 06:43:01 +0000467 "mov $dst, $src\t@ hir2lor", []>;
Evan Chengd8336062009-07-26 23:59:01 +0000468def tMOVtgpr2gpr : T1I<(outs GPR:$dst), (ins tGPR:$src),
Evan Cheng446c4282009-07-11 06:43:01 +0000469 "mov $dst, $src\t@ lor2hir", []>;
Evan Chengd8336062009-07-26 23:59:01 +0000470def tMOVgpr2gpr : T1I<(outs GPR:$dst), (ins GPR:$src),
Evan Cheng446c4282009-07-11 06:43:01 +0000471 "mov $dst, $src\t@ hir2hir", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000472} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000473
David Goodwinc9ee1182009-06-25 22:49:55 +0000474// multiply register
Evan Cheng446c4282009-07-11 06:43:01 +0000475let isCommutable = 1 in
476def tMUL : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
477 "mul", " $dst, $rhs",
478 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000479
David Goodwinc9ee1182009-06-25 22:49:55 +0000480// move inverse register
Evan Cheng446c4282009-07-11 06:43:01 +0000481def tMVN : T1sI<(outs tGPR:$dst), (ins tGPR:$src),
482 "mvn", " $dst, $src",
483 [(set tGPR:$dst, (not tGPR:$src))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000484
David Goodwinc9ee1182009-06-25 22:49:55 +0000485// bitwise or register
Evan Cheng446c4282009-07-11 06:43:01 +0000486let isCommutable = 1 in
487def tORR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
488 "orr", " $dst, $rhs",
489 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000490
David Goodwinc9ee1182009-06-25 22:49:55 +0000491// swaps
Evan Cheng446c4282009-07-11 06:43:01 +0000492def tREV : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
493 "rev", " $dst, $src",
494 [(set tGPR:$dst, (bswap tGPR:$src))]>,
David Goodwinf1daf7d2009-07-08 23:10:31 +0000495 Requires<[IsThumb1Only, HasV6]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000496
Evan Cheng446c4282009-07-11 06:43:01 +0000497def tREV16 : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
498 "rev16", " $dst, $src",
499 [(set tGPR:$dst,
500 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
501 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
502 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
503 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
David Goodwinf1daf7d2009-07-08 23:10:31 +0000504 Requires<[IsThumb1Only, HasV6]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000505
Evan Cheng446c4282009-07-11 06:43:01 +0000506def tREVSH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
507 "revsh", " $dst, $src",
508 [(set tGPR:$dst,
509 (sext_inreg
510 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
511 (shl tGPR:$src, (i32 8))), i16))]>,
512 Requires<[IsThumb1Only, HasV6]>;
513
David Goodwinc9ee1182009-06-25 22:49:55 +0000514// rotate right register
Evan Cheng446c4282009-07-11 06:43:01 +0000515def tROR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
516 "ror", " $dst, $rhs",
517 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
518
519// negate register
520def tRSB : T1sI<(outs tGPR:$dst), (ins tGPR:$src),
521 "rsb", " $dst, $src, #0",
522 [(set tGPR:$dst, (ineg tGPR:$src))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000523
David Goodwinc9ee1182009-06-25 22:49:55 +0000524// Subtract with carry register
Evan Cheng446c4282009-07-11 06:43:01 +0000525let Uses = [CPSR] in
526def tSBC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
527 "sbc", " $dst, $rhs",
528 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000529
David Goodwinc9ee1182009-06-25 22:49:55 +0000530// Subtract immediate
Evan Cheng446c4282009-07-11 06:43:01 +0000531def tSUBi3 : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
532 "sub", " $dst, $lhs, $rhs",
533 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000534
Evan Cheng446c4282009-07-11 06:43:01 +0000535def tSUBi8 : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
536 "sub", " $dst, $rhs",
537 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000538
David Goodwinc9ee1182009-06-25 22:49:55 +0000539// subtract register
Evan Cheng446c4282009-07-11 06:43:01 +0000540def tSUBrr : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
541 "sub", " $dst, $lhs, $rhs",
542 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
David Goodwinc9ee1182009-06-25 22:49:55 +0000543
544// TODO: A7-96: STMIA - store multiple.
Evan Chenga8e29892007-01-19 07:51:42 +0000545
Evan Chenga6e43222009-07-17 05:43:12 +0000546def tSUBspi : T1It<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs),
Evan Cheng3fdadfc2007-01-26 21:33:19 +0000547 "sub $dst, $rhs * 4", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000548
David Goodwinc9ee1182009-06-25 22:49:55 +0000549// sign-extend byte
Evan Cheng446c4282009-07-11 06:43:01 +0000550def tSXTB : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
551 "sxtb", " $dst, $src",
552 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
553 Requires<[IsThumb1Only, HasV6]>;
David Goodwinc9ee1182009-06-25 22:49:55 +0000554
555// sign-extend short
Evan Cheng446c4282009-07-11 06:43:01 +0000556def tSXTH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
557 "sxth", " $dst, $src",
558 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
559 Requires<[IsThumb1Only, HasV6]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000560
David Goodwinc9ee1182009-06-25 22:49:55 +0000561// test
Evan Chenge864b742009-06-26 00:19:07 +0000562let isCommutable = 1, Defs = [CPSR] in
Evan Cheng446c4282009-07-11 06:43:01 +0000563def tTST : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
564 "tst", " $lhs, $rhs",
565 [(ARMcmpZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000566
David Goodwinc9ee1182009-06-25 22:49:55 +0000567// zero-extend byte
Evan Cheng446c4282009-07-11 06:43:01 +0000568def tUXTB : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
569 "uxtb", " $dst, $src",
570 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
571 Requires<[IsThumb1Only, HasV6]>;
David Goodwinc9ee1182009-06-25 22:49:55 +0000572
573// zero-extend short
Evan Cheng446c4282009-07-11 06:43:01 +0000574def tUXTH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
575 "uxth", " $dst, $src",
576 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
577 Requires<[IsThumb1Only, HasV6]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000578
579
580// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
581// Expanded by the scheduler into a branch sequence.
Evan Cheng446c4282009-07-11 06:43:01 +0000582// FIXME: Add actual movcc in IT blocks for Thumb2.
Evan Chenga8e29892007-01-19 07:51:42 +0000583let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
584 def tMOVCCr :
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000585 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
Evan Chenga8e29892007-01-19 07:51:42 +0000586 "@ tMOVCCr $cc",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000587 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000588
589// tLEApcrel - Load a pc-relative address into a register without offending the
590// assembler.
Evan Cheng81c102b2009-07-23 18:26:03 +0000591def tLEApcrel : T1I<(outs tGPR:$dst), (ins i32imm:$label),
592 "adr $dst, #$label", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000593
Evan Cheng81c102b2009-07-23 18:26:03 +0000594def tLEApcrelJT : T1I<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
595 "adr $dst, #${label}_${id:no_hash}", []>;
Evan Chengd85ac4d2007-01-27 02:29:45 +0000596
Evan Chenga8e29892007-01-19 07:51:42 +0000597//===----------------------------------------------------------------------===//
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000598// TLS Instructions
599//
600
601// __aeabi_read_tp preserves the registers r1-r3.
602let isCall = 1,
603 Defs = [R0, LR] in {
David Goodwin334c2642009-07-08 16:09:28 +0000604 def tTPsoft : T1Ix2<(outs), (ins),
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000605 "bl __aeabi_read_tp",
606 [(set R0, ARMthread_pointer)]>;
607}
608
609//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +0000610// Non-Instruction Patterns
611//
612
Evan Cheng892837a2009-07-10 02:09:04 +0000613// Add with carry
David Goodwinc9d138f2009-07-27 19:59:26 +0000614def : T1Pat<(addc tGPR:$lhs, imm0_7:$rhs),
615 (tADDi3 tGPR:$lhs, imm0_7:$rhs)>;
616def : T1Pat<(addc tGPR:$lhs, imm8_255:$rhs),
617 (tADDi3 tGPR:$lhs, imm8_255:$rhs)>;
618def : T1Pat<(addc tGPR:$lhs, tGPR:$rhs),
619 (tADDrr tGPR:$lhs, tGPR:$rhs)>;
Evan Cheng892837a2009-07-10 02:09:04 +0000620
621// Subtract with carry
David Goodwinc9d138f2009-07-27 19:59:26 +0000622def : T1Pat<(addc tGPR:$lhs, imm0_7_neg:$rhs),
623 (tSUBi3 tGPR:$lhs, imm0_7_neg:$rhs)>;
624def : T1Pat<(addc tGPR:$lhs, imm8_255_neg:$rhs),
625 (tSUBi8 tGPR:$lhs, imm8_255_neg:$rhs)>;
626def : T1Pat<(subc tGPR:$lhs, tGPR:$rhs),
627 (tSUBrr tGPR:$lhs, tGPR:$rhs)>;
Evan Cheng892837a2009-07-10 02:09:04 +0000628
Evan Chenga8e29892007-01-19 07:51:42 +0000629// ConstantPool, GlobalAddress
David Goodwinc9d138f2009-07-27 19:59:26 +0000630def : T1Pat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
631def : T1Pat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
Evan Chenga8e29892007-01-19 07:51:42 +0000632
Evan Chengd85ac4d2007-01-27 02:29:45 +0000633// JumpTable
David Goodwinc9d138f2009-07-27 19:59:26 +0000634def : T1Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
635 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
Evan Chengd85ac4d2007-01-27 02:29:45 +0000636
Evan Chenga8e29892007-01-19 07:51:42 +0000637// Direct calls
Evan Cheng20a2a0a2009-07-29 21:26:42 +0000638def : T1Pat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>,
639 Requires<[IsThumb1Only, IsNotDarwin]>;
640def : T1Pat<(ARMtcall texternalsym:$func), (tBLr9 texternalsym:$func)>,
641 Requires<[IsThumb1Only, IsDarwin]>;
642
643def : Tv5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>,
644 Requires<[IsThumb1Only, HasV5T, IsNotDarwin]>;
645def : Tv5Pat<(ARMcall texternalsym:$func), (tBLXi_r9 texternalsym:$func)>,
646 Requires<[IsThumb1Only, HasV5T, IsDarwin]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000647
648// Indirect calls to ARM routines
Evan Cheng20a2a0a2009-07-29 21:26:42 +0000649def : Tv5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>,
650 Requires<[IsThumb1Only, HasV5T, IsNotDarwin]>;
651def : Tv5Pat<(ARMcall tGPR:$dst), (tBLXr_r9 tGPR:$dst)>,
652 Requires<[IsThumb1Only, HasV5T, IsDarwin]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000653
654// zextload i1 -> zextload i8
Evan Chengf3c21b82009-06-30 02:15:48 +0000655def : T1Pat<(zextloadi1 t_addrmode_s1:$addr),
656 (tLDRB t_addrmode_s1:$addr)>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000657
Evan Chengb60c02e2007-01-26 19:13:16 +0000658// extload -> zextload
Evan Chengf3c21b82009-06-30 02:15:48 +0000659def : T1Pat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
660def : T1Pat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
661def : T1Pat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
Evan Chengb60c02e2007-01-26 19:13:16 +0000662
Evan Cheng2f297df2009-07-11 07:08:13 +0000663// If it's possible to use [r,r] address mode for sextload, select to
664// ldr{b|h} + sxt{b|h} instead.
Evan Cheng3ecadc82009-07-21 18:15:26 +0000665def : T1Pat<(sextloadi8 t_addrmode_s1:$addr),
666 (tSXTB (tLDRB t_addrmode_s1:$addr))>;
667def : T1Pat<(sextloadi16 t_addrmode_s2:$addr),
668 (tSXTH (tLDRH t_addrmode_s2:$addr))>;
Evan Cheng2f297df2009-07-11 07:08:13 +0000669
670
Evan Chenga8e29892007-01-19 07:51:42 +0000671// Large immediate handling.
672
673// Two piece imms.
Evan Cheng9cb9e672009-06-27 02:26:13 +0000674def : T1Pat<(i32 thumb_immshifted:$src),
675 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
676 (thumb_immshifted_shamt imm:$src))>;
Evan Chenga8e29892007-01-19 07:51:42 +0000677
Evan Cheng9cb9e672009-06-27 02:26:13 +0000678def : T1Pat<(i32 imm0_255_comp:$src),
679 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;