blob: 8a2fbba9fec0b450a6dd20bb0884dfd7e7e06e0e [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",
122 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>, Requires<[IsThumb]>;
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",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000127 [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb]>;
128}
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 Chengb783fa32007-07-19 01:14:50 +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.
Jim Grosbach0e4e9742009-04-07 20:34:09 +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
Evan Chengb783fa32007-07-19 01:14:50 +0000165def tPOP_RET : TI<(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 {
Evan Chengb783fa32007-07-19 01:14:50 +0000171 def tBL : TIx2<(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
Evan Chengb783fa32007-07-19 01:14:50 +0000175 def tBLXi : TIx2<(outs), (ins i32imm:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 "blx ${func:call}",
177 [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>;
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000178 def tBLXr : TI<(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
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000182 def tBX : TIx2<(outs), (ins tGPR:$func, variable_ops),
Evan Chengb783fa32007-07-19 01:14:50 +0000183 "cpy 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
Evan Chengb783fa32007-07-19 01:14:50 +0000190 def tB : TI<(outs), (ins brtarget:$target), "b $target",
191 [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192
193 // Far jump
Evan Chengb783fa32007-07-19 01:14:50 +0000194 def tBfar : TIx2<(outs), (ins brtarget:$target), "bl $target\t@ far jump",[]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195
Evan Chengb783fa32007-07-19 01:14:50 +0000196 def tBR_JTr : TJTI<(outs),
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000197 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengb783fa32007-07-19 01:14:50 +0000198 "cpy pc, $target \n\t.align\t2\n$jt",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000199 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 }
201}
202
203// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach7ea52762009-03-27 23:06:27 +0000204// a two-value operand where a dag node expects two operands. :(
Evan Cheng37e7c752007-07-21 00:34:19 +0000205let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000206 def tBcc : TI<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
207 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208
209//===----------------------------------------------------------------------===//
210// Load Store Instructions.
211//
212
Dan Gohman5574cc72008-12-03 18:15:48 +0000213let canFoldAsLoad = 1 in
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000214def tLDR : TI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 "ldr $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000216 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000218def tLDRB : TI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219 "ldrb $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000220 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000222def tLDRH : TI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223 "ldrh $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000224 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000226def tLDRSB : TI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227 "ldrsb $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000228 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000230def tLDRSH : TI2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231 "ldrsh $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000232 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233
Dan Gohman5574cc72008-12-03 18:15:48 +0000234let canFoldAsLoad = 1 in
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000235def tLDRspi : TIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236 "ldr $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000237 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238
239// Special instruction for restore. It cannot clobber condition register
240// when it's expanded by eliminateCallFramePseudoInstr().
Dan Gohman5574cc72008-12-03 18:15:48 +0000241let canFoldAsLoad = 1, mayLoad = 1 in
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000242def tRestore : TIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243 "ldr $dst, $addr", []>;
244
245// Load tconstpool
Dan Gohman5574cc72008-12-03 18:15:48 +0000246let canFoldAsLoad = 1 in
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000247def tLDRpci : TIs<(outs tGPR:$dst), (ins i32imm:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248 "ldr $dst, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000249 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250
251// Special LDR for loads from non-pc-relative constpools.
Dan Gohman5574cc72008-12-03 18:15:48 +0000252let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000253def tLDRcp : TIs<(outs tGPR:$dst), (ins i32imm:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254 "ldr $dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000256def tSTR : TI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 "str $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000258 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000260def tSTRB : TI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 "strb $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000262 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000264def tSTRH : TI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265 "strh $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000266 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000268def tSTRspi : TIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 "str $src, $addr",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000270 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271
Chris Lattner6887b142008-01-06 08:36:04 +0000272let mayStore = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273// Special instruction for spill. It cannot clobber condition register
274// when it's expanded by eliminateCallFramePseudoInstr().
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000275def tSpill : TIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276 "str $src, $addr", []>;
277}
278
279//===----------------------------------------------------------------------===//
280// Load / store multiple Instructions.
281//
282
283// TODO: A7-44: LDMIA - load multiple
284
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000285let mayLoad = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000286def tPOP : TI<(outs reglist:$dst1, variable_ops), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287 "pop $dst1", []>;
288
Chris Lattner6887b142008-01-06 08:36:04 +0000289let mayStore = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000290def tPUSH : TI<(outs), (ins reglist:$src1, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 "push $src1", []>;
292
293//===----------------------------------------------------------------------===//
294// Arithmetic Instructions.
295//
296
David Goodwin375a65d2009-06-25 17:52:32 +0000297// Add with carry
Eli Friedman2e051ed2009-06-19 01:43:08 +0000298let isCommutable = 1 in
Evan Cheng6fc534c2009-06-23 19:38:13 +0000299def tADC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300 "adc $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000301 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302
Evan Cheng6fc534c2009-06-23 19:38:13 +0000303def tADDS : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 "add $dst, $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000305 [(set tGPR:$dst, (addc tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306
307
Evan Cheng6fc534c2009-06-23 19:38:13 +0000308def tADDi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 "add $dst, $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000310 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311
Evan Cheng6fc534c2009-06-23 19:38:13 +0000312def tADDi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 "add $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000314 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315
Evan Cheng6fc534c2009-06-23 19:38:13 +0000316def tADDrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 "add $dst, $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000318 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319
Evan Chengd97d7142009-06-12 20:46:18 +0000320let neverHasSideEffects = 1 in
Evan Cheng6fc534c2009-06-23 19:38:13 +0000321def tADDhirr : T1It<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000322 "add $dst, $rhs @ addhirr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323
Eli Friedman2e051ed2009-06-19 01:43:08 +0000324let isCommutable = 1 in
Evan Cheng6fc534c2009-06-23 19:38:13 +0000325def tAND : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 "and $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000327 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328
Evan Cheng6fc534c2009-06-23 19:38:13 +0000329def tASRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330 "asr $dst, $lhs, $rhs",
Bob Wilson74590a02009-06-22 22:08:29 +0000331 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332
Evan Cheng6fc534c2009-06-23 19:38:13 +0000333def tASRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 "asr $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000335 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336
Evan Cheng6fc534c2009-06-23 19:38:13 +0000337def tBIC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 "bic $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000339 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340
341
Evan Cheng6fc534c2009-06-23 19:38:13 +0000342def tCMN : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 "cmn $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000344 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345
Evan Cheng6fc534c2009-06-23 19:38:13 +0000346def tCMPi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347 "cmp $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000348 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349
Evan Cheng6fc534c2009-06-23 19:38:13 +0000350def tCMPr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 "cmp $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000352 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000353
Evan Cheng6fc534c2009-06-23 19:38:13 +0000354def tTST : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355 "tst $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000356 [(ARMcmpNZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357
Evan Cheng6fc534c2009-06-23 19:38:13 +0000358def tCMNNZ : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359 "cmn $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000360 [(ARMcmpNZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361
Evan Cheng6fc534c2009-06-23 19:38:13 +0000362def tCMPNZi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 "cmp $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000364 [(ARMcmpNZ tGPR:$lhs, imm0_255:$rhs)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365
Evan Cheng6fc534c2009-06-23 19:38:13 +0000366def tCMPNZr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367 "cmp $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000368 [(ARMcmpNZ tGPR:$lhs, tGPR:$rhs)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369
370// TODO: A7-37: CMP(3) - cmp hi regs
371
Eli Friedman2e051ed2009-06-19 01:43:08 +0000372let isCommutable = 1 in
Evan Cheng6fc534c2009-06-23 19:38:13 +0000373def tEOR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374 "eor $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000375 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
Evan Cheng6fc534c2009-06-23 19:38:13 +0000377def tLSLri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 "lsl $dst, $lhs, $rhs",
Bob Wilson74590a02009-06-22 22:08:29 +0000379 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380
Evan Cheng6fc534c2009-06-23 19:38:13 +0000381def tLSLrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 "lsl $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000383 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
Evan Cheng6fc534c2009-06-23 19:38:13 +0000385def tLSRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386 "lsr $dst, $lhs, $rhs",
Bob Wilson74590a02009-06-22 22:08:29 +0000387 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388
Evan Cheng6fc534c2009-06-23 19:38:13 +0000389def tLSRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 "lsr $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000391 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
393// FIXME: This is not rematerializable because mov changes the condition code.
Evan Cheng6fc534c2009-06-23 19:38:13 +0000394def tMOVi8 : T1I<(outs tGPR:$dst), (ins i32imm:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 "mov $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000396 [(set tGPR:$dst, imm0_255:$src)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397
398// TODO: A7-73: MOV(2) - mov setting flag.
399
400
401// Note: MOV(2) of two low regs updates the flags, so we emit this as 'cpy',
402// which is MOV(3). This also supports high registers.
Evan Chengd97d7142009-06-12 20:46:18 +0000403let neverHasSideEffects = 1 in {
Evan Cheng6fc534c2009-06-23 19:38:13 +0000404def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000405 "cpy $dst, $src", []>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000406def tMOVhir2lor : T1I<(outs tGPR:$dst), (ins GPR:$src),
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000407 "cpy $dst, $src\t@ hir2lor", []>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000408def tMOVlor2hir : T1I<(outs GPR:$dst), (ins tGPR:$src),
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000409 "cpy $dst, $src\t@ lor2hir", []>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000410def tMOVhir2hir : T1I<(outs GPR:$dst), (ins GPR:$src),
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000411 "cpy $dst, $src\t@ hir2hir", []>;
Evan Chengd97d7142009-06-12 20:46:18 +0000412} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
Eli Friedman2e051ed2009-06-19 01:43:08 +0000414let isCommutable = 1 in
Evan Cheng6fc534c2009-06-23 19:38:13 +0000415def tMUL : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416 "mul $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000417 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418
Evan Cheng6fc534c2009-06-23 19:38:13 +0000419def tMVN : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420 "mvn $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000421 [(set tGPR:$dst, (not tGPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422
Evan Cheng6fc534c2009-06-23 19:38:13 +0000423def tNEG : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 "neg $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000425 [(set tGPR:$dst, (ineg tGPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426
Eli Friedman2e051ed2009-06-19 01:43:08 +0000427let isCommutable = 1 in
Evan Cheng6fc534c2009-06-23 19:38:13 +0000428def tORR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429 "orr $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000430 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431
432
Evan Cheng6fc534c2009-06-23 19:38:13 +0000433def tREV : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 "rev $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000435 [(set tGPR:$dst, (bswap tGPR:$src))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436 Requires<[IsThumb, HasV6]>;
437
Evan Cheng6fc534c2009-06-23 19:38:13 +0000438def tREV16 : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439 "rev16 $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000440 [(set tGPR:$dst,
Bob Wilson74590a02009-06-22 22:08:29 +0000441 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
442 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
443 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
444 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445 Requires<[IsThumb, HasV6]>;
446
Evan Cheng6fc534c2009-06-23 19:38:13 +0000447def tREVSH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448 "revsh $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000449 [(set tGPR:$dst,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 (sext_inreg
Bob Wilson74590a02009-06-22 22:08:29 +0000451 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
452 (shl tGPR:$src, (i32 8))), i16))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 Requires<[IsThumb, HasV6]>;
454
Evan Cheng6fc534c2009-06-23 19:38:13 +0000455def tROR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 "ror $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000457 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458
459
460// Subtract with carry
Evan Cheng6fc534c2009-06-23 19:38:13 +0000461def tSBC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462 "sbc $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000463 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464
Evan Cheng6fc534c2009-06-23 19:38:13 +0000465def tSUBS : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466 "sub $dst, $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000467 [(set tGPR:$dst, (subc tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468
469
470// TODO: A7-96: STMIA - store multiple.
471
Evan Cheng6fc534c2009-06-23 19:38:13 +0000472def tSUBi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 "sub $dst, $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000474 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000475
Evan Cheng6fc534c2009-06-23 19:38:13 +0000476def tSUBi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477 "sub $dst, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000478 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000479
Evan Cheng6fc534c2009-06-23 19:38:13 +0000480def tSUBrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 "sub $dst, $lhs, $rhs",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000482 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483
Evan Cheng6fc534c2009-06-23 19:38:13 +0000484def tSUBspi : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 "sub $dst, $rhs * 4", []>;
486
Evan Cheng6fc534c2009-06-23 19:38:13 +0000487def tSXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488 "sxtb $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000489 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490 Requires<[IsThumb, HasV6]>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000491def tSXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 "sxth $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000493 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 Requires<[IsThumb, HasV6]>;
495
496
Evan Cheng6fc534c2009-06-23 19:38:13 +0000497def tUXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498 "uxtb $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000499 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 Requires<[IsThumb, HasV6]>;
Evan Cheng6fc534c2009-06-23 19:38:13 +0000501def tUXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 "uxth $dst, $src",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000503 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 Requires<[IsThumb, HasV6]>;
505
506
507// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
508// Expanded by the scheduler into a branch sequence.
509let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
510 def tMOVCCr :
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000511 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 "@ tMOVCCr $cc",
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000513 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514
515// tLEApcrel - Load a pc-relative address into a register without offending the
516// assembler.
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000517def tLEApcrel : TIx2<(outs tGPR:$dst), (ins i32imm:$label),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
519 "${:private}PCRELL${:uid}+4))\n"),
520 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
521 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
522 []>;
523
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000524def tLEApcrelJT : TIx2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
526 "${:private}PCRELL${:uid}+4))\n"),
527 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
528 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
529 []>;
530
531//===----------------------------------------------------------------------===//
532// TLS Instructions
533//
534
535// __aeabi_read_tp preserves the registers r1-r3.
536let isCall = 1,
537 Defs = [R0, LR] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000538 def tTPsoft : TIx2<(outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 "bl __aeabi_read_tp",
540 [(set R0, ARMthread_pointer)]>;
541}
542
543//===----------------------------------------------------------------------===//
544// Non-Instruction Patterns
545//
546
547// ConstantPool, GlobalAddress
548def : ThumbPat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
549def : ThumbPat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
550
551// JumpTable
552def : ThumbPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
553 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
554
555// Direct calls
556def : ThumbPat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>;
557def : ThumbV5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>;
558
559// Indirect calls to ARM routines
Jim Grosbach0e4e9742009-04-07 20:34:09 +0000560def : ThumbV5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561
562// zextload i1 -> zextload i8
563def : ThumbPat<(zextloadi1 t_addrmode_s1:$addr),
564 (tLDRB t_addrmode_s1:$addr)>;
Jim Grosbach7ea52762009-03-27 23:06:27 +0000565
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566// extload -> zextload
567def : ThumbPat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
568def : ThumbPat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
569def : ThumbPat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
570
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571// Large immediate handling.
572
573// Two piece imms.
Evan Cheng6fc534c2009-06-23 19:38:13 +0000574def : Thumb1Pat<(i32 thumb_immshifted:$src),
575 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
576 (thumb_immshifted_shamt imm:$src))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577
Evan Cheng6fc534c2009-06-23 19:38:13 +0000578def : Thumb1Pat<(i32 imm0_255_comp:$src),
579 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;