blob: d6a5d8e2989db6616d946e28d6a6682989ea5af6 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- ARMInstrThumb.td - Thumb support for ARM ---------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +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
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021def imm_neg_XFORM : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000022 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023}]>;
24def imm_comp_XFORM : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000025 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +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 Gohmanfaeb4a32008-09-12 16:56:44 +000031 return (uint32_t)N->getZExtValue() < 8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032}]>;
33def imm0_7_neg : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000034 return (uint32_t)-N->getZExtValue() < 8;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035}], imm_neg_XFORM>;
36
37def imm0_255 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000038 return (uint32_t)N->getZExtValue() < 256;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039}]>;
40def imm0_255_comp : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000041 return ~((uint32_t)N->getZExtValue()) < 256;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000042}]>;
43
44def imm8_255 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000045 return (uint32_t)N->getZExtValue() >= 8 && (uint32_t)N->getZExtValue() < 256;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000046}]>;
47def imm8_255_neg : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000048 unsigned Val = -N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +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 Gohmanfaeb4a32008-09-12 16:56:44 +000056 return ARM_AM::isThumbImmShiftedVal((unsigned)N->getZExtValue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057}]>;
58
59def thumb_immshifted_val : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000060 unsigned V = ARM_AM::getThumbImmNonShiftedVal((unsigned)N->getZExtValue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 return CurDAG->getTargetConstant(V, MVT::i32);
62}]>;
63
64def thumb_immshifted_shamt : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +000065 unsigned V = ARM_AM::getThumbImmValShift((unsigned)N->getZExtValue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +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 Grosbach0e4e9742009-04-07 20:34:09 +000076 let MIOperandInfo = (ops tGPR:$base, tGPR:$offsreg);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077}
78
79// t_addrmode_s4 := reg + reg
80// reg + imm5 * 4
81//
82def t_addrmode_s4 : Operand<i32>,
83 ComplexPattern<i32, 3, "SelectThumbAddrModeS4", []> {
84 let PrintMethod = "printThumbAddrModeS4Operand";
Jim Grosbach0e4e9742009-04-07 20:34:09 +000085 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086}
87
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 Grosbach0e4e9742009-04-07 20:34:09 +000094 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095}
96
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 Grosbach0e4e9742009-04-07 20:34:09 +0000103 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Dan Gohmanf17a25c2007-07-18 16:29:46 +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 Grosbach0e4e9742009-04-07 20:34:09 +0000111 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000112}
113
114//===----------------------------------------------------------------------===//
115// Miscellaneous Instructions.
116//
117
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000118let Defs = [SP], Uses = [SP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000119def tADJCALLSTACKUP :
Bill Wendling22f8deb2007-11-13 00:44:25 +0000120PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
121 "@ tADJCALLSTACKUP $amt1",
David Goodwin4a897932009-07-08 23:10:31 +0000122 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>, Requires<[IsThumb1Only]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
Jim Grosbach7ea52762009-03-27 23:06:27 +0000124def tADJCALLSTACKDOWN :
Evan Chengb783fa32007-07-19 01:14:50 +0000125PseudoInst<(outs), (ins i32imm:$amt),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126 "@ tADJCALLSTACKDOWN $amt",
David Goodwin4a897932009-07-08 23:10:31 +0000127 [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb1Only]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000128}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129
130let isNotDuplicable = 1 in
Evan Cheng41799702009-06-24 23:47:58 +0000131def tPICADD : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, pclabel:$cp),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132 "$cp:\n\tadd $dst, pc",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000133 [(set tGPR:$dst, (ARMpic_add tGPR:$lhs, imm:$cp))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134
Evan Chengae2ed1f2009-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
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153//===----------------------------------------------------------------------===//
154// Control Flow Instructions.
155//
156
157let isReturn = 1, isTerminator = 1 in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000158 def tBX_RET : TI<(outs), (ins), "bx lr", [(ARMretflag)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159 // Alternative return instruction used by vararg functions.
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000160 def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), "bx $target", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161}
162
163// FIXME: remove when we have a way to marking a MI with these properties.
Evan Cheng8610a3b2008-01-07 23:56:57 +0000164let isReturn = 1, isTerminator = 1 in
David Goodwin41afec22009-07-08 16:09:28 +0000165def tPOP_RET : T1I<(outs reglist:$dst1, variable_ops), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 "pop $dst1", []>;
167
Jim Grosbach7ea52762009-03-27 23:06:27 +0000168let isCall = 1,
Evan Cheng27396a62009-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 Cheng80ab2a82009-07-29 20:10:36 +0000172 D24, D25, D26, D27, D28, D29, D30, D31, CPSR] in {
David Goodwin41afec22009-07-08 16:09:28 +0000173 def tBL : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174 "bl ${func:call}",
175 [(ARMtcall tglobaladdr:$func)]>;
176 // ARMv5T and above
David Goodwin41afec22009-07-08 16:09:28 +0000177 def tBLXi : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 "blx ${func:call}",
179 [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>;
David Goodwin41afec22009-07-08 16:09:28 +0000180 def tBLXr : T1I<(outs), (ins tGPR:$func, variable_ops),
Evan Chengb783fa32007-07-19 01:14:50 +0000181 "blx $func",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000182 [(ARMtcall tGPR:$func)]>, Requires<[HasV5T]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 // ARMv4T
David Goodwin41afec22009-07-08 16:09:28 +0000184 def tBX : T1Ix2<(outs), (ins tGPR:$func, variable_ops),
Evan Chengfb1d1472009-07-14 01:49:27 +0000185 "mov lr, pc\n\tbx $func",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000186 [(ARMcall_nolink tGPR:$func)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187}
188
Evan Cheng37e7c752007-07-21 00:34:19 +0000189let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 let isBarrier = 1 in {
191 let isPredicable = 1 in
David Goodwinf6154702009-06-30 18:04:13 +0000192 def tB : T1I<(outs), (ins brtarget:$target), "b $target",
193 [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194
195 // Far jump
David Goodwinf6154702009-06-30 18:04:13 +0000196 def tBfar : T1Ix2<(outs), (ins brtarget:$target),
197 "bl $target\t@ far jump",[]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198
David Goodwinf6154702009-06-30 18:04:13 +0000199 def tBR_JTr : T1JTI<(outs),
200 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Cheng5c037152009-07-28 20:53:24 +0000201 "mov pc, $target\n\t.align\t2\n$jt",
David Goodwinf6154702009-06-30 18:04:13 +0000202 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 }
204}
205
206// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach7ea52762009-03-27 23:06:27 +0000207// a two-value operand where a dag node expects two operands. :(
Evan Cheng37e7c752007-07-21 00:34:19 +0000208let isBranch = 1, isTerminator = 1 in
David Goodwinf6154702009-06-30 18:04:13 +0000209 def tBcc : T1I<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
Evan Chengb783fa32007-07-19 01:14:50 +0000210 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000211
212//===----------------------------------------------------------------------===//
213// Load Store Instructions.
214//
215
Dan Gohman5574cc72008-12-03 18:15:48 +0000216let canFoldAsLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000217def tLDR : T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
218 "ldr", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000219 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000221def tLDRB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
222 "ldrb", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000223 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000225def tLDRH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
226 "ldrh", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000227 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228
Evan Cheng76aeed32009-07-11 07:08:13 +0000229let AddedComplexity = 10 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000230def tLDRSB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
231 "ldrsb", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000232 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233
Evan Cheng76aeed32009-07-11 07:08:13 +0000234let AddedComplexity = 10 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000235def tLDRSH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
236 "ldrsh", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000237 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238
Dan Gohman5574cc72008-12-03 18:15:48 +0000239let canFoldAsLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000240def tLDRspi : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
241 "ldr", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000242 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243
244// Special instruction for restore. It cannot clobber condition register
245// when it's expanded by eliminateCallFramePseudoInstr().
Dan Gohman5574cc72008-12-03 18:15:48 +0000246let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000247def tRestore : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
248 "ldr", " $dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249
250// Load tconstpool
Dan Gohman5574cc72008-12-03 18:15:48 +0000251let canFoldAsLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000252def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr),
253 "ldr", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000254 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255
256// Special LDR for loads from non-pc-relative constpools.
Dan Gohman5574cc72008-12-03 18:15:48 +0000257let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000258def tLDRcp : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr),
259 "ldr", " $dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000261def tSTR : T1pI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
262 "str", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000263 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000265def tSTRB : T1pI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
266 "strb", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000267 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000269def tSTRH : T1pI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
270 "strh", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000271 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000273def tSTRspi : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
274 "str", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000275 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276
Chris Lattner6887b142008-01-06 08:36:04 +0000277let mayStore = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278// Special instruction for spill. It cannot clobber condition register
279// when it's expanded by eliminateCallFramePseudoInstr().
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000280def tSpill : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
281 "str", " $src, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282}
283
284//===----------------------------------------------------------------------===//
285// Load / store multiple Instructions.
286//
287
288// TODO: A7-44: LDMIA - load multiple
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000289// TODO: Allow these to be predicated
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000291let mayLoad = 1 in
David Goodwin41afec22009-07-08 16:09:28 +0000292def tPOP : T1I<(outs reglist:$dst1, variable_ops), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293 "pop $dst1", []>;
294
Chris Lattner6887b142008-01-06 08:36:04 +0000295let mayStore = 1 in
David Goodwin41afec22009-07-08 16:09:28 +0000296def tPUSH : T1I<(outs), (ins reglist:$src1, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297 "push $src1", []>;
298
299//===----------------------------------------------------------------------===//
300// Arithmetic Instructions.
301//
302
David Goodwin8768bff2009-06-25 22:49:55 +0000303// Add with carry register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000304let isCommutable = 1, Uses = [CPSR] in
305def tADC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
306 "adc", " $dst, $rhs",
Evan Cheng986e3b72009-07-10 02:09:04 +0000307 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308
David Goodwin8768bff2009-06-25 22:49:55 +0000309// Add immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000310def tADDi3 : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
311 "add", " $dst, $lhs, $rhs",
312 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000314def tADDi8 : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
315 "add", " $dst, $rhs",
316 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317
David Goodwin8768bff2009-06-25 22:49:55 +0000318// Add register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000319let isCommutable = 1 in
320def tADDrr : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
321 "add", " $dst, $lhs, $rhs",
322 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323
Evan Chengd97d7142009-06-12 20:46:18 +0000324let neverHasSideEffects = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000325def tADDhirr : T1pIt<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
326 "add", " $dst, $rhs @ addhirr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327
David Goodwin8768bff2009-06-25 22:49:55 +0000328// And register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000329let isCommutable = 1 in
330def tAND : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
331 "and", " $dst, $rhs",
332 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333
David Goodwin8768bff2009-06-25 22:49:55 +0000334// ASR immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000335def tASRri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
336 "asr", " $dst, $lhs, $rhs",
337 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338
David Goodwin8768bff2009-06-25 22:49:55 +0000339// ASR register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000340def tASRrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
341 "asr", " $dst, $rhs",
342 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343
David Goodwin8768bff2009-06-25 22:49:55 +0000344// BIC register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000345def tBIC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
346 "bic", " $dst, $rhs",
347 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348
David Goodwin8768bff2009-06-25 22:49:55 +0000349// CMN register
350let Defs = [CPSR] in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000351def tCMN : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
352 "cmn", " $lhs, $rhs",
353 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
354def tCMNZ : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
355 "cmn", " $lhs, $rhs",
356 [(ARMcmpZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000357}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358
David Goodwin8768bff2009-06-25 22:49:55 +0000359// CMP immediate
360let Defs = [CPSR] in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000361def tCMPi8 : T1pI<(outs), (ins tGPR:$lhs, i32imm:$rhs),
362 "cmp", " $lhs, $rhs",
363 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
364def tCMPZi8 : T1pI<(outs), (ins tGPR:$lhs, i32imm:$rhs),
365 "cmp", " $lhs, $rhs",
366 [(ARMcmpZ tGPR:$lhs, imm0_255:$rhs)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367
David Goodwin8768bff2009-06-25 22:49:55 +0000368}
369
370// CMP register
371let Defs = [CPSR] in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000372def tCMPr : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
373 "cmp", " $lhs, $rhs",
374 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
375def tCMPZr : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
376 "cmp", " $lhs, $rhs",
377 [(ARMcmpZ tGPR:$lhs, tGPR:$rhs)]>;
378
379// TODO: Make use of the followings cmp hi regs
380def tCMPhir : T1pI<(outs), (ins GPR:$lhs, GPR:$rhs),
381 "cmp", " $lhs, $rhs", []>;
382def tCMPZhir : T1pI<(outs), (ins GPR:$lhs, GPR:$rhs),
383 "cmp", " $lhs, $rhs", []>;
David Goodwin8768bff2009-06-25 22:49:55 +0000384}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386
David Goodwin8768bff2009-06-25 22:49:55 +0000387// XOR register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000388let isCommutable = 1 in
389def tEOR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
390 "eor", " $dst, $rhs",
391 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
David Goodwin8768bff2009-06-25 22:49:55 +0000393// LSL immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000394def tLSLri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
395 "lsl", " $dst, $lhs, $rhs",
396 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397
David Goodwin8768bff2009-06-25 22:49:55 +0000398// LSL register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000399def tLSLrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
400 "lsl", " $dst, $rhs",
401 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402
David Goodwin8768bff2009-06-25 22:49:55 +0000403// LSR immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000404def tLSRri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
405 "lsr", " $dst, $lhs, $rhs",
406 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407
David Goodwin8768bff2009-06-25 22:49:55 +0000408// LSR register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000409def tLSRrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
410 "lsr", " $dst, $rhs",
411 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412
David Goodwin8768bff2009-06-25 22:49:55 +0000413// move register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000414def tMOVi8 : T1sI<(outs tGPR:$dst), (ins i32imm:$src),
415 "mov", " $dst, $src",
416 [(set tGPR:$dst, imm0_255:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417
418// TODO: A7-73: MOV(2) - mov setting flag.
419
420
Evan Chengd97d7142009-06-12 20:46:18 +0000421let neverHasSideEffects = 1 in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000422// FIXME: Make this predicable.
Evan Cheng6fc534c2009-06-23 19:38:13 +0000423def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000424 "mov $dst, $src", []>;
425let Defs = [CPSR] in
426def tMOVSr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
427 "movs $dst, $src", []>;
428
429// FIXME: Make these predicable.
Evan Chengdf827f22009-07-26 23:59:01 +0000430def tMOVgpr2tgpr : T1I<(outs tGPR:$dst), (ins GPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000431 "mov $dst, $src\t@ hir2lor", []>;
Evan Chengdf827f22009-07-26 23:59:01 +0000432def tMOVtgpr2gpr : T1I<(outs GPR:$dst), (ins tGPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000433 "mov $dst, $src\t@ lor2hir", []>;
Evan Chengdf827f22009-07-26 23:59:01 +0000434def tMOVgpr2gpr : T1I<(outs GPR:$dst), (ins GPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000435 "mov $dst, $src\t@ hir2hir", []>;
Evan Chengd97d7142009-06-12 20:46:18 +0000436} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437
David Goodwin8768bff2009-06-25 22:49:55 +0000438// multiply register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000439let isCommutable = 1 in
440def tMUL : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
441 "mul", " $dst, $rhs",
442 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443
David Goodwin8768bff2009-06-25 22:49:55 +0000444// move inverse register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000445def tMVN : T1sI<(outs tGPR:$dst), (ins tGPR:$src),
446 "mvn", " $dst, $src",
447 [(set tGPR:$dst, (not tGPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448
David Goodwin8768bff2009-06-25 22:49:55 +0000449// bitwise or register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000450let isCommutable = 1 in
451def tORR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
452 "orr", " $dst, $rhs",
453 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454
David Goodwin8768bff2009-06-25 22:49:55 +0000455// swaps
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000456def tREV : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
457 "rev", " $dst, $src",
458 [(set tGPR:$dst, (bswap tGPR:$src))]>,
David Goodwin4a897932009-07-08 23:10:31 +0000459 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000461def tREV16 : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
462 "rev16", " $dst, $src",
463 [(set tGPR:$dst,
464 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
465 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
466 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
467 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
David Goodwin4a897932009-07-08 23:10:31 +0000468 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000470def tREVSH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
471 "revsh", " $dst, $src",
472 [(set tGPR:$dst,
473 (sext_inreg
474 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
475 (shl tGPR:$src, (i32 8))), i16))]>,
476 Requires<[IsThumb1Only, HasV6]>;
477
David Goodwin8768bff2009-06-25 22:49:55 +0000478// rotate right register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000479def tROR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
480 "ror", " $dst, $rhs",
481 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
482
483// negate register
484def tRSB : T1sI<(outs tGPR:$dst), (ins tGPR:$src),
485 "rsb", " $dst, $src, #0",
486 [(set tGPR:$dst, (ineg tGPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487
David Goodwin8768bff2009-06-25 22:49:55 +0000488// Subtract with carry register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000489let Uses = [CPSR] in
490def tSBC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
491 "sbc", " $dst, $rhs",
492 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493
David Goodwin8768bff2009-06-25 22:49:55 +0000494// Subtract immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000495def tSUBi3 : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
496 "sub", " $dst, $lhs, $rhs",
497 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000498
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000499def tSUBi8 : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
500 "sub", " $dst, $rhs",
501 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000502
David Goodwin8768bff2009-06-25 22:49:55 +0000503// subtract register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000504def tSUBrr : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
505 "sub", " $dst, $lhs, $rhs",
506 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000507
508// TODO: A7-96: STMIA - store multiple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509
Evan Chengec369ef2009-07-17 05:43:12 +0000510def tSUBspi : T1It<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511 "sub $dst, $rhs * 4", []>;
512
David Goodwin8768bff2009-06-25 22:49:55 +0000513// sign-extend byte
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000514def tSXTB : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
515 "sxtb", " $dst, $src",
516 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
517 Requires<[IsThumb1Only, HasV6]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000518
519// sign-extend short
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000520def tSXTH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
521 "sxth", " $dst, $src",
522 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
523 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524
David Goodwin8768bff2009-06-25 22:49:55 +0000525// test
Evan Cheng138f60e2009-06-26 00:19:07 +0000526let isCommutable = 1, Defs = [CPSR] in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000527def tTST : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
528 "tst", " $lhs, $rhs",
529 [(ARMcmpZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530
David Goodwin8768bff2009-06-25 22:49:55 +0000531// zero-extend byte
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000532def tUXTB : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
533 "uxtb", " $dst, $src",
534 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
535 Requires<[IsThumb1Only, HasV6]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000536
537// zero-extend short
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000538def tUXTH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
539 "uxth", " $dst, $src",
540 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
541 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542
543
544// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
545// Expanded by the scheduler into a branch sequence.
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000546// FIXME: Add actual movcc in IT blocks for Thumb2.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
548 def tMOVCCr :
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000549 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 "@ tMOVCCr $cc",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000551 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552
553// tLEApcrel - Load a pc-relative address into a register without offending the
554// assembler.
Evan Cheng6683bb62009-07-23 18:26:03 +0000555def tLEApcrel : T1I<(outs tGPR:$dst), (ins i32imm:$label),
556 "adr $dst, #$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557
Evan Cheng6683bb62009-07-23 18:26:03 +0000558def tLEApcrelJT : T1I<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
559 "adr $dst, #${label}_${id:no_hash}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560
561//===----------------------------------------------------------------------===//
562// TLS Instructions
563//
564
565// __aeabi_read_tp preserves the registers r1-r3.
566let isCall = 1,
567 Defs = [R0, LR] in {
David Goodwin41afec22009-07-08 16:09:28 +0000568 def tTPsoft : T1Ix2<(outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569 "bl __aeabi_read_tp",
570 [(set R0, ARMthread_pointer)]>;
571}
572
573//===----------------------------------------------------------------------===//
574// Non-Instruction Patterns
575//
576
Evan Cheng986e3b72009-07-10 02:09:04 +0000577// Add with carry
David Goodwin27c016b2009-07-27 19:59:26 +0000578def : T1Pat<(addc tGPR:$lhs, imm0_7:$rhs),
579 (tADDi3 tGPR:$lhs, imm0_7:$rhs)>;
580def : T1Pat<(addc tGPR:$lhs, imm8_255:$rhs),
581 (tADDi3 tGPR:$lhs, imm8_255:$rhs)>;
582def : T1Pat<(addc tGPR:$lhs, tGPR:$rhs),
583 (tADDrr tGPR:$lhs, tGPR:$rhs)>;
Evan Cheng986e3b72009-07-10 02:09:04 +0000584
585// Subtract with carry
David Goodwin27c016b2009-07-27 19:59:26 +0000586def : T1Pat<(addc tGPR:$lhs, imm0_7_neg:$rhs),
587 (tSUBi3 tGPR:$lhs, imm0_7_neg:$rhs)>;
588def : T1Pat<(addc tGPR:$lhs, imm8_255_neg:$rhs),
589 (tSUBi8 tGPR:$lhs, imm8_255_neg:$rhs)>;
590def : T1Pat<(subc tGPR:$lhs, tGPR:$rhs),
591 (tSUBrr tGPR:$lhs, tGPR:$rhs)>;
Evan Cheng986e3b72009-07-10 02:09:04 +0000592
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593// ConstantPool, GlobalAddress
David Goodwin27c016b2009-07-27 19:59:26 +0000594def : T1Pat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
595def : T1Pat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
597// JumpTable
David Goodwin27c016b2009-07-27 19:59:26 +0000598def : T1Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
599 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600
601// Direct calls
David Goodwin27c016b2009-07-27 19:59:26 +0000602def : T1Pat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>;
Evan Cheng19bb7c72009-06-27 02:26:13 +0000603def : Tv5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604
605// Indirect calls to ARM routines
Evan Cheng19bb7c72009-06-27 02:26:13 +0000606def : Tv5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607
608// zextload i1 -> zextload i8
Evan Cheng503be112009-06-30 02:15:48 +0000609def : T1Pat<(zextloadi1 t_addrmode_s1:$addr),
610 (tLDRB t_addrmode_s1:$addr)>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000611
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612// extload -> zextload
Evan Cheng503be112009-06-30 02:15:48 +0000613def : T1Pat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
614def : T1Pat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
615def : T1Pat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616
Evan Cheng76aeed32009-07-11 07:08:13 +0000617// If it's possible to use [r,r] address mode for sextload, select to
618// ldr{b|h} + sxt{b|h} instead.
Evan Cheng58fec0c2009-07-21 18:15:26 +0000619def : T1Pat<(sextloadi8 t_addrmode_s1:$addr),
620 (tSXTB (tLDRB t_addrmode_s1:$addr))>;
621def : T1Pat<(sextloadi16 t_addrmode_s2:$addr),
622 (tSXTH (tLDRH t_addrmode_s2:$addr))>;
Evan Cheng76aeed32009-07-11 07:08:13 +0000623
624
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625// Large immediate handling.
626
627// Two piece imms.
Evan Cheng19bb7c72009-06-27 02:26:13 +0000628def : T1Pat<(i32 thumb_immshifted:$src),
629 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
630 (thumb_immshifted_shamt imm:$src))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631
Evan Cheng19bb7c72009-06-27 02:26:13 +0000632def : T1Pat<(i32 imm0_255_comp:$src),
633 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;