blob: b1b97ad6ae6a42acbcdb5b00e0a38038e1335350 [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,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 Defs = [R0, R1, R2, R3, LR,
170 D0, D1, D2, D3, D4, D5, D6, D7] in {
David Goodwin41afec22009-07-08 16:09:28 +0000171 def tBL : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 "bl ${func:call}",
173 [(ARMtcall tglobaladdr:$func)]>;
174 // ARMv5T and above
David Goodwin41afec22009-07-08 16:09:28 +0000175 def tBLXi : T1Ix2<(outs), (ins i32imm:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 "blx ${func:call}",
177 [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>;
David Goodwin41afec22009-07-08 16:09:28 +0000178 def tBLXr : T1I<(outs), (ins tGPR:$func, variable_ops),
Evan Chengb783fa32007-07-19 01:14:50 +0000179 "blx $func",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000180 [(ARMtcall tGPR:$func)]>, Requires<[HasV5T]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 // ARMv4T
David Goodwin41afec22009-07-08 16:09:28 +0000182 def tBX : T1Ix2<(outs), (ins tGPR:$func, variable_ops),
Evan Chengfb1d1472009-07-14 01:49:27 +0000183 "mov lr, pc\n\tbx $func",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000184 [(ARMcall_nolink tGPR:$func)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185}
186
Evan Cheng37e7c752007-07-21 00:34:19 +0000187let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 let isBarrier = 1 in {
189 let isPredicable = 1 in
David Goodwinf6154702009-06-30 18:04:13 +0000190 def tB : T1I<(outs), (ins brtarget:$target), "b $target",
191 [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192
193 // Far jump
David Goodwinf6154702009-06-30 18:04:13 +0000194 def tBfar : T1Ix2<(outs), (ins brtarget:$target),
195 "bl $target\t@ far jump",[]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196
David Goodwinf6154702009-06-30 18:04:13 +0000197 def tBR_JTr : T1JTI<(outs),
198 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengfb1d1472009-07-14 01:49:27 +0000199 "mov pc, $target \n\t.align\t2\n$jt",
David Goodwinf6154702009-06-30 18:04:13 +0000200 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 }
202}
203
204// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach7ea52762009-03-27 23:06:27 +0000205// a two-value operand where a dag node expects two operands. :(
Evan Cheng37e7c752007-07-21 00:34:19 +0000206let isBranch = 1, isTerminator = 1 in
David Goodwinf6154702009-06-30 18:04:13 +0000207 def tBcc : T1I<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
Evan Chengb783fa32007-07-19 01:14:50 +0000208 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209
210//===----------------------------------------------------------------------===//
211// Load Store Instructions.
212//
213
Dan Gohman5574cc72008-12-03 18:15:48 +0000214let canFoldAsLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000215def tLDR : T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
216 "ldr", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000217 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000219def tLDRB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
220 "ldrb", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000221 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000223def tLDRH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
224 "ldrh", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000225 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226
Evan Cheng76aeed32009-07-11 07:08:13 +0000227let AddedComplexity = 10 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000228def tLDRSB : T1pI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
229 "ldrsb", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000230 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231
Evan Cheng76aeed32009-07-11 07:08:13 +0000232let AddedComplexity = 10 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000233def tLDRSH : T1pI2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
234 "ldrsh", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000235 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236
Dan Gohman5574cc72008-12-03 18:15:48 +0000237let canFoldAsLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000238def tLDRspi : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
239 "ldr", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000240 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241
242// Special instruction for restore. It cannot clobber condition register
243// when it's expanded by eliminateCallFramePseudoInstr().
Dan Gohman5574cc72008-12-03 18:15:48 +0000244let canFoldAsLoad = 1, mayLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000245def tRestore : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
246 "ldr", " $dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247
248// Load tconstpool
Dan Gohman5574cc72008-12-03 18:15:48 +0000249let canFoldAsLoad = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000250def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr),
251 "ldr", " $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000252 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253
254// Special LDR for loads from non-pc-relative constpools.
Dan Gohman5574cc72008-12-03 18:15:48 +0000255let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000256def tLDRcp : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr),
257 "ldr", " $dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000259def tSTR : T1pI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
260 "str", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000261 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000263def tSTRB : T1pI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
264 "strb", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000265 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000267def tSTRH : T1pI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
268 "strh", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000269 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000271def tSTRspi : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
272 "str", " $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000273 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274
Chris Lattner6887b142008-01-06 08:36:04 +0000275let mayStore = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276// Special instruction for spill. It cannot clobber condition register
277// when it's expanded by eliminateCallFramePseudoInstr().
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000278def tSpill : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
279 "str", " $src, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280}
281
282//===----------------------------------------------------------------------===//
283// Load / store multiple Instructions.
284//
285
286// TODO: A7-44: LDMIA - load multiple
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000287// TODO: Allow these to be predicated
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000289let mayLoad = 1 in
David Goodwin41afec22009-07-08 16:09:28 +0000290def tPOP : T1I<(outs reglist:$dst1, variable_ops), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 "pop $dst1", []>;
292
Chris Lattner6887b142008-01-06 08:36:04 +0000293let mayStore = 1 in
David Goodwin41afec22009-07-08 16:09:28 +0000294def tPUSH : T1I<(outs), (ins reglist:$src1, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 "push $src1", []>;
296
297//===----------------------------------------------------------------------===//
298// Arithmetic Instructions.
299//
300
David Goodwin8768bff2009-06-25 22:49:55 +0000301// Add with carry register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000302let isCommutable = 1, Uses = [CPSR] in
303def tADC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
304 "adc", " $dst, $rhs",
Evan Cheng986e3b72009-07-10 02:09:04 +0000305 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306
David Goodwin8768bff2009-06-25 22:49:55 +0000307// Add immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000308def tADDi3 : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
309 "add", " $dst, $lhs, $rhs",
310 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000312def tADDi8 : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
313 "add", " $dst, $rhs",
314 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315
David Goodwin8768bff2009-06-25 22:49:55 +0000316// Add register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000317let isCommutable = 1 in
318def tADDrr : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
319 "add", " $dst, $lhs, $rhs",
320 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321
Evan Chengd97d7142009-06-12 20:46:18 +0000322let neverHasSideEffects = 1 in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000323def tADDhirr : T1pIt<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
324 "add", " $dst, $rhs @ addhirr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325
David Goodwin8768bff2009-06-25 22:49:55 +0000326// And register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000327let isCommutable = 1 in
328def tAND : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
329 "and", " $dst, $rhs",
330 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331
David Goodwin8768bff2009-06-25 22:49:55 +0000332// ASR immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000333def tASRri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
334 "asr", " $dst, $lhs, $rhs",
335 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336
David Goodwin8768bff2009-06-25 22:49:55 +0000337// ASR register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000338def tASRrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
339 "asr", " $dst, $rhs",
340 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341
David Goodwin8768bff2009-06-25 22:49:55 +0000342// BIC register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000343def tBIC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
344 "bic", " $dst, $rhs",
345 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346
David Goodwin8768bff2009-06-25 22:49:55 +0000347// CMN register
348let Defs = [CPSR] in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000349def tCMN : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
350 "cmn", " $lhs, $rhs",
351 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
352def tCMNZ : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
353 "cmn", " $lhs, $rhs",
354 [(ARMcmpZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000355}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356
David Goodwin8768bff2009-06-25 22:49:55 +0000357// CMP immediate
358let Defs = [CPSR] in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000359def tCMPi8 : T1pI<(outs), (ins tGPR:$lhs, i32imm:$rhs),
360 "cmp", " $lhs, $rhs",
361 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
362def tCMPZi8 : T1pI<(outs), (ins tGPR:$lhs, i32imm:$rhs),
363 "cmp", " $lhs, $rhs",
364 [(ARMcmpZ tGPR:$lhs, imm0_255:$rhs)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365
David Goodwin8768bff2009-06-25 22:49:55 +0000366}
367
368// CMP register
369let Defs = [CPSR] in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000370def tCMPr : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
371 "cmp", " $lhs, $rhs",
372 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
373def tCMPZr : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
374 "cmp", " $lhs, $rhs",
375 [(ARMcmpZ tGPR:$lhs, tGPR:$rhs)]>;
376
377// TODO: Make use of the followings cmp hi regs
378def tCMPhir : T1pI<(outs), (ins GPR:$lhs, GPR:$rhs),
379 "cmp", " $lhs, $rhs", []>;
380def tCMPZhir : T1pI<(outs), (ins GPR:$lhs, GPR:$rhs),
381 "cmp", " $lhs, $rhs", []>;
David Goodwin8768bff2009-06-25 22:49:55 +0000382}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
David Goodwin8768bff2009-06-25 22:49:55 +0000385// XOR register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000386let isCommutable = 1 in
387def tEOR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
388 "eor", " $dst, $rhs",
389 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390
David Goodwin8768bff2009-06-25 22:49:55 +0000391// LSL immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000392def tLSLri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
393 "lsl", " $dst, $lhs, $rhs",
394 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395
David Goodwin8768bff2009-06-25 22:49:55 +0000396// LSL register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000397def tLSLrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
398 "lsl", " $dst, $rhs",
399 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400
David Goodwin8768bff2009-06-25 22:49:55 +0000401// LSR immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000402def tLSRri : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
403 "lsr", " $dst, $lhs, $rhs",
404 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405
David Goodwin8768bff2009-06-25 22:49:55 +0000406// LSR register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000407def tLSRrr : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
408 "lsr", " $dst, $rhs",
409 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410
David Goodwin8768bff2009-06-25 22:49:55 +0000411// move register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000412def tMOVi8 : T1sI<(outs tGPR:$dst), (ins i32imm:$src),
413 "mov", " $dst, $src",
414 [(set tGPR:$dst, imm0_255:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415
416// TODO: A7-73: MOV(2) - mov setting flag.
417
418
Evan Chengd97d7142009-06-12 20:46:18 +0000419let neverHasSideEffects = 1 in {
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000420// FIXME: Make this predicable.
Evan Cheng6fc534c2009-06-23 19:38:13 +0000421def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000422 "mov $dst, $src", []>;
423let Defs = [CPSR] in
424def tMOVSr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
425 "movs $dst, $src", []>;
426
427// FIXME: Make these predicable.
Evan Cheng6fc534c2009-06-23 19:38:13 +0000428def tMOVhir2lor : T1I<(outs tGPR:$dst), (ins GPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000429 "mov $dst, $src\t@ hir2lor", []>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000430def tMOVlor2hir : T1I<(outs GPR:$dst), (ins tGPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000431 "mov $dst, $src\t@ lor2hir", []>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000432def tMOVhir2hir : T1I<(outs GPR:$dst), (ins GPR:$src),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000433 "mov $dst, $src\t@ hir2hir", []>;
Evan Chengd97d7142009-06-12 20:46:18 +0000434} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435
David Goodwin8768bff2009-06-25 22:49:55 +0000436// multiply register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000437let isCommutable = 1 in
438def tMUL : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
439 "mul", " $dst, $rhs",
440 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441
David Goodwin8768bff2009-06-25 22:49:55 +0000442// move inverse register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000443def tMVN : T1sI<(outs tGPR:$dst), (ins tGPR:$src),
444 "mvn", " $dst, $src",
445 [(set tGPR:$dst, (not tGPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
David Goodwin8768bff2009-06-25 22:49:55 +0000447// bitwise or register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000448let isCommutable = 1 in
449def tORR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
450 "orr", " $dst, $rhs",
451 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452
David Goodwin8768bff2009-06-25 22:49:55 +0000453// swaps
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000454def tREV : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
455 "rev", " $dst, $src",
456 [(set tGPR:$dst, (bswap tGPR:$src))]>,
David Goodwin4a897932009-07-08 23:10:31 +0000457 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000459def tREV16 : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
460 "rev16", " $dst, $src",
461 [(set tGPR:$dst,
462 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
463 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
464 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
465 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
David Goodwin4a897932009-07-08 23:10:31 +0000466 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000468def tREVSH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
469 "revsh", " $dst, $src",
470 [(set tGPR:$dst,
471 (sext_inreg
472 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
473 (shl tGPR:$src, (i32 8))), i16))]>,
474 Requires<[IsThumb1Only, HasV6]>;
475
David Goodwin8768bff2009-06-25 22:49:55 +0000476// rotate right register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000477def tROR : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
478 "ror", " $dst, $rhs",
479 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
480
481// negate register
482def tRSB : T1sI<(outs tGPR:$dst), (ins tGPR:$src),
483 "rsb", " $dst, $src, #0",
484 [(set tGPR:$dst, (ineg tGPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485
David Goodwin8768bff2009-06-25 22:49:55 +0000486// Subtract with carry register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000487let Uses = [CPSR] in
488def tSBC : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
489 "sbc", " $dst, $rhs",
490 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491
David Goodwin8768bff2009-06-25 22:49:55 +0000492// Subtract immediate
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000493def tSUBi3 : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
494 "sub", " $dst, $lhs, $rhs",
495 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000496
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000497def tSUBi8 : T1sIt<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
498 "sub", " $dst, $rhs",
499 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000500
David Goodwin8768bff2009-06-25 22:49:55 +0000501// subtract register
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000502def tSUBrr : T1sI<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
503 "sub", " $dst, $lhs, $rhs",
504 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000505
506// TODO: A7-96: STMIA - store multiple.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507
Evan Cheng6fc534c2009-06-23 19:38:13 +0000508def tSUBspi : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 "sub $dst, $rhs * 4", []>;
510
David Goodwin8768bff2009-06-25 22:49:55 +0000511// sign-extend byte
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000512def tSXTB : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
513 "sxtb", " $dst, $src",
514 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
515 Requires<[IsThumb1Only, HasV6]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000516
517// sign-extend short
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000518def tSXTH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
519 "sxth", " $dst, $src",
520 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
521 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522
David Goodwin8768bff2009-06-25 22:49:55 +0000523// test
Evan Cheng138f60e2009-06-26 00:19:07 +0000524let isCommutable = 1, Defs = [CPSR] in
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000525def tTST : T1pI<(outs), (ins tGPR:$lhs, tGPR:$rhs),
526 "tst", " $lhs, $rhs",
527 [(ARMcmpZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528
David Goodwin8768bff2009-06-25 22:49:55 +0000529// zero-extend byte
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000530def tUXTB : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
531 "uxtb", " $dst, $src",
532 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
533 Requires<[IsThumb1Only, HasV6]>;
David Goodwin8768bff2009-06-25 22:49:55 +0000534
535// zero-extend short
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000536def tUXTH : T1pI<(outs tGPR:$dst), (ins tGPR:$src),
537 "uxth", " $dst, $src",
538 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
539 Requires<[IsThumb1Only, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540
541
542// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
543// Expanded by the scheduler into a branch sequence.
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000544// FIXME: Add actual movcc in IT blocks for Thumb2.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
546 def tMOVCCr :
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000547 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 "@ tMOVCCr $cc",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000549 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550
551// tLEApcrel - Load a pc-relative address into a register without offending the
552// assembler.
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000553let Defs = [CPSR] in {
David Goodwin41afec22009-07-08 16:09:28 +0000554def tLEApcrel : T1Ix2<(outs tGPR:$dst), (ins i32imm:$label),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
556 "${:private}PCRELL${:uid}+4))\n"),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000557 !strconcat("\tmovs $dst, #PCRELV${:uid}\n",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
559 []>;
560
David Goodwin41afec22009-07-08 16:09:28 +0000561def tLEApcrelJT : T1Ix2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
563 "${:private}PCRELL${:uid}+4))\n"),
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000564 !strconcat("\tmovs $dst, #PCRELV${:uid}\n",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
566 []>;
Evan Cheng7bd2ad12009-07-11 06:43:01 +0000567}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568
569//===----------------------------------------------------------------------===//
570// TLS Instructions
571//
572
573// __aeabi_read_tp preserves the registers r1-r3.
574let isCall = 1,
575 Defs = [R0, LR] in {
David Goodwin41afec22009-07-08 16:09:28 +0000576 def tTPsoft : T1Ix2<(outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577 "bl __aeabi_read_tp",
578 [(set R0, ARMthread_pointer)]>;
579}
580
581//===----------------------------------------------------------------------===//
582// Non-Instruction Patterns
583//
584
Evan Cheng986e3b72009-07-10 02:09:04 +0000585// Add with carry
586def : TPat<(addc tGPR:$lhs, imm0_7:$rhs),
587 (tADDi3 tGPR:$lhs, imm0_7:$rhs)>;
588def : TPat<(addc tGPR:$lhs, imm8_255:$rhs),
589 (tADDi3 tGPR:$lhs, imm8_255:$rhs)>;
590def : TPat<(addc tGPR:$lhs, tGPR:$rhs),
591 (tADDrr tGPR:$lhs, tGPR:$rhs)>;
592
593// Subtract with carry
594def : TPat<(addc tGPR:$lhs, imm0_7_neg:$rhs),
595 (tSUBi3 tGPR:$lhs, imm0_7_neg:$rhs)>;
596def : TPat<(addc tGPR:$lhs, imm8_255_neg:$rhs),
597 (tSUBi8 tGPR:$lhs, imm8_255_neg:$rhs)>;
598def : TPat<(subc tGPR:$lhs, tGPR:$rhs),
599 (tSUBrr tGPR:$lhs, tGPR:$rhs)>;
600
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601// ConstantPool, GlobalAddress
Evan Cheng19bb7c72009-06-27 02:26:13 +0000602def : TPat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
603def : TPat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604
605// JumpTable
Evan Cheng19bb7c72009-06-27 02:26:13 +0000606def : TPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
607 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608
609// Direct calls
Evan Cheng19bb7c72009-06-27 02:26:13 +0000610def : TPat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>;
611def : Tv5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
613// Indirect calls to ARM routines
Evan Cheng19bb7c72009-06-27 02:26:13 +0000614def : Tv5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615
616// zextload i1 -> zextload i8
Evan Cheng503be112009-06-30 02:15:48 +0000617def : T1Pat<(zextloadi1 t_addrmode_s1:$addr),
618 (tLDRB t_addrmode_s1:$addr)>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000619
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620// extload -> zextload
Evan Cheng503be112009-06-30 02:15:48 +0000621def : T1Pat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
622def : T1Pat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
623def : T1Pat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624
Evan Cheng76aeed32009-07-11 07:08:13 +0000625// If it's possible to use [r,r] address mode for sextload, select to
626// ldr{b|h} + sxt{b|h} instead.
627def : TPat<(sextloadi8 t_addrmode_s1:$addr),
628 (tSXTB (tLDRB t_addrmode_s1:$addr))>;
629def : TPat<(sextloadi16 t_addrmode_s2:$addr),
630 (tSXTH (tLDRH t_addrmode_s2:$addr))>;
631
632
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633// Large immediate handling.
634
635// Two piece imms.
Evan Cheng19bb7c72009-06-27 02:26:13 +0000636def : T1Pat<(i32 thumb_immshifted:$src),
637 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
638 (thumb_immshifted_shamt imm:$src))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
Evan Cheng19bb7c72009-06-27 02:26:13 +0000640def : T1Pat<(i32 imm0_255_comp:$src),
641 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;