1 //===- ARMInstrThumb.td - Thumb support for ARM ---------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the Thumb instruction set.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Thumb specific DAG Nodes.
18 def ARMtcall : SDNode<"ARMISD::tCALL", SDT_ARMcall,
19 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
21 def imm_neg_XFORM : SDNodeXForm<imm, [{
22 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
24 def imm_comp_XFORM : SDNodeXForm<imm, [{
25 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
29 /// imm0_7 predicate - True if the 32-bit immediate is in the range [0,7].
30 def imm0_7 : PatLeaf<(i32 imm), [{
31 return (uint32_t)N->getZExtValue() < 8;
33 def imm0_7_neg : PatLeaf<(i32 imm), [{
34 return (uint32_t)-N->getZExtValue() < 8;
37 def imm0_255 : PatLeaf<(i32 imm), [{
38 return (uint32_t)N->getZExtValue() < 256;
40 def imm0_255_comp : PatLeaf<(i32 imm), [{
41 return ~((uint32_t)N->getZExtValue()) < 256;
44 def imm8_255 : PatLeaf<(i32 imm), [{
45 return (uint32_t)N->getZExtValue() >= 8 && (uint32_t)N->getZExtValue() < 256;
47 def imm8_255_neg : PatLeaf<(i32 imm), [{
48 unsigned Val = -N->getZExtValue();
49 return Val >= 8 && Val < 256;
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.
55 def thumb_immshifted : PatLeaf<(imm), [{
56 return ARM_AM::isThumbImmShiftedVal((unsigned)N->getZExtValue());
59 def thumb_immshifted_val : SDNodeXForm<imm, [{
60 unsigned V = ARM_AM::getThumbImmNonShiftedVal((unsigned)N->getZExtValue());
61 return CurDAG->getTargetConstant(V, MVT::i32);
64 def thumb_immshifted_shamt : SDNodeXForm<imm, [{
65 unsigned V = ARM_AM::getThumbImmValShift((unsigned)N->getZExtValue());
66 return CurDAG->getTargetConstant(V, MVT::i32);
69 // Define Thumb specific addressing modes.
71 // t_addrmode_rr := reg + reg
73 def t_addrmode_rr : Operand<i32>,
74 ComplexPattern<i32, 2, "SelectThumbAddrModeRR", []> {
75 let PrintMethod = "printThumbAddrModeRROperand";
76 let MIOperandInfo = (ops tGPR:$base, tGPR:$offsreg);
79 // t_addrmode_s4 := reg + reg
82 def t_addrmode_s4 : Operand<i32>,
83 ComplexPattern<i32, 3, "SelectThumbAddrModeS4", []> {
84 let PrintMethod = "printThumbAddrModeS4Operand";
85 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
88 // t_addrmode_s2 := reg + reg
91 def t_addrmode_s2 : Operand<i32>,
92 ComplexPattern<i32, 3, "SelectThumbAddrModeS2", []> {
93 let PrintMethod = "printThumbAddrModeS2Operand";
94 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
97 // t_addrmode_s1 := reg + reg
100 def t_addrmode_s1 : Operand<i32>,
101 ComplexPattern<i32, 3, "SelectThumbAddrModeS1", []> {
102 let PrintMethod = "printThumbAddrModeS1Operand";
103 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
106 // t_addrmode_sp := sp + imm8 * 4
108 def t_addrmode_sp : Operand<i32>,
109 ComplexPattern<i32, 2, "SelectThumbAddrModeSP", []> {
110 let PrintMethod = "printThumbAddrModeSPOperand";
111 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
114 //===----------------------------------------------------------------------===//
115 // Miscellaneous Instructions.
118 let Defs = [SP], Uses = [SP] in {
119 def tADJCALLSTACKUP :
120 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
121 "@ tADJCALLSTACKUP $amt1",
122 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>, Requires<[IsThumb]>;
124 def tADJCALLSTACKDOWN :
125 PseudoInst<(outs), (ins i32imm:$amt),
126 "@ tADJCALLSTACKDOWN $amt",
127 [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb]>;
130 let isNotDuplicable = 1 in
131 def tPICADD : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, pclabel:$cp),
132 "$cp:\n\tadd $dst, pc",
133 [(set tGPR:$dst, (ARMpic_add tGPR:$lhs, imm:$cp))]>;
136 def tADDrPCi : T1I<(outs tGPR:$dst), (ins i32imm:$rhs),
137 "add $dst, pc, $rhs * 4", []>;
140 // FIXME: hard code sp?
141 def tADDrSPi : T1I<(outs tGPR:$dst), (ins GPR:$sp, i32imm:$rhs),
142 "add $dst, $sp, $rhs * 4 @ addrspi", []>;
145 // FIXME: hard code sp?
146 def tADDspi : T1It<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs),
147 "add $dst, $rhs * 4", []>;
149 // FIXME: Make use of the following?
153 //===----------------------------------------------------------------------===//
154 // Control Flow Instructions.
157 let isReturn = 1, isTerminator = 1 in {
158 def tBX_RET : TI<(outs), (ins), "bx lr", [(ARMretflag)]>;
159 // Alternative return instruction used by vararg functions.
160 def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), "bx $target", []>;
163 // FIXME: remove when we have a way to marking a MI with these properties.
164 let isReturn = 1, isTerminator = 1 in
165 def tPOP_RET : TI<(outs reglist:$dst1, variable_ops), (ins),
169 Defs = [R0, R1, R2, R3, LR,
170 D0, D1, D2, D3, D4, D5, D6, D7] in {
171 def tBL : TIx2<(outs), (ins i32imm:$func, variable_ops),
173 [(ARMtcall tglobaladdr:$func)]>;
175 def tBLXi : TIx2<(outs), (ins i32imm:$func, variable_ops),
177 [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>;
178 def tBLXr : TI<(outs), (ins tGPR:$func, variable_ops),
180 [(ARMtcall tGPR:$func)]>, Requires<[HasV5T]>;
182 def tBX : TIx2<(outs), (ins tGPR:$func, variable_ops),
183 "cpy lr, pc\n\tbx $func",
184 [(ARMcall_nolink tGPR:$func)]>;
187 let isBranch = 1, isTerminator = 1 in {
188 let isBarrier = 1 in {
189 let isPredicable = 1 in
190 def tB : T1I<(outs), (ins brtarget:$target), "b $target",
194 def tBfar : T1Ix2<(outs), (ins brtarget:$target),
195 "bl $target\t@ far jump",[]>;
197 def tBR_JTr : T1JTI<(outs),
198 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
199 "cpy pc, $target \n\t.align\t2\n$jt",
200 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
204 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
205 // a two-value operand where a dag node expects two operands. :(
206 let isBranch = 1, isTerminator = 1 in
207 def tBcc : T1I<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
208 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
210 //===----------------------------------------------------------------------===//
211 // Load Store Instructions.
214 let canFoldAsLoad = 1 in
215 def tLDR : T1I4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
217 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
219 def tLDRB : T1I1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
221 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
223 def tLDRH : T1I2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
225 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
227 def tLDRSB : T1I1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
229 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
231 def tLDRSH : T1I2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
233 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
235 let canFoldAsLoad = 1 in
236 def tLDRspi : T1Is<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
238 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
240 // Special instruction for restore. It cannot clobber condition register
241 // when it's expanded by eliminateCallFramePseudoInstr().
242 let canFoldAsLoad = 1, mayLoad = 1 in
243 def tRestore : T1Is<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
244 "ldr $dst, $addr", []>;
247 let canFoldAsLoad = 1 in
248 def tLDRpci : T1Is<(outs tGPR:$dst), (ins i32imm:$addr),
250 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
252 // Special LDR for loads from non-pc-relative constpools.
253 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
254 def tLDRcp : T1Is<(outs tGPR:$dst), (ins i32imm:$addr),
255 "ldr $dst, $addr", []>;
257 def tSTR : T1I4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
259 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
261 def tSTRB : T1I1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
263 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
265 def tSTRH : T1I2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
267 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
269 def tSTRspi : T1Is<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
271 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
273 let mayStore = 1 in {
274 // Special instruction for spill. It cannot clobber condition register
275 // when it's expanded by eliminateCallFramePseudoInstr().
276 def tSpill : T1Is<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
277 "str $src, $addr", []>;
280 //===----------------------------------------------------------------------===//
281 // Load / store multiple Instructions.
284 // TODO: A7-44: LDMIA - load multiple
287 def tPOP : TI<(outs reglist:$dst1, variable_ops), (ins),
291 def tPUSH : TI<(outs), (ins reglist:$src1, variable_ops),
294 //===----------------------------------------------------------------------===//
295 // Arithmetic Instructions.
298 // Add with carry register
299 let isCommutable = 1, Defs = [CPSR], Uses = [CPSR] in
300 def tADCS : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
302 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
305 let Defs = [CPSR] in {
306 def tADDi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
307 "add $dst, $lhs, $rhs",
308 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
309 def tADDSi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
310 "add $dst, $lhs, $rhs",
311 [(set tGPR:$dst, (addc tGPR:$lhs, imm0_7:$rhs))]>;
314 let Defs = [CPSR] in {
315 def tADDi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
317 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
318 def tADDSi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
320 [(set tGPR:$dst, (addc tGPR:$lhs, imm8_255:$rhs))]>;
324 let isCommutable = 1, Defs = [CPSR] in {
325 def tADDrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
326 "add $dst, $lhs, $rhs",
327 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
328 def tADDSrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
329 "add $dst, $lhs, $rhs",
330 [(set tGPR:$dst, (addc tGPR:$lhs, tGPR:$rhs))]>;
333 let neverHasSideEffects = 1 in
334 def tADDhirr : T1It<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
335 "add $dst, $rhs @ addhirr", []>;
338 let isCommutable = 1, Defs = [CPSR] in
339 def tAND : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
341 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
345 def tASRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
346 "asr $dst, $lhs, $rhs",
347 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
351 def tASRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
353 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
357 def tBIC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
359 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
362 let Defs = [CPSR] in {
363 def tCMN : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
365 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
366 def tCMNZ : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
368 [(ARMcmpZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
372 let Defs = [CPSR] in {
373 def tCMPi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
375 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
376 def tCMPZi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
378 [(ARMcmpZ tGPR:$lhs, imm0_255:$rhs)]>;
383 let Defs = [CPSR] in {
384 def tCMPr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
386 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
387 def tCMPZr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
389 [(ARMcmpZ tGPR:$lhs, tGPR:$rhs)]>;
392 // TODO: A7-37: CMP(3) - cmp hi regs
395 let isCommutable = 1, Defs = [CPSR] in
396 def tEOR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
398 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
402 def tLSLri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
403 "lsl $dst, $lhs, $rhs",
404 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
408 def tLSLrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
410 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
414 def tLSRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
415 "lsr $dst, $lhs, $rhs",
416 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
420 def tLSRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
422 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
426 def tMOVi8 : T1I<(outs tGPR:$dst), (ins i32imm:$src),
428 [(set tGPR:$dst, imm0_255:$src)]>;
430 // TODO: A7-73: MOV(2) - mov setting flag.
433 // Note: MOV(2) of two low regs updates the flags, so we emit this as 'cpy',
434 // which is MOV(3). This also supports high registers.
435 let neverHasSideEffects = 1 in {
436 def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
437 "cpy $dst, $src", []>;
438 def tMOVhir2lor : T1I<(outs tGPR:$dst), (ins GPR:$src),
439 "cpy $dst, $src\t@ hir2lor", []>;
440 def tMOVlor2hir : T1I<(outs GPR:$dst), (ins tGPR:$src),
441 "cpy $dst, $src\t@ lor2hir", []>;
442 def tMOVhir2hir : T1I<(outs GPR:$dst), (ins GPR:$src),
443 "cpy $dst, $src\t@ hir2hir", []>;
444 } // neverHasSideEffects
447 let isCommutable = 1, Defs = [CPSR] in
448 def tMUL : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
450 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
452 // move inverse register
454 def tMVN : T1I<(outs tGPR:$dst), (ins tGPR:$src),
456 [(set tGPR:$dst, (not tGPR:$src))]>;
460 def tNEG : T1I<(outs tGPR:$dst), (ins tGPR:$src),
462 [(set tGPR:$dst, (ineg tGPR:$src))]>;
464 // bitwise or register
465 let isCommutable = 1, Defs = [CPSR] in
466 def tORR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
468 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
471 def tREV : T1I<(outs tGPR:$dst), (ins tGPR:$src),
473 [(set tGPR:$dst, (bswap tGPR:$src))]>,
474 Requires<[IsThumb, HasV6]>;
476 def tREV16 : T1I<(outs tGPR:$dst), (ins tGPR:$src),
479 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
480 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
481 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
482 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
483 Requires<[IsThumb, HasV6]>;
485 def tREVSH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
489 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
490 (shl tGPR:$src, (i32 8))), i16))]>,
491 Requires<[IsThumb, HasV6]>;
493 // rotate right register
495 def tROR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
497 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
499 // Subtract with carry register
500 let Defs = [CPSR], Uses = [CPSR] in
501 def tSBCS : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
503 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
505 // Subtract immediate
506 let Defs = [CPSR] in {
507 def tSUBi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
508 "sub $dst, $lhs, $rhs",
509 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
510 def tSUBSi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
511 "sub $dst, $lhs, $rhs",
512 [(set tGPR:$dst, (addc tGPR:$lhs, imm0_7_neg:$rhs))]>;
515 let Defs = [CPSR] in {
516 def tSUBi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
518 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
519 def tSUBSi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
521 [(set tGPR:$dst, (addc tGPR:$lhs, imm8_255_neg:$rhs))]>;
525 let Defs = [CPSR] in {
526 def tSUBrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
527 "sub $dst, $lhs, $rhs",
528 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
529 def tSUBSrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
530 "sub $dst, $lhs, $rhs",
531 [(set tGPR:$dst, (subc tGPR:$lhs, tGPR:$rhs))]>;
534 // TODO: A7-96: STMIA - store multiple.
536 def tSUBspi : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
537 "sub $dst, $rhs * 4", []>;
540 def tSXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
542 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
543 Requires<[IsThumb, HasV6]>;
546 def tSXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
548 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
549 Requires<[IsThumb, HasV6]>;
552 let isCommutable = 1, Defs = [CPSR] in
553 def tTST : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
555 [(ARMcmpZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
558 def tUXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
560 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
561 Requires<[IsThumb, HasV6]>;
564 def tUXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
566 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
567 Requires<[IsThumb, HasV6]>;
570 // Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
571 // Expanded by the scheduler into a branch sequence.
572 let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
574 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
576 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
578 // tLEApcrel - Load a pc-relative address into a register without offending the
580 def tLEApcrel : TIx2<(outs tGPR:$dst), (ins i32imm:$label),
581 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
582 "${:private}PCRELL${:uid}+4))\n"),
583 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
584 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
587 def tLEApcrelJT : TIx2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
588 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
589 "${:private}PCRELL${:uid}+4))\n"),
590 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
591 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
594 //===----------------------------------------------------------------------===//
598 // __aeabi_read_tp preserves the registers r1-r3.
601 def tTPsoft : TIx2<(outs), (ins),
602 "bl __aeabi_read_tp",
603 [(set R0, ARMthread_pointer)]>;
606 //===----------------------------------------------------------------------===//
607 // Non-Instruction Patterns
610 // ConstantPool, GlobalAddress
611 def : TPat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
612 def : TPat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
615 def : TPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
616 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
619 def : TPat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>;
620 def : Tv5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>;
622 // Indirect calls to ARM routines
623 def : Tv5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>;
625 // zextload i1 -> zextload i8
626 def : T1Pat<(zextloadi1 t_addrmode_s1:$addr),
627 (tLDRB t_addrmode_s1:$addr)>;
629 // extload -> zextload
630 def : T1Pat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
631 def : T1Pat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
632 def : T1Pat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
634 // Large immediate handling.
637 def : T1Pat<(i32 thumb_immshifted:$src),
638 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
639 (thumb_immshifted_shamt imm:$src))>;
641 def : T1Pat<(i32 imm0_255_comp:$src),
642 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;