1 //===- ARMInstrThumb2.td - Thumb2 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 Thumb2 instruction set.
12 //===----------------------------------------------------------------------===//
14 // IT block predicate field
15 def it_pred_asmoperand : AsmOperandClass {
16 let Name = "ITCondCode";
17 let ParserMethod = "parseITCondCode";
19 def it_pred : Operand<i32> {
20 let PrintMethod = "printMandatoryPredicateOperand";
21 let ParserMatchClass = it_pred_asmoperand;
24 // IT block condition mask
25 def it_mask_asmoperand : AsmOperandClass { let Name = "ITMask"; }
26 def it_mask : Operand<i32> {
27 let PrintMethod = "printThumbITMask";
28 let ParserMatchClass = it_mask_asmoperand;
31 // Shifted operands. No register controlled shifts for Thumb2.
32 // Note: We do not support rrx shifted operands yet.
33 def t2_so_reg : Operand<i32>, // reg imm
34 ComplexPattern<i32, 2, "SelectT2ShifterOperandReg",
36 let EncoderMethod = "getT2SORegOpValue";
37 let PrintMethod = "printT2SOOperand";
38 let DecoderMethod = "DecodeSORegImmOperand";
39 let ParserMatchClass = ShiftedImmAsmOperand;
40 let MIOperandInfo = (ops rGPR, i32imm);
43 // t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
44 def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
45 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
48 // t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
49 def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
50 return CurDAG->getTargetConstant(-((int)N->getZExtValue()), MVT::i32);
53 // t2_so_imm - Match a 32-bit immediate operand, which is an
54 // 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
55 // immediate splatted into multiple bytes of the word.
56 def t2_so_imm_asmoperand : AsmOperandClass { let Name = "T2SOImm"; }
57 def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{
58 return ARM_AM::getT2SOImmVal(Imm) != -1;
60 let ParserMatchClass = t2_so_imm_asmoperand;
61 let EncoderMethod = "getT2SOImmOpValue";
62 let DecoderMethod = "DecodeT2SOImm";
65 // t2_so_imm_not - Match an immediate that is a complement
67 def t2_so_imm_not : Operand<i32>,
69 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
70 }], t2_so_imm_not_XFORM>;
72 // t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
73 def t2_so_imm_neg : Operand<i32>,
75 return ARM_AM::getT2SOImmVal(-((uint32_t)N->getZExtValue())) != -1;
76 }], t2_so_imm_neg_XFORM>;
78 /// imm1_31 predicate - True if the 32-bit immediate is in the range [1,31].
79 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{
80 return (int32_t)Imm >= 1 && (int32_t)Imm < 32;
83 /// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095].
84 def imm0_4095 : Operand<i32>,
86 return Imm >= 0 && Imm < 4096;
89 def imm0_4095_neg : PatLeaf<(i32 imm), [{
90 return (uint32_t)(-N->getZExtValue()) < 4096;
93 def imm0_255_neg : PatLeaf<(i32 imm), [{
94 return (uint32_t)(-N->getZExtValue()) < 255;
97 def imm0_255_not : PatLeaf<(i32 imm), [{
98 return (uint32_t)(~N->getZExtValue()) < 255;
101 def lo5AllOne : PatLeaf<(i32 imm), [{
102 // Returns true if all low 5-bits are 1.
103 return (((uint32_t)N->getZExtValue()) & 0x1FUL) == 0x1FUL;
106 // Define Thumb2 specific addressing modes.
108 // t2addrmode_imm12 := reg + imm12
109 def t2addrmode_imm12 : Operand<i32>,
110 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> {
111 let PrintMethod = "printAddrModeImm12Operand";
112 let EncoderMethod = "getAddrModeImm12OpValue";
113 let DecoderMethod = "DecodeT2AddrModeImm12";
114 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
117 // t2ldrlabel := imm12
118 def t2ldrlabel : Operand<i32> {
119 let EncoderMethod = "getAddrModeImm12OpValue";
123 // ADR instruction labels.
124 def t2adrlabel : Operand<i32> {
125 let EncoderMethod = "getT2AdrLabelOpValue";
129 // t2addrmode_imm8 := reg +/- imm8
130 def MemImm8OffsetAsmOperand : AsmOperandClass { let Name = "MemImm8Offset"; }
131 def t2addrmode_imm8 : Operand<i32>,
132 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
133 let PrintMethod = "printT2AddrModeImm8Operand";
134 let EncoderMethod = "getT2AddrModeImm8OpValue";
135 let DecoderMethod = "DecodeT2AddrModeImm8";
136 let ParserMatchClass = MemImm8OffsetAsmOperand;
137 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
140 def t2am_imm8_offset : Operand<i32>,
141 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset",
142 [], [SDNPWantRoot]> {
143 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
144 let EncoderMethod = "getT2AddrModeImm8OffsetOpValue";
145 let DecoderMethod = "DecodeT2Imm8";
148 // t2addrmode_imm8s4 := reg +/- (imm8 << 2)
149 def t2addrmode_imm8s4 : Operand<i32> {
150 let PrintMethod = "printT2AddrModeImm8s4Operand";
151 let EncoderMethod = "getT2AddrModeImm8s4OpValue";
152 let DecoderMethod = "DecodeT2AddrModeImm8s4";
153 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
156 def t2am_imm8s4_offset : Operand<i32> {
157 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
158 let DecoderMethod = "DecodeT2Imm8S4";
161 // t2addrmode_so_reg := reg + (reg << imm2)
162 def t2addrmode_so_reg : Operand<i32>,
163 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> {
164 let PrintMethod = "printT2AddrModeSoRegOperand";
165 let EncoderMethod = "getT2AddrModeSORegOpValue";
166 let DecoderMethod = "DecodeT2AddrModeSOReg";
167 let MIOperandInfo = (ops GPR:$base, rGPR:$offsreg, i32imm:$offsimm);
170 // t2addrmode_reg := reg
171 // Used by load/store exclusive instructions. Useful to enable right assembly
172 // parsing and printing. Not used for any codegen matching.
174 def t2addrmode_reg : Operand<i32> {
175 let PrintMethod = "printAddrMode7Operand";
176 let DecoderMethod = "DecodeGPRRegisterClass";
177 let MIOperandInfo = (ops GPR);
180 //===----------------------------------------------------------------------===//
181 // Multiclass helpers...
185 class T2OneRegImm<dag oops, dag iops, InstrItinClass itin,
186 string opc, string asm, list<dag> pattern>
187 : T2I<oops, iops, itin, opc, asm, pattern> {
192 let Inst{26} = imm{11};
193 let Inst{14-12} = imm{10-8};
194 let Inst{7-0} = imm{7-0};
198 class T2sOneRegImm<dag oops, dag iops, InstrItinClass itin,
199 string opc, string asm, list<dag> pattern>
200 : T2sI<oops, iops, itin, opc, asm, pattern> {
206 let Inst{26} = imm{11};
207 let Inst{14-12} = imm{10-8};
208 let Inst{7-0} = imm{7-0};
211 class T2OneRegCmpImm<dag oops, dag iops, InstrItinClass itin,
212 string opc, string asm, list<dag> pattern>
213 : T2I<oops, iops, itin, opc, asm, pattern> {
217 let Inst{19-16} = Rn;
218 let Inst{26} = imm{11};
219 let Inst{14-12} = imm{10-8};
220 let Inst{7-0} = imm{7-0};
224 class T2OneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
225 string opc, string asm, list<dag> pattern>
226 : T2I<oops, iops, itin, opc, asm, pattern> {
231 let Inst{3-0} = ShiftedRm{3-0};
232 let Inst{5-4} = ShiftedRm{6-5};
233 let Inst{14-12} = ShiftedRm{11-9};
234 let Inst{7-6} = ShiftedRm{8-7};
237 class T2sOneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
238 string opc, string asm, list<dag> pattern>
239 : T2sI<oops, iops, itin, opc, asm, pattern> {
244 let Inst{3-0} = ShiftedRm{3-0};
245 let Inst{5-4} = ShiftedRm{6-5};
246 let Inst{14-12} = ShiftedRm{11-9};
247 let Inst{7-6} = ShiftedRm{8-7};
250 class T2OneRegCmpShiftedReg<dag oops, dag iops, InstrItinClass itin,
251 string opc, string asm, list<dag> pattern>
252 : T2I<oops, iops, itin, opc, asm, pattern> {
256 let Inst{19-16} = Rn;
257 let Inst{3-0} = ShiftedRm{3-0};
258 let Inst{5-4} = ShiftedRm{6-5};
259 let Inst{14-12} = ShiftedRm{11-9};
260 let Inst{7-6} = ShiftedRm{8-7};
263 class T2TwoReg<dag oops, dag iops, InstrItinClass itin,
264 string opc, string asm, list<dag> pattern>
265 : T2I<oops, iops, itin, opc, asm, pattern> {
273 class T2sTwoReg<dag oops, dag iops, InstrItinClass itin,
274 string opc, string asm, list<dag> pattern>
275 : T2sI<oops, iops, itin, opc, asm, pattern> {
283 class T2TwoRegCmp<dag oops, dag iops, InstrItinClass itin,
284 string opc, string asm, list<dag> pattern>
285 : T2I<oops, iops, itin, opc, asm, pattern> {
289 let Inst{19-16} = Rn;
294 class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin,
295 string opc, string asm, list<dag> pattern>
296 : T2I<oops, iops, itin, opc, asm, pattern> {
302 let Inst{19-16} = Rn;
303 let Inst{26} = imm{11};
304 let Inst{14-12} = imm{10-8};
305 let Inst{7-0} = imm{7-0};
308 class T2sTwoRegImm<dag oops, dag iops, InstrItinClass itin,
309 string opc, string asm, list<dag> pattern>
310 : T2sI<oops, iops, itin, opc, asm, pattern> {
316 let Inst{19-16} = Rn;
317 let Inst{26} = imm{11};
318 let Inst{14-12} = imm{10-8};
319 let Inst{7-0} = imm{7-0};
322 class T2TwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
323 string opc, string asm, list<dag> pattern>
324 : T2I<oops, iops, itin, opc, asm, pattern> {
331 let Inst{14-12} = imm{4-2};
332 let Inst{7-6} = imm{1-0};
335 class T2sTwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
336 string opc, string asm, list<dag> pattern>
337 : T2sI<oops, iops, itin, opc, asm, pattern> {
344 let Inst{14-12} = imm{4-2};
345 let Inst{7-6} = imm{1-0};
348 class T2ThreeReg<dag oops, dag iops, InstrItinClass itin,
349 string opc, string asm, list<dag> pattern>
350 : T2I<oops, iops, itin, opc, asm, pattern> {
356 let Inst{19-16} = Rn;
360 class T2sThreeReg<dag oops, dag iops, InstrItinClass itin,
361 string opc, string asm, list<dag> pattern>
362 : T2sI<oops, iops, itin, opc, asm, pattern> {
368 let Inst{19-16} = Rn;
372 class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
373 string opc, string asm, list<dag> pattern>
374 : T2I<oops, iops, itin, opc, asm, pattern> {
380 let Inst{19-16} = Rn;
381 let Inst{3-0} = ShiftedRm{3-0};
382 let Inst{5-4} = ShiftedRm{6-5};
383 let Inst{14-12} = ShiftedRm{11-9};
384 let Inst{7-6} = ShiftedRm{8-7};
387 class T2sTwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
388 string opc, string asm, list<dag> pattern>
389 : T2sI<oops, iops, itin, opc, asm, pattern> {
395 let Inst{19-16} = Rn;
396 let Inst{3-0} = ShiftedRm{3-0};
397 let Inst{5-4} = ShiftedRm{6-5};
398 let Inst{14-12} = ShiftedRm{11-9};
399 let Inst{7-6} = ShiftedRm{8-7};
402 class T2FourReg<dag oops, dag iops, InstrItinClass itin,
403 string opc, string asm, list<dag> pattern>
404 : T2I<oops, iops, itin, opc, asm, pattern> {
410 let Inst{19-16} = Rn;
411 let Inst{15-12} = Ra;
416 class T2MulLong<bits<3> opc22_20, bits<4> opc7_4,
417 dag oops, dag iops, InstrItinClass itin,
418 string opc, string asm, list<dag> pattern>
419 : T2I<oops, iops, itin, opc, asm, pattern> {
425 let Inst{31-23} = 0b111110111;
426 let Inst{22-20} = opc22_20;
427 let Inst{19-16} = Rn;
428 let Inst{15-12} = RdLo;
429 let Inst{11-8} = RdHi;
430 let Inst{7-4} = opc7_4;
435 /// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
436 /// unary operation that produces a value. These are predicable and can be
437 /// changed to modify CPSR.
438 multiclass T2I_un_irs<bits<4> opcod, string opc,
439 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
440 PatFrag opnode, bit Cheap = 0, bit ReMat = 0> {
442 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii,
444 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]> {
445 let isAsCheapAsAMove = Cheap;
446 let isReMaterializable = ReMat;
447 let Inst{31-27} = 0b11110;
449 let Inst{24-21} = opcod;
450 let Inst{19-16} = 0b1111; // Rn
454 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir,
456 [(set rGPR:$Rd, (opnode rGPR:$Rm))]> {
457 let Inst{31-27} = 0b11101;
458 let Inst{26-25} = 0b01;
459 let Inst{24-21} = opcod;
460 let Inst{19-16} = 0b1111; // Rn
461 let Inst{14-12} = 0b000; // imm3
462 let Inst{7-6} = 0b00; // imm2
463 let Inst{5-4} = 0b00; // type
466 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis,
467 opc, ".w\t$Rd, $ShiftedRm",
468 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]> {
469 let Inst{31-27} = 0b11101;
470 let Inst{26-25} = 0b01;
471 let Inst{24-21} = opcod;
472 let Inst{19-16} = 0b1111; // Rn
476 /// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
477 /// binary operation that produces a value. These are predicable and can be
478 /// changed to modify CPSR.
479 multiclass T2I_bin_irs<bits<4> opcod, string opc,
480 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
481 PatFrag opnode, string baseOpc, bit Commutable = 0,
484 def ri : T2sTwoRegImm<
485 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
486 opc, "\t$Rd, $Rn, $imm",
487 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]> {
488 let Inst{31-27} = 0b11110;
490 let Inst{24-21} = opcod;
494 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
495 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
496 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
497 let isCommutable = Commutable;
498 let Inst{31-27} = 0b11101;
499 let Inst{26-25} = 0b01;
500 let Inst{24-21} = opcod;
501 let Inst{14-12} = 0b000; // imm3
502 let Inst{7-6} = 0b00; // imm2
503 let Inst{5-4} = 0b00; // type
506 def rs : T2sTwoRegShiftedReg<
507 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
508 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
509 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]> {
510 let Inst{31-27} = 0b11101;
511 let Inst{26-25} = 0b01;
512 let Inst{24-21} = opcod;
514 // Assembly aliases for optional destination operand when it's the same
515 // as the source operand.
516 def : t2InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
517 (!cast<Instruction>(!strconcat(baseOpc, "ri")) rGPR:$Rdn, rGPR:$Rdn,
518 t2_so_imm:$imm, pred:$p,
520 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $Rm"),
521 (!cast<Instruction>(!strconcat(baseOpc, "rr")) rGPR:$Rdn, rGPR:$Rdn,
524 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $shift"),
525 (!cast<Instruction>(!strconcat(baseOpc, "rs")) rGPR:$Rdn, rGPR:$Rdn,
526 t2_so_reg:$shift, pred:$p,
530 /// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
531 // the ".w" suffix to indicate that they are wide.
532 multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
533 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
534 PatFrag opnode, string baseOpc, bit Commutable = 0> :
535 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, baseOpc, Commutable, ".w"> {
536 // Assembler aliases w/o the ".w" suffix.
537 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
538 (!cast<Instruction>(!strconcat(baseOpc, "rr")) rGPR:$Rd, rGPR:$Rn,
541 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $shift"),
542 (!cast<Instruction>(!strconcat(baseOpc, "rs")) rGPR:$Rd, rGPR:$Rn,
543 t2_so_reg:$shift, pred:$p,
546 // and with the optional destination operand, too.
547 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
548 (!cast<Instruction>(!strconcat(baseOpc, "rr")) rGPR:$Rdn, rGPR:$Rdn,
551 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $shift"),
552 (!cast<Instruction>(!strconcat(baseOpc, "rs")) rGPR:$Rdn, rGPR:$Rdn,
553 t2_so_reg:$shift, pred:$p,
557 /// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
558 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
559 /// it is equivalent to the T2I_bin_irs counterpart.
560 multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
562 def ri : T2sTwoRegImm<
563 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
564 opc, ".w\t$Rd, $Rn, $imm",
565 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
566 let Inst{31-27} = 0b11110;
568 let Inst{24-21} = opcod;
572 def rr : T2sThreeReg<
573 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
574 opc, "\t$Rd, $Rn, $Rm",
575 [/* For disassembly only; pattern left blank */]> {
576 let Inst{31-27} = 0b11101;
577 let Inst{26-25} = 0b01;
578 let Inst{24-21} = opcod;
579 let Inst{14-12} = 0b000; // imm3
580 let Inst{7-6} = 0b00; // imm2
581 let Inst{5-4} = 0b00; // type
584 def rs : T2sTwoRegShiftedReg<
585 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
586 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm",
587 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
588 let Inst{31-27} = 0b11101;
589 let Inst{26-25} = 0b01;
590 let Inst{24-21} = opcod;
594 /// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
595 /// instruction modifies the CPSR register.
596 let isCodeGenOnly = 1, Defs = [CPSR] in {
597 multiclass T2I_bin_s_irs<bits<4> opcod, string opc,
598 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
599 PatFrag opnode, bit Commutable = 0> {
601 def ri : T2TwoRegImm<
602 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_imm:$imm), iii,
603 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $imm",
604 [(set rGPR:$Rd, CPSR, (opnode GPR:$Rn, t2_so_imm:$imm))]> {
605 let Inst{31-27} = 0b11110;
607 let Inst{24-21} = opcod;
608 let Inst{20} = 1; // The S bit.
613 (outs rGPR:$Rd), (ins GPR:$Rn, rGPR:$Rm), iir,
614 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $Rm",
615 [(set rGPR:$Rd, CPSR, (opnode GPR:$Rn, rGPR:$Rm))]> {
616 let isCommutable = Commutable;
617 let Inst{31-27} = 0b11101;
618 let Inst{26-25} = 0b01;
619 let Inst{24-21} = opcod;
620 let Inst{20} = 1; // The S bit.
621 let Inst{14-12} = 0b000; // imm3
622 let Inst{7-6} = 0b00; // imm2
623 let Inst{5-4} = 0b00; // type
626 def rs : T2TwoRegShiftedReg<
627 (outs rGPR:$Rd), (ins GPR:$Rn, t2_so_reg:$ShiftedRm), iis,
628 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $ShiftedRm",
629 [(set rGPR:$Rd, CPSR, (opnode GPR:$Rn, t2_so_reg:$ShiftedRm))]> {
630 let Inst{31-27} = 0b11101;
631 let Inst{26-25} = 0b01;
632 let Inst{24-21} = opcod;
633 let Inst{20} = 1; // The S bit.
638 /// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
639 /// patterns for a binary operation that produces a value.
640 multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
641 bit Commutable = 0> {
643 // The register-immediate version is re-materializable. This is useful
644 // in particular for taking the address of a local.
645 let isReMaterializable = 1 in {
646 def ri : T2sTwoRegImm<
647 (outs rGPR:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi,
648 opc, ".w\t$Rd, $Rn, $imm",
649 [(set rGPR:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]> {
650 let Inst{31-27} = 0b11110;
653 let Inst{23-21} = op23_21;
659 (outs rGPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
660 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
661 [(set rGPR:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> {
665 let Inst{31-27} = 0b11110;
666 let Inst{26} = imm{11};
667 let Inst{25-24} = 0b10;
668 let Inst{23-21} = op23_21;
669 let Inst{20} = 0; // The S bit.
670 let Inst{19-16} = Rn;
672 let Inst{14-12} = imm{10-8};
674 let Inst{7-0} = imm{7-0};
677 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iALUr,
678 opc, ".w\t$Rd, $Rn, $Rm",
679 [(set rGPR:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]> {
680 let isCommutable = Commutable;
681 let Inst{31-27} = 0b11101;
682 let Inst{26-25} = 0b01;
684 let Inst{23-21} = op23_21;
685 let Inst{14-12} = 0b000; // imm3
686 let Inst{7-6} = 0b00; // imm2
687 let Inst{5-4} = 0b00; // type
690 def rs : T2sTwoRegShiftedReg<
691 (outs rGPR:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm),
692 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
693 [(set rGPR:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]> {
694 let Inst{31-27} = 0b11101;
695 let Inst{26-25} = 0b01;
697 let Inst{23-21} = op23_21;
701 /// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
702 /// for a binary operation that produces a value and use the carry
703 /// bit. It's not predicable.
704 let Defs = [CPSR], Uses = [CPSR] in {
705 multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
706 bit Commutable = 0> {
708 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
709 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
710 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_imm:$imm, CPSR))]>,
711 Requires<[IsThumb2]> {
712 let Inst{31-27} = 0b11110;
714 let Inst{24-21} = opcod;
718 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
719 opc, ".w\t$Rd, $Rn, $Rm",
720 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, rGPR:$Rm, CPSR))]>,
721 Requires<[IsThumb2]> {
722 let isCommutable = Commutable;
723 let Inst{31-27} = 0b11101;
724 let Inst{26-25} = 0b01;
725 let Inst{24-21} = opcod;
726 let Inst{14-12} = 0b000; // imm3
727 let Inst{7-6} = 0b00; // imm2
728 let Inst{5-4} = 0b00; // type
731 def rs : T2sTwoRegShiftedReg<
732 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
733 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
734 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm, CPSR))]>,
735 Requires<[IsThumb2]> {
736 let Inst{31-27} = 0b11101;
737 let Inst{26-25} = 0b01;
738 let Inst{24-21} = opcod;
743 /// T2I_rbin_s_is - Same as T2I_rbin_irs except sets 's' bit and the register
744 /// version is not needed since this is only for codegen.
745 let isCodeGenOnly = 1, Defs = [CPSR] in {
746 multiclass T2I_rbin_s_is<bits<4> opcod, string opc, PatFrag opnode> {
748 def ri : T2TwoRegImm<
749 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
750 !strconcat(opc, "s"), ".w\t$Rd, $Rn, $imm",
751 [(set rGPR:$Rd, CPSR, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
752 let Inst{31-27} = 0b11110;
754 let Inst{24-21} = opcod;
755 let Inst{20} = 1; // The S bit.
759 def rs : T2TwoRegShiftedReg<
760 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
761 IIC_iALUsi, !strconcat(opc, "s"), "\t$Rd, $Rn, $ShiftedRm",
762 [(set rGPR:$Rd, CPSR, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
763 let Inst{31-27} = 0b11101;
764 let Inst{26-25} = 0b01;
765 let Inst{24-21} = opcod;
766 let Inst{20} = 1; // The S bit.
771 /// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
772 // rotate operation that produces a value.
773 multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode> {
775 def ri : T2sTwoRegShiftImm<
776 (outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi,
777 opc, ".w\t$Rd, $Rm, $imm",
778 [(set rGPR:$Rd, (opnode rGPR:$Rm, (i32 ty:$imm)))]> {
779 let Inst{31-27} = 0b11101;
780 let Inst{26-21} = 0b010010;
781 let Inst{19-16} = 0b1111; // Rn
782 let Inst{5-4} = opcod;
785 def rr : T2sThreeReg<
786 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr,
787 opc, ".w\t$Rd, $Rn, $Rm",
788 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
789 let Inst{31-27} = 0b11111;
790 let Inst{26-23} = 0b0100;
791 let Inst{22-21} = opcod;
792 let Inst{15-12} = 0b1111;
793 let Inst{7-4} = 0b0000;
797 /// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
798 /// patterns. Similar to T2I_bin_irs except the instruction does not produce
799 /// a explicit result, only implicitly set CPSR.
800 let isCompare = 1, Defs = [CPSR] in {
801 multiclass T2I_cmp_irs<bits<4> opcod, string opc,
802 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
805 def ri : T2OneRegCmpImm<
806 (outs), (ins GPR:$Rn, t2_so_imm:$imm), iii,
807 opc, ".w\t$Rn, $imm",
808 [(opnode GPR:$Rn, t2_so_imm:$imm)]> {
809 let Inst{31-27} = 0b11110;
811 let Inst{24-21} = opcod;
812 let Inst{20} = 1; // The S bit.
814 let Inst{11-8} = 0b1111; // Rd
817 def rr : T2TwoRegCmp<
818 (outs), (ins GPR:$Rn, rGPR:$Rm), iir,
820 [(opnode GPR:$Rn, rGPR:$Rm)]> {
821 let Inst{31-27} = 0b11101;
822 let Inst{26-25} = 0b01;
823 let Inst{24-21} = opcod;
824 let Inst{20} = 1; // The S bit.
825 let Inst{14-12} = 0b000; // imm3
826 let Inst{11-8} = 0b1111; // Rd
827 let Inst{7-6} = 0b00; // imm2
828 let Inst{5-4} = 0b00; // type
831 def rs : T2OneRegCmpShiftedReg<
832 (outs), (ins GPR:$Rn, t2_so_reg:$ShiftedRm), iis,
833 opc, ".w\t$Rn, $ShiftedRm",
834 [(opnode GPR:$Rn, t2_so_reg:$ShiftedRm)]> {
835 let Inst{31-27} = 0b11101;
836 let Inst{26-25} = 0b01;
837 let Inst{24-21} = opcod;
838 let Inst{20} = 1; // The S bit.
839 let Inst{11-8} = 0b1111; // Rd
844 /// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
845 multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
846 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
848 def i12 : T2Ii12<(outs target:$Rt), (ins t2addrmode_imm12:$addr), iii,
849 opc, ".w\t$Rt, $addr",
850 [(set target:$Rt, (opnode t2addrmode_imm12:$addr))]> {
851 let Inst{31-27} = 0b11111;
852 let Inst{26-25} = 0b00;
853 let Inst{24} = signed;
855 let Inst{22-21} = opcod;
856 let Inst{20} = 1; // load
859 let Inst{15-12} = Rt;
862 let addr{12} = 1; // add = TRUE
863 let Inst{19-16} = addr{16-13}; // Rn
864 let Inst{23} = addr{12}; // U
865 let Inst{11-0} = addr{11-0}; // imm
867 def i8 : T2Ii8 <(outs target:$Rt), (ins t2addrmode_imm8:$addr), iii,
869 [(set target:$Rt, (opnode t2addrmode_imm8:$addr))]> {
870 let Inst{31-27} = 0b11111;
871 let Inst{26-25} = 0b00;
872 let Inst{24} = signed;
874 let Inst{22-21} = opcod;
875 let Inst{20} = 1; // load
877 // Offset: index==TRUE, wback==FALSE
878 let Inst{10} = 1; // The P bit.
879 let Inst{8} = 0; // The W bit.
882 let Inst{15-12} = Rt;
885 let Inst{19-16} = addr{12-9}; // Rn
886 let Inst{9} = addr{8}; // U
887 let Inst{7-0} = addr{7-0}; // imm
889 def s : T2Iso <(outs target:$Rt), (ins t2addrmode_so_reg:$addr), iis,
890 opc, ".w\t$Rt, $addr",
891 [(set target:$Rt, (opnode t2addrmode_so_reg:$addr))]> {
892 let Inst{31-27} = 0b11111;
893 let Inst{26-25} = 0b00;
894 let Inst{24} = signed;
896 let Inst{22-21} = opcod;
897 let Inst{20} = 1; // load
898 let Inst{11-6} = 0b000000;
901 let Inst{15-12} = Rt;
904 let Inst{19-16} = addr{9-6}; // Rn
905 let Inst{3-0} = addr{5-2}; // Rm
906 let Inst{5-4} = addr{1-0}; // imm
908 let DecoderMethod = "DecodeT2LoadShift";
911 // FIXME: Is the pci variant actually needed?
912 def pci : T2Ipc <(outs target:$Rt), (ins t2ldrlabel:$addr), iii,
913 opc, ".w\t$Rt, $addr",
914 [(set target:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> {
915 let isReMaterializable = 1;
916 let Inst{31-27} = 0b11111;
917 let Inst{26-25} = 0b00;
918 let Inst{24} = signed;
919 let Inst{23} = ?; // add = (U == '1')
920 let Inst{22-21} = opcod;
921 let Inst{20} = 1; // load
922 let Inst{19-16} = 0b1111; // Rn
925 let Inst{15-12} = Rt{3-0};
926 let Inst{11-0} = addr{11-0};
930 /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
931 multiclass T2I_st<bits<2> opcod, string opc,
932 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
934 def i12 : T2Ii12<(outs), (ins target:$Rt, t2addrmode_imm12:$addr), iii,
935 opc, ".w\t$Rt, $addr",
936 [(opnode target:$Rt, t2addrmode_imm12:$addr)]> {
937 let Inst{31-27} = 0b11111;
938 let Inst{26-23} = 0b0001;
939 let Inst{22-21} = opcod;
940 let Inst{20} = 0; // !load
943 let Inst{15-12} = Rt;
946 let addr{12} = 1; // add = TRUE
947 let Inst{19-16} = addr{16-13}; // Rn
948 let Inst{23} = addr{12}; // U
949 let Inst{11-0} = addr{11-0}; // imm
951 def i8 : T2Ii8 <(outs), (ins target:$Rt, t2addrmode_imm8:$addr), iii,
953 [(opnode target:$Rt, t2addrmode_imm8:$addr)]> {
954 let Inst{31-27} = 0b11111;
955 let Inst{26-23} = 0b0000;
956 let Inst{22-21} = opcod;
957 let Inst{20} = 0; // !load
959 // Offset: index==TRUE, wback==FALSE
960 let Inst{10} = 1; // The P bit.
961 let Inst{8} = 0; // The W bit.
964 let Inst{15-12} = Rt;
967 let Inst{19-16} = addr{12-9}; // Rn
968 let Inst{9} = addr{8}; // U
969 let Inst{7-0} = addr{7-0}; // imm
971 def s : T2Iso <(outs), (ins target:$Rt, t2addrmode_so_reg:$addr), iis,
972 opc, ".w\t$Rt, $addr",
973 [(opnode target:$Rt, t2addrmode_so_reg:$addr)]> {
974 let Inst{31-27} = 0b11111;
975 let Inst{26-23} = 0b0000;
976 let Inst{22-21} = opcod;
977 let Inst{20} = 0; // !load
978 let Inst{11-6} = 0b000000;
981 let Inst{15-12} = Rt;
984 let Inst{19-16} = addr{9-6}; // Rn
985 let Inst{3-0} = addr{5-2}; // Rm
986 let Inst{5-4} = addr{1-0}; // imm
990 /// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
991 /// register and one whose operand is a register rotated by 8/16/24.
992 class T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode>
993 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
994 opc, ".w\t$Rd, $Rm$rot",
995 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
996 Requires<[IsThumb2]> {
997 let Inst{31-27} = 0b11111;
998 let Inst{26-23} = 0b0100;
999 let Inst{22-20} = opcod;
1000 let Inst{19-16} = 0b1111; // Rn
1001 let Inst{15-12} = 0b1111;
1005 let Inst{5-4} = rot{1-0}; // rotate
1008 // UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
1009 class T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode>
1010 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot),
1011 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1012 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
1013 Requires<[HasT2ExtractPack, IsThumb2]> {
1015 let Inst{31-27} = 0b11111;
1016 let Inst{26-23} = 0b0100;
1017 let Inst{22-20} = opcod;
1018 let Inst{19-16} = 0b1111; // Rn
1019 let Inst{15-12} = 0b1111;
1021 let Inst{5-4} = rot;
1024 // SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
1026 class T2I_ext_rrot_sxtb16<bits<3> opcod, string opc>
1027 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1028 opc, "\t$Rd, $Rm$rot", []>,
1029 Requires<[IsThumb2, HasT2ExtractPack]> {
1031 let Inst{31-27} = 0b11111;
1032 let Inst{26-23} = 0b0100;
1033 let Inst{22-20} = opcod;
1034 let Inst{19-16} = 0b1111; // Rn
1035 let Inst{15-12} = 0b1111;
1037 let Inst{5-4} = rot;
1040 /// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
1041 /// register and one whose operand is a register rotated by 8/16/24.
1042 class T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode>
1043 : T2ThreeReg<(outs rGPR:$Rd),
1044 (ins rGPR:$Rn, rGPR:$Rm, rot_imm:$rot),
1045 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot",
1046 [(set rGPR:$Rd, (opnode rGPR:$Rn, (rotr rGPR:$Rm,rot_imm:$rot)))]>,
1047 Requires<[HasT2ExtractPack, IsThumb2]> {
1049 let Inst{31-27} = 0b11111;
1050 let Inst{26-23} = 0b0100;
1051 let Inst{22-20} = opcod;
1052 let Inst{15-12} = 0b1111;
1054 let Inst{5-4} = rot;
1057 class T2I_exta_rrot_np<bits<3> opcod, string opc>
1058 : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm,rot_imm:$rot),
1059 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot", []> {
1061 let Inst{31-27} = 0b11111;
1062 let Inst{26-23} = 0b0100;
1063 let Inst{22-20} = opcod;
1064 let Inst{15-12} = 0b1111;
1066 let Inst{5-4} = rot;
1069 //===----------------------------------------------------------------------===//
1071 //===----------------------------------------------------------------------===//
1073 //===----------------------------------------------------------------------===//
1074 // Miscellaneous Instructions.
1077 class T2PCOneRegImm<dag oops, dag iops, InstrItinClass itin,
1078 string asm, list<dag> pattern>
1079 : T2XI<oops, iops, itin, asm, pattern> {
1083 let Inst{11-8} = Rd;
1084 let Inst{26} = label{11};
1085 let Inst{14-12} = label{10-8};
1086 let Inst{7-0} = label{7-0};
1089 // LEApcrel - Load a pc-relative address into a register without offending the
1091 def t2ADR : T2PCOneRegImm<(outs rGPR:$Rd),
1092 (ins t2adrlabel:$addr, pred:$p),
1093 IIC_iALUi, "adr{$p}.w\t$Rd, #$addr", []> {
1094 let Inst{31-27} = 0b11110;
1095 let Inst{25-24} = 0b10;
1096 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1099 let Inst{19-16} = 0b1111; // Rn
1104 let Inst{11-8} = Rd;
1105 let Inst{23} = addr{12};
1106 let Inst{21} = addr{12};
1107 let Inst{26} = addr{11};
1108 let Inst{14-12} = addr{10-8};
1109 let Inst{7-0} = addr{7-0};
1112 let neverHasSideEffects = 1, isReMaterializable = 1 in
1113 def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p),
1115 def t2LEApcrelJT : t2PseudoInst<(outs rGPR:$Rd),
1116 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1121 //===----------------------------------------------------------------------===//
1122 // Load / store Instructions.
1126 let canFoldAsLoad = 1, isReMaterializable = 1 in
1127 defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si, GPR,
1128 UnOpFrag<(load node:$Src)>>;
1130 // Loads with zero extension
1131 defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1132 rGPR, UnOpFrag<(zextloadi16 node:$Src)>>;
1133 defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1134 rGPR, UnOpFrag<(zextloadi8 node:$Src)>>;
1136 // Loads with sign extension
1137 defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1138 rGPR, UnOpFrag<(sextloadi16 node:$Src)>>;
1139 defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1140 rGPR, UnOpFrag<(sextloadi8 node:$Src)>>;
1142 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1144 def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$Rt, rGPR:$Rt2),
1145 (ins t2addrmode_imm8s4:$addr),
1146 IIC_iLoad_d_i, "ldrd", "\t$Rt, $Rt2, $addr", []>;
1147 } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
1149 // zextload i1 -> zextload i8
1150 def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1151 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1152 def : T2Pat<(zextloadi1 t2addrmode_imm8:$addr),
1153 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1154 def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1155 (t2LDRBs t2addrmode_so_reg:$addr)>;
1156 def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1157 (t2LDRBpci tconstpool:$addr)>;
1159 // extload -> zextload
1160 // FIXME: Reduce the number of patterns by legalizing extload to zextload
1162 def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1163 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1164 def : T2Pat<(extloadi1 t2addrmode_imm8:$addr),
1165 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1166 def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1167 (t2LDRBs t2addrmode_so_reg:$addr)>;
1168 def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1169 (t2LDRBpci tconstpool:$addr)>;
1171 def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1172 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1173 def : T2Pat<(extloadi8 t2addrmode_imm8:$addr),
1174 (t2LDRBi8 t2addrmode_imm8:$addr)>;
1175 def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1176 (t2LDRBs t2addrmode_so_reg:$addr)>;
1177 def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1178 (t2LDRBpci tconstpool:$addr)>;
1180 def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1181 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1182 def : T2Pat<(extloadi16 t2addrmode_imm8:$addr),
1183 (t2LDRHi8 t2addrmode_imm8:$addr)>;
1184 def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1185 (t2LDRHs t2addrmode_so_reg:$addr)>;
1186 def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1187 (t2LDRHpci tconstpool:$addr)>;
1189 // FIXME: The destination register of the loads and stores can't be PC, but
1190 // can be SP. We need another regclass (similar to rGPR) to represent
1191 // that. Not a pressing issue since these are selected manually,
1196 let mayLoad = 1, neverHasSideEffects = 1 in {
1197 def t2LDR_PRE : T2Iidxldst<0, 0b10, 1, 1, (outs GPR:$Rt, GPR:$Rn),
1198 (ins t2addrmode_imm8:$addr),
1199 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
1200 "ldr", "\t$Rt, $addr!", "$addr.base = $Rn",
1203 def t2LDR_POST : T2Iidxldst<0, 0b10, 1, 0, (outs GPR:$Rt, GPR:$Rn),
1204 (ins GPR:$base, t2am_imm8_offset:$addr),
1205 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
1206 "ldr", "\t$Rt, [$Rn], $addr", "$base = $Rn",
1209 def t2LDRB_PRE : T2Iidxldst<0, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn),
1210 (ins t2addrmode_imm8:$addr),
1211 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1212 "ldrb", "\t$Rt, $addr!", "$addr.base = $Rn",
1214 def t2LDRB_POST : T2Iidxldst<0, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn),
1215 (ins GPR:$base, t2am_imm8_offset:$addr),
1216 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1217 "ldrb", "\t$Rt, [$Rn], $addr", "$base = $Rn",
1220 def t2LDRH_PRE : T2Iidxldst<0, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn),
1221 (ins t2addrmode_imm8:$addr),
1222 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1223 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn",
1225 def t2LDRH_POST : T2Iidxldst<0, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn),
1226 (ins GPR:$base, t2am_imm8_offset:$addr),
1227 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1228 "ldrh", "\t$Rt, [$Rn], $addr", "$base = $Rn",
1231 def t2LDRSB_PRE : T2Iidxldst<1, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn),
1232 (ins t2addrmode_imm8:$addr),
1233 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1234 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn",
1236 def t2LDRSB_POST : T2Iidxldst<1, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn),
1237 (ins GPR:$base, t2am_imm8_offset:$addr),
1238 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1239 "ldrsb", "\t$Rt, [$Rn], $addr", "$base = $Rn",
1242 def t2LDRSH_PRE : T2Iidxldst<1, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn),
1243 (ins t2addrmode_imm8:$addr),
1244 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1245 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn",
1247 def t2LDRSH_POST : T2Iidxldst<1, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn),
1248 (ins GPR:$base, t2am_imm8_offset:$addr),
1249 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1250 "ldrsh", "\t$Rt, [$Rn], $addr", "$base = $Rn",
1252 } // mayLoad = 1, neverHasSideEffects = 1
1254 // LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110) and are
1255 // for disassembly only.
1256 // Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
1257 class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1258 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_imm8:$addr), ii, opc,
1259 "\t$Rt, $addr", []> {
1260 let Inst{31-27} = 0b11111;
1261 let Inst{26-25} = 0b00;
1262 let Inst{24} = signed;
1264 let Inst{22-21} = type;
1265 let Inst{20} = 1; // load
1267 let Inst{10-8} = 0b110; // PUW.
1271 let Inst{15-12} = Rt;
1272 let Inst{19-16} = addr{12-9};
1273 let Inst{7-0} = addr{7-0};
1276 def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1277 def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1278 def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1279 def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1280 def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
1283 defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si, GPR,
1284 BinOpFrag<(store node:$LHS, node:$RHS)>>;
1285 defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
1286 rGPR, BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1287 defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
1288 rGPR, BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
1291 let mayLoad = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
1292 def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
1293 (ins GPR:$Rt, GPR:$Rt2, t2addrmode_imm8s4:$addr),
1294 IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>;
1297 def t2STR_PRE : T2Iidxldst<0, 0b10, 0, 1, (outs GPRnopc:$base_wb),
1298 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr),
1299 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1300 "str", "\t$Rt, [$Rn, $addr]!",
1301 "$Rn = $base_wb,@earlyclobber $base_wb",
1302 [(set GPRnopc:$base_wb,
1303 (pre_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr))]>;
1305 def t2STR_POST : T2Iidxldst<0, 0b10, 0, 0, (outs GPRnopc:$base_wb),
1306 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr),
1307 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
1308 "str", "\t$Rt, [$Rn], $addr",
1309 "$Rn = $base_wb,@earlyclobber $base_wb",
1310 [(set GPRnopc:$base_wb,
1311 (post_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr))]>;
1313 def t2STRH_PRE : T2Iidxldst<0, 0b01, 0, 1, (outs GPRnopc:$base_wb),
1314 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr),
1315 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1316 "strh", "\t$Rt, [$Rn, $addr]!",
1317 "$Rn = $base_wb,@earlyclobber $base_wb",
1318 [(set GPRnopc:$base_wb,
1319 (pre_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr))]>;
1321 def t2STRH_POST : T2Iidxldst<0, 0b01, 0, 0, (outs GPRnopc:$base_wb),
1322 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr),
1323 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1324 "strh", "\t$Rt, [$Rn], $addr",
1325 "$Rn = $base_wb,@earlyclobber $base_wb",
1326 [(set GPRnopc:$base_wb,
1327 (post_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr))]>;
1329 def t2STRB_PRE : T2Iidxldst<0, 0b00, 0, 1, (outs GPRnopc:$base_wb),
1330 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr),
1331 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
1332 "strb", "\t$Rt, [$Rn, $addr]!",
1333 "$Rn = $base_wb,@earlyclobber $base_wb",
1334 [(set GPRnopc:$base_wb,
1335 (pre_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr))]>;
1337 def t2STRB_POST : T2Iidxldst<0, 0b00, 0, 0, (outs GPRnopc:$base_wb),
1338 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr),
1339 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1340 "strb", "\t$Rt, [$Rn], $addr",
1341 "$Rn = $base_wb,@earlyclobber $base_wb",
1342 [(set GPRnopc:$base_wb,
1343 (post_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$addr))]>;
1345 // STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1347 // Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
1348 class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1349 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_imm8:$addr), ii, opc,
1350 "\t$Rt, $addr", []> {
1351 let Inst{31-27} = 0b11111;
1352 let Inst{26-25} = 0b00;
1353 let Inst{24} = 0; // not signed
1355 let Inst{22-21} = type;
1356 let Inst{20} = 0; // store
1358 let Inst{10-8} = 0b110; // PUW
1362 let Inst{15-12} = Rt;
1363 let Inst{19-16} = addr{12-9};
1364 let Inst{7-0} = addr{7-0};
1367 def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1368 def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1369 def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
1371 // ldrd / strd pre / post variants
1372 // For disassembly only.
1374 def t2LDRD_PRE : T2Ii8s4Tied<1, 1, 1,
1375 (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1376 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
1377 "ldrd", "\t$Rt, $Rt2, [$base, $imm]!", []>;
1379 def t2LDRD_POST : T2Ii8s4Tied<0, 1, 1,
1380 (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1381 (ins GPR:$base, t2am_imm8s4_offset:$imm), IIC_iLoad_d_ru,
1382 "ldrd", "\t$Rt, $Rt2, [$base], $imm", []>;
1384 def t2STRD_PRE : T2Ii8s4Tied<1, 1, 0, (outs GPR:$wb),
1385 (ins rGPR:$Rt, rGPR:$Rt2, GPR:$base, t2am_imm8s4_offset:$imm),
1386 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, [$base, $imm]!", []>;
1388 def t2STRD_POST : T2Ii8s4Tied<0, 1, 0, (outs GPR:$wb),
1389 (ins rGPR:$Rt, rGPR:$Rt2, GPR:$base, t2am_imm8s4_offset:$imm),
1390 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, [$base], $imm", []>;
1392 // T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1393 // data/instruction access. These are for disassembly only.
1394 // instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1395 // (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
1396 multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
1398 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
1400 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
1401 let Inst{31-25} = 0b1111100;
1402 let Inst{24} = instr;
1404 let Inst{21} = write;
1406 let Inst{15-12} = 0b1111;
1409 let addr{12} = 1; // add = TRUE
1410 let Inst{19-16} = addr{16-13}; // Rn
1411 let Inst{23} = addr{12}; // U
1412 let Inst{11-0} = addr{11-0}; // imm12
1415 def i8 : T2Ii8<(outs), (ins t2addrmode_imm8:$addr), IIC_Preload, opc,
1417 [(ARMPreload t2addrmode_imm8:$addr, (i32 write), (i32 instr))]> {
1418 let Inst{31-25} = 0b1111100;
1419 let Inst{24} = instr;
1420 let Inst{23} = 0; // U = 0
1422 let Inst{21} = write;
1424 let Inst{15-12} = 0b1111;
1425 let Inst{11-8} = 0b1100;
1428 let Inst{19-16} = addr{12-9}; // Rn
1429 let Inst{7-0} = addr{7-0}; // imm8
1432 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
1434 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
1435 let Inst{31-25} = 0b1111100;
1436 let Inst{24} = instr;
1437 let Inst{23} = 0; // add = TRUE for T1
1439 let Inst{21} = write;
1441 let Inst{15-12} = 0b1111;
1442 let Inst{11-6} = 0000000;
1445 let Inst{19-16} = addr{9-6}; // Rn
1446 let Inst{3-0} = addr{5-2}; // Rm
1447 let Inst{5-4} = addr{1-0}; // imm2
1449 let DecoderMethod = "DecodeT2LoadShift";
1453 defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1454 defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1455 defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
1457 //===----------------------------------------------------------------------===//
1458 // Load / store multiple Instructions.
1461 multiclass thumb2_ldst_mult<string asm, InstrItinClass itin,
1462 InstrItinClass itin_upd, bit L_bit> {
1464 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1465 itin, !strconcat(asm, "ia${p}.w\t$Rn, $regs"), []> {
1469 let Inst{31-27} = 0b11101;
1470 let Inst{26-25} = 0b00;
1471 let Inst{24-23} = 0b01; // Increment After
1473 let Inst{21} = 0; // No writeback
1474 let Inst{20} = L_bit;
1475 let Inst{19-16} = Rn;
1476 let Inst{15-0} = regs;
1479 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1480 itin_upd, !strconcat(asm, "ia${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1484 let Inst{31-27} = 0b11101;
1485 let Inst{26-25} = 0b00;
1486 let Inst{24-23} = 0b01; // Increment After
1488 let Inst{21} = 1; // Writeback
1489 let Inst{20} = L_bit;
1490 let Inst{19-16} = Rn;
1491 let Inst{15-0} = regs;
1494 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1495 itin, !strconcat(asm, "db${p}.w\t$Rn, $regs"), []> {
1499 let Inst{31-27} = 0b11101;
1500 let Inst{26-25} = 0b00;
1501 let Inst{24-23} = 0b10; // Decrement Before
1503 let Inst{21} = 0; // No writeback
1504 let Inst{20} = L_bit;
1505 let Inst{19-16} = Rn;
1506 let Inst{15-0} = regs;
1509 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1510 itin_upd, !strconcat(asm, "db${p}.w\t$Rn, $regs"), "$Rn = $wb", []> {
1514 let Inst{31-27} = 0b11101;
1515 let Inst{26-25} = 0b00;
1516 let Inst{24-23} = 0b10; // Decrement Before
1518 let Inst{21} = 1; // Writeback
1519 let Inst{20} = L_bit;
1520 let Inst{19-16} = Rn;
1521 let Inst{15-0} = regs;
1525 let neverHasSideEffects = 1 in {
1527 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1528 defm t2LDM : thumb2_ldst_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
1530 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1531 defm t2STM : thumb2_ldst_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
1533 } // neverHasSideEffects
1536 //===----------------------------------------------------------------------===//
1537 // Move Instructions.
1540 let neverHasSideEffects = 1 in
1541 def t2MOVr : T2sTwoReg<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVr,
1542 "mov", ".w\t$Rd, $Rm", []> {
1543 let Inst{31-27} = 0b11101;
1544 let Inst{26-25} = 0b01;
1545 let Inst{24-21} = 0b0010;
1546 let Inst{19-16} = 0b1111; // Rn
1547 let Inst{14-12} = 0b000;
1548 let Inst{7-4} = 0b0000;
1551 // AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1552 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
1553 AddedComplexity = 1 in
1554 def t2MOVi : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), IIC_iMOVi,
1555 "mov", ".w\t$Rd, $imm",
1556 [(set rGPR:$Rd, t2_so_imm:$imm)]> {
1557 let Inst{31-27} = 0b11110;
1559 let Inst{24-21} = 0b0010;
1560 let Inst{19-16} = 0b1111; // Rn
1564 def : t2InstAlias<"mov${s}${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1565 pred:$p, cc_out:$s)>;
1567 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
1568 def t2MOVi16 : T2I<(outs rGPR:$Rd), (ins imm0_65535_expr:$imm), IIC_iMOVi,
1569 "movw", "\t$Rd, $imm",
1570 [(set rGPR:$Rd, imm0_65535:$imm)]> {
1571 let Inst{31-27} = 0b11110;
1573 let Inst{24-21} = 0b0010;
1574 let Inst{20} = 0; // The S bit.
1580 let Inst{11-8} = Rd;
1581 let Inst{19-16} = imm{15-12};
1582 let Inst{26} = imm{11};
1583 let Inst{14-12} = imm{10-8};
1584 let Inst{7-0} = imm{7-0};
1587 def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
1588 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1590 let Constraints = "$src = $Rd" in {
1591 def t2MOVTi16 : T2I<(outs rGPR:$Rd),
1592 (ins rGPR:$src, imm0_65535_expr:$imm), IIC_iMOVi,
1593 "movt", "\t$Rd, $imm",
1595 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
1596 let Inst{31-27} = 0b11110;
1598 let Inst{24-21} = 0b0110;
1599 let Inst{20} = 0; // The S bit.
1605 let Inst{11-8} = Rd;
1606 let Inst{19-16} = imm{15-12};
1607 let Inst{26} = imm{11};
1608 let Inst{14-12} = imm{10-8};
1609 let Inst{7-0} = imm{7-0};
1612 def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
1613 (ins rGPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1616 def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
1618 //===----------------------------------------------------------------------===//
1619 // Extend Instructions.
1624 def t2SXTB : T2I_ext_rrot<0b100, "sxtb",
1625 UnOpFrag<(sext_inreg node:$Src, i8)>>;
1626 def t2SXTH : T2I_ext_rrot<0b000, "sxth",
1627 UnOpFrag<(sext_inreg node:$Src, i16)>>;
1628 def t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
1630 def t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
1631 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1632 def t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
1633 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1634 def t2SXTAB16 : T2I_exta_rrot_np<0b010, "sxtab16">;
1636 // TODO: SXT(A){B|H}16
1640 let AddedComplexity = 16 in {
1641 def t2UXTB : T2I_ext_rrot<0b101, "uxtb",
1642 UnOpFrag<(and node:$Src, 0x000000FF)>>;
1643 def t2UXTH : T2I_ext_rrot<0b001, "uxth",
1644 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1645 def t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
1646 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1648 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1649 // The transformation should probably be done as a combiner action
1650 // instead so we can include a check for masking back in the upper
1651 // eight bits of the source into the lower eight bits of the result.
1652 //def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
1653 // (t2UXTB16 rGPR:$Src, 3)>,
1654 // Requires<[HasT2ExtractPack, IsThumb2]>;
1655 def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
1656 (t2UXTB16 rGPR:$Src, 1)>,
1657 Requires<[HasT2ExtractPack, IsThumb2]>;
1659 def t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
1660 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1661 def t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
1662 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1663 def t2UXTAB16 : T2I_exta_rrot_np<0b011, "uxtab16">;
1666 //===----------------------------------------------------------------------===//
1667 // Arithmetic Instructions.
1670 defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1671 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1672 defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1673 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1675 // ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
1676 defm t2ADDS : T2I_bin_s_irs <0b1000, "add",
1677 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
1678 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
1679 defm t2SUBS : T2I_bin_s_irs <0b1101, "sub",
1680 IIC_iALUi, IIC_iALUr, IIC_iALUsi,
1681 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
1683 let hasPostISelHook = 1 in {
1684 defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
1685 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
1686 defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
1687 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
1691 defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
1692 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1693 defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb",
1694 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
1696 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1697 // The assume-no-carry-in form uses the negation of the input since add/sub
1698 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
1699 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1701 // The AddedComplexity preferences the first variant over the others since
1702 // it can be shrunk to a 16-bit wide encoding, while the others cannot.
1703 let AddedComplexity = 1 in
1704 def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1705 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1706 def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1707 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1708 def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1709 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1710 let AddedComplexity = 1 in
1711 def : T2Pat<(ARMaddc rGPR:$src, imm0_255_neg:$imm),
1712 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1713 def : T2Pat<(ARMaddc rGPR:$src, t2_so_imm_neg:$imm),
1714 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
1715 // The with-carry-in form matches bitwise not instead of the negation.
1716 // Effectively, the inverse interpretation of the carry flag already accounts
1717 // for part of the negation.
1718 let AddedComplexity = 1 in
1719 def : T2Pat<(ARMadde rGPR:$src, imm0_255_not:$imm, CPSR),
1720 (t2SBCri rGPR:$src, imm0_255_not:$imm)>;
1721 def : T2Pat<(ARMadde rGPR:$src, t2_so_imm_not:$imm, CPSR),
1722 (t2SBCri rGPR:$src, t2_so_imm_not:$imm)>;
1724 // Select Bytes -- for disassembly only
1726 def t2SEL : T2ThreeReg<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1727 NoItinerary, "sel", "\t$Rd, $Rn, $Rm", []>,
1728 Requires<[IsThumb2, HasThumb2DSP]> {
1729 let Inst{31-27} = 0b11111;
1730 let Inst{26-24} = 0b010;
1732 let Inst{22-20} = 0b010;
1733 let Inst{15-12} = 0b1111;
1735 let Inst{6-4} = 0b000;
1738 // A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1739 // And Miscellaneous operations -- for disassembly only
1740 class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1741 list<dag> pat = [/* For disassembly only; pattern left blank */],
1742 dag iops = (ins rGPR:$Rn, rGPR:$Rm),
1743 string asm = "\t$Rd, $Rn, $Rm">
1744 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, pat>,
1745 Requires<[IsThumb2, HasThumb2DSP]> {
1746 let Inst{31-27} = 0b11111;
1747 let Inst{26-23} = 0b0101;
1748 let Inst{22-20} = op22_20;
1749 let Inst{15-12} = 0b1111;
1750 let Inst{7-4} = op7_4;
1756 let Inst{11-8} = Rd;
1757 let Inst{19-16} = Rn;
1761 // Saturating add/subtract -- for disassembly only
1763 def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
1764 [(set rGPR:$Rd, (int_arm_qadd rGPR:$Rn, rGPR:$Rm))],
1765 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
1766 def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
1767 def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
1768 def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
1769 def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd", [],
1770 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
1771 def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub", [],
1772 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
1773 def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
1774 def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
1775 [(set rGPR:$Rd, (int_arm_qsub rGPR:$Rn, rGPR:$Rm))],
1776 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
1777 def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
1778 def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
1779 def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
1780 def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
1781 def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
1782 def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
1783 def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
1784 def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
1786 // Signed/Unsigned add/subtract -- for disassembly only
1788 def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
1789 def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
1790 def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
1791 def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
1792 def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
1793 def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
1794 def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
1795 def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
1796 def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
1797 def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
1798 def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
1799 def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
1801 // Signed/Unsigned halving add/subtract -- for disassembly only
1803 def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
1804 def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
1805 def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
1806 def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
1807 def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
1808 def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
1809 def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
1810 def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
1811 def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
1812 def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
1813 def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
1814 def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
1816 // Helper class for disassembly only
1817 // A6.3.16 & A6.3.17
1818 // T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
1819 class T2ThreeReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
1820 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
1821 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
1822 let Inst{31-27} = 0b11111;
1823 let Inst{26-24} = 0b011;
1824 let Inst{23} = long;
1825 let Inst{22-20} = op22_20;
1826 let Inst{7-4} = op7_4;
1829 class T2FourReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
1830 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
1831 : T2FourReg<oops, iops, itin, opc, asm, pattern> {
1832 let Inst{31-27} = 0b11111;
1833 let Inst{26-24} = 0b011;
1834 let Inst{23} = long;
1835 let Inst{22-20} = op22_20;
1836 let Inst{7-4} = op7_4;
1839 // Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
1841 def t2USAD8 : T2ThreeReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
1842 (ins rGPR:$Rn, rGPR:$Rm),
1843 NoItinerary, "usad8", "\t$Rd, $Rn, $Rm", []>,
1844 Requires<[IsThumb2, HasThumb2DSP]> {
1845 let Inst{15-12} = 0b1111;
1847 def t2USADA8 : T2FourReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
1848 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), NoItinerary,
1849 "usada8", "\t$Rd, $Rn, $Rm, $Ra", []>,
1850 Requires<[IsThumb2, HasThumb2DSP]>;
1852 // Signed/Unsigned saturate -- for disassembly only
1854 class T2SatI<dag oops, dag iops, InstrItinClass itin,
1855 string opc, string asm, list<dag> pattern>
1856 : T2I<oops, iops, itin, opc, asm, pattern> {
1862 let Inst{11-8} = Rd;
1863 let Inst{19-16} = Rn;
1864 let Inst{4-0} = sat_imm;
1865 let Inst{21} = sh{5};
1866 let Inst{14-12} = sh{4-2};
1867 let Inst{7-6} = sh{1-0};
1871 (outs rGPR:$Rd), (ins imm1_32:$sat_imm, rGPR:$Rn, shift_imm:$sh),
1872 NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh",
1873 [/* For disassembly only; pattern left blank */]> {
1874 let Inst{31-27} = 0b11110;
1875 let Inst{25-22} = 0b1100;
1880 def t2SSAT16: T2SatI<
1881 (outs rGPR:$Rd), (ins imm1_16:$sat_imm, rGPR:$Rn), NoItinerary,
1882 "ssat16", "\t$Rd, $sat_imm, $Rn",
1883 [/* For disassembly only; pattern left blank */]>,
1884 Requires<[IsThumb2, HasThumb2DSP]> {
1885 let Inst{31-27} = 0b11110;
1886 let Inst{25-22} = 0b1100;
1889 let Inst{21} = 1; // sh = '1'
1890 let Inst{14-12} = 0b000; // imm3 = '000'
1891 let Inst{7-6} = 0b00; // imm2 = '00'
1895 (outs rGPR:$Rd), (ins i32imm:$sat_imm, rGPR:$Rn, shift_imm:$sh),
1896 NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh",
1897 [/* For disassembly only; pattern left blank */]> {
1898 let Inst{31-27} = 0b11110;
1899 let Inst{25-22} = 0b1110;
1904 def t2USAT16: T2SatI<(outs rGPR:$Rd), (ins i32imm:$sat_imm, rGPR:$Rn),
1906 "usat16", "\t$Rd, $sat_imm, $Rn",
1907 [/* For disassembly only; pattern left blank */]>,
1908 Requires<[IsThumb2, HasThumb2DSP]> {
1909 let Inst{31-27} = 0b11110;
1910 let Inst{25-22} = 0b1110;
1913 let Inst{21} = 1; // sh = '1'
1914 let Inst{14-12} = 0b000; // imm3 = '000'
1915 let Inst{7-6} = 0b00; // imm2 = '00'
1918 def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
1919 def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
1921 //===----------------------------------------------------------------------===//
1922 // Shift and rotate Instructions.
1925 defm t2LSL : T2I_sh_ir<0b00, "lsl", imm1_31, BinOpFrag<(shl node:$LHS, node:$RHS)>>;
1926 defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr, BinOpFrag<(srl node:$LHS, node:$RHS)>>;
1927 defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr, BinOpFrag<(sra node:$LHS, node:$RHS)>>;
1928 defm t2ROR : T2I_sh_ir<0b11, "ror", imm1_31, BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
1930 // (rotr x, (and y, 0x...1f)) ==> (ROR x, y)
1931 def : Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)),
1932 (t2RORrr rGPR:$lhs, rGPR:$rhs)>;
1934 let Uses = [CPSR] in {
1935 def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1936 "rrx", "\t$Rd, $Rm",
1937 [(set rGPR:$Rd, (ARMrrx rGPR:$Rm))]> {
1938 let Inst{31-27} = 0b11101;
1939 let Inst{26-25} = 0b01;
1940 let Inst{24-21} = 0b0010;
1941 let Inst{19-16} = 0b1111; // Rn
1942 let Inst{14-12} = 0b000;
1943 let Inst{7-4} = 0b0011;
1947 let isCodeGenOnly = 1, Defs = [CPSR] in {
1948 def t2MOVsrl_flag : T2TwoRegShiftImm<
1949 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1950 "lsrs", ".w\t$Rd, $Rm, #1",
1951 [(set rGPR:$Rd, (ARMsrl_flag rGPR:$Rm))]> {
1952 let Inst{31-27} = 0b11101;
1953 let Inst{26-25} = 0b01;
1954 let Inst{24-21} = 0b0010;
1955 let Inst{20} = 1; // The S bit.
1956 let Inst{19-16} = 0b1111; // Rn
1957 let Inst{5-4} = 0b01; // Shift type.
1958 // Shift amount = Inst{14-12:7-6} = 1.
1959 let Inst{14-12} = 0b000;
1960 let Inst{7-6} = 0b01;
1962 def t2MOVsra_flag : T2TwoRegShiftImm<
1963 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
1964 "asrs", ".w\t$Rd, $Rm, #1",
1965 [(set rGPR:$Rd, (ARMsra_flag rGPR:$Rm))]> {
1966 let Inst{31-27} = 0b11101;
1967 let Inst{26-25} = 0b01;
1968 let Inst{24-21} = 0b0010;
1969 let Inst{20} = 1; // The S bit.
1970 let Inst{19-16} = 0b1111; // Rn
1971 let Inst{5-4} = 0b10; // Shift type.
1972 // Shift amount = Inst{14-12:7-6} = 1.
1973 let Inst{14-12} = 0b000;
1974 let Inst{7-6} = 0b01;
1978 //===----------------------------------------------------------------------===//
1979 // Bitwise Instructions.
1982 defm t2AND : T2I_bin_w_irs<0b0000, "and",
1983 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
1984 BinOpFrag<(and node:$LHS, node:$RHS)>, "t2AND", 1>;
1985 defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
1986 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
1987 BinOpFrag<(or node:$LHS, node:$RHS)>, "t2ORR", 1>;
1988 defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
1989 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
1990 BinOpFrag<(xor node:$LHS, node:$RHS)>, "t2EOR", 1>;
1992 defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
1993 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
1994 BinOpFrag<(and node:$LHS, (not node:$RHS))>,
1997 class T2BitFI<dag oops, dag iops, InstrItinClass itin,
1998 string opc, string asm, list<dag> pattern>
1999 : T2I<oops, iops, itin, opc, asm, pattern> {
2004 let Inst{11-8} = Rd;
2005 let Inst{4-0} = msb{4-0};
2006 let Inst{14-12} = lsb{4-2};
2007 let Inst{7-6} = lsb{1-0};
2010 class T2TwoRegBitFI<dag oops, dag iops, InstrItinClass itin,
2011 string opc, string asm, list<dag> pattern>
2012 : T2BitFI<oops, iops, itin, opc, asm, pattern> {
2015 let Inst{19-16} = Rn;
2018 let Constraints = "$src = $Rd" in
2019 def t2BFC : T2BitFI<(outs rGPR:$Rd), (ins rGPR:$src, bf_inv_mask_imm:$imm),
2020 IIC_iUNAsi, "bfc", "\t$Rd, $imm",
2021 [(set rGPR:$Rd, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
2022 let Inst{31-27} = 0b11110;
2023 let Inst{26} = 0; // should be 0.
2025 let Inst{24-20} = 0b10110;
2026 let Inst{19-16} = 0b1111; // Rn
2028 let Inst{5} = 0; // should be 0.
2031 let msb{4-0} = imm{9-5};
2032 let lsb{4-0} = imm{4-0};
2035 def t2SBFX: T2TwoRegBitFI<
2036 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2037 IIC_iUNAsi, "sbfx", "\t$Rd, $Rn, $lsb, $msb", []> {
2038 let Inst{31-27} = 0b11110;
2040 let Inst{24-20} = 0b10100;
2044 def t2UBFX: T2TwoRegBitFI<
2045 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2046 IIC_iUNAsi, "ubfx", "\t$Rd, $Rn, $lsb, $msb", []> {
2047 let Inst{31-27} = 0b11110;
2049 let Inst{24-20} = 0b11100;
2053 // A8.6.18 BFI - Bitfield insert (Encoding T1)
2054 let Constraints = "$src = $Rd" in {
2055 def t2BFI : T2TwoRegBitFI<(outs rGPR:$Rd),
2056 (ins rGPR:$src, rGPR:$Rn, bf_inv_mask_imm:$imm),
2057 IIC_iBITi, "bfi", "\t$Rd, $Rn, $imm",
2058 [(set rGPR:$Rd, (ARMbfi rGPR:$src, rGPR:$Rn,
2059 bf_inv_mask_imm:$imm))]> {
2060 let Inst{31-27} = 0b11110;
2061 let Inst{26} = 0; // should be 0.
2063 let Inst{24-20} = 0b10110;
2065 let Inst{5} = 0; // should be 0.
2068 let msb{4-0} = imm{9-5};
2069 let lsb{4-0} = imm{4-0};
2072 // GNU as only supports this form of bfi (w/ 4 arguments)
2073 let isAsmParserOnly = 1 in
2074 def t2BFI4p : T2TwoRegBitFI<(outs rGPR:$Rd),
2075 (ins rGPR:$src, rGPR:$Rn, lsb_pos_imm:$lsbit,
2077 IIC_iBITi, "bfi", "\t$Rd, $Rn, $lsbit, $width",
2079 let Inst{31-27} = 0b11110;
2080 let Inst{26} = 0; // should be 0.
2082 let Inst{24-20} = 0b10110;
2084 let Inst{5} = 0; // should be 0.
2088 let msb{4-0} = width; // Custom encoder => lsb+width-1
2089 let lsb{4-0} = lsbit;
2093 defm t2ORN : T2I_bin_irs<0b0011, "orn",
2094 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2095 BinOpFrag<(or node:$LHS, (not node:$RHS))>,
2098 // Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
2099 let AddedComplexity = 1 in
2100 defm t2MVN : T2I_un_irs <0b0011, "mvn",
2101 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
2102 UnOpFrag<(not node:$Src)>, 1, 1>;
2105 let AddedComplexity = 1 in
2106 def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
2107 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
2109 // FIXME: Disable this pattern on Darwin to workaround an assembler bug.
2110 def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
2111 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
2112 Requires<[IsThumb2]>;
2114 def : T2Pat<(t2_so_imm_not:$src),
2115 (t2MVNi t2_so_imm_not:$src)>;
2117 //===----------------------------------------------------------------------===//
2118 // Multiply Instructions.
2120 let isCommutable = 1 in
2121 def t2MUL: T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2122 "mul", "\t$Rd, $Rn, $Rm",
2123 [(set rGPR:$Rd, (mul rGPR:$Rn, rGPR:$Rm))]> {
2124 let Inst{31-27} = 0b11111;
2125 let Inst{26-23} = 0b0110;
2126 let Inst{22-20} = 0b000;
2127 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2128 let Inst{7-4} = 0b0000; // Multiply
2131 def t2MLA: T2FourReg<
2132 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2133 "mla", "\t$Rd, $Rn, $Rm, $Ra",
2134 [(set rGPR:$Rd, (add (mul rGPR:$Rn, rGPR:$Rm), rGPR:$Ra))]> {
2135 let Inst{31-27} = 0b11111;
2136 let Inst{26-23} = 0b0110;
2137 let Inst{22-20} = 0b000;
2138 let Inst{7-4} = 0b0000; // Multiply
2141 def t2MLS: T2FourReg<
2142 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2143 "mls", "\t$Rd, $Rn, $Rm, $Ra",
2144 [(set rGPR:$Rd, (sub rGPR:$Ra, (mul rGPR:$Rn, rGPR:$Rm)))]> {
2145 let Inst{31-27} = 0b11111;
2146 let Inst{26-23} = 0b0110;
2147 let Inst{22-20} = 0b000;
2148 let Inst{7-4} = 0b0001; // Multiply and Subtract
2151 // Extra precision multiplies with low / high results
2152 let neverHasSideEffects = 1 in {
2153 let isCommutable = 1 in {
2154 def t2SMULL : T2MulLong<0b000, 0b0000,
2155 (outs rGPR:$RdLo, rGPR:$RdHi),
2156 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
2157 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2159 def t2UMULL : T2MulLong<0b010, 0b0000,
2160 (outs rGPR:$RdLo, rGPR:$RdHi),
2161 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
2162 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2165 // Multiply + accumulate
2166 def t2SMLAL : T2MulLong<0b100, 0b0000,
2167 (outs rGPR:$RdLo, rGPR:$RdHi),
2168 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2169 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2171 def t2UMLAL : T2MulLong<0b110, 0b0000,
2172 (outs rGPR:$RdLo, rGPR:$RdHi),
2173 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2174 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2176 def t2UMAAL : T2MulLong<0b110, 0b0110,
2177 (outs rGPR:$RdLo, rGPR:$RdHi),
2178 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2179 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2180 Requires<[IsThumb2, HasThumb2DSP]>;
2181 } // neverHasSideEffects
2183 // Rounding variants of the below included for disassembly only
2185 // Most significant word multiply
2186 def t2SMMUL : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2187 "smmul", "\t$Rd, $Rn, $Rm",
2188 [(set rGPR:$Rd, (mulhs rGPR:$Rn, rGPR:$Rm))]>,
2189 Requires<[IsThumb2, HasThumb2DSP]> {
2190 let Inst{31-27} = 0b11111;
2191 let Inst{26-23} = 0b0110;
2192 let Inst{22-20} = 0b101;
2193 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2194 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2197 def t2SMMULR : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2198 "smmulr", "\t$Rd, $Rn, $Rm", []>,
2199 Requires<[IsThumb2, HasThumb2DSP]> {
2200 let Inst{31-27} = 0b11111;
2201 let Inst{26-23} = 0b0110;
2202 let Inst{22-20} = 0b101;
2203 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2204 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2207 def t2SMMLA : T2FourReg<
2208 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2209 "smmla", "\t$Rd, $Rn, $Rm, $Ra",
2210 [(set rGPR:$Rd, (add (mulhs rGPR:$Rm, rGPR:$Rn), rGPR:$Ra))]>,
2211 Requires<[IsThumb2, HasThumb2DSP]> {
2212 let Inst{31-27} = 0b11111;
2213 let Inst{26-23} = 0b0110;
2214 let Inst{22-20} = 0b101;
2215 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2218 def t2SMMLAR: T2FourReg<
2219 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2220 "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
2221 Requires<[IsThumb2, HasThumb2DSP]> {
2222 let Inst{31-27} = 0b11111;
2223 let Inst{26-23} = 0b0110;
2224 let Inst{22-20} = 0b101;
2225 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2228 def t2SMMLS: T2FourReg<
2229 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2230 "smmls", "\t$Rd, $Rn, $Rm, $Ra",
2231 [(set rGPR:$Rd, (sub rGPR:$Ra, (mulhs rGPR:$Rn, rGPR:$Rm)))]>,
2232 Requires<[IsThumb2, HasThumb2DSP]> {
2233 let Inst{31-27} = 0b11111;
2234 let Inst{26-23} = 0b0110;
2235 let Inst{22-20} = 0b110;
2236 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2239 def t2SMMLSR:T2FourReg<
2240 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2241 "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
2242 Requires<[IsThumb2, HasThumb2DSP]> {
2243 let Inst{31-27} = 0b11111;
2244 let Inst{26-23} = 0b0110;
2245 let Inst{22-20} = 0b110;
2246 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2249 multiclass T2I_smul<string opc, PatFrag opnode> {
2250 def BB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2251 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
2252 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
2253 (sext_inreg rGPR:$Rm, i16)))]>,
2254 Requires<[IsThumb2, HasThumb2DSP]> {
2255 let Inst{31-27} = 0b11111;
2256 let Inst{26-23} = 0b0110;
2257 let Inst{22-20} = 0b001;
2258 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2259 let Inst{7-6} = 0b00;
2260 let Inst{5-4} = 0b00;
2263 def BT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2264 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
2265 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
2266 (sra rGPR:$Rm, (i32 16))))]>,
2267 Requires<[IsThumb2, HasThumb2DSP]> {
2268 let Inst{31-27} = 0b11111;
2269 let Inst{26-23} = 0b0110;
2270 let Inst{22-20} = 0b001;
2271 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2272 let Inst{7-6} = 0b00;
2273 let Inst{5-4} = 0b01;
2276 def TB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2277 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
2278 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
2279 (sext_inreg rGPR:$Rm, i16)))]>,
2280 Requires<[IsThumb2, HasThumb2DSP]> {
2281 let Inst{31-27} = 0b11111;
2282 let Inst{26-23} = 0b0110;
2283 let Inst{22-20} = 0b001;
2284 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2285 let Inst{7-6} = 0b00;
2286 let Inst{5-4} = 0b10;
2289 def TT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2290 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
2291 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
2292 (sra rGPR:$Rm, (i32 16))))]>,
2293 Requires<[IsThumb2, HasThumb2DSP]> {
2294 let Inst{31-27} = 0b11111;
2295 let Inst{26-23} = 0b0110;
2296 let Inst{22-20} = 0b001;
2297 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2298 let Inst{7-6} = 0b00;
2299 let Inst{5-4} = 0b11;
2302 def WB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2303 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
2304 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
2305 (sext_inreg rGPR:$Rm, i16)), (i32 16)))]>,
2306 Requires<[IsThumb2, HasThumb2DSP]> {
2307 let Inst{31-27} = 0b11111;
2308 let Inst{26-23} = 0b0110;
2309 let Inst{22-20} = 0b011;
2310 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2311 let Inst{7-6} = 0b00;
2312 let Inst{5-4} = 0b00;
2315 def WT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2316 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
2317 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
2318 (sra rGPR:$Rm, (i32 16))), (i32 16)))]>,
2319 Requires<[IsThumb2, HasThumb2DSP]> {
2320 let Inst{31-27} = 0b11111;
2321 let Inst{26-23} = 0b0110;
2322 let Inst{22-20} = 0b011;
2323 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2324 let Inst{7-6} = 0b00;
2325 let Inst{5-4} = 0b01;
2330 multiclass T2I_smla<string opc, PatFrag opnode> {
2332 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2333 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
2334 [(set rGPR:$Rd, (add rGPR:$Ra,
2335 (opnode (sext_inreg rGPR:$Rn, i16),
2336 (sext_inreg rGPR:$Rm, i16))))]>,
2337 Requires<[IsThumb2, HasThumb2DSP]> {
2338 let Inst{31-27} = 0b11111;
2339 let Inst{26-23} = 0b0110;
2340 let Inst{22-20} = 0b001;
2341 let Inst{7-6} = 0b00;
2342 let Inst{5-4} = 0b00;
2346 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2347 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
2348 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sext_inreg rGPR:$Rn, i16),
2349 (sra rGPR:$Rm, (i32 16)))))]>,
2350 Requires<[IsThumb2, HasThumb2DSP]> {
2351 let Inst{31-27} = 0b11111;
2352 let Inst{26-23} = 0b0110;
2353 let Inst{22-20} = 0b001;
2354 let Inst{7-6} = 0b00;
2355 let Inst{5-4} = 0b01;
2359 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2360 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
2361 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
2362 (sext_inreg rGPR:$Rm, i16))))]>,
2363 Requires<[IsThumb2, HasThumb2DSP]> {
2364 let Inst{31-27} = 0b11111;
2365 let Inst{26-23} = 0b0110;
2366 let Inst{22-20} = 0b001;
2367 let Inst{7-6} = 0b00;
2368 let Inst{5-4} = 0b10;
2372 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2373 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
2374 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
2375 (sra rGPR:$Rm, (i32 16)))))]>,
2376 Requires<[IsThumb2, HasThumb2DSP]> {
2377 let Inst{31-27} = 0b11111;
2378 let Inst{26-23} = 0b0110;
2379 let Inst{22-20} = 0b001;
2380 let Inst{7-6} = 0b00;
2381 let Inst{5-4} = 0b11;
2385 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2386 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
2387 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
2388 (sext_inreg rGPR:$Rm, i16)), (i32 16))))]>,
2389 Requires<[IsThumb2, HasThumb2DSP]> {
2390 let Inst{31-27} = 0b11111;
2391 let Inst{26-23} = 0b0110;
2392 let Inst{22-20} = 0b011;
2393 let Inst{7-6} = 0b00;
2394 let Inst{5-4} = 0b00;
2398 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2399 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
2400 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
2401 (sra rGPR:$Rm, (i32 16))), (i32 16))))]>,
2402 Requires<[IsThumb2, HasThumb2DSP]> {
2403 let Inst{31-27} = 0b11111;
2404 let Inst{26-23} = 0b0110;
2405 let Inst{22-20} = 0b011;
2406 let Inst{7-6} = 0b00;
2407 let Inst{5-4} = 0b01;
2411 defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2412 defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2414 // Halfword multiple accumulate long: SMLAL<x><y> -- for disassembly only
2415 def t2SMLALBB : T2FourReg_mac<1, 0b100, 0b1000, (outs rGPR:$Ra,rGPR:$Rd),
2416 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbb", "\t$Ra, $Rd, $Rn, $Rm",
2417 [/* For disassembly only; pattern left blank */]>,
2418 Requires<[IsThumb2, HasThumb2DSP]>;
2419 def t2SMLALBT : T2FourReg_mac<1, 0b100, 0b1001, (outs rGPR:$Ra,rGPR:$Rd),
2420 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbt", "\t$Ra, $Rd, $Rn, $Rm",
2421 [/* For disassembly only; pattern left blank */]>,
2422 Requires<[IsThumb2, HasThumb2DSP]>;
2423 def t2SMLALTB : T2FourReg_mac<1, 0b100, 0b1010, (outs rGPR:$Ra,rGPR:$Rd),
2424 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltb", "\t$Ra, $Rd, $Rn, $Rm",
2425 [/* For disassembly only; pattern left blank */]>,
2426 Requires<[IsThumb2, HasThumb2DSP]>;
2427 def t2SMLALTT : T2FourReg_mac<1, 0b100, 0b1011, (outs rGPR:$Ra,rGPR:$Rd),
2428 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltt", "\t$Ra, $Rd, $Rn, $Rm",
2429 [/* For disassembly only; pattern left blank */]>,
2430 Requires<[IsThumb2, HasThumb2DSP]>;
2432 // Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2433 // These are for disassembly only.
2435 def t2SMUAD: T2ThreeReg_mac<
2436 0, 0b010, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2437 IIC_iMAC32, "smuad", "\t$Rd, $Rn, $Rm", []>,
2438 Requires<[IsThumb2, HasThumb2DSP]> {
2439 let Inst{15-12} = 0b1111;
2441 def t2SMUADX:T2ThreeReg_mac<
2442 0, 0b010, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2443 IIC_iMAC32, "smuadx", "\t$Rd, $Rn, $Rm", []>,
2444 Requires<[IsThumb2, HasThumb2DSP]> {
2445 let Inst{15-12} = 0b1111;
2447 def t2SMUSD: T2ThreeReg_mac<
2448 0, 0b100, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2449 IIC_iMAC32, "smusd", "\t$Rd, $Rn, $Rm", []>,
2450 Requires<[IsThumb2, HasThumb2DSP]> {
2451 let Inst{15-12} = 0b1111;
2453 def t2SMUSDX:T2ThreeReg_mac<
2454 0, 0b100, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2455 IIC_iMAC32, "smusdx", "\t$Rd, $Rn, $Rm", []>,
2456 Requires<[IsThumb2, HasThumb2DSP]> {
2457 let Inst{15-12} = 0b1111;
2459 def t2SMLAD : T2FourReg_mac<
2460 0, 0b010, 0b0000, (outs rGPR:$Rd),
2461 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlad",
2462 "\t$Rd, $Rn, $Rm, $Ra", []>,
2463 Requires<[IsThumb2, HasThumb2DSP]>;
2464 def t2SMLADX : T2FourReg_mac<
2465 0, 0b010, 0b0001, (outs rGPR:$Rd),
2466 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smladx",
2467 "\t$Rd, $Rn, $Rm, $Ra", []>,
2468 Requires<[IsThumb2, HasThumb2DSP]>;
2469 def t2SMLSD : T2FourReg_mac<0, 0b100, 0b0000, (outs rGPR:$Rd),
2470 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsd",
2471 "\t$Rd, $Rn, $Rm, $Ra", []>,
2472 Requires<[IsThumb2, HasThumb2DSP]>;
2473 def t2SMLSDX : T2FourReg_mac<0, 0b100, 0b0001, (outs rGPR:$Rd),
2474 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsdx",
2475 "\t$Rd, $Rn, $Rm, $Ra", []>,
2476 Requires<[IsThumb2, HasThumb2DSP]>;
2477 def t2SMLALD : T2FourReg_mac<1, 0b100, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
2478 (ins rGPR:$Rm, rGPR:$Rn), IIC_iMAC64, "smlald",
2479 "\t$Ra, $Rd, $Rm, $Rn", []>,
2480 Requires<[IsThumb2, HasThumb2DSP]>;
2481 def t2SMLALDX : T2FourReg_mac<1, 0b100, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2482 (ins rGPR:$Rm,rGPR:$Rn), IIC_iMAC64, "smlaldx",
2483 "\t$Ra, $Rd, $Rm, $Rn", []>,
2484 Requires<[IsThumb2, HasThumb2DSP]>;
2485 def t2SMLSLD : T2FourReg_mac<1, 0b101, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
2486 (ins rGPR:$Rm,rGPR:$Rn), IIC_iMAC64, "smlsld",
2487 "\t$Ra, $Rd, $Rm, $Rn", []>,
2488 Requires<[IsThumb2, HasThumb2DSP]>;
2489 def t2SMLSLDX : T2FourReg_mac<1, 0b101, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2490 (ins rGPR:$Rm,rGPR:$Rn), IIC_iMAC64, "smlsldx",
2491 "\t$Ra, $Rd, $Rm, $Rn", []>,
2492 Requires<[IsThumb2, HasThumb2DSP]>;
2494 //===----------------------------------------------------------------------===//
2495 // Division Instructions.
2496 // Signed and unsigned division on v7-M
2498 def t2SDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUi,
2499 "sdiv", "\t$Rd, $Rn, $Rm",
2500 [(set rGPR:$Rd, (sdiv rGPR:$Rn, rGPR:$Rm))]>,
2501 Requires<[HasDivide, IsThumb2]> {
2502 let Inst{31-27} = 0b11111;
2503 let Inst{26-21} = 0b011100;
2505 let Inst{15-12} = 0b1111;
2506 let Inst{7-4} = 0b1111;
2509 def t2UDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUi,
2510 "udiv", "\t$Rd, $Rn, $Rm",
2511 [(set rGPR:$Rd, (udiv rGPR:$Rn, rGPR:$Rm))]>,
2512 Requires<[HasDivide, IsThumb2]> {
2513 let Inst{31-27} = 0b11111;
2514 let Inst{26-21} = 0b011101;
2516 let Inst{15-12} = 0b1111;
2517 let Inst{7-4} = 0b1111;
2520 //===----------------------------------------------------------------------===//
2521 // Misc. Arithmetic Instructions.
2524 class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2525 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2526 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2527 let Inst{31-27} = 0b11111;
2528 let Inst{26-22} = 0b01010;
2529 let Inst{21-20} = op1;
2530 let Inst{15-12} = 0b1111;
2531 let Inst{7-6} = 0b10;
2532 let Inst{5-4} = op2;
2536 def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2537 "clz", "\t$Rd, $Rm", [(set rGPR:$Rd, (ctlz rGPR:$Rm))]>;
2539 def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2540 "rbit", "\t$Rd, $Rm",
2541 [(set rGPR:$Rd, (ARMrbit rGPR:$Rm))]>;
2543 def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2544 "rev", ".w\t$Rd, $Rm", [(set rGPR:$Rd, (bswap rGPR:$Rm))]>;
2546 def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2547 "rev16", ".w\t$Rd, $Rm",
2548 [(set rGPR:$Rd, (rotr (bswap rGPR:$Rm), (i32 16)))]>;
2550 def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2551 "revsh", ".w\t$Rd, $Rm",
2552 [(set rGPR:$Rd, (sra (bswap rGPR:$Rm), (i32 16)))]>;
2554 def : T2Pat<(or (sra (shl rGPR:$Rm, (i32 24)), (i32 16)),
2555 (and (srl rGPR:$Rm, (i32 8)), 0xFF)),
2556 (t2REVSH rGPR:$Rm)>;
2558 def t2PKHBT : T2ThreeReg<
2559 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, i32imm:$sh),
2560 IIC_iBITsi, "pkhbt", "\t$Rd, $Rn, $Rm, lsl $sh",
2561 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF),
2562 (and (shl rGPR:$Rm, pkh_lsl_amt:$sh),
2564 Requires<[HasT2ExtractPack, IsThumb2]> {
2565 let Inst{31-27} = 0b11101;
2566 let Inst{26-25} = 0b01;
2567 let Inst{24-20} = 0b01100;
2568 let Inst{5} = 0; // BT form
2572 let Inst{14-12} = sh{4-2};
2573 let Inst{7-6} = sh{1-0};
2576 // Alternate cases for PKHBT where identities eliminate some nodes.
2577 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2578 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
2579 Requires<[HasT2ExtractPack, IsThumb2]>;
2580 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2581 (t2PKHBT rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
2582 Requires<[HasT2ExtractPack, IsThumb2]>;
2584 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2585 // will match the pattern below.
2586 def t2PKHTB : T2ThreeReg<
2587 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, i32imm:$sh),
2588 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm, asr $sh",
2589 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF0000),
2590 (and (sra rGPR:$Rm, pkh_asr_amt:$sh),
2592 Requires<[HasT2ExtractPack, IsThumb2]> {
2593 let Inst{31-27} = 0b11101;
2594 let Inst{26-25} = 0b01;
2595 let Inst{24-20} = 0b01100;
2596 let Inst{5} = 1; // TB form
2600 let Inst{14-12} = sh{4-2};
2601 let Inst{7-6} = sh{1-0};
2604 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
2605 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
2606 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
2607 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
2608 Requires<[HasT2ExtractPack, IsThumb2]>;
2609 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
2610 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2611 (t2PKHTB rGPR:$src1, rGPR:$src2, imm1_15:$sh)>,
2612 Requires<[HasT2ExtractPack, IsThumb2]>;
2614 //===----------------------------------------------------------------------===//
2615 // Comparison Instructions...
2617 defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
2618 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
2619 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2621 def : T2Pat<(ARMcmpZ GPR:$lhs, t2_so_imm:$imm),
2622 (t2CMPri GPR:$lhs, t2_so_imm:$imm)>;
2623 def : T2Pat<(ARMcmpZ GPR:$lhs, rGPR:$rhs),
2624 (t2CMPrr GPR:$lhs, rGPR:$rhs)>;
2625 def : T2Pat<(ARMcmpZ GPR:$lhs, t2_so_reg:$rhs),
2626 (t2CMPrs GPR:$lhs, t2_so_reg:$rhs)>;
2628 //FIXME: Disable CMN, as CCodes are backwards from compare expectations
2629 // Compare-to-zero still works out, just not the relationals
2630 //defm t2CMN : T2I_cmp_irs<0b1000, "cmn",
2631 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
2632 defm t2CMNz : T2I_cmp_irs<0b1000, "cmn",
2633 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
2634 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2636 //def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2637 // (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
2639 def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
2640 (t2CMNzri GPR:$src, t2_so_imm_neg:$imm)>;
2642 defm t2TST : T2I_cmp_irs<0b0000, "tst",
2643 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2644 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>;
2645 defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
2646 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2647 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>;
2649 // Conditional moves
2650 // FIXME: should be able to write a pattern for ARMcmov, but can't use
2651 // a two-value operand where a dag node expects two operands. :(
2652 let neverHasSideEffects = 1 in {
2653 def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd),
2654 (ins rGPR:$false, rGPR:$Rm, pred:$p),
2656 [/*(set rGPR:$Rd, (ARMcmov rGPR:$false, rGPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
2657 RegConstraint<"$false = $Rd">;
2659 let isMoveImm = 1 in
2660 def t2MOVCCi : t2PseudoInst<(outs rGPR:$Rd),
2661 (ins rGPR:$false, t2_so_imm:$imm, pred:$p),
2663 [/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
2664 RegConstraint<"$false = $Rd">;
2666 // FIXME: Pseudo-ize these. For now, just mark codegen only.
2667 let isCodeGenOnly = 1 in {
2668 let isMoveImm = 1 in
2669 def t2MOVCCi16 : T2I<(outs rGPR:$Rd), (ins rGPR:$false, imm0_65535_expr:$imm),
2671 "movw", "\t$Rd, $imm", []>,
2672 RegConstraint<"$false = $Rd"> {
2673 let Inst{31-27} = 0b11110;
2675 let Inst{24-21} = 0b0010;
2676 let Inst{20} = 0; // The S bit.
2682 let Inst{11-8} = Rd;
2683 let Inst{19-16} = imm{15-12};
2684 let Inst{26} = imm{11};
2685 let Inst{14-12} = imm{10-8};
2686 let Inst{7-0} = imm{7-0};
2689 let isMoveImm = 1 in
2690 def t2MOVCCi32imm : PseudoInst<(outs rGPR:$dst),
2691 (ins rGPR:$false, i32imm:$src, pred:$p),
2692 IIC_iCMOVix2, []>, RegConstraint<"$false = $dst">;
2694 let isMoveImm = 1 in
2695 def t2MVNCCi : T2OneRegImm<(outs rGPR:$Rd), (ins rGPR:$false, t2_so_imm:$imm),
2696 IIC_iCMOVi, "mvn", ".w\t$Rd, $imm",
2697 [/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm_not:$imm,
2698 imm:$cc, CCR:$ccr))*/]>,
2699 RegConstraint<"$false = $Rd"> {
2700 let Inst{31-27} = 0b11110;
2702 let Inst{24-21} = 0b0011;
2703 let Inst{20} = 0; // The S bit.
2704 let Inst{19-16} = 0b1111; // Rn
2708 class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
2709 string opc, string asm, list<dag> pattern>
2710 : T2TwoRegShiftImm<oops, iops, itin, opc, asm, pattern> {
2711 let Inst{31-27} = 0b11101;
2712 let Inst{26-25} = 0b01;
2713 let Inst{24-21} = 0b0010;
2714 let Inst{20} = 0; // The S bit.
2715 let Inst{19-16} = 0b1111; // Rn
2716 let Inst{5-4} = opcod; // Shift type.
2718 def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$Rd),
2719 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2720 IIC_iCMOVsi, "lsl", ".w\t$Rd, $Rm, $imm", []>,
2721 RegConstraint<"$false = $Rd">;
2722 def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$Rd),
2723 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2724 IIC_iCMOVsi, "lsr", ".w\t$Rd, $Rm, $imm", []>,
2725 RegConstraint<"$false = $Rd">;
2726 def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$Rd),
2727 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2728 IIC_iCMOVsi, "asr", ".w\t$Rd, $Rm, $imm", []>,
2729 RegConstraint<"$false = $Rd">;
2730 def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$Rd),
2731 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
2732 IIC_iCMOVsi, "ror", ".w\t$Rd, $Rm, $imm", []>,
2733 RegConstraint<"$false = $Rd">;
2734 } // isCodeGenOnly = 1
2735 } // neverHasSideEffects
2737 //===----------------------------------------------------------------------===//
2738 // Atomic operations intrinsics
2741 // memory barriers protect the atomic sequences
2742 let hasSideEffects = 1 in {
2743 def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2744 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
2745 Requires<[IsThumb, HasDB]> {
2747 let Inst{31-4} = 0xf3bf8f5;
2748 let Inst{3-0} = opt;
2752 def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
2754 [/* For disassembly only; pattern left blank */]>,
2755 Requires<[IsThumb, HasDB]> {
2757 let Inst{31-4} = 0xf3bf8f4;
2758 let Inst{3-0} = opt;
2761 // ISB has only full system option -- for disassembly only
2762 def t2ISB : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "isb", "",
2763 [/* For disassembly only; pattern left blank */]>,
2764 Requires<[IsThumb2, HasV7]> {
2765 let Inst{31-4} = 0xf3bf8f6;
2766 let Inst{3-0} = 0b1111;
2769 class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
2770 InstrItinClass itin, string opc, string asm, string cstr,
2771 list<dag> pattern, bits<4> rt2 = 0b1111>
2772 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2773 let Inst{31-27} = 0b11101;
2774 let Inst{26-20} = 0b0001101;
2775 let Inst{11-8} = rt2;
2776 let Inst{7-6} = 0b01;
2777 let Inst{5-4} = opcod;
2778 let Inst{3-0} = 0b1111;
2782 let Inst{19-16} = addr;
2783 let Inst{15-12} = Rt;
2785 class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
2786 InstrItinClass itin, string opc, string asm, string cstr,
2787 list<dag> pattern, bits<4> rt2 = 0b1111>
2788 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
2789 let Inst{31-27} = 0b11101;
2790 let Inst{26-20} = 0b0001100;
2791 let Inst{11-8} = rt2;
2792 let Inst{7-6} = 0b01;
2793 let Inst{5-4} = opcod;
2799 let Inst{19-16} = addr;
2800 let Inst{15-12} = Rt;
2803 let mayLoad = 1 in {
2804 def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$Rt), (ins t2addrmode_reg:$addr),
2805 AddrModeNone, 4, NoItinerary,
2806 "ldrexb", "\t$Rt, $addr", "", []>;
2807 def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$Rt), (ins t2addrmode_reg:$addr),
2808 AddrModeNone, 4, NoItinerary,
2809 "ldrexh", "\t$Rt, $addr", "", []>;
2810 def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_reg:$addr),
2811 AddrModeNone, 4, NoItinerary,
2812 "ldrex", "\t$Rt, $addr", "", []> {
2813 let Inst{31-27} = 0b11101;
2814 let Inst{26-20} = 0b0000101;
2815 let Inst{11-8} = 0b1111;
2816 let Inst{7-0} = 0b00000000; // imm8 = 0
2820 let Inst{19-16} = addr;
2821 let Inst{15-12} = Rt;
2823 let hasExtraDefRegAllocReq = 1 in
2824 def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$Rt, rGPR:$Rt2),
2825 (ins t2addrmode_reg:$addr),
2826 AddrModeNone, 4, NoItinerary,
2827 "ldrexd", "\t$Rt, $Rt2, $addr", "",
2830 let Inst{11-8} = Rt2;
2834 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
2835 def t2STREXB : T2I_strex<0b00, (outs rGPR:$Rd),
2836 (ins rGPR:$Rt, t2addrmode_reg:$addr),
2837 AddrModeNone, 4, NoItinerary,
2838 "strexb", "\t$Rd, $Rt, $addr", "", []>;
2839 def t2STREXH : T2I_strex<0b01, (outs rGPR:$Rd),
2840 (ins rGPR:$Rt, t2addrmode_reg:$addr),
2841 AddrModeNone, 4, NoItinerary,
2842 "strexh", "\t$Rd, $Rt, $addr", "", []>;
2843 def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt, t2addrmode_reg:$addr),
2844 AddrModeNone, 4, NoItinerary,
2845 "strex", "\t$Rd, $Rt, $addr", "",
2847 let Inst{31-27} = 0b11101;
2848 let Inst{26-20} = 0b0000100;
2849 let Inst{7-0} = 0b00000000; // imm8 = 0
2854 let Inst{11-8} = Rd;
2855 let Inst{19-16} = addr;
2856 let Inst{15-12} = Rt;
2860 let hasExtraSrcRegAllocReq = 1, Constraints = "@earlyclobber $Rd" in
2861 def t2STREXD : T2I_strex<0b11, (outs rGPR:$Rd),
2862 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_reg:$addr),
2863 AddrModeNone, 4, NoItinerary,
2864 "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [],
2867 let Inst{11-8} = Rt2;
2870 // Clear-Exclusive is for disassembly only.
2871 def t2CLREX : T2XI<(outs), (ins), NoItinerary, "clrex",
2872 [/* For disassembly only; pattern left blank */]>,
2873 Requires<[IsThumb2, HasV7]> {
2874 let Inst{31-16} = 0xf3bf;
2875 let Inst{15-14} = 0b10;
2878 let Inst{11-8} = 0b1111;
2879 let Inst{7-4} = 0b0010;
2880 let Inst{3-0} = 0b1111;
2883 //===----------------------------------------------------------------------===//
2884 // SJLJ Exception handling intrinsics
2885 // eh_sjlj_setjmp() is an instruction sequence to store the return
2886 // address and save #0 in R0 for the non-longjmp case.
2887 // Since by its nature we may be coming from some other function to get
2888 // here, and we're using the stack frame for the containing function to
2889 // save/restore registers, we can't keep anything live in regs across
2890 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2891 // when we get here from a longjmp(). We force everything out of registers
2892 // except for our own input by listing the relevant registers in Defs. By
2893 // doing so, we also cause the prologue/epilogue code to actively preserve
2894 // all of the callee-saved resgisters, which is exactly what we want.
2895 // $val is a scratch register for our use.
2897 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
2898 QQQQ0, QQQQ1, QQQQ2, QQQQ3 ],
2899 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
2900 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
2901 AddrModeNone, 0, NoItinerary, "", "",
2902 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
2903 Requires<[IsThumb2, HasVFP2]>;
2907 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
2908 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in {
2909 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
2910 AddrModeNone, 0, NoItinerary, "", "",
2911 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
2912 Requires<[IsThumb2, NoVFP]>;
2916 //===----------------------------------------------------------------------===//
2917 // Control-Flow Instructions
2920 // FIXME: remove when we have a way to marking a MI with these properties.
2921 // FIXME: Should pc be an implicit operand like PICADD, etc?
2922 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2923 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2924 def t2LDMIA_RET: t2PseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2925 reglist:$regs, variable_ops),
2926 4, IIC_iLoad_mBr, [],
2927 (t2LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2928 RegConstraint<"$Rn = $wb">;
2930 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
2931 let isPredicable = 1 in
2932 def t2B : T2XI<(outs), (ins uncondbrtarget:$target), IIC_Br,
2934 [(br bb:$target)]> {
2935 let Inst{31-27} = 0b11110;
2936 let Inst{15-14} = 0b10;
2940 let Inst{26} = target{19};
2941 let Inst{11} = target{18};
2942 let Inst{13} = target{17};
2943 let Inst{21-16} = target{16-11};
2944 let Inst{10-0} = target{10-0};
2947 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2948 def t2BR_JT : t2PseudoInst<(outs),
2949 (ins GPR:$target, GPR:$index, i32imm:$jt, i32imm:$id),
2951 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]>;
2953 // FIXME: Add a non-pc based case that can be predicated.
2954 def t2TBB_JT : t2PseudoInst<(outs),
2955 (ins GPR:$index, i32imm:$jt, i32imm:$id),
2958 def t2TBH_JT : t2PseudoInst<(outs),
2959 (ins GPR:$index, i32imm:$jt, i32imm:$id),
2962 def t2TBB : T2I<(outs), (ins GPR:$Rn, GPR:$Rm), IIC_Br,
2963 "tbb", "\t[$Rn, $Rm]", []> {
2966 let Inst{31-20} = 0b111010001101;
2967 let Inst{19-16} = Rn;
2968 let Inst{15-5} = 0b11110000000;
2969 let Inst{4} = 0; // B form
2973 def t2TBH : T2I<(outs), (ins GPR:$Rn, GPR:$Rm), IIC_Br,
2974 "tbh", "\t[$Rn, $Rm, lsl #1]", []> {
2977 let Inst{31-20} = 0b111010001101;
2978 let Inst{19-16} = Rn;
2979 let Inst{15-5} = 0b11110000000;
2980 let Inst{4} = 1; // H form
2983 } // isNotDuplicable, isIndirectBranch
2985 } // isBranch, isTerminator, isBarrier
2987 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2988 // a two-value operand where a dag node expects two operands. :(
2989 let isBranch = 1, isTerminator = 1 in
2990 def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
2992 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
2993 let Inst{31-27} = 0b11110;
2994 let Inst{15-14} = 0b10;
2998 let Inst{25-22} = p;
3001 let Inst{26} = target{20};
3002 let Inst{11} = target{19};
3003 let Inst{13} = target{18};
3004 let Inst{21-16} = target{17-12};
3005 let Inst{10-0} = target{11-1};
3007 let DecoderMethod = "DecodeThumb2BCCInstruction";
3010 // Tail calls. The Darwin version of thumb tail calls uses a t2 branch, so
3012 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
3014 let Defs = [R0, R1, R2, R3, R9, R12, QQQQ0, QQQQ2, QQQQ3, PC],
3016 def tTAILJMPd: tPseudoExpand<(outs), (ins uncondbrtarget:$dst, variable_ops),
3018 (t2B uncondbrtarget:$dst)>,
3019 Requires<[IsThumb2, IsDarwin]>;
3023 let Defs = [ITSTATE] in
3024 def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
3025 AddrModeNone, 2, IIC_iALUx,
3026 "it$mask\t$cc", "", []> {
3027 // 16-bit instruction.
3028 let Inst{31-16} = 0x0000;
3029 let Inst{15-8} = 0b10111111;
3034 let Inst{3-0} = mask;
3036 let DecoderMethod = "DecodeIT";
3039 // Branch and Exchange Jazelle -- for disassembly only
3041 def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func",
3042 [/* For disassembly only; pattern left blank */]> {
3043 let Inst{31-27} = 0b11110;
3045 let Inst{25-20} = 0b111100;
3046 let Inst{15-14} = 0b10;
3050 let Inst{19-16} = func;
3053 // Compare and branch on zero / non-zero
3054 let isBranch = 1, isTerminator = 1 in {
3055 def tCBZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3056 "cbz\t$Rn, $target", []>,
3057 T1Misc<{0,0,?,1,?,?,?}>,
3058 Requires<[IsThumb2]> {
3062 let Inst{9} = target{5};
3063 let Inst{7-3} = target{4-0};
3067 def tCBNZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3068 "cbnz\t$Rn, $target", []>,
3069 T1Misc<{1,0,?,1,?,?,?}>,
3070 Requires<[IsThumb2]> {
3074 let Inst{9} = target{5};
3075 let Inst{7-3} = target{4-0};
3081 // Change Processor State is a system instruction -- for disassembly and
3083 // FIXME: Since the asm parser has currently no clean way to handle optional
3084 // operands, create 3 versions of the same instruction. Once there's a clean
3085 // framework to represent optional operands, change this behavior.
3086 class t2CPS<dag iops, string asm_op> : T2XI<(outs), iops, NoItinerary,
3087 !strconcat("cps", asm_op),
3088 [/* For disassembly only; pattern left blank */]> {
3094 let Inst{31-27} = 0b11110;
3096 let Inst{25-20} = 0b111010;
3097 let Inst{19-16} = 0b1111;
3098 let Inst{15-14} = 0b10;
3100 let Inst{10-9} = imod;
3102 let Inst{7-5} = iflags;
3103 let Inst{4-0} = mode;
3104 let DecoderMethod = "DecodeT2CPSInstruction";
3108 def t2CPS3p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags, i32imm:$mode),
3109 "$imod.w\t$iflags, $mode">;
3110 let mode = 0, M = 0 in
3111 def t2CPS2p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags),
3112 "$imod.w\t$iflags">;
3113 let imod = 0, iflags = 0, M = 1 in
3114 def t2CPS1p : t2CPS<(ins i32imm:$mode), "\t$mode">;
3116 // A6.3.4 Branches and miscellaneous control
3117 // Table A6-14 Change Processor State, and hint instructions
3118 // Helper class for disassembly only.
3119 class T2I_hint<bits<8> op7_0, string opc, string asm>
3120 : T2I<(outs), (ins), NoItinerary, opc, asm,
3121 [/* For disassembly only; pattern left blank */]> {
3122 let Inst{31-20} = 0xf3a;
3123 let Inst{19-16} = 0b1111;
3124 let Inst{15-14} = 0b10;
3126 let Inst{10-8} = 0b000;
3127 let Inst{7-0} = op7_0;
3130 def t2NOP : T2I_hint<0b00000000, "nop", ".w">;
3131 def t2YIELD : T2I_hint<0b00000001, "yield", ".w">;
3132 def t2WFE : T2I_hint<0b00000010, "wfe", ".w">;
3133 def t2WFI : T2I_hint<0b00000011, "wfi", ".w">;
3134 def t2SEV : T2I_hint<0b00000100, "sev", ".w">;
3136 def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt", []> {
3137 let Inst{31-20} = 0xf3a;
3138 let Inst{15-14} = 0b10;
3140 let Inst{10-8} = 0b000;
3141 let Inst{7-4} = 0b1111;
3144 let Inst{3-0} = opt;
3147 // Secure Monitor Call is a system instruction -- for disassembly only
3148 // Option = Inst{19-16}
3149 def t2SMC : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
3150 [/* For disassembly only; pattern left blank */]> {
3151 let Inst{31-27} = 0b11110;
3152 let Inst{26-20} = 0b1111111;
3153 let Inst{15-12} = 0b1000;
3156 let Inst{19-16} = opt;
3159 class T2SRS<bits<12> op31_20,
3160 dag oops, dag iops, InstrItinClass itin,
3161 string opc, string asm, list<dag> pattern>
3162 : T2I<oops, iops, itin, opc, asm, pattern> {
3163 let Inst{31-20} = op31_20{11-0};
3166 let Inst{4-0} = mode{4-0};
3169 // Store Return State is a system instruction -- for disassembly only
3170 def t2SRSDBW : T2SRS<0b111010000010,
3171 (outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp!, $mode",
3172 [/* For disassembly only; pattern left blank */]>;
3173 def t2SRSDB : T2SRS<0b111010000000,
3174 (outs),(ins i32imm:$mode),NoItinerary,"srsdb","\tsp, $mode",
3175 [/* For disassembly only; pattern left blank */]>;
3176 def t2SRSIAW : T2SRS<0b111010011010,
3177 (outs),(ins i32imm:$mode),NoItinerary,"srsia","\tsp!, $mode",
3178 [/* For disassembly only; pattern left blank */]>;
3179 def t2SRSIA : T2SRS<0b111010011000,
3180 (outs), (ins i32imm:$mode),NoItinerary,"srsia","\tsp, $mode",
3181 [/* For disassembly only; pattern left blank */]>;
3183 // Return From Exception is a system instruction -- for disassembly only
3185 class T2RFE<bits<12> op31_20, dag oops, dag iops, InstrItinClass itin,
3186 string opc, string asm, list<dag> pattern>
3187 : T2I<oops, iops, itin, opc, asm, pattern> {
3188 let Inst{31-20} = op31_20{11-0};
3191 let Inst{19-16} = Rn;
3192 let Inst{15-0} = 0xc000;
3195 def t2RFEDBW : T2RFE<0b111010000011,
3196 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn!",
3197 [/* For disassembly only; pattern left blank */]>;
3198 def t2RFEDB : T2RFE<0b111010000001,
3199 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn",
3200 [/* For disassembly only; pattern left blank */]>;
3201 def t2RFEIAW : T2RFE<0b111010011011,
3202 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn!",
3203 [/* For disassembly only; pattern left blank */]>;
3204 def t2RFEIA : T2RFE<0b111010011001,
3205 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn",
3206 [/* For disassembly only; pattern left blank */]>;
3208 //===----------------------------------------------------------------------===//
3209 // Non-Instruction Patterns
3212 // 32-bit immediate using movw + movt.
3213 // This is a single pseudo instruction to make it re-materializable.
3214 // FIXME: Remove this when we can do generalized remat.
3215 let isReMaterializable = 1, isMoveImm = 1 in
3216 def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
3217 [(set rGPR:$dst, (i32 imm:$src))]>,
3218 Requires<[IsThumb, HasV6T2]>;
3220 // Pseudo instruction that combines movw + movt + add pc (if pic).
3221 // It also makes it possible to rematerialize the instructions.
3222 // FIXME: Remove this when we can do generalized remat and when machine licm
3223 // can properly the instructions.
3224 let isReMaterializable = 1 in {
3225 def t2MOV_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3227 [(set rGPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
3228 Requires<[IsThumb2, UseMovt]>;
3230 def t2MOV_ga_dyn : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3232 [(set rGPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
3233 Requires<[IsThumb2, UseMovt]>;
3236 // ConstantPool, GlobalAddress, and JumpTable
3237 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
3238 Requires<[IsThumb2, DontUseMovt]>;
3239 def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
3240 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
3241 Requires<[IsThumb2, UseMovt]>;
3243 def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3244 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
3246 // Pseudo instruction that combines ldr from constpool and add pc. This should
3247 // be expanded into two instructions late to allow if-conversion and
3249 let canFoldAsLoad = 1, isReMaterializable = 1 in
3250 def t2LDRpci_pic : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr, pclabel:$cp),
3252 [(set rGPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
3254 Requires<[IsThumb2]>;
3256 //===----------------------------------------------------------------------===//
3257 // Move between special register and ARM core register -- for disassembly only
3260 class T2SpecialReg<bits<12> op31_20, bits<2> op15_14, bits<1> op12,
3261 dag oops, dag iops, InstrItinClass itin,
3262 string opc, string asm, list<dag> pattern>
3263 : T2I<oops, iops, itin, opc, asm, pattern> {
3264 let Inst{31-20} = op31_20{11-0};
3265 let Inst{15-14} = op15_14{1-0};
3267 let Inst{12} = op12{0};
3271 class T2MRS<bits<12> op31_20, bits<2> op15_14, bits<1> op12,
3272 dag oops, dag iops, InstrItinClass itin,
3273 string opc, string asm, list<dag> pattern>
3274 : T2SpecialReg<op31_20, op15_14, op12, oops, iops, itin, opc, asm, pattern> {
3276 let Inst{11-8} = Rd;
3277 let Inst{19-16} = 0b1111;
3280 def t2MRS : T2MRS<0b111100111110, 0b10, 0,
3281 (outs rGPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, cpsr",
3282 [/* For disassembly only; pattern left blank */]>;
3283 def t2MRSsys : T2MRS<0b111100111111, 0b10, 0,
3284 (outs rGPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, spsr",
3285 [/* For disassembly only; pattern left blank */]>;
3287 // Move from ARM core register to Special Register
3289 // No need to have both system and application versions, the encodings are the
3290 // same and the assembly parser has no way to distinguish between them. The mask
3291 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
3292 // the mask with the fields to be accessed in the special register.
3293 def t2MSR : T2SpecialReg<0b111100111000 /* op31-20 */, 0b10 /* op15-14 */,
3294 0 /* op12 */, (outs), (ins msr_mask:$mask, rGPR:$Rn),
3295 NoItinerary, "msr", "\t$mask, $Rn",
3296 [/* For disassembly only; pattern left blank */]> {
3299 let Inst{19-16} = Rn;
3300 let Inst{20} = mask{4}; // R Bit
3301 let Inst{11-8} = mask{3-0};
3304 //===----------------------------------------------------------------------===//
3305 // Move between coprocessor and ARM core register
3308 class t2MovRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops,
3310 : T2Cop<Op, oops, iops,
3311 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"),
3313 let Inst{27-24} = 0b1110;
3314 let Inst{20} = direction;
3324 let Inst{15-12} = Rt;
3325 let Inst{11-8} = cop;
3326 let Inst{23-21} = opc1;
3327 let Inst{7-5} = opc2;
3328 let Inst{3-0} = CRm;
3329 let Inst{19-16} = CRn;
3332 class t2MovRRCopro<bits<4> Op, string opc, bit direction,
3333 list<dag> pattern = []>
3335 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
3336 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
3337 let Inst{27-24} = 0b1100;
3338 let Inst{23-21} = 0b010;
3339 let Inst{20} = direction;
3347 let Inst{15-12} = Rt;
3348 let Inst{19-16} = Rt2;
3349 let Inst{11-8} = cop;
3350 let Inst{7-4} = opc1;
3351 let Inst{3-0} = CRm;
3354 /* from ARM core register to coprocessor */
3355 def t2MCR : t2MovRCopro<0b1110, "mcr", 0,
3357 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3358 c_imm:$CRm, imm0_7:$opc2),
3359 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3360 imm:$CRm, imm:$opc2)]>;
3361 def t2MCR2 : t2MovRCopro<0b1111, "mcr2", 0,
3362 (outs), (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3363 c_imm:$CRm, imm0_7:$opc2),
3364 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3365 imm:$CRm, imm:$opc2)]>;
3367 /* from coprocessor to ARM core register */
3368 def t2MRC : t2MovRCopro<0b1110, "mrc", 1,
3369 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3370 c_imm:$CRm, imm0_7:$opc2), []>;
3372 def t2MRC2 : t2MovRCopro<0b1111, "mrc2", 1,
3373 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3374 c_imm:$CRm, imm0_7:$opc2), []>;
3376 def : T2v6Pat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3377 (t2MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3379 def : T2v6Pat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3380 (t2MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3383 /* from ARM core register to coprocessor */
3384 def t2MCRR : t2MovRRCopro<0b1110, "mcrr", 0,
3385 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
3387 def t2MCRR2 : t2MovRRCopro<0b1111, "mcrr2", 0,
3388 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt,
3389 GPR:$Rt2, imm:$CRm)]>;
3390 /* from coprocessor to ARM core register */
3391 def t2MRRC : t2MovRRCopro<0b1110, "mrrc", 1>;
3393 def t2MRRC2 : t2MovRRCopro<0b1111, "mrrc2", 1>;
3395 //===----------------------------------------------------------------------===//
3396 // Other Coprocessor Instructions.
3399 def tCDP : T2Cop<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
3400 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
3401 "cdp\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3402 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3403 imm:$CRm, imm:$opc2)]> {
3404 let Inst{27-24} = 0b1110;
3413 let Inst{3-0} = CRm;
3415 let Inst{7-5} = opc2;
3416 let Inst{11-8} = cop;
3417 let Inst{15-12} = CRd;
3418 let Inst{19-16} = CRn;
3419 let Inst{23-20} = opc1;
3422 def t2CDP2 : T2Cop<0b1111, (outs), (ins p_imm:$cop, imm0_15:$opc1,
3423 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
3424 "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3425 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3426 imm:$CRm, imm:$opc2)]> {
3427 let Inst{27-24} = 0b1110;
3436 let Inst{3-0} = CRm;
3438 let Inst{7-5} = opc2;
3439 let Inst{11-8} = cop;
3440 let Inst{15-12} = CRd;
3441 let Inst{19-16} = CRn;
3442 let Inst{23-20} = opc1;
3447 //===----------------------------------------------------------------------===//
3448 // Non-Instruction Patterns
3451 // SXT/UXT with no rotate
3452 let AddedComplexity = 16 in {
3453 def : T2Pat<(and rGPR:$Rm, 0x000000FF), (t2UXTB rGPR:$Rm, 0)>,
3454 Requires<[IsThumb2]>;
3455 def : T2Pat<(and rGPR:$Rm, 0x0000FFFF), (t2UXTH rGPR:$Rm, 0)>,
3456 Requires<[IsThumb2]>;
3457 def : T2Pat<(and rGPR:$Rm, 0x00FF00FF), (t2UXTB16 rGPR:$Rm, 0)>,
3458 Requires<[HasT2ExtractPack, IsThumb2]>;
3459 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0x00FF)),
3460 (t2UXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3461 Requires<[HasT2ExtractPack, IsThumb2]>;
3462 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0xFFFF)),
3463 (t2UXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3464 Requires<[HasT2ExtractPack, IsThumb2]>;
3467 def : T2Pat<(sext_inreg rGPR:$Src, i8), (t2SXTB rGPR:$Src, 0)>,
3468 Requires<[IsThumb2]>;
3469 def : T2Pat<(sext_inreg rGPR:$Src, i16), (t2SXTH rGPR:$Src, 0)>,
3470 Requires<[IsThumb2]>;
3471 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i8)),
3472 (t2SXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3473 Requires<[HasT2ExtractPack, IsThumb2]>;
3474 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i16)),
3475 (t2SXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3476 Requires<[HasT2ExtractPack, IsThumb2]>;
3478 // Atomic load/store patterns
3479 def : T2Pat<(atomic_load_8 t2addrmode_imm12:$addr),
3480 (t2LDRBi12 t2addrmode_imm12:$addr)>;
3481 def : T2Pat<(atomic_load_8 t2addrmode_imm8:$addr),
3482 (t2LDRBi8 t2addrmode_imm8:$addr)>;
3483 def : T2Pat<(atomic_load_8 t2addrmode_so_reg:$addr),
3484 (t2LDRBs t2addrmode_so_reg:$addr)>;
3485 def : T2Pat<(atomic_load_16 t2addrmode_imm12:$addr),
3486 (t2LDRHi12 t2addrmode_imm12:$addr)>;
3487 def : T2Pat<(atomic_load_16 t2addrmode_imm8:$addr),
3488 (t2LDRHi8 t2addrmode_imm8:$addr)>;
3489 def : T2Pat<(atomic_load_16 t2addrmode_so_reg:$addr),
3490 (t2LDRHs t2addrmode_so_reg:$addr)>;
3491 def : T2Pat<(atomic_load_32 t2addrmode_imm12:$addr),
3492 (t2LDRi12 t2addrmode_imm12:$addr)>;
3493 def : T2Pat<(atomic_load_32 t2addrmode_imm8:$addr),
3494 (t2LDRi8 t2addrmode_imm8:$addr)>;
3495 def : T2Pat<(atomic_load_32 t2addrmode_so_reg:$addr),
3496 (t2LDRs t2addrmode_so_reg:$addr)>;
3497 def : T2Pat<(atomic_store_8 t2addrmode_imm12:$addr, GPR:$val),
3498 (t2STRBi12 GPR:$val, t2addrmode_imm12:$addr)>;
3499 def : T2Pat<(atomic_store_8 t2addrmode_imm8:$addr, GPR:$val),
3500 (t2STRBi8 GPR:$val, t2addrmode_imm8:$addr)>;
3501 def : T2Pat<(atomic_store_8 t2addrmode_so_reg:$addr, GPR:$val),
3502 (t2STRBs GPR:$val, t2addrmode_so_reg:$addr)>;
3503 def : T2Pat<(atomic_store_16 t2addrmode_imm12:$addr, GPR:$val),
3504 (t2STRHi12 GPR:$val, t2addrmode_imm12:$addr)>;
3505 def : T2Pat<(atomic_store_16 t2addrmode_imm8:$addr, GPR:$val),
3506 (t2STRHi8 GPR:$val, t2addrmode_imm8:$addr)>;
3507 def : T2Pat<(atomic_store_16 t2addrmode_so_reg:$addr, GPR:$val),
3508 (t2STRHs GPR:$val, t2addrmode_so_reg:$addr)>;
3509 def : T2Pat<(atomic_store_32 t2addrmode_imm12:$addr, GPR:$val),
3510 (t2STRi12 GPR:$val, t2addrmode_imm12:$addr)>;
3511 def : T2Pat<(atomic_store_32 t2addrmode_imm8:$addr, GPR:$val),
3512 (t2STRi8 GPR:$val, t2addrmode_imm8:$addr)>;
3513 def : T2Pat<(atomic_store_32 t2addrmode_so_reg:$addr, GPR:$val),
3514 (t2STRs GPR:$val, t2addrmode_so_reg:$addr)>;
3517 //===----------------------------------------------------------------------===//
3518 // Assembler aliases
3521 // Aliases for ADC without the ".w" optional width specifier.
3522 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $Rm",
3523 (t2ADCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3524 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $ShiftedRm",
3525 (t2ADCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3526 pred:$p, cc_out:$s)>;
3528 // Aliases for SBC without the ".w" optional width specifier.
3529 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $Rm",
3530 (t2SBCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3531 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $ShiftedRm",
3532 (t2SBCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3533 pred:$p, cc_out:$s)>;
3535 // Aliases for ADD without the ".w" optional width specifier.
3536 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
3537 (t2ADDri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
3538 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
3539 (t2ADDri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
3540 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm",
3541 (t2ADDrr rGPR:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3542 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm",
3543 (t2ADDrs rGPR:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
3544 pred:$p, cc_out:$s)>;