1 //===-- ARMInstrThumb2.td - Thumb2 support for ARM ---------*- tablegen -*-===//
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 // t2_shift_imm: An integer that encodes a shift amount and the type of shift
32 // (asr or lsl). The 6-bit immediate encodes as:
35 // {4-0} imm5 shift amount.
36 // asr #32 not allowed
37 def t2_shift_imm : Operand<i32> {
38 let PrintMethod = "printShiftImmOperand";
39 let ParserMatchClass = ShifterImmAsmOperand;
40 let DecoderMethod = "DecodeT2ShifterImmOperand";
43 // Shifted operands. No register controlled shifts for Thumb2.
44 // Note: We do not support rrx shifted operands yet.
45 def t2_so_reg : Operand<i32>, // reg imm
46 ComplexPattern<i32, 2, "SelectT2ShifterOperandReg",
48 let EncoderMethod = "getT2SORegOpValue";
49 let PrintMethod = "printT2SOOperand";
50 let DecoderMethod = "DecodeSORegImmOperand";
51 let ParserMatchClass = ShiftedImmAsmOperand;
52 let MIOperandInfo = (ops rGPR, i32imm);
55 // t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
56 def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
57 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
60 // t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
61 def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
62 return CurDAG->getTargetConstant(-((int)N->getZExtValue()), MVT::i32);
65 // so_imm_notSext_XFORM - Return a so_imm value packed into the format
66 // described for so_imm_notSext def below, with sign extension from 16
68 def t2_so_imm_notSext16_XFORM : SDNodeXForm<imm, [{
69 APInt apIntN = N->getAPIntValue();
70 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue();
71 return CurDAG->getTargetConstant(~N16bitSignExt, MVT::i32);
74 // t2_so_imm - Match a 32-bit immediate operand, which is an
75 // 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
76 // immediate splatted into multiple bytes of the word.
77 def t2_so_imm_asmoperand : ImmAsmOperand { let Name = "T2SOImm"; }
78 def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{
79 return ARM_AM::getT2SOImmVal(Imm) != -1;
81 let ParserMatchClass = t2_so_imm_asmoperand;
82 let EncoderMethod = "getT2SOImmOpValue";
83 let DecoderMethod = "DecodeT2SOImm";
86 // t2_so_imm_not - Match an immediate that is a complement
88 // Note: this pattern doesn't require an encoder method and such, as it's
89 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
90 // is handled by the destination instructions, which use t2_so_imm.
91 def t2_so_imm_not_asmoperand : AsmOperandClass { let Name = "T2SOImmNot"; }
92 def t2_so_imm_not : Operand<i32>, PatLeaf<(imm), [{
93 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
94 }], t2_so_imm_not_XFORM> {
95 let ParserMatchClass = t2_so_imm_not_asmoperand;
98 // t2_so_imm_notSext - match an immediate that is a complement of a t2_so_imm
99 // if the upper 16 bits are zero.
100 def t2_so_imm_notSext : Operand<i32>, PatLeaf<(imm), [{
101 APInt apIntN = N->getAPIntValue();
102 if (!apIntN.isIntN(16)) return false;
103 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue();
104 return ARM_AM::getT2SOImmVal(~N16bitSignExt) != -1;
105 }], t2_so_imm_notSext16_XFORM> {
106 let ParserMatchClass = t2_so_imm_not_asmoperand;
109 // t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
110 def t2_so_imm_neg_asmoperand : AsmOperandClass { let Name = "T2SOImmNeg"; }
111 def t2_so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
112 int64_t Value = -(int)N->getZExtValue();
113 return Value && ARM_AM::getT2SOImmVal(Value) != -1;
114 }], t2_so_imm_neg_XFORM> {
115 let ParserMatchClass = t2_so_imm_neg_asmoperand;
118 /// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095].
119 def imm0_4095_asmoperand: ImmAsmOperand { let Name = "Imm0_4095"; }
120 def imm0_4095 : Operand<i32>, ImmLeaf<i32, [{
121 return Imm >= 0 && Imm < 4096;
123 let ParserMatchClass = imm0_4095_asmoperand;
126 def imm0_4095_neg_asmoperand: AsmOperandClass { let Name = "Imm0_4095Neg"; }
127 def imm0_4095_neg : Operand<i32>, PatLeaf<(i32 imm), [{
128 return (uint32_t)(-N->getZExtValue()) < 4096;
130 let ParserMatchClass = imm0_4095_neg_asmoperand;
133 def imm0_255_neg : PatLeaf<(i32 imm), [{
134 return (uint32_t)(-N->getZExtValue()) < 255;
137 def imm0_255_not : PatLeaf<(i32 imm), [{
138 return (uint32_t)(~N->getZExtValue()) < 255;
141 def lo5AllOne : PatLeaf<(i32 imm), [{
142 // Returns true if all low 5-bits are 1.
143 return (((uint32_t)N->getZExtValue()) & 0x1FUL) == 0x1FUL;
146 // Define Thumb2 specific addressing modes.
148 // t2addrmode_imm12 := reg + imm12
149 def t2addrmode_imm12_asmoperand : AsmOperandClass {let Name="MemUImm12Offset";}
150 def t2addrmode_imm12 : Operand<i32>,
151 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> {
152 let PrintMethod = "printAddrModeImm12Operand";
153 let EncoderMethod = "getAddrModeImm12OpValue";
154 let DecoderMethod = "DecodeT2AddrModeImm12";
155 let ParserMatchClass = t2addrmode_imm12_asmoperand;
156 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
159 // t2ldrlabel := imm12
160 def t2ldrlabel : Operand<i32> {
161 let EncoderMethod = "getAddrModeImm12OpValue";
162 let PrintMethod = "printT2LdrLabelOperand";
165 def t2ldr_pcrel_imm12_asmoperand : AsmOperandClass {let Name = "MemPCRelImm12";}
166 def t2ldr_pcrel_imm12 : Operand<i32> {
167 let ParserMatchClass = t2ldr_pcrel_imm12_asmoperand;
168 // used for assembler pseudo instruction and maps to t2ldrlabel, so
169 // doesn't need encoder or print methods of its own.
172 // ADR instruction labels.
173 def t2adrlabel : Operand<i32> {
174 let EncoderMethod = "getT2AdrLabelOpValue";
175 let PrintMethod = "printAdrLabelOperand";
179 // t2addrmode_posimm8 := reg + imm8
180 def MemPosImm8OffsetAsmOperand : AsmOperandClass {let Name="MemPosImm8Offset";}
181 def t2addrmode_posimm8 : Operand<i32> {
182 let PrintMethod = "printT2AddrModeImm8Operand";
183 let EncoderMethod = "getT2AddrModeImm8OpValue";
184 let DecoderMethod = "DecodeT2AddrModeImm8";
185 let ParserMatchClass = MemPosImm8OffsetAsmOperand;
186 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
189 // t2addrmode_negimm8 := reg - imm8
190 def MemNegImm8OffsetAsmOperand : AsmOperandClass {let Name="MemNegImm8Offset";}
191 def t2addrmode_negimm8 : Operand<i32>,
192 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
193 let PrintMethod = "printT2AddrModeImm8Operand";
194 let EncoderMethod = "getT2AddrModeImm8OpValue";
195 let DecoderMethod = "DecodeT2AddrModeImm8";
196 let ParserMatchClass = MemNegImm8OffsetAsmOperand;
197 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
200 // t2addrmode_imm8 := reg +/- imm8
201 def MemImm8OffsetAsmOperand : AsmOperandClass { let Name = "MemImm8Offset"; }
202 def t2addrmode_imm8 : Operand<i32>,
203 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
204 let PrintMethod = "printT2AddrModeImm8Operand";
205 let EncoderMethod = "getT2AddrModeImm8OpValue";
206 let DecoderMethod = "DecodeT2AddrModeImm8";
207 let ParserMatchClass = MemImm8OffsetAsmOperand;
208 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
211 def t2am_imm8_offset : Operand<i32>,
212 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset",
213 [], [SDNPWantRoot]> {
214 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
215 let EncoderMethod = "getT2AddrModeImm8OffsetOpValue";
216 let DecoderMethod = "DecodeT2Imm8";
219 // t2addrmode_imm8s4 := reg +/- (imm8 << 2)
220 def MemImm8s4OffsetAsmOperand : AsmOperandClass {let Name = "MemImm8s4Offset";}
221 def t2addrmode_imm8s4 : Operand<i32> {
222 let PrintMethod = "printT2AddrModeImm8s4Operand";
223 let EncoderMethod = "getT2AddrModeImm8s4OpValue";
224 let DecoderMethod = "DecodeT2AddrModeImm8s4";
225 let ParserMatchClass = MemImm8s4OffsetAsmOperand;
226 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
229 def t2am_imm8s4_offset_asmoperand : AsmOperandClass { let Name = "Imm8s4"; }
230 def t2am_imm8s4_offset : Operand<i32> {
231 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
232 let EncoderMethod = "getT2Imm8s4OpValue";
233 let DecoderMethod = "DecodeT2Imm8S4";
236 // t2addrmode_imm0_1020s4 := reg + (imm8 << 2)
237 def MemImm0_1020s4OffsetAsmOperand : AsmOperandClass {
238 let Name = "MemImm0_1020s4Offset";
240 def t2addrmode_imm0_1020s4 : Operand<i32> {
241 let PrintMethod = "printT2AddrModeImm0_1020s4Operand";
242 let EncoderMethod = "getT2AddrModeImm0_1020s4OpValue";
243 let DecoderMethod = "DecodeT2AddrModeImm0_1020s4";
244 let ParserMatchClass = MemImm0_1020s4OffsetAsmOperand;
245 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
248 // t2addrmode_so_reg := reg + (reg << imm2)
249 def t2addrmode_so_reg_asmoperand : AsmOperandClass {let Name="T2MemRegOffset";}
250 def t2addrmode_so_reg : Operand<i32>,
251 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> {
252 let PrintMethod = "printT2AddrModeSoRegOperand";
253 let EncoderMethod = "getT2AddrModeSORegOpValue";
254 let DecoderMethod = "DecodeT2AddrModeSOReg";
255 let ParserMatchClass = t2addrmode_so_reg_asmoperand;
256 let MIOperandInfo = (ops GPR:$base, rGPR:$offsreg, i32imm:$offsimm);
259 // Addresses for the TBB/TBH instructions.
260 def addrmode_tbb_asmoperand : AsmOperandClass { let Name = "MemTBB"; }
261 def addrmode_tbb : Operand<i32> {
262 let PrintMethod = "printAddrModeTBB";
263 let ParserMatchClass = addrmode_tbb_asmoperand;
264 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm);
266 def addrmode_tbh_asmoperand : AsmOperandClass { let Name = "MemTBH"; }
267 def addrmode_tbh : Operand<i32> {
268 let PrintMethod = "printAddrModeTBH";
269 let ParserMatchClass = addrmode_tbh_asmoperand;
270 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm);
273 //===----------------------------------------------------------------------===//
274 // Multiclass helpers...
278 class T2OneRegImm<dag oops, dag iops, InstrItinClass itin,
279 string opc, string asm, list<dag> pattern>
280 : T2I<oops, iops, itin, opc, asm, pattern> {
285 let Inst{26} = imm{11};
286 let Inst{14-12} = imm{10-8};
287 let Inst{7-0} = imm{7-0};
291 class T2sOneRegImm<dag oops, dag iops, InstrItinClass itin,
292 string opc, string asm, list<dag> pattern>
293 : T2sI<oops, iops, itin, opc, asm, pattern> {
299 let Inst{26} = imm{11};
300 let Inst{14-12} = imm{10-8};
301 let Inst{7-0} = imm{7-0};
304 class T2OneRegCmpImm<dag oops, dag iops, InstrItinClass itin,
305 string opc, string asm, list<dag> pattern>
306 : T2I<oops, iops, itin, opc, asm, pattern> {
310 let Inst{19-16} = Rn;
311 let Inst{26} = imm{11};
312 let Inst{14-12} = imm{10-8};
313 let Inst{7-0} = imm{7-0};
317 class T2OneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
318 string opc, string asm, list<dag> pattern>
319 : T2I<oops, iops, itin, opc, asm, pattern> {
324 let Inst{3-0} = ShiftedRm{3-0};
325 let Inst{5-4} = ShiftedRm{6-5};
326 let Inst{14-12} = ShiftedRm{11-9};
327 let Inst{7-6} = ShiftedRm{8-7};
330 class T2sOneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
331 string opc, string asm, list<dag> pattern>
332 : T2sI<oops, iops, itin, opc, asm, pattern> {
337 let Inst{3-0} = ShiftedRm{3-0};
338 let Inst{5-4} = ShiftedRm{6-5};
339 let Inst{14-12} = ShiftedRm{11-9};
340 let Inst{7-6} = ShiftedRm{8-7};
343 class T2OneRegCmpShiftedReg<dag oops, dag iops, InstrItinClass itin,
344 string opc, string asm, list<dag> pattern>
345 : T2I<oops, iops, itin, opc, asm, pattern> {
349 let Inst{19-16} = Rn;
350 let Inst{3-0} = ShiftedRm{3-0};
351 let Inst{5-4} = ShiftedRm{6-5};
352 let Inst{14-12} = ShiftedRm{11-9};
353 let Inst{7-6} = ShiftedRm{8-7};
356 class T2TwoReg<dag oops, dag iops, InstrItinClass itin,
357 string opc, string asm, list<dag> pattern>
358 : T2I<oops, iops, itin, opc, asm, pattern> {
366 class T2sTwoReg<dag oops, dag iops, InstrItinClass itin,
367 string opc, string asm, list<dag> pattern>
368 : T2sI<oops, iops, itin, opc, asm, pattern> {
376 class T2TwoRegCmp<dag oops, dag iops, InstrItinClass itin,
377 string opc, string asm, list<dag> pattern>
378 : T2I<oops, iops, itin, opc, asm, pattern> {
382 let Inst{19-16} = Rn;
387 class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin,
388 string opc, string asm, list<dag> pattern>
389 : T2I<oops, iops, itin, opc, asm, pattern> {
395 let Inst{19-16} = Rn;
396 let Inst{26} = imm{11};
397 let Inst{14-12} = imm{10-8};
398 let Inst{7-0} = imm{7-0};
401 class T2sTwoRegImm<dag oops, dag iops, InstrItinClass itin,
402 string opc, string asm, list<dag> pattern>
403 : T2sI<oops, iops, itin, opc, asm, pattern> {
409 let Inst{19-16} = Rn;
410 let Inst{26} = imm{11};
411 let Inst{14-12} = imm{10-8};
412 let Inst{7-0} = imm{7-0};
415 class T2TwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
416 string opc, string asm, list<dag> pattern>
417 : T2I<oops, iops, itin, opc, asm, pattern> {
424 let Inst{14-12} = imm{4-2};
425 let Inst{7-6} = imm{1-0};
428 class T2sTwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
429 string opc, string asm, list<dag> pattern>
430 : T2sI<oops, iops, itin, opc, asm, pattern> {
437 let Inst{14-12} = imm{4-2};
438 let Inst{7-6} = imm{1-0};
441 class T2ThreeReg<dag oops, dag iops, InstrItinClass itin,
442 string opc, string asm, list<dag> pattern>
443 : T2I<oops, iops, itin, opc, asm, pattern> {
449 let Inst{19-16} = Rn;
453 class T2sThreeReg<dag oops, dag iops, InstrItinClass itin,
454 string opc, string asm, list<dag> pattern>
455 : T2sI<oops, iops, itin, opc, asm, pattern> {
461 let Inst{19-16} = Rn;
465 class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
466 string opc, string asm, list<dag> pattern>
467 : T2I<oops, iops, itin, opc, asm, pattern> {
473 let Inst{19-16} = Rn;
474 let Inst{3-0} = ShiftedRm{3-0};
475 let Inst{5-4} = ShiftedRm{6-5};
476 let Inst{14-12} = ShiftedRm{11-9};
477 let Inst{7-6} = ShiftedRm{8-7};
480 class T2sTwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
481 string opc, string asm, list<dag> pattern>
482 : T2sI<oops, iops, itin, opc, asm, pattern> {
488 let Inst{19-16} = Rn;
489 let Inst{3-0} = ShiftedRm{3-0};
490 let Inst{5-4} = ShiftedRm{6-5};
491 let Inst{14-12} = ShiftedRm{11-9};
492 let Inst{7-6} = ShiftedRm{8-7};
495 class T2FourReg<dag oops, dag iops, InstrItinClass itin,
496 string opc, string asm, list<dag> pattern>
497 : T2I<oops, iops, itin, opc, asm, pattern> {
503 let Inst{19-16} = Rn;
504 let Inst{15-12} = Ra;
509 class T2MulLong<bits<3> opc22_20, bits<4> opc7_4,
510 dag oops, dag iops, InstrItinClass itin,
511 string opc, string asm, list<dag> pattern>
512 : T2I<oops, iops, itin, opc, asm, pattern> {
518 let Inst{31-23} = 0b111110111;
519 let Inst{22-20} = opc22_20;
520 let Inst{19-16} = Rn;
521 let Inst{15-12} = RdLo;
522 let Inst{11-8} = RdHi;
523 let Inst{7-4} = opc7_4;
528 /// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
529 /// binary operation that produces a value. These are predicable and can be
530 /// changed to modify CPSR.
531 multiclass T2I_bin_irs<bits<4> opcod, string opc,
532 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
533 PatFrag opnode, bit Commutable = 0,
536 def ri : T2sTwoRegImm<
537 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
538 opc, "\t$Rd, $Rn, $imm",
539 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]> {
540 let Inst{31-27} = 0b11110;
542 let Inst{24-21} = opcod;
546 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
547 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
548 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
549 let isCommutable = Commutable;
550 let Inst{31-27} = 0b11101;
551 let Inst{26-25} = 0b01;
552 let Inst{24-21} = opcod;
553 let Inst{14-12} = 0b000; // imm3
554 let Inst{7-6} = 0b00; // imm2
555 let Inst{5-4} = 0b00; // type
558 def rs : T2sTwoRegShiftedReg<
559 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
560 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
561 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]> {
562 let Inst{31-27} = 0b11101;
563 let Inst{26-25} = 0b01;
564 let Inst{24-21} = opcod;
566 // Assembly aliases for optional destination operand when it's the same
567 // as the source operand.
568 def : t2InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
569 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn,
570 t2_so_imm:$imm, pred:$p,
572 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $Rm"),
573 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn,
576 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $shift"),
577 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn,
578 t2_so_reg:$shift, pred:$p,
582 /// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
583 // the ".w" suffix to indicate that they are wide.
584 multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
585 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
586 PatFrag opnode, bit Commutable = 0> :
587 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w"> {
588 // Assembler aliases w/ the ".w" suffix.
589 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rd, $Rn, $imm"),
590 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p,
592 // Assembler aliases w/o the ".w" suffix.
593 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
594 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
596 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $shift"),
597 (!cast<Instruction>(NAME#"rs") rGPR:$Rd, rGPR:$Rn, t2_so_reg:$shift,
598 pred:$p, cc_out:$s)>;
600 // and with the optional destination operand, too.
601 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rdn, $imm"),
602 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm,
603 pred:$p, cc_out:$s)>;
604 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
605 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
607 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $shift"),
608 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$shift,
609 pred:$p, cc_out:$s)>;
612 /// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
613 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
614 /// it is equivalent to the T2I_bin_irs counterpart.
615 multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
617 def ri : T2sTwoRegImm<
618 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
619 opc, ".w\t$Rd, $Rn, $imm",
620 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
621 let Inst{31-27} = 0b11110;
623 let Inst{24-21} = opcod;
627 def rr : T2sThreeReg<
628 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
629 opc, "\t$Rd, $Rn, $Rm",
630 [/* For disassembly only; pattern left blank */]> {
631 let Inst{31-27} = 0b11101;
632 let Inst{26-25} = 0b01;
633 let Inst{24-21} = opcod;
634 let Inst{14-12} = 0b000; // imm3
635 let Inst{7-6} = 0b00; // imm2
636 let Inst{5-4} = 0b00; // type
639 def rs : T2sTwoRegShiftedReg<
640 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
641 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm",
642 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
643 let Inst{31-27} = 0b11101;
644 let Inst{26-25} = 0b01;
645 let Inst{24-21} = opcod;
649 /// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
650 /// instruction modifies the CPSR register.
652 /// These opcodes will be converted to the real non-S opcodes by
653 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
654 let hasPostISelHook = 1, Defs = [CPSR] in {
655 multiclass T2I_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
656 InstrItinClass iis, PatFrag opnode,
657 bit Commutable = 0> {
659 def ri : t2PseudoInst<(outs rGPR:$Rd),
660 (ins GPRnopc:$Rn, t2_so_imm:$imm, pred:$p),
662 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
665 def rr : t2PseudoInst<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm, pred:$p),
667 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
669 let isCommutable = Commutable;
672 def rs : t2PseudoInst<(outs rGPR:$Rd),
673 (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
675 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
676 t2_so_reg:$ShiftedRm))]>;
680 /// T2I_rbin_s_is - Same as T2I_bin_s_irs, except selection DAG
681 /// operands are reversed.
682 let hasPostISelHook = 1, Defs = [CPSR] in {
683 multiclass T2I_rbin_s_is<PatFrag opnode> {
685 def ri : t2PseudoInst<(outs rGPR:$Rd),
686 (ins rGPR:$Rn, t2_so_imm:$imm, pred:$p),
688 [(set rGPR:$Rd, CPSR, (opnode t2_so_imm:$imm,
691 def rs : t2PseudoInst<(outs rGPR:$Rd),
692 (ins rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
694 [(set rGPR:$Rd, CPSR, (opnode t2_so_reg:$ShiftedRm,
699 /// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
700 /// patterns for a binary operation that produces a value.
701 multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
702 bit Commutable = 0> {
704 // The register-immediate version is re-materializable. This is useful
705 // in particular for taking the address of a local.
706 let isReMaterializable = 1 in {
707 def ri : T2sTwoRegImm<
708 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi,
709 opc, ".w\t$Rd, $Rn, $imm",
710 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]> {
711 let Inst{31-27} = 0b11110;
714 let Inst{23-21} = op23_21;
720 (outs GPRnopc:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
721 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
722 [(set GPRnopc:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> {
726 let Inst{31-27} = 0b11110;
727 let Inst{26} = imm{11};
728 let Inst{25-24} = 0b10;
729 let Inst{23-21} = op23_21;
730 let Inst{20} = 0; // The S bit.
731 let Inst{19-16} = Rn;
733 let Inst{14-12} = imm{10-8};
735 let Inst{7-0} = imm{7-0};
738 def rr : T2sThreeReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm),
739 IIC_iALUr, opc, ".w\t$Rd, $Rn, $Rm",
740 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]> {
741 let isCommutable = Commutable;
742 let Inst{31-27} = 0b11101;
743 let Inst{26-25} = 0b01;
745 let Inst{23-21} = op23_21;
746 let Inst{14-12} = 0b000; // imm3
747 let Inst{7-6} = 0b00; // imm2
748 let Inst{5-4} = 0b00; // type
751 def rs : T2sTwoRegShiftedReg<
752 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm),
753 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
754 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]> {
755 let Inst{31-27} = 0b11101;
756 let Inst{26-25} = 0b01;
758 let Inst{23-21} = op23_21;
761 // Predicated versions.
762 def CCri : t2PseudoExpand<(outs GPRnopc:$Rd),
763 (ins GPRnopc:$Rfalse, GPRnopc:$Rn, t2_so_imm:$imm,
764 pred:$p, cc_out:$s), 4, IIC_iALUi, [],
765 (!cast<Instruction>(NAME#ri) GPRnopc:$Rd,
766 GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>,
767 RegConstraint<"$Rfalse = $Rd">;
768 def CCri12 : t2PseudoExpand<(outs GPRnopc:$Rd),
769 (ins GPRnopc:$Rfalse, GPR:$Rn, imm0_4095:$imm,
772 (!cast<Instruction>(NAME#ri12) GPRnopc:$Rd,
773 GPR:$Rn, imm0_4095:$imm, pred:$p)>,
774 RegConstraint<"$Rfalse = $Rd">;
775 def CCrr : t2PseudoExpand<(outs GPRnopc:$Rd),
776 (ins GPRnopc:$Rfalse, GPRnopc:$Rn, rGPR:$Rm,
777 pred:$p, cc_out:$s), 4, IIC_iALUr, [],
778 (!cast<Instruction>(NAME#rr) GPRnopc:$Rd,
779 GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>,
780 RegConstraint<"$Rfalse = $Rd">;
781 def CCrs : t2PseudoExpand<(outs GPRnopc:$Rd),
782 (ins GPRnopc:$Rfalse, GPRnopc:$Rn, t2_so_reg:$Rm,
783 pred:$p, cc_out:$s), 4, IIC_iALUsi, [],
784 (!cast<Instruction>(NAME#rs) GPRnopc:$Rd,
785 GPRnopc:$Rn, t2_so_reg:$Rm, pred:$p, cc_out:$s)>,
786 RegConstraint<"$Rfalse = $Rd">;
789 /// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
790 /// for a binary operation that produces a value and use the carry
791 /// bit. It's not predicable.
792 let Defs = [CPSR], Uses = [CPSR] in {
793 multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
794 bit Commutable = 0> {
796 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
797 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
798 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_imm:$imm, CPSR))]>,
799 Requires<[IsThumb2]> {
800 let Inst{31-27} = 0b11110;
802 let Inst{24-21} = opcod;
806 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
807 opc, ".w\t$Rd, $Rn, $Rm",
808 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, rGPR:$Rm, CPSR))]>,
809 Requires<[IsThumb2]> {
810 let isCommutable = Commutable;
811 let Inst{31-27} = 0b11101;
812 let Inst{26-25} = 0b01;
813 let Inst{24-21} = opcod;
814 let Inst{14-12} = 0b000; // imm3
815 let Inst{7-6} = 0b00; // imm2
816 let Inst{5-4} = 0b00; // type
819 def rs : T2sTwoRegShiftedReg<
820 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
821 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
822 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm, CPSR))]>,
823 Requires<[IsThumb2]> {
824 let Inst{31-27} = 0b11101;
825 let Inst{26-25} = 0b01;
826 let Inst{24-21} = opcod;
831 /// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
832 // rotate operation that produces a value.
833 multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode> {
835 def ri : T2sTwoRegShiftImm<
836 (outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi,
837 opc, ".w\t$Rd, $Rm, $imm",
838 [(set rGPR:$Rd, (opnode rGPR:$Rm, (i32 ty:$imm)))]> {
839 let Inst{31-27} = 0b11101;
840 let Inst{26-21} = 0b010010;
841 let Inst{19-16} = 0b1111; // Rn
842 let Inst{5-4} = opcod;
845 def rr : T2sThreeReg<
846 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr,
847 opc, ".w\t$Rd, $Rn, $Rm",
848 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
849 let Inst{31-27} = 0b11111;
850 let Inst{26-23} = 0b0100;
851 let Inst{22-21} = opcod;
852 let Inst{15-12} = 0b1111;
853 let Inst{7-4} = 0b0000;
856 // Optional destination register
857 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"),
858 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
860 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"),
861 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
864 // Assembler aliases w/o the ".w" suffix.
865 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $imm"),
866 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, ty:$imm, pred:$p,
868 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
869 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
872 // and with the optional destination operand, too.
873 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $imm"),
874 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
876 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
877 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
881 /// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
882 /// patterns. Similar to T2I_bin_irs except the instruction does not produce
883 /// a explicit result, only implicitly set CPSR.
884 multiclass T2I_cmp_irs<bits<4> opcod, string opc,
885 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
887 let isCompare = 1, Defs = [CPSR] in {
889 def ri : T2OneRegCmpImm<
890 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), iii,
891 opc, ".w\t$Rn, $imm",
892 [(opnode GPRnopc:$Rn, t2_so_imm:$imm)]> {
893 let Inst{31-27} = 0b11110;
895 let Inst{24-21} = opcod;
896 let Inst{20} = 1; // The S bit.
898 let Inst{11-8} = 0b1111; // Rd
901 def rr : T2TwoRegCmp<
902 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), iir,
904 [(opnode GPRnopc:$Rn, rGPR:$Rm)]> {
905 let Inst{31-27} = 0b11101;
906 let Inst{26-25} = 0b01;
907 let Inst{24-21} = opcod;
908 let Inst{20} = 1; // The S bit.
909 let Inst{14-12} = 0b000; // imm3
910 let Inst{11-8} = 0b1111; // Rd
911 let Inst{7-6} = 0b00; // imm2
912 let Inst{5-4} = 0b00; // type
915 def rs : T2OneRegCmpShiftedReg<
916 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), iis,
917 opc, ".w\t$Rn, $ShiftedRm",
918 [(opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]> {
919 let Inst{31-27} = 0b11101;
920 let Inst{26-25} = 0b01;
921 let Inst{24-21} = opcod;
922 let Inst{20} = 1; // The S bit.
923 let Inst{11-8} = 0b1111; // Rd
927 // Assembler aliases w/o the ".w" suffix.
928 // No alias here for 'rr' version as not all instantiations of this
929 // multiclass want one (CMP in particular, does not).
930 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $imm"),
931 (!cast<Instruction>(NAME#"ri") GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
932 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $shift"),
933 (!cast<Instruction>(NAME#"rs") GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
936 /// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
937 multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
938 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
940 def i12 : T2Ii12<(outs target:$Rt), (ins t2addrmode_imm12:$addr), iii,
941 opc, ".w\t$Rt, $addr",
942 [(set target:$Rt, (opnode t2addrmode_imm12:$addr))]> {
945 let Inst{31-25} = 0b1111100;
946 let Inst{24} = signed;
948 let Inst{22-21} = opcod;
949 let Inst{20} = 1; // load
950 let Inst{19-16} = addr{16-13}; // Rn
951 let Inst{15-12} = Rt;
952 let Inst{11-0} = addr{11-0}; // imm
954 def i8 : T2Ii8 <(outs target:$Rt), (ins t2addrmode_negimm8:$addr), iii,
956 [(set target:$Rt, (opnode t2addrmode_negimm8:$addr))]> {
959 let Inst{31-27} = 0b11111;
960 let Inst{26-25} = 0b00;
961 let Inst{24} = signed;
963 let Inst{22-21} = opcod;
964 let Inst{20} = 1; // load
965 let Inst{19-16} = addr{12-9}; // Rn
966 let Inst{15-12} = Rt;
968 // Offset: index==TRUE, wback==FALSE
969 let Inst{10} = 1; // The P bit.
970 let Inst{9} = addr{8}; // U
971 let Inst{8} = 0; // The W bit.
972 let Inst{7-0} = addr{7-0}; // imm
974 def s : T2Iso <(outs target:$Rt), (ins t2addrmode_so_reg:$addr), iis,
975 opc, ".w\t$Rt, $addr",
976 [(set target:$Rt, (opnode t2addrmode_so_reg:$addr))]> {
977 let Inst{31-27} = 0b11111;
978 let Inst{26-25} = 0b00;
979 let Inst{24} = signed;
981 let Inst{22-21} = opcod;
982 let Inst{20} = 1; // load
983 let Inst{11-6} = 0b000000;
986 let Inst{15-12} = Rt;
989 let Inst{19-16} = addr{9-6}; // Rn
990 let Inst{3-0} = addr{5-2}; // Rm
991 let Inst{5-4} = addr{1-0}; // imm
993 let DecoderMethod = "DecodeT2LoadShift";
996 // pci variant is very similar to i12, but supports negative offsets
998 def pci : T2Ipc <(outs target:$Rt), (ins t2ldrlabel:$addr), iii,
999 opc, ".w\t$Rt, $addr",
1000 [(set target:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> {
1001 let isReMaterializable = 1;
1002 let Inst{31-27} = 0b11111;
1003 let Inst{26-25} = 0b00;
1004 let Inst{24} = signed;
1005 let Inst{23} = ?; // add = (U == '1')
1006 let Inst{22-21} = opcod;
1007 let Inst{20} = 1; // load
1008 let Inst{19-16} = 0b1111; // Rn
1011 let Inst{15-12} = Rt{3-0};
1012 let Inst{11-0} = addr{11-0};
1016 /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
1017 multiclass T2I_st<bits<2> opcod, string opc,
1018 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
1020 def i12 : T2Ii12<(outs), (ins target:$Rt, t2addrmode_imm12:$addr), iii,
1021 opc, ".w\t$Rt, $addr",
1022 [(opnode target:$Rt, t2addrmode_imm12:$addr)]> {
1023 let Inst{31-27} = 0b11111;
1024 let Inst{26-23} = 0b0001;
1025 let Inst{22-21} = opcod;
1026 let Inst{20} = 0; // !load
1029 let Inst{15-12} = Rt;
1032 let addr{12} = 1; // add = TRUE
1033 let Inst{19-16} = addr{16-13}; // Rn
1034 let Inst{23} = addr{12}; // U
1035 let Inst{11-0} = addr{11-0}; // imm
1037 def i8 : T2Ii8 <(outs), (ins target:$Rt, t2addrmode_negimm8:$addr), iii,
1038 opc, "\t$Rt, $addr",
1039 [(opnode target:$Rt, t2addrmode_negimm8:$addr)]> {
1040 let Inst{31-27} = 0b11111;
1041 let Inst{26-23} = 0b0000;
1042 let Inst{22-21} = opcod;
1043 let Inst{20} = 0; // !load
1045 // Offset: index==TRUE, wback==FALSE
1046 let Inst{10} = 1; // The P bit.
1047 let Inst{8} = 0; // The W bit.
1050 let Inst{15-12} = Rt;
1053 let Inst{19-16} = addr{12-9}; // Rn
1054 let Inst{9} = addr{8}; // U
1055 let Inst{7-0} = addr{7-0}; // imm
1057 def s : T2Iso <(outs), (ins target:$Rt, t2addrmode_so_reg:$addr), iis,
1058 opc, ".w\t$Rt, $addr",
1059 [(opnode target:$Rt, t2addrmode_so_reg:$addr)]> {
1060 let Inst{31-27} = 0b11111;
1061 let Inst{26-23} = 0b0000;
1062 let Inst{22-21} = opcod;
1063 let Inst{20} = 0; // !load
1064 let Inst{11-6} = 0b000000;
1067 let Inst{15-12} = Rt;
1070 let Inst{19-16} = addr{9-6}; // Rn
1071 let Inst{3-0} = addr{5-2}; // Rm
1072 let Inst{5-4} = addr{1-0}; // imm
1076 /// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
1077 /// register and one whose operand is a register rotated by 8/16/24.
1078 class T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode>
1079 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1080 opc, ".w\t$Rd, $Rm$rot",
1081 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
1082 Requires<[IsThumb2]> {
1083 let Inst{31-27} = 0b11111;
1084 let Inst{26-23} = 0b0100;
1085 let Inst{22-20} = opcod;
1086 let Inst{19-16} = 0b1111; // Rn
1087 let Inst{15-12} = 0b1111;
1091 let Inst{5-4} = rot{1-0}; // rotate
1094 // UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
1095 class T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode>
1096 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot),
1097 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1098 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
1099 Requires<[HasT2ExtractPack, IsThumb2]> {
1101 let Inst{31-27} = 0b11111;
1102 let Inst{26-23} = 0b0100;
1103 let Inst{22-20} = opcod;
1104 let Inst{19-16} = 0b1111; // Rn
1105 let Inst{15-12} = 0b1111;
1107 let Inst{5-4} = rot;
1110 // SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
1112 class T2I_ext_rrot_sxtb16<bits<3> opcod, string opc>
1113 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1114 opc, "\t$Rd, $Rm$rot", []>,
1115 Requires<[IsThumb2, HasT2ExtractPack]> {
1117 let Inst{31-27} = 0b11111;
1118 let Inst{26-23} = 0b0100;
1119 let Inst{22-20} = opcod;
1120 let Inst{19-16} = 0b1111; // Rn
1121 let Inst{15-12} = 0b1111;
1123 let Inst{5-4} = rot;
1126 /// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
1127 /// register and one whose operand is a register rotated by 8/16/24.
1128 class T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode>
1129 : T2ThreeReg<(outs rGPR:$Rd),
1130 (ins rGPR:$Rn, rGPR:$Rm, rot_imm:$rot),
1131 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot",
1132 [(set rGPR:$Rd, (opnode rGPR:$Rn, (rotr rGPR:$Rm,rot_imm:$rot)))]>,
1133 Requires<[HasT2ExtractPack, IsThumb2]> {
1135 let Inst{31-27} = 0b11111;
1136 let Inst{26-23} = 0b0100;
1137 let Inst{22-20} = opcod;
1138 let Inst{15-12} = 0b1111;
1140 let Inst{5-4} = rot;
1143 class T2I_exta_rrot_np<bits<3> opcod, string opc>
1144 : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm,rot_imm:$rot),
1145 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot", []> {
1147 let Inst{31-27} = 0b11111;
1148 let Inst{26-23} = 0b0100;
1149 let Inst{22-20} = opcod;
1150 let Inst{15-12} = 0b1111;
1152 let Inst{5-4} = rot;
1155 //===----------------------------------------------------------------------===//
1157 //===----------------------------------------------------------------------===//
1159 //===----------------------------------------------------------------------===//
1160 // Miscellaneous Instructions.
1163 class T2PCOneRegImm<dag oops, dag iops, InstrItinClass itin,
1164 string asm, list<dag> pattern>
1165 : T2XI<oops, iops, itin, asm, pattern> {
1169 let Inst{11-8} = Rd;
1170 let Inst{26} = label{11};
1171 let Inst{14-12} = label{10-8};
1172 let Inst{7-0} = label{7-0};
1175 // LEApcrel - Load a pc-relative address into a register without offending the
1177 def t2ADR : T2PCOneRegImm<(outs rGPR:$Rd),
1178 (ins t2adrlabel:$addr, pred:$p),
1179 IIC_iALUi, "adr{$p}.w\t$Rd, $addr", []> {
1180 let Inst{31-27} = 0b11110;
1181 let Inst{25-24} = 0b10;
1182 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1185 let Inst{19-16} = 0b1111; // Rn
1190 let Inst{11-8} = Rd;
1191 let Inst{23} = addr{12};
1192 let Inst{21} = addr{12};
1193 let Inst{26} = addr{11};
1194 let Inst{14-12} = addr{10-8};
1195 let Inst{7-0} = addr{7-0};
1197 let DecoderMethod = "DecodeT2Adr";
1200 let neverHasSideEffects = 1, isReMaterializable = 1 in
1201 def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p),
1203 let hasSideEffects = 1 in
1204 def t2LEApcrelJT : t2PseudoInst<(outs rGPR:$Rd),
1205 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1210 //===----------------------------------------------------------------------===//
1211 // Load / store Instructions.
1215 let canFoldAsLoad = 1, isReMaterializable = 1 in
1216 defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si, GPR,
1217 UnOpFrag<(load node:$Src)>>;
1219 // Loads with zero extension
1220 defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1221 rGPR, UnOpFrag<(zextloadi16 node:$Src)>>;
1222 defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1223 rGPR, UnOpFrag<(zextloadi8 node:$Src)>>;
1225 // Loads with sign extension
1226 defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1227 rGPR, UnOpFrag<(sextloadi16 node:$Src)>>;
1228 defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1229 rGPR, UnOpFrag<(sextloadi8 node:$Src)>>;
1231 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1233 def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$Rt, rGPR:$Rt2),
1234 (ins t2addrmode_imm8s4:$addr),
1235 IIC_iLoad_d_i, "ldrd", "\t$Rt, $Rt2, $addr", "", []>;
1236 } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
1238 // zextload i1 -> zextload i8
1239 def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1240 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1241 def : T2Pat<(zextloadi1 t2addrmode_negimm8:$addr),
1242 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1243 def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1244 (t2LDRBs t2addrmode_so_reg:$addr)>;
1245 def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1246 (t2LDRBpci tconstpool:$addr)>;
1248 // extload -> zextload
1249 // FIXME: Reduce the number of patterns by legalizing extload to zextload
1251 def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1252 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1253 def : T2Pat<(extloadi1 t2addrmode_negimm8:$addr),
1254 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1255 def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1256 (t2LDRBs t2addrmode_so_reg:$addr)>;
1257 def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1258 (t2LDRBpci tconstpool:$addr)>;
1260 def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1261 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1262 def : T2Pat<(extloadi8 t2addrmode_negimm8:$addr),
1263 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1264 def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1265 (t2LDRBs t2addrmode_so_reg:$addr)>;
1266 def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1267 (t2LDRBpci tconstpool:$addr)>;
1269 def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1270 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1271 def : T2Pat<(extloadi16 t2addrmode_negimm8:$addr),
1272 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
1273 def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1274 (t2LDRHs t2addrmode_so_reg:$addr)>;
1275 def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1276 (t2LDRHpci tconstpool:$addr)>;
1278 // FIXME: The destination register of the loads and stores can't be PC, but
1279 // can be SP. We need another regclass (similar to rGPR) to represent
1280 // that. Not a pressing issue since these are selected manually,
1285 let mayLoad = 1, neverHasSideEffects = 1 in {
1286 def t2LDR_PRE : T2Ipreldst<0, 0b10, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1287 (ins t2addrmode_imm8:$addr),
1288 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
1289 "ldr", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1291 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1294 def t2LDR_POST : T2Ipostldst<0, 0b10, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1295 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1296 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
1297 "ldr", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1299 def t2LDRB_PRE : T2Ipreldst<0, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1300 (ins t2addrmode_imm8:$addr),
1301 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1302 "ldrb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1304 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1306 def t2LDRB_POST : T2Ipostldst<0, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1307 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1308 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1309 "ldrb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1311 def t2LDRH_PRE : T2Ipreldst<0, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1312 (ins t2addrmode_imm8:$addr),
1313 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1314 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1316 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1318 def t2LDRH_POST : T2Ipostldst<0, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1319 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1320 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1321 "ldrh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1323 def t2LDRSB_PRE : T2Ipreldst<1, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1324 (ins t2addrmode_imm8:$addr),
1325 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1326 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1328 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1330 def t2LDRSB_POST : T2Ipostldst<1, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1331 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1332 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1333 "ldrsb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1335 def t2LDRSH_PRE : T2Ipreldst<1, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1336 (ins t2addrmode_imm8:$addr),
1337 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1338 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1340 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1342 def t2LDRSH_POST : T2Ipostldst<1, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1343 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1344 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1345 "ldrsh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1346 } // mayLoad = 1, neverHasSideEffects = 1
1348 // LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110).
1349 // Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
1350 class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1351 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_posimm8:$addr), ii, opc,
1352 "\t$Rt, $addr", []> {
1355 let Inst{31-27} = 0b11111;
1356 let Inst{26-25} = 0b00;
1357 let Inst{24} = signed;
1359 let Inst{22-21} = type;
1360 let Inst{20} = 1; // load
1361 let Inst{19-16} = addr{12-9};
1362 let Inst{15-12} = Rt;
1364 let Inst{10-8} = 0b110; // PUW.
1365 let Inst{7-0} = addr{7-0};
1368 def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1369 def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1370 def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1371 def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1372 def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
1375 defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si, GPR,
1376 BinOpFrag<(store node:$LHS, node:$RHS)>>;
1377 defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
1378 rGPR, BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1379 defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
1380 rGPR, BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
1383 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
1384 def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
1385 (ins GPR:$Rt, GPR:$Rt2, t2addrmode_imm8s4:$addr),
1386 IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", "", []>;
1390 let mayStore = 1, neverHasSideEffects = 1 in {
1391 def t2STR_PRE : T2Ipreldst<0, 0b10, 0, 1, (outs GPRnopc:$Rn_wb),
1392 (ins GPRnopc:$Rt, t2addrmode_imm8:$addr),
1393 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1394 "str", "\t$Rt, $addr!",
1395 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1396 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1398 def t2STRH_PRE : T2Ipreldst<0, 0b01, 0, 1, (outs GPRnopc:$Rn_wb),
1399 (ins rGPR:$Rt, t2addrmode_imm8:$addr),
1400 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1401 "strh", "\t$Rt, $addr!",
1402 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1403 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1406 def t2STRB_PRE : T2Ipreldst<0, 0b00, 0, 1, (outs GPRnopc:$Rn_wb),
1407 (ins rGPR:$Rt, t2addrmode_imm8:$addr),
1408 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
1409 "strb", "\t$Rt, $addr!",
1410 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1411 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1413 } // mayStore = 1, neverHasSideEffects = 1
1415 def t2STR_POST : T2Ipostldst<0, 0b10, 0, 0, (outs GPRnopc:$Rn_wb),
1416 (ins GPRnopc:$Rt, addr_offset_none:$Rn,
1417 t2am_imm8_offset:$offset),
1418 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
1419 "str", "\t$Rt, $Rn$offset",
1420 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1421 [(set GPRnopc:$Rn_wb,
1422 (post_store GPRnopc:$Rt, addr_offset_none:$Rn,
1423 t2am_imm8_offset:$offset))]>;
1425 def t2STRH_POST : T2Ipostldst<0, 0b01, 0, 0, (outs GPRnopc:$Rn_wb),
1426 (ins rGPR:$Rt, addr_offset_none:$Rn,
1427 t2am_imm8_offset:$offset),
1428 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1429 "strh", "\t$Rt, $Rn$offset",
1430 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1431 [(set GPRnopc:$Rn_wb,
1432 (post_truncsti16 rGPR:$Rt, addr_offset_none:$Rn,
1433 t2am_imm8_offset:$offset))]>;
1435 def t2STRB_POST : T2Ipostldst<0, 0b00, 0, 0, (outs GPRnopc:$Rn_wb),
1436 (ins rGPR:$Rt, addr_offset_none:$Rn,
1437 t2am_imm8_offset:$offset),
1438 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1439 "strb", "\t$Rt, $Rn$offset",
1440 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1441 [(set GPRnopc:$Rn_wb,
1442 (post_truncsti8 rGPR:$Rt, addr_offset_none:$Rn,
1443 t2am_imm8_offset:$offset))]>;
1445 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
1446 // put the patterns on the instruction definitions directly as ISel wants
1447 // the address base and offset to be separate operands, not a single
1448 // complex operand like we represent the instructions themselves. The
1449 // pseudos map between the two.
1450 let usesCustomInserter = 1,
1451 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
1452 def t2STR_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1453 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1455 [(set GPRnopc:$Rn_wb,
1456 (pre_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1457 def t2STRB_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1458 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1460 [(set GPRnopc:$Rn_wb,
1461 (pre_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1462 def t2STRH_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1463 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1465 [(set GPRnopc:$Rn_wb,
1466 (pre_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1469 // STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1471 // Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
1472 class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1473 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_imm8:$addr), ii, opc,
1474 "\t$Rt, $addr", []> {
1475 let Inst{31-27} = 0b11111;
1476 let Inst{26-25} = 0b00;
1477 let Inst{24} = 0; // not signed
1479 let Inst{22-21} = type;
1480 let Inst{20} = 0; // store
1482 let Inst{10-8} = 0b110; // PUW
1486 let Inst{15-12} = Rt;
1487 let Inst{19-16} = addr{12-9};
1488 let Inst{7-0} = addr{7-0};
1491 def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1492 def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1493 def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
1495 // ldrd / strd pre / post variants
1496 // For disassembly only.
1498 def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1499 (ins t2addrmode_imm8s4:$addr), IIC_iLoad_d_ru,
1500 "ldrd", "\t$Rt, $Rt2, $addr!", "$addr.base = $wb", []> {
1501 let AsmMatchConverter = "cvtT2LdrdPre";
1502 let DecoderMethod = "DecodeT2LDRDPreInstruction";
1505 def t2LDRD_POST : T2Ii8s4post<0, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1506 (ins addr_offset_none:$addr, t2am_imm8s4_offset:$imm),
1507 IIC_iLoad_d_ru, "ldrd", "\t$Rt, $Rt2, $addr$imm",
1508 "$addr.base = $wb", []>;
1510 def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs GPR:$wb),
1511 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr),
1512 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr!",
1513 "$addr.base = $wb", []> {
1514 let AsmMatchConverter = "cvtT2StrdPre";
1515 let DecoderMethod = "DecodeT2STRDPreInstruction";
1518 def t2STRD_POST : T2Ii8s4post<0, 1, 0, (outs GPR:$wb),
1519 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr,
1520 t2am_imm8s4_offset:$imm),
1521 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr$imm",
1522 "$addr.base = $wb", []>;
1524 // T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1525 // data/instruction access.
1526 // instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1527 // (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
1528 multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
1530 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
1532 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
1533 let Inst{31-25} = 0b1111100;
1534 let Inst{24} = instr;
1536 let Inst{21} = write;
1538 let Inst{15-12} = 0b1111;
1541 let addr{12} = 1; // add = TRUE
1542 let Inst{19-16} = addr{16-13}; // Rn
1543 let Inst{23} = addr{12}; // U
1544 let Inst{11-0} = addr{11-0}; // imm12
1547 def i8 : T2Ii8<(outs), (ins t2addrmode_negimm8:$addr), IIC_Preload, opc,
1549 [(ARMPreload t2addrmode_negimm8:$addr, (i32 write), (i32 instr))]> {
1550 let Inst{31-25} = 0b1111100;
1551 let Inst{24} = instr;
1552 let Inst{23} = 0; // U = 0
1554 let Inst{21} = write;
1556 let Inst{15-12} = 0b1111;
1557 let Inst{11-8} = 0b1100;
1560 let Inst{19-16} = addr{12-9}; // Rn
1561 let Inst{7-0} = addr{7-0}; // imm8
1564 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
1566 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
1567 let Inst{31-25} = 0b1111100;
1568 let Inst{24} = instr;
1569 let Inst{23} = 0; // add = TRUE for T1
1571 let Inst{21} = write;
1573 let Inst{15-12} = 0b1111;
1574 let Inst{11-6} = 0000000;
1577 let Inst{19-16} = addr{9-6}; // Rn
1578 let Inst{3-0} = addr{5-2}; // Rm
1579 let Inst{5-4} = addr{1-0}; // imm2
1581 let DecoderMethod = "DecodeT2LoadShift";
1583 // FIXME: We should have a separate 'pci' variant here. As-is we represent
1584 // it via the i12 variant, which it's related to, but that means we can
1585 // represent negative immediates, which aren't legal for anything except
1586 // the 'pci' case (Rn == 15).
1589 defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1590 defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1591 defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
1593 // Pseudos for atomic loads. Setting mayStore prevents reordering.
1594 let mayLoad = 1, mayStore = 1, hasSideEffects = 0 in {
1595 def ATOMIC_t2LDRBi12 : t2PseudoExpand<(outs rGPR:$Rt),
1596 (ins t2addrmode_imm12:$addr, pred:$p),
1597 4, IIC_iLoad_bh_i, [],
1598 (t2LDRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
1599 def ATOMIC_t2LDRBi8 : t2PseudoExpand<(outs rGPR:$Rt),
1600 (ins t2addrmode_negimm8:$addr, pred:$p),
1601 4, IIC_iLoad_bh_i, [],
1602 (t2LDRBi8 rGPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1603 def ATOMIC_t2LDRBs : t2PseudoExpand<(outs rGPR:$Rt),
1604 (ins t2addrmode_so_reg:$addr, pred:$p),
1605 4, IIC_iLoad_bh_si, [],
1606 (t2LDRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
1607 def ATOMIC_t2LDRHi12 : t2PseudoExpand<(outs rGPR:$Rt),
1608 (ins t2addrmode_imm12:$addr, pred:$p),
1609 4, IIC_iLoad_bh_i, [],
1610 (t2LDRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
1611 def ATOMIC_t2LDRHi8 : t2PseudoExpand<(outs rGPR:$Rt),
1612 (ins t2addrmode_negimm8:$addr, pred:$p),
1613 4, IIC_iLoad_bh_i, [],
1614 (t2LDRHi8 rGPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1615 def ATOMIC_t2LDRHs : t2PseudoExpand<(outs rGPR:$Rt),
1616 (ins t2addrmode_so_reg:$addr, pred:$p),
1617 4, IIC_iLoad_bh_si, [],
1618 (t2LDRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
1619 def ATOMIC_t2LDRi12 : t2PseudoExpand<(outs GPR:$Rt),
1620 (ins t2addrmode_imm12:$addr, pred:$p),
1622 (t2LDRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
1623 def ATOMIC_t2LDRi8 : t2PseudoExpand<(outs GPR:$Rt),
1624 (ins t2addrmode_negimm8:$addr, pred:$p),
1626 (t2LDRi8 GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1627 def ATOMIC_t2LDRs : t2PseudoExpand<(outs GPR:$Rt),
1628 (ins t2addrmode_so_reg:$addr, pred:$p),
1629 4, IIC_iLoad_si, [],
1630 (t2LDRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
1633 //===----------------------------------------------------------------------===//
1634 // Load / store multiple Instructions.
1637 multiclass thumb2_ld_mult<string asm, InstrItinClass itin,
1638 InstrItinClass itin_upd, bit L_bit> {
1640 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1641 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1645 let Inst{31-27} = 0b11101;
1646 let Inst{26-25} = 0b00;
1647 let Inst{24-23} = 0b01; // Increment After
1649 let Inst{21} = 0; // No writeback
1650 let Inst{20} = L_bit;
1651 let Inst{19-16} = Rn;
1652 let Inst{15-0} = regs;
1655 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1656 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1660 let Inst{31-27} = 0b11101;
1661 let Inst{26-25} = 0b00;
1662 let Inst{24-23} = 0b01; // Increment After
1664 let Inst{21} = 1; // Writeback
1665 let Inst{20} = L_bit;
1666 let Inst{19-16} = Rn;
1667 let Inst{15-0} = regs;
1670 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1671 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
1675 let Inst{31-27} = 0b11101;
1676 let Inst{26-25} = 0b00;
1677 let Inst{24-23} = 0b10; // Decrement Before
1679 let Inst{21} = 0; // No writeback
1680 let Inst{20} = L_bit;
1681 let Inst{19-16} = Rn;
1682 let Inst{15-0} = regs;
1685 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1686 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1690 let Inst{31-27} = 0b11101;
1691 let Inst{26-25} = 0b00;
1692 let Inst{24-23} = 0b10; // Decrement Before
1694 let Inst{21} = 1; // Writeback
1695 let Inst{20} = L_bit;
1696 let Inst{19-16} = Rn;
1697 let Inst{15-0} = regs;
1701 let neverHasSideEffects = 1 in {
1703 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1704 defm t2LDM : thumb2_ld_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
1706 multiclass thumb2_st_mult<string asm, InstrItinClass itin,
1707 InstrItinClass itin_upd, bit L_bit> {
1709 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1710 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1714 let Inst{31-27} = 0b11101;
1715 let Inst{26-25} = 0b00;
1716 let Inst{24-23} = 0b01; // Increment After
1718 let Inst{21} = 0; // No writeback
1719 let Inst{20} = L_bit;
1720 let Inst{19-16} = Rn;
1722 let Inst{14} = regs{14};
1724 let Inst{12-0} = regs{12-0};
1727 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1728 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1732 let Inst{31-27} = 0b11101;
1733 let Inst{26-25} = 0b00;
1734 let Inst{24-23} = 0b01; // Increment After
1736 let Inst{21} = 1; // Writeback
1737 let Inst{20} = L_bit;
1738 let Inst{19-16} = Rn;
1740 let Inst{14} = regs{14};
1742 let Inst{12-0} = regs{12-0};
1745 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1746 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
1750 let Inst{31-27} = 0b11101;
1751 let Inst{26-25} = 0b00;
1752 let Inst{24-23} = 0b10; // Decrement Before
1754 let Inst{21} = 0; // No writeback
1755 let Inst{20} = L_bit;
1756 let Inst{19-16} = Rn;
1758 let Inst{14} = regs{14};
1760 let Inst{12-0} = regs{12-0};
1763 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1764 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1768 let Inst{31-27} = 0b11101;
1769 let Inst{26-25} = 0b00;
1770 let Inst{24-23} = 0b10; // Decrement Before
1772 let Inst{21} = 1; // Writeback
1773 let Inst{20} = L_bit;
1774 let Inst{19-16} = Rn;
1776 let Inst{14} = regs{14};
1778 let Inst{12-0} = regs{12-0};
1783 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1784 defm t2STM : thumb2_st_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
1786 } // neverHasSideEffects
1789 //===----------------------------------------------------------------------===//
1790 // Move Instructions.
1793 let neverHasSideEffects = 1 in
1794 def t2MOVr : T2sTwoReg<(outs GPRnopc:$Rd), (ins GPR:$Rm), IIC_iMOVr,
1795 "mov", ".w\t$Rd, $Rm", []> {
1796 let Inst{31-27} = 0b11101;
1797 let Inst{26-25} = 0b01;
1798 let Inst{24-21} = 0b0010;
1799 let Inst{19-16} = 0b1111; // Rn
1800 let Inst{14-12} = 0b000;
1801 let Inst{7-4} = 0b0000;
1803 def : t2InstAlias<"mov${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1804 pred:$p, zero_reg)>;
1805 def : t2InstAlias<"movs${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1807 def : t2InstAlias<"movs${p} $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1810 // AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1811 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
1812 AddedComplexity = 1 in
1813 def t2MOVi : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), IIC_iMOVi,
1814 "mov", ".w\t$Rd, $imm",
1815 [(set rGPR:$Rd, t2_so_imm:$imm)]> {
1816 let Inst{31-27} = 0b11110;
1818 let Inst{24-21} = 0b0010;
1819 let Inst{19-16} = 0b1111; // Rn
1823 // cc_out is handled as part of the explicit mnemonic in the parser for 'mov'.
1824 // Use aliases to get that to play nice here.
1825 def : t2InstAlias<"movs${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1827 def : t2InstAlias<"movs${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1830 def : t2InstAlias<"mov${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1831 pred:$p, zero_reg)>;
1832 def : t2InstAlias<"mov${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1833 pred:$p, zero_reg)>;
1835 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
1836 def t2MOVi16 : T2I<(outs rGPR:$Rd), (ins imm0_65535_expr:$imm), IIC_iMOVi,
1837 "movw", "\t$Rd, $imm",
1838 [(set rGPR:$Rd, imm0_65535:$imm)]> {
1839 let Inst{31-27} = 0b11110;
1841 let Inst{24-21} = 0b0010;
1842 let Inst{20} = 0; // The S bit.
1848 let Inst{11-8} = Rd;
1849 let Inst{19-16} = imm{15-12};
1850 let Inst{26} = imm{11};
1851 let Inst{14-12} = imm{10-8};
1852 let Inst{7-0} = imm{7-0};
1853 let DecoderMethod = "DecodeT2MOVTWInstruction";
1856 def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
1857 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1859 let Constraints = "$src = $Rd" in {
1860 def t2MOVTi16 : T2I<(outs rGPR:$Rd),
1861 (ins rGPR:$src, imm0_65535_expr:$imm), IIC_iMOVi,
1862 "movt", "\t$Rd, $imm",
1864 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
1865 let Inst{31-27} = 0b11110;
1867 let Inst{24-21} = 0b0110;
1868 let Inst{20} = 0; // The S bit.
1874 let Inst{11-8} = Rd;
1875 let Inst{19-16} = imm{15-12};
1876 let Inst{26} = imm{11};
1877 let Inst{14-12} = imm{10-8};
1878 let Inst{7-0} = imm{7-0};
1879 let DecoderMethod = "DecodeT2MOVTWInstruction";
1882 def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
1883 (ins rGPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1886 def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
1888 //===----------------------------------------------------------------------===//
1889 // Extend Instructions.
1894 def t2SXTB : T2I_ext_rrot<0b100, "sxtb",
1895 UnOpFrag<(sext_inreg node:$Src, i8)>>;
1896 def t2SXTH : T2I_ext_rrot<0b000, "sxth",
1897 UnOpFrag<(sext_inreg node:$Src, i16)>>;
1898 def t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
1900 def t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
1901 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1902 def t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
1903 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1904 def t2SXTAB16 : T2I_exta_rrot_np<0b010, "sxtab16">;
1908 let AddedComplexity = 16 in {
1909 def t2UXTB : T2I_ext_rrot<0b101, "uxtb",
1910 UnOpFrag<(and node:$Src, 0x000000FF)>>;
1911 def t2UXTH : T2I_ext_rrot<0b001, "uxth",
1912 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1913 def t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
1914 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1916 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1917 // The transformation should probably be done as a combiner action
1918 // instead so we can include a check for masking back in the upper
1919 // eight bits of the source into the lower eight bits of the result.
1920 //def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
1921 // (t2UXTB16 rGPR:$Src, 3)>,
1922 // Requires<[HasT2ExtractPack, IsThumb2]>;
1923 def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
1924 (t2UXTB16 rGPR:$Src, 1)>,
1925 Requires<[HasT2ExtractPack, IsThumb2]>;
1927 def t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
1928 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1929 def t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
1930 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1931 def t2UXTAB16 : T2I_exta_rrot_np<0b011, "uxtab16">;
1934 //===----------------------------------------------------------------------===//
1935 // Arithmetic Instructions.
1938 defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1939 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1940 defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1941 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1943 // ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
1945 // Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the
1946 // selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by
1947 // AdjustInstrPostInstrSelection where we determine whether or not to
1948 // set the "s" bit based on CPSR liveness.
1950 // FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen
1951 // support for an optional CPSR definition that corresponds to the DAG
1952 // node's second value. We can then eliminate the implicit def of CPSR.
1953 defm t2ADDS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi,
1954 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
1955 defm t2SUBS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi,
1956 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
1958 let hasPostISelHook = 1 in {
1959 defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
1960 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
1961 defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
1962 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
1966 defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
1967 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1969 // FIXME: Eliminate them if we can write def : Pat patterns which defines
1970 // CPSR and the implicit def of CPSR is not needed.
1971 defm t2RSBS : T2I_rbin_s_is <BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
1973 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1974 // The assume-no-carry-in form uses the negation of the input since add/sub
1975 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
1976 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1978 // The AddedComplexity preferences the first variant over the others since
1979 // it can be shrunk to a 16-bit wide encoding, while the others cannot.
1980 let AddedComplexity = 1 in
1981 def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1982 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1983 def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1984 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1985 def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1986 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1987 def : T2Pat<(add GPR:$src, imm0_65535_neg:$imm),
1988 (t2SUBrr GPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
1990 let AddedComplexity = 1 in
1991 def : T2Pat<(ARMaddc rGPR:$src, imm0_255_neg:$imm),
1992 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1993 def : T2Pat<(ARMaddc rGPR:$src, t2_so_imm_neg:$imm),
1994 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
1995 def : T2Pat<(ARMaddc rGPR:$src, imm0_65535_neg:$imm),
1996 (t2SUBSrr rGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
1997 // The with-carry-in form matches bitwise not instead of the negation.
1998 // Effectively, the inverse interpretation of the carry flag already accounts
1999 // for part of the negation.
2000 let AddedComplexity = 1 in
2001 def : T2Pat<(ARMadde rGPR:$src, imm0_255_not:$imm, CPSR),
2002 (t2SBCri rGPR:$src, imm0_255_not:$imm)>;
2003 def : T2Pat<(ARMadde rGPR:$src, t2_so_imm_not:$imm, CPSR),
2004 (t2SBCri rGPR:$src, t2_so_imm_not:$imm)>;
2005 def : T2Pat<(ARMadde rGPR:$src, imm0_65535_neg:$imm, CPSR),
2006 (t2SBCrr rGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
2008 // Select Bytes -- for disassembly only
2010 def t2SEL : T2ThreeReg<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2011 NoItinerary, "sel", "\t$Rd, $Rn, $Rm", []>,
2012 Requires<[IsThumb2, HasThumb2DSP]> {
2013 let Inst{31-27} = 0b11111;
2014 let Inst{26-24} = 0b010;
2016 let Inst{22-20} = 0b010;
2017 let Inst{15-12} = 0b1111;
2019 let Inst{6-4} = 0b000;
2022 // A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
2023 // And Miscellaneous operations -- for disassembly only
2024 class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
2025 list<dag> pat = [/* For disassembly only; pattern left blank */],
2026 dag iops = (ins rGPR:$Rn, rGPR:$Rm),
2027 string asm = "\t$Rd, $Rn, $Rm">
2028 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, pat>,
2029 Requires<[IsThumb2, HasThumb2DSP]> {
2030 let Inst{31-27} = 0b11111;
2031 let Inst{26-23} = 0b0101;
2032 let Inst{22-20} = op22_20;
2033 let Inst{15-12} = 0b1111;
2034 let Inst{7-4} = op7_4;
2040 let Inst{11-8} = Rd;
2041 let Inst{19-16} = Rn;
2045 // Saturating add/subtract -- for disassembly only
2047 def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
2048 [(set rGPR:$Rd, (int_arm_qadd rGPR:$Rn, rGPR:$Rm))],
2049 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2050 def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
2051 def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
2052 def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
2053 def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd", [],
2054 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2055 def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub", [],
2056 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2057 def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
2058 def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
2059 [(set rGPR:$Rd, (int_arm_qsub rGPR:$Rn, rGPR:$Rm))],
2060 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2061 def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
2062 def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
2063 def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
2064 def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
2065 def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
2066 def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
2067 def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
2068 def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
2070 // Signed/Unsigned add/subtract -- for disassembly only
2072 def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
2073 def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
2074 def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
2075 def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
2076 def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
2077 def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
2078 def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
2079 def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
2080 def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
2081 def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
2082 def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
2083 def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
2085 // Signed/Unsigned halving add/subtract -- for disassembly only
2087 def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
2088 def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
2089 def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
2090 def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
2091 def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
2092 def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
2093 def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
2094 def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
2095 def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
2096 def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
2097 def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
2098 def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
2100 // Helper class for disassembly only
2101 // A6.3.16 & A6.3.17
2102 // T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
2103 class T2ThreeReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2104 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2105 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2106 let Inst{31-27} = 0b11111;
2107 let Inst{26-24} = 0b011;
2108 let Inst{23} = long;
2109 let Inst{22-20} = op22_20;
2110 let Inst{7-4} = op7_4;
2113 class T2FourReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2114 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2115 : T2FourReg<oops, iops, itin, opc, asm, pattern> {
2116 let Inst{31-27} = 0b11111;
2117 let Inst{26-24} = 0b011;
2118 let Inst{23} = long;
2119 let Inst{22-20} = op22_20;
2120 let Inst{7-4} = op7_4;
2123 // Unsigned Sum of Absolute Differences [and Accumulate].
2124 def t2USAD8 : T2ThreeReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2125 (ins rGPR:$Rn, rGPR:$Rm),
2126 NoItinerary, "usad8", "\t$Rd, $Rn, $Rm", []>,
2127 Requires<[IsThumb2, HasThumb2DSP]> {
2128 let Inst{15-12} = 0b1111;
2130 def t2USADA8 : T2FourReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2131 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), NoItinerary,
2132 "usada8", "\t$Rd, $Rn, $Rm, $Ra", []>,
2133 Requires<[IsThumb2, HasThumb2DSP]>;
2135 // Signed/Unsigned saturate.
2136 class T2SatI<dag oops, dag iops, InstrItinClass itin,
2137 string opc, string asm, list<dag> pattern>
2138 : T2I<oops, iops, itin, opc, asm, pattern> {
2144 let Inst{11-8} = Rd;
2145 let Inst{19-16} = Rn;
2146 let Inst{4-0} = sat_imm;
2147 let Inst{21} = sh{5};
2148 let Inst{14-12} = sh{4-2};
2149 let Inst{7-6} = sh{1-0};
2154 (ins imm1_32:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
2155 NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
2156 let Inst{31-27} = 0b11110;
2157 let Inst{25-22} = 0b1100;
2163 def t2SSAT16: T2SatI<
2164 (outs rGPR:$Rd), (ins imm1_16:$sat_imm, rGPR:$Rn), NoItinerary,
2165 "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
2166 Requires<[IsThumb2, HasThumb2DSP]> {
2167 let Inst{31-27} = 0b11110;
2168 let Inst{25-22} = 0b1100;
2171 let Inst{21} = 1; // sh = '1'
2172 let Inst{14-12} = 0b000; // imm3 = '000'
2173 let Inst{7-6} = 0b00; // imm2 = '00'
2174 let Inst{5-4} = 0b00;
2179 (ins imm0_31:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
2180 NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
2181 let Inst{31-27} = 0b11110;
2182 let Inst{25-22} = 0b1110;
2187 def t2USAT16: T2SatI<(outs rGPR:$Rd), (ins imm0_15:$sat_imm, rGPR:$Rn),
2189 "usat16", "\t$Rd, $sat_imm, $Rn", []>,
2190 Requires<[IsThumb2, HasThumb2DSP]> {
2191 let Inst{31-22} = 0b1111001110;
2194 let Inst{21} = 1; // sh = '1'
2195 let Inst{14-12} = 0b000; // imm3 = '000'
2196 let Inst{7-6} = 0b00; // imm2 = '00'
2197 let Inst{5-4} = 0b00;
2200 def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
2201 def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
2203 //===----------------------------------------------------------------------===//
2204 // Shift and rotate Instructions.
2207 defm t2LSL : T2I_sh_ir<0b00, "lsl", imm0_31,
2208 BinOpFrag<(shl node:$LHS, node:$RHS)>>;
2209 defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr,
2210 BinOpFrag<(srl node:$LHS, node:$RHS)>>;
2211 defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr,
2212 BinOpFrag<(sra node:$LHS, node:$RHS)>>;
2213 defm t2ROR : T2I_sh_ir<0b11, "ror", imm0_31,
2214 BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
2216 // (rotr x, (and y, 0x...1f)) ==> (ROR x, y)
2217 def : T2Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)),
2218 (t2RORrr rGPR:$lhs, rGPR:$rhs)>;
2220 let Uses = [CPSR] in {
2221 def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2222 "rrx", "\t$Rd, $Rm",
2223 [(set rGPR:$Rd, (ARMrrx rGPR:$Rm))]> {
2224 let Inst{31-27} = 0b11101;
2225 let Inst{26-25} = 0b01;
2226 let Inst{24-21} = 0b0010;
2227 let Inst{19-16} = 0b1111; // Rn
2228 let Inst{14-12} = 0b000;
2229 let Inst{7-4} = 0b0011;
2233 let isCodeGenOnly = 1, Defs = [CPSR] in {
2234 def t2MOVsrl_flag : T2TwoRegShiftImm<
2235 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2236 "lsrs", ".w\t$Rd, $Rm, #1",
2237 [(set rGPR:$Rd, (ARMsrl_flag rGPR:$Rm))]> {
2238 let Inst{31-27} = 0b11101;
2239 let Inst{26-25} = 0b01;
2240 let Inst{24-21} = 0b0010;
2241 let Inst{20} = 1; // The S bit.
2242 let Inst{19-16} = 0b1111; // Rn
2243 let Inst{5-4} = 0b01; // Shift type.
2244 // Shift amount = Inst{14-12:7-6} = 1.
2245 let Inst{14-12} = 0b000;
2246 let Inst{7-6} = 0b01;
2248 def t2MOVsra_flag : T2TwoRegShiftImm<
2249 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2250 "asrs", ".w\t$Rd, $Rm, #1",
2251 [(set rGPR:$Rd, (ARMsra_flag rGPR:$Rm))]> {
2252 let Inst{31-27} = 0b11101;
2253 let Inst{26-25} = 0b01;
2254 let Inst{24-21} = 0b0010;
2255 let Inst{20} = 1; // The S bit.
2256 let Inst{19-16} = 0b1111; // Rn
2257 let Inst{5-4} = 0b10; // Shift type.
2258 // Shift amount = Inst{14-12:7-6} = 1.
2259 let Inst{14-12} = 0b000;
2260 let Inst{7-6} = 0b01;
2264 //===----------------------------------------------------------------------===//
2265 // Bitwise Instructions.
2268 defm t2AND : T2I_bin_w_irs<0b0000, "and",
2269 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2270 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
2271 defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
2272 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2273 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
2274 defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
2275 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2276 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
2278 defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
2279 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2280 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
2282 class T2BitFI<dag oops, dag iops, InstrItinClass itin,
2283 string opc, string asm, list<dag> pattern>
2284 : T2I<oops, iops, itin, opc, asm, pattern> {
2289 let Inst{11-8} = Rd;
2290 let Inst{4-0} = msb{4-0};
2291 let Inst{14-12} = lsb{4-2};
2292 let Inst{7-6} = lsb{1-0};
2295 class T2TwoRegBitFI<dag oops, dag iops, InstrItinClass itin,
2296 string opc, string asm, list<dag> pattern>
2297 : T2BitFI<oops, iops, itin, opc, asm, pattern> {
2300 let Inst{19-16} = Rn;
2303 let Constraints = "$src = $Rd" in
2304 def t2BFC : T2BitFI<(outs rGPR:$Rd), (ins rGPR:$src, bf_inv_mask_imm:$imm),
2305 IIC_iUNAsi, "bfc", "\t$Rd, $imm",
2306 [(set rGPR:$Rd, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
2307 let Inst{31-27} = 0b11110;
2308 let Inst{26} = 0; // should be 0.
2310 let Inst{24-20} = 0b10110;
2311 let Inst{19-16} = 0b1111; // Rn
2313 let Inst{5} = 0; // should be 0.
2316 let msb{4-0} = imm{9-5};
2317 let lsb{4-0} = imm{4-0};
2320 def t2SBFX: T2TwoRegBitFI<
2321 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2322 IIC_iUNAsi, "sbfx", "\t$Rd, $Rn, $lsb, $msb", []> {
2323 let Inst{31-27} = 0b11110;
2325 let Inst{24-20} = 0b10100;
2329 def t2UBFX: T2TwoRegBitFI<
2330 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2331 IIC_iUNAsi, "ubfx", "\t$Rd, $Rn, $lsb, $msb", []> {
2332 let Inst{31-27} = 0b11110;
2334 let Inst{24-20} = 0b11100;
2338 // A8.6.18 BFI - Bitfield insert (Encoding T1)
2339 let Constraints = "$src = $Rd" in {
2340 def t2BFI : T2TwoRegBitFI<(outs rGPR:$Rd),
2341 (ins rGPR:$src, rGPR:$Rn, bf_inv_mask_imm:$imm),
2342 IIC_iBITi, "bfi", "\t$Rd, $Rn, $imm",
2343 [(set rGPR:$Rd, (ARMbfi rGPR:$src, rGPR:$Rn,
2344 bf_inv_mask_imm:$imm))]> {
2345 let Inst{31-27} = 0b11110;
2346 let Inst{26} = 0; // should be 0.
2348 let Inst{24-20} = 0b10110;
2350 let Inst{5} = 0; // should be 0.
2353 let msb{4-0} = imm{9-5};
2354 let lsb{4-0} = imm{4-0};
2358 defm t2ORN : T2I_bin_irs<0b0011, "orn",
2359 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2360 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
2362 /// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
2363 /// unary operation that produces a value. These are predicable and can be
2364 /// changed to modify CPSR.
2365 multiclass T2I_un_irs<bits<4> opcod, string opc,
2366 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
2367 PatFrag opnode, bit Cheap = 0, bit ReMat = 0> {
2369 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii,
2371 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]> {
2372 let isAsCheapAsAMove = Cheap;
2373 let isReMaterializable = ReMat;
2374 let Inst{31-27} = 0b11110;
2376 let Inst{24-21} = opcod;
2377 let Inst{19-16} = 0b1111; // Rn
2381 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir,
2382 opc, ".w\t$Rd, $Rm",
2383 [(set rGPR:$Rd, (opnode rGPR:$Rm))]> {
2384 let Inst{31-27} = 0b11101;
2385 let Inst{26-25} = 0b01;
2386 let Inst{24-21} = opcod;
2387 let Inst{19-16} = 0b1111; // Rn
2388 let Inst{14-12} = 0b000; // imm3
2389 let Inst{7-6} = 0b00; // imm2
2390 let Inst{5-4} = 0b00; // type
2393 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis,
2394 opc, ".w\t$Rd, $ShiftedRm",
2395 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]> {
2396 let Inst{31-27} = 0b11101;
2397 let Inst{26-25} = 0b01;
2398 let Inst{24-21} = opcod;
2399 let Inst{19-16} = 0b1111; // Rn
2403 // Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
2404 let AddedComplexity = 1 in
2405 defm t2MVN : T2I_un_irs <0b0011, "mvn",
2406 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
2407 UnOpFrag<(not node:$Src)>, 1, 1>;
2409 let AddedComplexity = 1 in
2410 def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
2411 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
2413 // top16Zero - answer true if the upper 16 bits of $src are 0, false otherwise
2414 def top16Zero: PatLeaf<(i32 rGPR:$src), [{
2415 return CurDAG->MaskedValueIsZero(SDValue(N,0), APInt::getHighBitsSet(32, 16));
2418 // so_imm_notSext is needed instead of so_imm_not, as the value of imm
2419 // will match the extended, not the original bitWidth for $src.
2420 def : T2Pat<(and top16Zero:$src, t2_so_imm_notSext:$imm),
2421 (t2BICri rGPR:$src, t2_so_imm_notSext:$imm)>;
2424 // FIXME: Disable this pattern on Darwin to workaround an assembler bug.
2425 def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
2426 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
2427 Requires<[IsThumb2]>;
2429 def : T2Pat<(t2_so_imm_not:$src),
2430 (t2MVNi t2_so_imm_not:$src)>;
2432 //===----------------------------------------------------------------------===//
2433 // Multiply Instructions.
2435 let isCommutable = 1 in
2436 def t2MUL: T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2437 "mul", "\t$Rd, $Rn, $Rm",
2438 [(set rGPR:$Rd, (mul rGPR:$Rn, rGPR:$Rm))]> {
2439 let Inst{31-27} = 0b11111;
2440 let Inst{26-23} = 0b0110;
2441 let Inst{22-20} = 0b000;
2442 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2443 let Inst{7-4} = 0b0000; // Multiply
2446 def t2MLA: T2FourReg<
2447 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2448 "mla", "\t$Rd, $Rn, $Rm, $Ra",
2449 [(set rGPR:$Rd, (add (mul rGPR:$Rn, rGPR:$Rm), rGPR:$Ra))]> {
2450 let Inst{31-27} = 0b11111;
2451 let Inst{26-23} = 0b0110;
2452 let Inst{22-20} = 0b000;
2453 let Inst{7-4} = 0b0000; // Multiply
2456 def t2MLS: T2FourReg<
2457 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2458 "mls", "\t$Rd, $Rn, $Rm, $Ra",
2459 [(set rGPR:$Rd, (sub rGPR:$Ra, (mul rGPR:$Rn, rGPR:$Rm)))]> {
2460 let Inst{31-27} = 0b11111;
2461 let Inst{26-23} = 0b0110;
2462 let Inst{22-20} = 0b000;
2463 let Inst{7-4} = 0b0001; // Multiply and Subtract
2466 // Extra precision multiplies with low / high results
2467 let neverHasSideEffects = 1 in {
2468 let isCommutable = 1 in {
2469 def t2SMULL : T2MulLong<0b000, 0b0000,
2470 (outs rGPR:$RdLo, rGPR:$RdHi),
2471 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
2472 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2474 def t2UMULL : T2MulLong<0b010, 0b0000,
2475 (outs rGPR:$RdLo, rGPR:$RdHi),
2476 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
2477 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2480 // Multiply + accumulate
2481 def t2SMLAL : T2MulLong<0b100, 0b0000,
2482 (outs rGPR:$RdLo, rGPR:$RdHi),
2483 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2484 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2486 def t2UMLAL : T2MulLong<0b110, 0b0000,
2487 (outs rGPR:$RdLo, rGPR:$RdHi),
2488 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2489 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2491 def t2UMAAL : T2MulLong<0b110, 0b0110,
2492 (outs rGPR:$RdLo, rGPR:$RdHi),
2493 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2494 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2495 Requires<[IsThumb2, HasThumb2DSP]>;
2496 } // neverHasSideEffects
2498 // Rounding variants of the below included for disassembly only
2500 // Most significant word multiply
2501 def t2SMMUL : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2502 "smmul", "\t$Rd, $Rn, $Rm",
2503 [(set rGPR:$Rd, (mulhs rGPR:$Rn, rGPR:$Rm))]>,
2504 Requires<[IsThumb2, HasThumb2DSP]> {
2505 let Inst{31-27} = 0b11111;
2506 let Inst{26-23} = 0b0110;
2507 let Inst{22-20} = 0b101;
2508 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2509 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2512 def t2SMMULR : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2513 "smmulr", "\t$Rd, $Rn, $Rm", []>,
2514 Requires<[IsThumb2, HasThumb2DSP]> {
2515 let Inst{31-27} = 0b11111;
2516 let Inst{26-23} = 0b0110;
2517 let Inst{22-20} = 0b101;
2518 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2519 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2522 def t2SMMLA : T2FourReg<
2523 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2524 "smmla", "\t$Rd, $Rn, $Rm, $Ra",
2525 [(set rGPR:$Rd, (add (mulhs rGPR:$Rm, rGPR:$Rn), rGPR:$Ra))]>,
2526 Requires<[IsThumb2, HasThumb2DSP]> {
2527 let Inst{31-27} = 0b11111;
2528 let Inst{26-23} = 0b0110;
2529 let Inst{22-20} = 0b101;
2530 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2533 def t2SMMLAR: T2FourReg<
2534 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2535 "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
2536 Requires<[IsThumb2, HasThumb2DSP]> {
2537 let Inst{31-27} = 0b11111;
2538 let Inst{26-23} = 0b0110;
2539 let Inst{22-20} = 0b101;
2540 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2543 def t2SMMLS: T2FourReg<
2544 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2545 "smmls", "\t$Rd, $Rn, $Rm, $Ra",
2546 [(set rGPR:$Rd, (sub rGPR:$Ra, (mulhs rGPR:$Rn, rGPR:$Rm)))]>,
2547 Requires<[IsThumb2, HasThumb2DSP]> {
2548 let Inst{31-27} = 0b11111;
2549 let Inst{26-23} = 0b0110;
2550 let Inst{22-20} = 0b110;
2551 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2554 def t2SMMLSR:T2FourReg<
2555 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2556 "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
2557 Requires<[IsThumb2, HasThumb2DSP]> {
2558 let Inst{31-27} = 0b11111;
2559 let Inst{26-23} = 0b0110;
2560 let Inst{22-20} = 0b110;
2561 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2564 multiclass T2I_smul<string opc, PatFrag opnode> {
2565 def BB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2566 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
2567 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
2568 (sext_inreg rGPR:$Rm, i16)))]>,
2569 Requires<[IsThumb2, HasThumb2DSP]> {
2570 let Inst{31-27} = 0b11111;
2571 let Inst{26-23} = 0b0110;
2572 let Inst{22-20} = 0b001;
2573 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2574 let Inst{7-6} = 0b00;
2575 let Inst{5-4} = 0b00;
2578 def BT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2579 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
2580 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
2581 (sra rGPR:$Rm, (i32 16))))]>,
2582 Requires<[IsThumb2, HasThumb2DSP]> {
2583 let Inst{31-27} = 0b11111;
2584 let Inst{26-23} = 0b0110;
2585 let Inst{22-20} = 0b001;
2586 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2587 let Inst{7-6} = 0b00;
2588 let Inst{5-4} = 0b01;
2591 def TB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2592 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
2593 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
2594 (sext_inreg rGPR:$Rm, i16)))]>,
2595 Requires<[IsThumb2, HasThumb2DSP]> {
2596 let Inst{31-27} = 0b11111;
2597 let Inst{26-23} = 0b0110;
2598 let Inst{22-20} = 0b001;
2599 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2600 let Inst{7-6} = 0b00;
2601 let Inst{5-4} = 0b10;
2604 def TT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2605 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
2606 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
2607 (sra rGPR:$Rm, (i32 16))))]>,
2608 Requires<[IsThumb2, HasThumb2DSP]> {
2609 let Inst{31-27} = 0b11111;
2610 let Inst{26-23} = 0b0110;
2611 let Inst{22-20} = 0b001;
2612 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2613 let Inst{7-6} = 0b00;
2614 let Inst{5-4} = 0b11;
2617 def WB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2618 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
2619 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
2620 (sext_inreg rGPR:$Rm, i16)), (i32 16)))]>,
2621 Requires<[IsThumb2, HasThumb2DSP]> {
2622 let Inst{31-27} = 0b11111;
2623 let Inst{26-23} = 0b0110;
2624 let Inst{22-20} = 0b011;
2625 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2626 let Inst{7-6} = 0b00;
2627 let Inst{5-4} = 0b00;
2630 def WT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2631 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
2632 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
2633 (sra rGPR:$Rm, (i32 16))), (i32 16)))]>,
2634 Requires<[IsThumb2, HasThumb2DSP]> {
2635 let Inst{31-27} = 0b11111;
2636 let Inst{26-23} = 0b0110;
2637 let Inst{22-20} = 0b011;
2638 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2639 let Inst{7-6} = 0b00;
2640 let Inst{5-4} = 0b01;
2645 multiclass T2I_smla<string opc, PatFrag opnode> {
2647 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2648 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
2649 [(set rGPR:$Rd, (add rGPR:$Ra,
2650 (opnode (sext_inreg rGPR:$Rn, i16),
2651 (sext_inreg rGPR:$Rm, i16))))]>,
2652 Requires<[IsThumb2, HasThumb2DSP]> {
2653 let Inst{31-27} = 0b11111;
2654 let Inst{26-23} = 0b0110;
2655 let Inst{22-20} = 0b001;
2656 let Inst{7-6} = 0b00;
2657 let Inst{5-4} = 0b00;
2661 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2662 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
2663 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sext_inreg rGPR:$Rn, i16),
2664 (sra rGPR:$Rm, (i32 16)))))]>,
2665 Requires<[IsThumb2, HasThumb2DSP]> {
2666 let Inst{31-27} = 0b11111;
2667 let Inst{26-23} = 0b0110;
2668 let Inst{22-20} = 0b001;
2669 let Inst{7-6} = 0b00;
2670 let Inst{5-4} = 0b01;
2674 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2675 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
2676 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
2677 (sext_inreg rGPR:$Rm, i16))))]>,
2678 Requires<[IsThumb2, HasThumb2DSP]> {
2679 let Inst{31-27} = 0b11111;
2680 let Inst{26-23} = 0b0110;
2681 let Inst{22-20} = 0b001;
2682 let Inst{7-6} = 0b00;
2683 let Inst{5-4} = 0b10;
2687 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2688 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
2689 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
2690 (sra rGPR:$Rm, (i32 16)))))]>,
2691 Requires<[IsThumb2, HasThumb2DSP]> {
2692 let Inst{31-27} = 0b11111;
2693 let Inst{26-23} = 0b0110;
2694 let Inst{22-20} = 0b001;
2695 let Inst{7-6} = 0b00;
2696 let Inst{5-4} = 0b11;
2700 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2701 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
2702 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
2703 (sext_inreg rGPR:$Rm, i16)), (i32 16))))]>,
2704 Requires<[IsThumb2, HasThumb2DSP]> {
2705 let Inst{31-27} = 0b11111;
2706 let Inst{26-23} = 0b0110;
2707 let Inst{22-20} = 0b011;
2708 let Inst{7-6} = 0b00;
2709 let Inst{5-4} = 0b00;
2713 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2714 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
2715 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
2716 (sra rGPR:$Rm, (i32 16))), (i32 16))))]>,
2717 Requires<[IsThumb2, HasThumb2DSP]> {
2718 let Inst{31-27} = 0b11111;
2719 let Inst{26-23} = 0b0110;
2720 let Inst{22-20} = 0b011;
2721 let Inst{7-6} = 0b00;
2722 let Inst{5-4} = 0b01;
2726 defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2727 defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2729 // Halfword multiple accumulate long: SMLAL<x><y>
2730 def t2SMLALBB : T2FourReg_mac<1, 0b100, 0b1000, (outs rGPR:$Ra,rGPR:$Rd),
2731 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbb", "\t$Ra, $Rd, $Rn, $Rm",
2732 [/* For disassembly only; pattern left blank */]>,
2733 Requires<[IsThumb2, HasThumb2DSP]>;
2734 def t2SMLALBT : T2FourReg_mac<1, 0b100, 0b1001, (outs rGPR:$Ra,rGPR:$Rd),
2735 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbt", "\t$Ra, $Rd, $Rn, $Rm",
2736 [/* For disassembly only; pattern left blank */]>,
2737 Requires<[IsThumb2, HasThumb2DSP]>;
2738 def t2SMLALTB : T2FourReg_mac<1, 0b100, 0b1010, (outs rGPR:$Ra,rGPR:$Rd),
2739 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltb", "\t$Ra, $Rd, $Rn, $Rm",
2740 [/* For disassembly only; pattern left blank */]>,
2741 Requires<[IsThumb2, HasThumb2DSP]>;
2742 def t2SMLALTT : T2FourReg_mac<1, 0b100, 0b1011, (outs rGPR:$Ra,rGPR:$Rd),
2743 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltt", "\t$Ra, $Rd, $Rn, $Rm",
2744 [/* For disassembly only; pattern left blank */]>,
2745 Requires<[IsThumb2, HasThumb2DSP]>;
2747 // Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2748 def t2SMUAD: T2ThreeReg_mac<
2749 0, 0b010, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2750 IIC_iMAC32, "smuad", "\t$Rd, $Rn, $Rm", []>,
2751 Requires<[IsThumb2, HasThumb2DSP]> {
2752 let Inst{15-12} = 0b1111;
2754 def t2SMUADX:T2ThreeReg_mac<
2755 0, 0b010, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2756 IIC_iMAC32, "smuadx", "\t$Rd, $Rn, $Rm", []>,
2757 Requires<[IsThumb2, HasThumb2DSP]> {
2758 let Inst{15-12} = 0b1111;
2760 def t2SMUSD: T2ThreeReg_mac<
2761 0, 0b100, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2762 IIC_iMAC32, "smusd", "\t$Rd, $Rn, $Rm", []>,
2763 Requires<[IsThumb2, HasThumb2DSP]> {
2764 let Inst{15-12} = 0b1111;
2766 def t2SMUSDX:T2ThreeReg_mac<
2767 0, 0b100, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2768 IIC_iMAC32, "smusdx", "\t$Rd, $Rn, $Rm", []>,
2769 Requires<[IsThumb2, HasThumb2DSP]> {
2770 let Inst{15-12} = 0b1111;
2772 def t2SMLAD : T2FourReg_mac<
2773 0, 0b010, 0b0000, (outs rGPR:$Rd),
2774 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlad",
2775 "\t$Rd, $Rn, $Rm, $Ra", []>,
2776 Requires<[IsThumb2, HasThumb2DSP]>;
2777 def t2SMLADX : T2FourReg_mac<
2778 0, 0b010, 0b0001, (outs rGPR:$Rd),
2779 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smladx",
2780 "\t$Rd, $Rn, $Rm, $Ra", []>,
2781 Requires<[IsThumb2, HasThumb2DSP]>;
2782 def t2SMLSD : T2FourReg_mac<0, 0b100, 0b0000, (outs rGPR:$Rd),
2783 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsd",
2784 "\t$Rd, $Rn, $Rm, $Ra", []>,
2785 Requires<[IsThumb2, HasThumb2DSP]>;
2786 def t2SMLSDX : T2FourReg_mac<0, 0b100, 0b0001, (outs rGPR:$Rd),
2787 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsdx",
2788 "\t$Rd, $Rn, $Rm, $Ra", []>,
2789 Requires<[IsThumb2, HasThumb2DSP]>;
2790 def t2SMLALD : T2FourReg_mac<1, 0b100, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
2791 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64, "smlald",
2792 "\t$Ra, $Rd, $Rn, $Rm", []>,
2793 Requires<[IsThumb2, HasThumb2DSP]>;
2794 def t2SMLALDX : T2FourReg_mac<1, 0b100, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2795 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaldx",
2796 "\t$Ra, $Rd, $Rn, $Rm", []>,
2797 Requires<[IsThumb2, HasThumb2DSP]>;
2798 def t2SMLSLD : T2FourReg_mac<1, 0b101, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
2799 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlsld",
2800 "\t$Ra, $Rd, $Rn, $Rm", []>,
2801 Requires<[IsThumb2, HasThumb2DSP]>;
2802 def t2SMLSLDX : T2FourReg_mac<1, 0b101, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2803 (ins rGPR:$Rm,rGPR:$Rn), IIC_iMAC64, "smlsldx",
2804 "\t$Ra, $Rd, $Rn, $Rm", []>,
2805 Requires<[IsThumb2, HasThumb2DSP]>;
2807 //===----------------------------------------------------------------------===//
2808 // Division Instructions.
2809 // Signed and unsigned division on v7-M
2811 def t2SDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUi,
2812 "sdiv", "\t$Rd, $Rn, $Rm",
2813 [(set rGPR:$Rd, (sdiv rGPR:$Rn, rGPR:$Rm))]>,
2814 Requires<[HasDivide, IsThumb2]> {
2815 let Inst{31-27} = 0b11111;
2816 let Inst{26-21} = 0b011100;
2818 let Inst{15-12} = 0b1111;
2819 let Inst{7-4} = 0b1111;
2822 def t2UDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUi,
2823 "udiv", "\t$Rd, $Rn, $Rm",
2824 [(set rGPR:$Rd, (udiv rGPR:$Rn, rGPR:$Rm))]>,
2825 Requires<[HasDivide, IsThumb2]> {
2826 let Inst{31-27} = 0b11111;
2827 let Inst{26-21} = 0b011101;
2829 let Inst{15-12} = 0b1111;
2830 let Inst{7-4} = 0b1111;
2833 //===----------------------------------------------------------------------===//
2834 // Misc. Arithmetic Instructions.
2837 class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2838 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2839 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2840 let Inst{31-27} = 0b11111;
2841 let Inst{26-22} = 0b01010;
2842 let Inst{21-20} = op1;
2843 let Inst{15-12} = 0b1111;
2844 let Inst{7-6} = 0b10;
2845 let Inst{5-4} = op2;
2849 def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2850 "clz", "\t$Rd, $Rm", [(set rGPR:$Rd, (ctlz rGPR:$Rm))]>;
2852 def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2853 "rbit", "\t$Rd, $Rm",
2854 [(set rGPR:$Rd, (ARMrbit rGPR:$Rm))]>;
2856 def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2857 "rev", ".w\t$Rd, $Rm", [(set rGPR:$Rd, (bswap rGPR:$Rm))]>;
2859 def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2860 "rev16", ".w\t$Rd, $Rm",
2861 [(set rGPR:$Rd, (rotr (bswap rGPR:$Rm), (i32 16)))]>;
2863 def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2864 "revsh", ".w\t$Rd, $Rm",
2865 [(set rGPR:$Rd, (sra (bswap rGPR:$Rm), (i32 16)))]>;
2867 def : T2Pat<(or (sra (shl rGPR:$Rm, (i32 24)), (i32 16)),
2868 (and (srl rGPR:$Rm, (i32 8)), 0xFF)),
2869 (t2REVSH rGPR:$Rm)>;
2871 def t2PKHBT : T2ThreeReg<
2872 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_lsl_amt:$sh),
2873 IIC_iBITsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
2874 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF),
2875 (and (shl rGPR:$Rm, pkh_lsl_amt:$sh),
2877 Requires<[HasT2ExtractPack, IsThumb2]> {
2878 let Inst{31-27} = 0b11101;
2879 let Inst{26-25} = 0b01;
2880 let Inst{24-20} = 0b01100;
2881 let Inst{5} = 0; // BT form
2885 let Inst{14-12} = sh{4-2};
2886 let Inst{7-6} = sh{1-0};
2889 // Alternate cases for PKHBT where identities eliminate some nodes.
2890 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2891 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
2892 Requires<[HasT2ExtractPack, IsThumb2]>;
2893 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2894 (t2PKHBT rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
2895 Requires<[HasT2ExtractPack, IsThumb2]>;
2897 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2898 // will match the pattern below.
2899 def t2PKHTB : T2ThreeReg<
2900 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_asr_amt:$sh),
2901 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
2902 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF0000),
2903 (and (sra rGPR:$Rm, pkh_asr_amt:$sh),
2905 Requires<[HasT2ExtractPack, IsThumb2]> {
2906 let Inst{31-27} = 0b11101;
2907 let Inst{26-25} = 0b01;
2908 let Inst{24-20} = 0b01100;
2909 let Inst{5} = 1; // TB form
2913 let Inst{14-12} = sh{4-2};
2914 let Inst{7-6} = sh{1-0};
2917 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
2918 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
2919 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
2920 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
2921 Requires<[HasT2ExtractPack, IsThumb2]>;
2922 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
2923 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2924 (t2PKHTB rGPR:$src1, rGPR:$src2, imm1_15:$sh)>,
2925 Requires<[HasT2ExtractPack, IsThumb2]>;
2927 //===----------------------------------------------------------------------===//
2928 // Comparison Instructions...
2930 defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
2931 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
2932 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2934 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_imm:$imm),
2935 (t2CMPri GPRnopc:$lhs, t2_so_imm:$imm)>;
2936 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, rGPR:$rhs),
2937 (t2CMPrr GPRnopc:$lhs, rGPR:$rhs)>;
2938 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_reg:$rhs),
2939 (t2CMPrs GPRnopc:$lhs, t2_so_reg:$rhs)>;
2941 let isCompare = 1, Defs = [CPSR] in {
2943 def t2CMNri : T2OneRegCmpImm<
2944 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iCMPi,
2945 "cmn", ".w\t$Rn, $imm",
2946 [(ARMcmn GPRnopc:$Rn, (ineg t2_so_imm:$imm))]> {
2947 let Inst{31-27} = 0b11110;
2949 let Inst{24-21} = 0b1000;
2950 let Inst{20} = 1; // The S bit.
2952 let Inst{11-8} = 0b1111; // Rd
2955 def t2CMNzrr : T2TwoRegCmp<
2956 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iCMPr,
2957 "cmn", ".w\t$Rn, $Rm",
2958 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
2959 GPRnopc:$Rn, rGPR:$Rm)]> {
2960 let Inst{31-27} = 0b11101;
2961 let Inst{26-25} = 0b01;
2962 let Inst{24-21} = 0b1000;
2963 let Inst{20} = 1; // The S bit.
2964 let Inst{14-12} = 0b000; // imm3
2965 let Inst{11-8} = 0b1111; // Rd
2966 let Inst{7-6} = 0b00; // imm2
2967 let Inst{5-4} = 0b00; // type
2970 def t2CMNzrs : T2OneRegCmpShiftedReg<
2971 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), IIC_iCMPsi,
2972 "cmn", ".w\t$Rn, $ShiftedRm",
2973 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
2974 GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]> {
2975 let Inst{31-27} = 0b11101;
2976 let Inst{26-25} = 0b01;
2977 let Inst{24-21} = 0b1000;
2978 let Inst{20} = 1; // The S bit.
2979 let Inst{11-8} = 0b1111; // Rd
2983 // Assembler aliases w/o the ".w" suffix.
2984 // No alias here for 'rr' version as not all instantiations of this multiclass
2985 // want one (CMP in particular, does not).
2986 def : t2InstAlias<"cmn${p} $Rn, $imm",
2987 (t2CMNri GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
2988 def : t2InstAlias<"cmn${p} $Rn, $shift",
2989 (t2CMNzrs GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
2991 def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2992 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
2994 def : T2Pat<(ARMcmpZ GPRnopc:$src, t2_so_imm_neg:$imm),
2995 (t2CMNri GPRnopc:$src, t2_so_imm_neg:$imm)>;
2997 defm t2TST : T2I_cmp_irs<0b0000, "tst",
2998 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2999 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>;
3000 defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
3001 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
3002 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>;
3004 // Conditional moves
3005 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3006 // a two-value operand where a dag node expects two operands. :(
3007 let neverHasSideEffects = 1 in {
3009 let isCommutable = 1, isSelect = 1 in
3010 def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd),
3011 (ins rGPR:$false, rGPR:$Rm, pred:$p),
3013 [/*(set rGPR:$Rd, (ARMcmov rGPR:$false, rGPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3014 RegConstraint<"$false = $Rd">;
3016 let isMoveImm = 1 in
3017 def t2MOVCCi : t2PseudoInst<(outs rGPR:$Rd),
3018 (ins rGPR:$false, t2_so_imm:$imm, pred:$p),
3020 [/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3021 RegConstraint<"$false = $Rd">;
3023 // FIXME: Pseudo-ize these. For now, just mark codegen only.
3024 let isCodeGenOnly = 1 in {
3025 let isMoveImm = 1 in
3026 def t2MOVCCi16 : T2I<(outs rGPR:$Rd), (ins rGPR:$false, imm0_65535_expr:$imm),
3028 "movw", "\t$Rd, $imm", []>,
3029 RegConstraint<"$false = $Rd"> {
3030 let Inst{31-27} = 0b11110;
3032 let Inst{24-21} = 0b0010;
3033 let Inst{20} = 0; // The S bit.
3039 let Inst{11-8} = Rd;
3040 let Inst{19-16} = imm{15-12};
3041 let Inst{26} = imm{11};
3042 let Inst{14-12} = imm{10-8};
3043 let Inst{7-0} = imm{7-0};
3046 let isMoveImm = 1 in
3047 def t2MOVCCi32imm : PseudoInst<(outs rGPR:$dst),
3048 (ins rGPR:$false, i32imm:$src, pred:$p),
3049 IIC_iCMOVix2, []>, RegConstraint<"$false = $dst">;
3051 let isMoveImm = 1 in
3052 def t2MVNCCi : T2OneRegImm<(outs rGPR:$Rd), (ins rGPR:$false, t2_so_imm:$imm),
3053 IIC_iCMOVi, "mvn", "\t$Rd, $imm",
3054 [/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm_not:$imm,
3055 imm:$cc, CCR:$ccr))*/]>,
3056 RegConstraint<"$false = $Rd"> {
3057 let Inst{31-27} = 0b11110;
3059 let Inst{24-21} = 0b0011;
3060 let Inst{20} = 0; // The S bit.
3061 let Inst{19-16} = 0b1111; // Rn
3065 class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
3066 string opc, string asm, list<dag> pattern>
3067 : T2TwoRegShiftImm<oops, iops, itin, opc, asm, pattern> {
3068 let Inst{31-27} = 0b11101;
3069 let Inst{26-25} = 0b01;
3070 let Inst{24-21} = 0b0010;
3071 let Inst{20} = 0; // The S bit.
3072 let Inst{19-16} = 0b1111; // Rn
3073 let Inst{5-4} = opcod; // Shift type.
3075 def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$Rd),
3076 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3077 IIC_iCMOVsi, "lsl", ".w\t$Rd, $Rm, $imm", []>,
3078 RegConstraint<"$false = $Rd">;
3079 def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$Rd),
3080 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3081 IIC_iCMOVsi, "lsr", ".w\t$Rd, $Rm, $imm", []>,
3082 RegConstraint<"$false = $Rd">;
3083 def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$Rd),
3084 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3085 IIC_iCMOVsi, "asr", ".w\t$Rd, $Rm, $imm", []>,
3086 RegConstraint<"$false = $Rd">;
3087 def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$Rd),
3088 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3089 IIC_iCMOVsi, "ror", ".w\t$Rd, $Rm, $imm", []>,
3090 RegConstraint<"$false = $Rd">;
3091 } // isCodeGenOnly = 1
3093 multiclass T2I_bincc_irs<Instruction iri, Instruction irr, Instruction irs,
3094 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis> {
3096 def ri : t2PseudoExpand<(outs rGPR:$Rd),
3097 (ins rGPR:$Rfalse, rGPR:$Rn, t2_so_imm:$imm,
3098 pred:$p, cc_out:$s),
3100 (iri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>,
3101 RegConstraint<"$Rfalse = $Rd">;
3103 def rr : t2PseudoExpand<(outs rGPR:$Rd),
3104 (ins rGPR:$Rfalse, rGPR:$Rn, rGPR:$Rm,
3105 pred:$p, cc_out:$s),
3107 (irr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>,
3108 RegConstraint<"$Rfalse = $Rd">;
3110 def rs : t2PseudoExpand<(outs rGPR:$Rd),
3111 (ins rGPR:$Rfalse, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3112 pred:$p, cc_out:$s),
3114 (irs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>,
3115 RegConstraint<"$Rfalse = $Rd">;
3118 defm t2ANDCC : T2I_bincc_irs<t2ANDri, t2ANDrr, t2ANDrs,
3119 IIC_iBITi, IIC_iBITr, IIC_iBITsi>;
3120 defm t2ORRCC : T2I_bincc_irs<t2ORRri, t2ORRrr, t2ORRrs,
3121 IIC_iBITi, IIC_iBITr, IIC_iBITsi>;
3122 defm t2EORCC : T2I_bincc_irs<t2EORri, t2EORrr, t2EORrs,
3123 IIC_iBITi, IIC_iBITr, IIC_iBITsi>;
3124 } // neverHasSideEffects
3126 //===----------------------------------------------------------------------===//
3127 // Atomic operations intrinsics
3130 // memory barriers protect the atomic sequences
3131 let hasSideEffects = 1 in {
3132 def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3133 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
3134 Requires<[IsThumb, HasDB]> {
3136 let Inst{31-4} = 0xf3bf8f5;
3137 let Inst{3-0} = opt;
3141 def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3142 "dsb", "\t$opt", []>,
3143 Requires<[IsThumb, HasDB]> {
3145 let Inst{31-4} = 0xf3bf8f4;
3146 let Inst{3-0} = opt;
3149 def t2ISB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3151 []>, Requires<[IsThumb, HasDB]> {
3153 let Inst{31-4} = 0xf3bf8f6;
3154 let Inst{3-0} = opt;
3157 class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
3158 InstrItinClass itin, string opc, string asm, string cstr,
3159 list<dag> pattern, bits<4> rt2 = 0b1111>
3160 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3161 let Inst{31-27} = 0b11101;
3162 let Inst{26-20} = 0b0001101;
3163 let Inst{11-8} = rt2;
3164 let Inst{7-6} = 0b01;
3165 let Inst{5-4} = opcod;
3166 let Inst{3-0} = 0b1111;
3170 let Inst{19-16} = addr;
3171 let Inst{15-12} = Rt;
3173 class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
3174 InstrItinClass itin, string opc, string asm, string cstr,
3175 list<dag> pattern, bits<4> rt2 = 0b1111>
3176 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3177 let Inst{31-27} = 0b11101;
3178 let Inst{26-20} = 0b0001100;
3179 let Inst{11-8} = rt2;
3180 let Inst{7-6} = 0b01;
3181 let Inst{5-4} = opcod;
3187 let Inst{19-16} = addr;
3188 let Inst{15-12} = Rt;
3191 let mayLoad = 1 in {
3192 def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3193 AddrModeNone, 4, NoItinerary,
3194 "ldrexb", "\t$Rt, $addr", "", []>;
3195 def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3196 AddrModeNone, 4, NoItinerary,
3197 "ldrexh", "\t$Rt, $addr", "", []>;
3198 def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_imm0_1020s4:$addr),
3199 AddrModeNone, 4, NoItinerary,
3200 "ldrex", "\t$Rt, $addr", "", []> {
3203 let Inst{31-27} = 0b11101;
3204 let Inst{26-20} = 0b0000101;
3205 let Inst{19-16} = addr{11-8};
3206 let Inst{15-12} = Rt;
3207 let Inst{11-8} = 0b1111;
3208 let Inst{7-0} = addr{7-0};
3210 let hasExtraDefRegAllocReq = 1 in
3211 def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$Rt, rGPR:$Rt2),
3212 (ins addr_offset_none:$addr),
3213 AddrModeNone, 4, NoItinerary,
3214 "ldrexd", "\t$Rt, $Rt2, $addr", "",
3217 let Inst{11-8} = Rt2;
3221 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
3222 def t2STREXB : T2I_strex<0b00, (outs rGPR:$Rd),
3223 (ins rGPR:$Rt, addr_offset_none:$addr),
3224 AddrModeNone, 4, NoItinerary,
3225 "strexb", "\t$Rd, $Rt, $addr", "", []>;
3226 def t2STREXH : T2I_strex<0b01, (outs rGPR:$Rd),
3227 (ins rGPR:$Rt, addr_offset_none:$addr),
3228 AddrModeNone, 4, NoItinerary,
3229 "strexh", "\t$Rd, $Rt, $addr", "", []>;
3230 def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt,
3231 t2addrmode_imm0_1020s4:$addr),
3232 AddrModeNone, 4, NoItinerary,
3233 "strex", "\t$Rd, $Rt, $addr", "",
3238 let Inst{31-27} = 0b11101;
3239 let Inst{26-20} = 0b0000100;
3240 let Inst{19-16} = addr{11-8};
3241 let Inst{15-12} = Rt;
3242 let Inst{11-8} = Rd;
3243 let Inst{7-0} = addr{7-0};
3245 let hasExtraSrcRegAllocReq = 1 in
3246 def t2STREXD : T2I_strex<0b11, (outs rGPR:$Rd),
3247 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr),
3248 AddrModeNone, 4, NoItinerary,
3249 "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [],
3252 let Inst{11-8} = Rt2;
3256 def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "", []>,
3257 Requires<[IsThumb2, HasV7]> {
3258 let Inst{31-16} = 0xf3bf;
3259 let Inst{15-14} = 0b10;
3262 let Inst{11-8} = 0b1111;
3263 let Inst{7-4} = 0b0010;
3264 let Inst{3-0} = 0b1111;
3267 //===----------------------------------------------------------------------===//
3268 // SJLJ Exception handling intrinsics
3269 // eh_sjlj_setjmp() is an instruction sequence to store the return
3270 // address and save #0 in R0 for the non-longjmp case.
3271 // Since by its nature we may be coming from some other function to get
3272 // here, and we're using the stack frame for the containing function to
3273 // save/restore registers, we can't keep anything live in regs across
3274 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
3275 // when we get here from a longjmp(). We force everything out of registers
3276 // except for our own input by listing the relevant registers in Defs. By
3277 // doing so, we also cause the prologue/epilogue code to actively preserve
3278 // all of the callee-saved resgisters, which is exactly what we want.
3279 // $val is a scratch register for our use.
3281 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
3282 Q0, Q1, Q2, Q3, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15],
3283 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1,
3284 usesCustomInserter = 1 in {
3285 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
3286 AddrModeNone, 0, NoItinerary, "", "",
3287 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
3288 Requires<[IsThumb2, HasVFP2]>;
3292 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
3293 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1,
3294 usesCustomInserter = 1 in {
3295 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
3296 AddrModeNone, 0, NoItinerary, "", "",
3297 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
3298 Requires<[IsThumb2, NoVFP]>;
3302 //===----------------------------------------------------------------------===//
3303 // Control-Flow Instructions
3306 // FIXME: remove when we have a way to marking a MI with these properties.
3307 // FIXME: Should pc be an implicit operand like PICADD, etc?
3308 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3309 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3310 def t2LDMIA_RET: t2PseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3311 reglist:$regs, variable_ops),
3312 4, IIC_iLoad_mBr, [],
3313 (t2LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3314 RegConstraint<"$Rn = $wb">;
3316 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
3317 let isPredicable = 1 in
3318 def t2B : T2I<(outs), (ins uncondbrtarget:$target), IIC_Br,
3320 [(br bb:$target)]> {
3321 let Inst{31-27} = 0b11110;
3322 let Inst{15-14} = 0b10;
3326 let Inst{26} = target{19};
3327 let Inst{11} = target{18};
3328 let Inst{13} = target{17};
3329 let Inst{21-16} = target{16-11};
3330 let Inst{10-0} = target{10-0};
3331 let DecoderMethod = "DecodeT2BInstruction";
3334 let isNotDuplicable = 1, isIndirectBranch = 1 in {
3335 def t2BR_JT : t2PseudoInst<(outs),
3336 (ins GPR:$target, GPR:$index, i32imm:$jt, i32imm:$id),
3338 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]>;
3340 // FIXME: Add a non-pc based case that can be predicated.
3341 def t2TBB_JT : t2PseudoInst<(outs),
3342 (ins GPR:$index, i32imm:$jt, i32imm:$id), 0, IIC_Br, []>;
3344 def t2TBH_JT : t2PseudoInst<(outs),
3345 (ins GPR:$index, i32imm:$jt, i32imm:$id), 0, IIC_Br, []>;
3347 def t2TBB : T2I<(outs), (ins addrmode_tbb:$addr), IIC_Br,
3348 "tbb", "\t$addr", []> {
3351 let Inst{31-20} = 0b111010001101;
3352 let Inst{19-16} = Rn;
3353 let Inst{15-5} = 0b11110000000;
3354 let Inst{4} = 0; // B form
3357 let DecoderMethod = "DecodeThumbTableBranch";
3360 def t2TBH : T2I<(outs), (ins addrmode_tbh:$addr), IIC_Br,
3361 "tbh", "\t$addr", []> {
3364 let Inst{31-20} = 0b111010001101;
3365 let Inst{19-16} = Rn;
3366 let Inst{15-5} = 0b11110000000;
3367 let Inst{4} = 1; // H form
3370 let DecoderMethod = "DecodeThumbTableBranch";
3372 } // isNotDuplicable, isIndirectBranch
3374 } // isBranch, isTerminator, isBarrier
3376 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
3377 // a two-value operand where a dag node expects ", "two operands. :(
3378 let isBranch = 1, isTerminator = 1 in
3379 def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
3381 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
3382 let Inst{31-27} = 0b11110;
3383 let Inst{15-14} = 0b10;
3387 let Inst{25-22} = p;
3390 let Inst{26} = target{20};
3391 let Inst{11} = target{19};
3392 let Inst{13} = target{18};
3393 let Inst{21-16} = target{17-12};
3394 let Inst{10-0} = target{11-1};
3396 let DecoderMethod = "DecodeThumb2BCCInstruction";
3399 // Tail calls. The IOS version of thumb tail calls uses a t2 branch, so
3401 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
3404 def tTAILJMPd: tPseudoExpand<(outs),
3405 (ins uncondbrtarget:$dst, pred:$p),
3407 (t2B uncondbrtarget:$dst, pred:$p)>,
3408 Requires<[IsThumb2, IsIOS]>;
3411 let isCall = 1, Defs = [LR], Uses = [SP] in {
3412 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
3413 // return stack predictor.
3414 def t2BMOVPCB_CALL : tPseudoInst<(outs),
3415 (ins t_bltarget:$func),
3416 6, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
3417 Requires<[IsThumb]>;
3421 def : T2Pat<(ARMcall_nolink texternalsym:$func),
3422 (t2BMOVPCB_CALL texternalsym:$func)>,
3423 Requires<[IsThumb]>;
3426 let Defs = [ITSTATE] in
3427 def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
3428 AddrModeNone, 2, IIC_iALUx,
3429 "it$mask\t$cc", "", []> {
3430 // 16-bit instruction.
3431 let Inst{31-16} = 0x0000;
3432 let Inst{15-8} = 0b10111111;
3437 let Inst{3-0} = mask;
3439 let DecoderMethod = "DecodeIT";
3442 // Branch and Exchange Jazelle -- for disassembly only
3444 def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func", []> {
3446 let Inst{31-27} = 0b11110;
3448 let Inst{25-20} = 0b111100;
3449 let Inst{19-16} = func;
3450 let Inst{15-0} = 0b1000111100000000;
3453 // Compare and branch on zero / non-zero
3454 let isBranch = 1, isTerminator = 1 in {
3455 def tCBZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3456 "cbz\t$Rn, $target", []>,
3457 T1Misc<{0,0,?,1,?,?,?}>,
3458 Requires<[IsThumb2]> {
3462 let Inst{9} = target{5};
3463 let Inst{7-3} = target{4-0};
3467 def tCBNZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3468 "cbnz\t$Rn, $target", []>,
3469 T1Misc<{1,0,?,1,?,?,?}>,
3470 Requires<[IsThumb2]> {
3474 let Inst{9} = target{5};
3475 let Inst{7-3} = target{4-0};
3481 // Change Processor State is a system instruction.
3482 // FIXME: Since the asm parser has currently no clean way to handle optional
3483 // operands, create 3 versions of the same instruction. Once there's a clean
3484 // framework to represent optional operands, change this behavior.
3485 class t2CPS<dag iops, string asm_op> : T2XI<(outs), iops, NoItinerary,
3486 !strconcat("cps", asm_op), []> {
3492 let Inst{31-27} = 0b11110;
3494 let Inst{25-20} = 0b111010;
3495 let Inst{19-16} = 0b1111;
3496 let Inst{15-14} = 0b10;
3498 let Inst{10-9} = imod;
3500 let Inst{7-5} = iflags;
3501 let Inst{4-0} = mode;
3502 let DecoderMethod = "DecodeT2CPSInstruction";
3506 def t2CPS3p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags, i32imm:$mode),
3507 "$imod.w\t$iflags, $mode">;
3508 let mode = 0, M = 0 in
3509 def t2CPS2p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags),
3510 "$imod.w\t$iflags">;
3511 let imod = 0, iflags = 0, M = 1 in
3512 def t2CPS1p : t2CPS<(ins imm0_31:$mode), "\t$mode">;
3514 // A6.3.4 Branches and miscellaneous control
3515 // Table A6-14 Change Processor State, and hint instructions
3516 def t2HINT : T2I<(outs), (ins imm0_255:$imm), NoItinerary, "hint", "\t$imm",[]>{
3518 let Inst{31-8} = 0b111100111010111110000000;
3519 let Inst{7-0} = imm;
3522 def : t2InstAlias<"hint$p.w $imm", (t2HINT imm0_255:$imm, pred:$p)>;
3523 def : t2InstAlias<"nop$p.w", (t2HINT 0, pred:$p)>;
3524 def : t2InstAlias<"yield$p.w", (t2HINT 1, pred:$p)>;
3525 def : t2InstAlias<"wfe$p.w", (t2HINT 2, pred:$p)>;
3526 def : t2InstAlias<"wfi$p.w", (t2HINT 3, pred:$p)>;
3527 def : t2InstAlias<"sev$p.w", (t2HINT 4, pred:$p)>;
3529 def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt", []> {
3531 let Inst{31-20} = 0b111100111010;
3532 let Inst{19-16} = 0b1111;
3533 let Inst{15-8} = 0b10000000;
3534 let Inst{7-4} = 0b1111;
3535 let Inst{3-0} = opt;
3538 // Secure Monitor Call is a system instruction.
3539 // Option = Inst{19-16}
3540 def t2SMC : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt", []> {
3541 let Inst{31-27} = 0b11110;
3542 let Inst{26-20} = 0b1111111;
3543 let Inst{15-12} = 0b1000;
3546 let Inst{19-16} = opt;
3549 class T2SRS<bits<2> Op, bit W, dag oops, dag iops, InstrItinClass itin,
3550 string opc, string asm, list<dag> pattern>
3551 : T2I<oops, iops, itin, opc, asm, pattern> {
3553 let Inst{31-25} = 0b1110100;
3554 let Inst{24-23} = Op;
3557 let Inst{20-16} = 0b01101;
3558 let Inst{15-5} = 0b11000000000;
3559 let Inst{4-0} = mode{4-0};
3562 // Store Return State is a system instruction.
3563 def t2SRSDB_UPD : T2SRS<0b00, 1, (outs), (ins imm0_31:$mode), NoItinerary,
3564 "srsdb", "\tsp!, $mode", []>;
3565 def t2SRSDB : T2SRS<0b00, 0, (outs), (ins imm0_31:$mode), NoItinerary,
3566 "srsdb","\tsp, $mode", []>;
3567 def t2SRSIA_UPD : T2SRS<0b11, 1, (outs), (ins imm0_31:$mode), NoItinerary,
3568 "srsia","\tsp!, $mode", []>;
3569 def t2SRSIA : T2SRS<0b11, 0, (outs), (ins imm0_31:$mode), NoItinerary,
3570 "srsia","\tsp, $mode", []>;
3572 // Return From Exception is a system instruction.
3573 class T2RFE<bits<12> op31_20, dag oops, dag iops, InstrItinClass itin,
3574 string opc, string asm, list<dag> pattern>
3575 : T2I<oops, iops, itin, opc, asm, pattern> {
3576 let Inst{31-20} = op31_20{11-0};
3579 let Inst{19-16} = Rn;
3580 let Inst{15-0} = 0xc000;
3583 def t2RFEDBW : T2RFE<0b111010000011,
3584 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn!",
3585 [/* For disassembly only; pattern left blank */]>;
3586 def t2RFEDB : T2RFE<0b111010000001,
3587 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn",
3588 [/* For disassembly only; pattern left blank */]>;
3589 def t2RFEIAW : T2RFE<0b111010011011,
3590 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn!",
3591 [/* For disassembly only; pattern left blank */]>;
3592 def t2RFEIA : T2RFE<0b111010011001,
3593 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn",
3594 [/* For disassembly only; pattern left blank */]>;
3596 //===----------------------------------------------------------------------===//
3597 // Non-Instruction Patterns
3600 // 32-bit immediate using movw + movt.
3601 // This is a single pseudo instruction to make it re-materializable.
3602 // FIXME: Remove this when we can do generalized remat.
3603 let isReMaterializable = 1, isMoveImm = 1 in
3604 def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
3605 [(set rGPR:$dst, (i32 imm:$src))]>,
3606 Requires<[IsThumb, HasV6T2]>;
3608 // Pseudo instruction that combines movw + movt + add pc (if pic).
3609 // It also makes it possible to rematerialize the instructions.
3610 // FIXME: Remove this when we can do generalized remat and when machine licm
3611 // can properly the instructions.
3612 let isReMaterializable = 1 in {
3613 def t2MOV_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3615 [(set rGPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
3616 Requires<[IsThumb2, UseMovt]>;
3618 def t2MOV_ga_dyn : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3620 [(set rGPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
3621 Requires<[IsThumb2, UseMovt]>;
3624 // ConstantPool, GlobalAddress, and JumpTable
3625 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
3626 Requires<[IsThumb2, DontUseMovt]>;
3627 def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
3628 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
3629 Requires<[IsThumb2, UseMovt]>;
3631 def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3632 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
3634 // Pseudo instruction that combines ldr from constpool and add pc. This should
3635 // be expanded into two instructions late to allow if-conversion and
3637 let canFoldAsLoad = 1, isReMaterializable = 1 in
3638 def t2LDRpci_pic : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr, pclabel:$cp),
3640 [(set rGPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
3642 Requires<[IsThumb2]>;
3644 // Pseudo isntruction that combines movs + predicated rsbmi
3645 // to implement integer ABS
3646 let usesCustomInserter = 1, Defs = [CPSR] in {
3647 def t2ABS : PseudoInst<(outs rGPR:$dst), (ins rGPR:$src),
3648 NoItinerary, []>, Requires<[IsThumb2]>;
3651 //===----------------------------------------------------------------------===//
3652 // Coprocessor load/store -- for disassembly only
3654 class T2CI<bits<4> op31_28, dag oops, dag iops, string opc, string asm>
3655 : T2I<oops, iops, NoItinerary, opc, asm, []> {
3656 let Inst{31-28} = op31_28;
3657 let Inst{27-25} = 0b110;
3660 multiclass t2LdStCop<bits<4> op31_28, bit load, bit Dbit, string asm> {
3661 def _OFFSET : T2CI<op31_28,
3662 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
3663 asm, "\t$cop, $CRd, $addr"> {
3667 let Inst{24} = 1; // P = 1
3668 let Inst{23} = addr{8};
3669 let Inst{22} = Dbit;
3670 let Inst{21} = 0; // W = 0
3671 let Inst{20} = load;
3672 let Inst{19-16} = addr{12-9};
3673 let Inst{15-12} = CRd;
3674 let Inst{11-8} = cop;
3675 let Inst{7-0} = addr{7-0};
3676 let DecoderMethod = "DecodeCopMemInstruction";
3678 def _PRE : T2CI<op31_28,
3679 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
3680 asm, "\t$cop, $CRd, $addr!"> {
3684 let Inst{24} = 1; // P = 1
3685 let Inst{23} = addr{8};
3686 let Inst{22} = Dbit;
3687 let Inst{21} = 1; // W = 1
3688 let Inst{20} = load;
3689 let Inst{19-16} = addr{12-9};
3690 let Inst{15-12} = CRd;
3691 let Inst{11-8} = cop;
3692 let Inst{7-0} = addr{7-0};
3693 let DecoderMethod = "DecodeCopMemInstruction";
3695 def _POST: T2CI<op31_28,
3696 (outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
3697 postidx_imm8s4:$offset),
3698 asm, "\t$cop, $CRd, $addr, $offset"> {
3703 let Inst{24} = 0; // P = 0
3704 let Inst{23} = offset{8};
3705 let Inst{22} = Dbit;
3706 let Inst{21} = 1; // W = 1
3707 let Inst{20} = load;
3708 let Inst{19-16} = addr;
3709 let Inst{15-12} = CRd;
3710 let Inst{11-8} = cop;
3711 let Inst{7-0} = offset{7-0};
3712 let DecoderMethod = "DecodeCopMemInstruction";
3714 def _OPTION : T2CI<op31_28, (outs),
3715 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
3716 coproc_option_imm:$option),
3717 asm, "\t$cop, $CRd, $addr, $option"> {
3722 let Inst{24} = 0; // P = 0
3723 let Inst{23} = 1; // U = 1
3724 let Inst{22} = Dbit;
3725 let Inst{21} = 0; // W = 0
3726 let Inst{20} = load;
3727 let Inst{19-16} = addr;
3728 let Inst{15-12} = CRd;
3729 let Inst{11-8} = cop;
3730 let Inst{7-0} = option;
3731 let DecoderMethod = "DecodeCopMemInstruction";
3735 defm t2LDC : t2LdStCop<0b1110, 1, 0, "ldc">;
3736 defm t2LDCL : t2LdStCop<0b1110, 1, 1, "ldcl">;
3737 defm t2STC : t2LdStCop<0b1110, 0, 0, "stc">;
3738 defm t2STCL : t2LdStCop<0b1110, 0, 1, "stcl">;
3739 defm t2LDC2 : t2LdStCop<0b1111, 1, 0, "ldc2">;
3740 defm t2LDC2L : t2LdStCop<0b1111, 1, 1, "ldc2l">;
3741 defm t2STC2 : t2LdStCop<0b1111, 0, 0, "stc2">;
3742 defm t2STC2L : t2LdStCop<0b1111, 0, 1, "stc2l">;
3745 //===----------------------------------------------------------------------===//
3746 // Move between special register and ARM core register -- for disassembly only
3748 // Move to ARM core register from Special Register
3752 // A/R class can only move from CPSR or SPSR.
3753 def t2MRS_AR : T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, apsr",
3754 []>, Requires<[IsThumb2,IsARClass]> {
3756 let Inst{31-12} = 0b11110011111011111000;
3757 let Inst{11-8} = Rd;
3758 let Inst{7-0} = 0b0000;
3761 def : t2InstAlias<"mrs${p} $Rd, cpsr", (t2MRS_AR GPR:$Rd, pred:$p)>;
3763 def t2MRSsys_AR: T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, spsr",
3764 []>, Requires<[IsThumb2,IsARClass]> {
3766 let Inst{31-12} = 0b11110011111111111000;
3767 let Inst{11-8} = Rd;
3768 let Inst{7-0} = 0b0000;
3773 // This MRS has a mask field in bits 7-0 and can take more values than
3774 // the A/R class (a full msr_mask).
3775 def t2MRS_M : T2I<(outs rGPR:$Rd), (ins msr_mask:$mask), NoItinerary,
3776 "mrs", "\t$Rd, $mask", []>,
3777 Requires<[IsThumb,IsMClass]> {
3780 let Inst{31-12} = 0b11110011111011111000;
3781 let Inst{11-8} = Rd;
3782 let Inst{19-16} = 0b1111;
3783 let Inst{7-0} = mask;
3787 // Move from ARM core register to Special Register
3791 // No need to have both system and application versions, the encodings are the
3792 // same and the assembly parser has no way to distinguish between them. The mask
3793 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
3794 // the mask with the fields to be accessed in the special register.
3795 def t2MSR_AR : T2I<(outs), (ins msr_mask:$mask, rGPR:$Rn),
3796 NoItinerary, "msr", "\t$mask, $Rn", []>,
3797 Requires<[IsThumb2,IsARClass]> {
3800 let Inst{31-21} = 0b11110011100;
3801 let Inst{20} = mask{4}; // R Bit
3802 let Inst{19-16} = Rn;
3803 let Inst{15-12} = 0b1000;
3804 let Inst{11-8} = mask{3-0};
3810 // Move from ARM core register to Special Register
3811 def t2MSR_M : T2I<(outs), (ins msr_mask:$SYSm, rGPR:$Rn),
3812 NoItinerary, "msr", "\t$SYSm, $Rn", []>,
3813 Requires<[IsThumb,IsMClass]> {
3816 let Inst{31-21} = 0b11110011100;
3818 let Inst{19-16} = Rn;
3819 let Inst{15-12} = 0b1000;
3820 let Inst{11-0} = SYSm;
3824 //===----------------------------------------------------------------------===//
3825 // Move between coprocessor and ARM core register
3828 class t2MovRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops,
3830 : T2Cop<Op, oops, iops,
3831 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"),
3833 let Inst{27-24} = 0b1110;
3834 let Inst{20} = direction;
3844 let Inst{15-12} = Rt;
3845 let Inst{11-8} = cop;
3846 let Inst{23-21} = opc1;
3847 let Inst{7-5} = opc2;
3848 let Inst{3-0} = CRm;
3849 let Inst{19-16} = CRn;
3852 class t2MovRRCopro<bits<4> Op, string opc, bit direction,
3853 list<dag> pattern = []>
3855 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
3856 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
3857 let Inst{27-24} = 0b1100;
3858 let Inst{23-21} = 0b010;
3859 let Inst{20} = direction;
3867 let Inst{15-12} = Rt;
3868 let Inst{19-16} = Rt2;
3869 let Inst{11-8} = cop;
3870 let Inst{7-4} = opc1;
3871 let Inst{3-0} = CRm;
3874 /* from ARM core register to coprocessor */
3875 def t2MCR : t2MovRCopro<0b1110, "mcr", 0,
3877 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3878 c_imm:$CRm, imm0_7:$opc2),
3879 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3880 imm:$CRm, imm:$opc2)]>;
3881 def : t2InstAlias<"mcr $cop, $opc1, $Rt, $CRn, $CRm",
3882 (t2MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3884 def t2MCR2 : t2MovRCopro<0b1111, "mcr2", 0,
3885 (outs), (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3886 c_imm:$CRm, imm0_7:$opc2),
3887 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3888 imm:$CRm, imm:$opc2)]>;
3889 def : t2InstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
3890 (t2MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3893 /* from coprocessor to ARM core register */
3894 def t2MRC : t2MovRCopro<0b1110, "mrc", 1,
3895 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3896 c_imm:$CRm, imm0_7:$opc2), []>;
3897 def : t2InstAlias<"mrc $cop, $opc1, $Rt, $CRn, $CRm",
3898 (t2MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3901 def t2MRC2 : t2MovRCopro<0b1111, "mrc2", 1,
3902 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3903 c_imm:$CRm, imm0_7:$opc2), []>;
3904 def : t2InstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
3905 (t2MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3908 def : T2v6Pat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3909 (t2MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3911 def : T2v6Pat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3912 (t2MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3915 /* from ARM core register to coprocessor */
3916 def t2MCRR : t2MovRRCopro<0b1110, "mcrr", 0,
3917 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
3919 def t2MCRR2 : t2MovRRCopro<0b1111, "mcrr2", 0,
3920 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt,
3921 GPR:$Rt2, imm:$CRm)]>;
3922 /* from coprocessor to ARM core register */
3923 def t2MRRC : t2MovRRCopro<0b1110, "mrrc", 1>;
3925 def t2MRRC2 : t2MovRRCopro<0b1111, "mrrc2", 1>;
3927 //===----------------------------------------------------------------------===//
3928 // Other Coprocessor Instructions.
3931 def tCDP : T2Cop<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
3932 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
3933 "cdp\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3934 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3935 imm:$CRm, imm:$opc2)]> {
3936 let Inst{27-24} = 0b1110;
3945 let Inst{3-0} = CRm;
3947 let Inst{7-5} = opc2;
3948 let Inst{11-8} = cop;
3949 let Inst{15-12} = CRd;
3950 let Inst{19-16} = CRn;
3951 let Inst{23-20} = opc1;
3954 def t2CDP2 : T2Cop<0b1111, (outs), (ins p_imm:$cop, imm0_15:$opc1,
3955 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
3956 "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3957 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3958 imm:$CRm, imm:$opc2)]> {
3959 let Inst{27-24} = 0b1110;
3968 let Inst{3-0} = CRm;
3970 let Inst{7-5} = opc2;
3971 let Inst{11-8} = cop;
3972 let Inst{15-12} = CRd;
3973 let Inst{19-16} = CRn;
3974 let Inst{23-20} = opc1;
3979 //===----------------------------------------------------------------------===//
3980 // Non-Instruction Patterns
3983 // SXT/UXT with no rotate
3984 let AddedComplexity = 16 in {
3985 def : T2Pat<(and rGPR:$Rm, 0x000000FF), (t2UXTB rGPR:$Rm, 0)>,
3986 Requires<[IsThumb2]>;
3987 def : T2Pat<(and rGPR:$Rm, 0x0000FFFF), (t2UXTH rGPR:$Rm, 0)>,
3988 Requires<[IsThumb2]>;
3989 def : T2Pat<(and rGPR:$Rm, 0x00FF00FF), (t2UXTB16 rGPR:$Rm, 0)>,
3990 Requires<[HasT2ExtractPack, IsThumb2]>;
3991 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0x00FF)),
3992 (t2UXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3993 Requires<[HasT2ExtractPack, IsThumb2]>;
3994 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0xFFFF)),
3995 (t2UXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3996 Requires<[HasT2ExtractPack, IsThumb2]>;
3999 def : T2Pat<(sext_inreg rGPR:$Src, i8), (t2SXTB rGPR:$Src, 0)>,
4000 Requires<[IsThumb2]>;
4001 def : T2Pat<(sext_inreg rGPR:$Src, i16), (t2SXTH rGPR:$Src, 0)>,
4002 Requires<[IsThumb2]>;
4003 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i8)),
4004 (t2SXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
4005 Requires<[HasT2ExtractPack, IsThumb2]>;
4006 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i16)),
4007 (t2SXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
4008 Requires<[HasT2ExtractPack, IsThumb2]>;
4010 // Atomic load/store patterns
4011 def : T2Pat<(atomic_load_8 t2addrmode_imm12:$addr),
4012 (ATOMIC_t2LDRBi12 t2addrmode_imm12:$addr)>;
4013 def : T2Pat<(atomic_load_8 t2addrmode_negimm8:$addr),
4014 (ATOMIC_t2LDRBi8 t2addrmode_negimm8:$addr)>;
4015 def : T2Pat<(atomic_load_8 t2addrmode_so_reg:$addr),
4016 (ATOMIC_t2LDRBs t2addrmode_so_reg:$addr)>;
4017 def : T2Pat<(atomic_load_16 t2addrmode_imm12:$addr),
4018 (ATOMIC_t2LDRHi12 t2addrmode_imm12:$addr)>;
4019 def : T2Pat<(atomic_load_16 t2addrmode_negimm8:$addr),
4020 (ATOMIC_t2LDRHi8 t2addrmode_negimm8:$addr)>;
4021 def : T2Pat<(atomic_load_16 t2addrmode_so_reg:$addr),
4022 (ATOMIC_t2LDRHs t2addrmode_so_reg:$addr)>;
4023 def : T2Pat<(atomic_load_32 t2addrmode_imm12:$addr),
4024 (ATOMIC_t2LDRi12 t2addrmode_imm12:$addr)>;
4025 def : T2Pat<(atomic_load_32 t2addrmode_negimm8:$addr),
4026 (ATOMIC_t2LDRi8 t2addrmode_negimm8:$addr)>;
4027 def : T2Pat<(atomic_load_32 t2addrmode_so_reg:$addr),
4028 (ATOMIC_t2LDRs t2addrmode_so_reg:$addr)>;
4029 def : T2Pat<(atomic_store_8 t2addrmode_imm12:$addr, GPR:$val),
4030 (t2STRBi12 GPR:$val, t2addrmode_imm12:$addr)>;
4031 def : T2Pat<(atomic_store_8 t2addrmode_negimm8:$addr, GPR:$val),
4032 (t2STRBi8 GPR:$val, t2addrmode_negimm8:$addr)>;
4033 def : T2Pat<(atomic_store_8 t2addrmode_so_reg:$addr, GPR:$val),
4034 (t2STRBs GPR:$val, t2addrmode_so_reg:$addr)>;
4035 def : T2Pat<(atomic_store_16 t2addrmode_imm12:$addr, GPR:$val),
4036 (t2STRHi12 GPR:$val, t2addrmode_imm12:$addr)>;
4037 def : T2Pat<(atomic_store_16 t2addrmode_negimm8:$addr, GPR:$val),
4038 (t2STRHi8 GPR:$val, t2addrmode_negimm8:$addr)>;
4039 def : T2Pat<(atomic_store_16 t2addrmode_so_reg:$addr, GPR:$val),
4040 (t2STRHs GPR:$val, t2addrmode_so_reg:$addr)>;
4041 def : T2Pat<(atomic_store_32 t2addrmode_imm12:$addr, GPR:$val),
4042 (t2STRi12 GPR:$val, t2addrmode_imm12:$addr)>;
4043 def : T2Pat<(atomic_store_32 t2addrmode_negimm8:$addr, GPR:$val),
4044 (t2STRi8 GPR:$val, t2addrmode_negimm8:$addr)>;
4045 def : T2Pat<(atomic_store_32 t2addrmode_so_reg:$addr, GPR:$val),
4046 (t2STRs GPR:$val, t2addrmode_so_reg:$addr)>;
4049 //===----------------------------------------------------------------------===//
4050 // Assembler aliases
4053 // Aliases for ADC without the ".w" optional width specifier.
4054 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $Rm",
4055 (t2ADCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4056 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $ShiftedRm",
4057 (t2ADCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
4058 pred:$p, cc_out:$s)>;
4060 // Aliases for SBC without the ".w" optional width specifier.
4061 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $Rm",
4062 (t2SBCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4063 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $ShiftedRm",
4064 (t2SBCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
4065 pred:$p, cc_out:$s)>;
4067 // Aliases for ADD without the ".w" optional width specifier.
4068 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4069 (t2ADDri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4070 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
4071 (t2ADDri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
4072 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm",
4073 (t2ADDrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4074 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm",
4075 (t2ADDrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
4076 pred:$p, cc_out:$s)>;
4077 // ... and with the destination and source register combined.
4078 def : t2InstAlias<"add${s}${p} $Rdn, $imm",
4079 (t2ADDri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4080 def : t2InstAlias<"add${p} $Rdn, $imm",
4081 (t2ADDri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095:$imm, pred:$p)>;
4082 def : t2InstAlias<"add${s}${p} $Rdn, $Rm",
4083 (t2ADDrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4084 def : t2InstAlias<"add${s}${p} $Rdn, $ShiftedRm",
4085 (t2ADDrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
4086 pred:$p, cc_out:$s)>;
4088 // add w/ negative immediates is just a sub.
4089 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4090 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
4092 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
4093 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
4094 def : t2InstAlias<"add${s}${p} $Rdn, $imm",
4095 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm_neg:$imm, pred:$p,
4097 def : t2InstAlias<"add${p} $Rdn, $imm",
4098 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
4100 def : t2InstAlias<"add${s}${p}.w $Rd, $Rn, $imm",
4101 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
4103 def : t2InstAlias<"addw${p} $Rd, $Rn, $imm",
4104 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
4105 def : t2InstAlias<"add${s}${p}.w $Rdn, $imm",
4106 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm_neg:$imm, pred:$p,
4108 def : t2InstAlias<"addw${p} $Rdn, $imm",
4109 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
4112 // Aliases for SUB without the ".w" optional width specifier.
4113 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm",
4114 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4115 def : t2InstAlias<"sub${p} $Rd, $Rn, $imm",
4116 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
4117 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $Rm",
4118 (t2SUBrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4119 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $ShiftedRm",
4120 (t2SUBrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
4121 pred:$p, cc_out:$s)>;
4122 // ... and with the destination and source register combined.
4123 def : t2InstAlias<"sub${s}${p} $Rdn, $imm",
4124 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4125 def : t2InstAlias<"sub${p} $Rdn, $imm",
4126 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095:$imm, pred:$p)>;
4127 def : t2InstAlias<"sub${s}${p}.w $Rdn, $Rm",
4128 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4129 def : t2InstAlias<"sub${s}${p} $Rdn, $Rm",
4130 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4131 def : t2InstAlias<"sub${s}${p} $Rdn, $ShiftedRm",
4132 (t2SUBrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
4133 pred:$p, cc_out:$s)>;
4135 // Alias for compares without the ".w" optional width specifier.
4136 def : t2InstAlias<"cmn${p} $Rn, $Rm",
4137 (t2CMNzrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4138 def : t2InstAlias<"teq${p} $Rn, $Rm",
4139 (t2TEQrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4140 def : t2InstAlias<"tst${p} $Rn, $Rm",
4141 (t2TSTrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4144 def : InstAlias<"dmb", (t2DMB 0xf)>, Requires<[IsThumb, HasDB]>;
4145 def : InstAlias<"dsb", (t2DSB 0xf)>, Requires<[IsThumb, HasDB]>;
4146 def : InstAlias<"isb", (t2ISB 0xf)>, Requires<[IsThumb, HasDB]>;
4148 // Alias for LDR, LDRB, LDRH, LDRSB, and LDRSH without the ".w" optional
4150 def : t2InstAlias<"ldr${p} $Rt, $addr",
4151 (t2LDRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4152 def : t2InstAlias<"ldrb${p} $Rt, $addr",
4153 (t2LDRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4154 def : t2InstAlias<"ldrh${p} $Rt, $addr",
4155 (t2LDRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4156 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4157 (t2LDRSBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4158 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4159 (t2LDRSHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4161 def : t2InstAlias<"ldr${p} $Rt, $addr",
4162 (t2LDRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4163 def : t2InstAlias<"ldrb${p} $Rt, $addr",
4164 (t2LDRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4165 def : t2InstAlias<"ldrh${p} $Rt, $addr",
4166 (t2LDRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4167 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4168 (t2LDRSBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4169 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4170 (t2LDRSHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4172 def : t2InstAlias<"ldr${p} $Rt, $addr",
4173 (t2LDRpci GPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4174 def : t2InstAlias<"ldrb${p} $Rt, $addr",
4175 (t2LDRBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4176 def : t2InstAlias<"ldrh${p} $Rt, $addr",
4177 (t2LDRHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4178 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4179 (t2LDRSBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4180 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4181 (t2LDRSHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4183 // Alias for MVN with(out) the ".w" optional width specifier.
4184 def : t2InstAlias<"mvn${s}${p}.w $Rd, $imm",
4185 (t2MVNi rGPR:$Rd, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4186 def : t2InstAlias<"mvn${s}${p} $Rd, $Rm",
4187 (t2MVNr rGPR:$Rd, rGPR:$Rm, pred:$p, cc_out:$s)>;
4188 def : t2InstAlias<"mvn${s}${p} $Rd, $ShiftedRm",
4189 (t2MVNs rGPR:$Rd, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>;
4191 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4192 // shift amount is zero (i.e., unspecified).
4193 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4194 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>,
4195 Requires<[HasT2ExtractPack, IsThumb2]>;
4196 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4197 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>,
4198 Requires<[HasT2ExtractPack, IsThumb2]>;
4200 // PUSH/POP aliases for STM/LDM
4201 def : t2InstAlias<"push${p}.w $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
4202 def : t2InstAlias<"push${p} $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
4203 def : t2InstAlias<"pop${p}.w $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4204 def : t2InstAlias<"pop${p} $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4206 // STMIA/STMIA_UPD aliases w/o the optional .w suffix
4207 def : t2InstAlias<"stm${p} $Rn, $regs",
4208 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4209 def : t2InstAlias<"stm${p} $Rn!, $regs",
4210 (t2STMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4212 // LDMIA/LDMIA_UPD aliases w/o the optional .w suffix
4213 def : t2InstAlias<"ldm${p} $Rn, $regs",
4214 (t2LDMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4215 def : t2InstAlias<"ldm${p} $Rn!, $regs",
4216 (t2LDMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4218 // STMDB/STMDB_UPD aliases w/ the optional .w suffix
4219 def : t2InstAlias<"stmdb${p}.w $Rn, $regs",
4220 (t2STMDB GPR:$Rn, pred:$p, reglist:$regs)>;
4221 def : t2InstAlias<"stmdb${p}.w $Rn!, $regs",
4222 (t2STMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4224 // LDMDB/LDMDB_UPD aliases w/ the optional .w suffix
4225 def : t2InstAlias<"ldmdb${p}.w $Rn, $regs",
4226 (t2LDMDB GPR:$Rn, pred:$p, reglist:$regs)>;
4227 def : t2InstAlias<"ldmdb${p}.w $Rn!, $regs",
4228 (t2LDMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4230 // Alias for REV/REV16/REVSH without the ".w" optional width specifier.
4231 def : t2InstAlias<"rev${p} $Rd, $Rm", (t2REV rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4232 def : t2InstAlias<"rev16${p} $Rd, $Rm", (t2REV16 rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4233 def : t2InstAlias<"revsh${p} $Rd, $Rm", (t2REVSH rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4236 // Alias for RSB without the ".w" optional width specifier, and with optional
4237 // implied destination register.
4238 def : t2InstAlias<"rsb${s}${p} $Rd, $Rn, $imm",
4239 (t2RSBri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4240 def : t2InstAlias<"rsb${s}${p} $Rdn, $imm",
4241 (t2RSBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4242 def : t2InstAlias<"rsb${s}${p} $Rdn, $Rm",
4243 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4244 def : t2InstAlias<"rsb${s}${p} $Rdn, $ShiftedRm",
4245 (t2RSBrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p,
4248 // SSAT/USAT optional shift operand.
4249 def : t2InstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4250 (t2SSAT rGPR:$Rd, imm1_32:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
4251 def : t2InstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4252 (t2USAT rGPR:$Rd, imm0_31:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
4254 // STM w/o the .w suffix.
4255 def : t2InstAlias<"stm${p} $Rn, $regs",
4256 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4258 // Alias for STR, STRB, and STRH without the ".w" optional
4260 def : t2InstAlias<"str${p} $Rt, $addr",
4261 (t2STRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4262 def : t2InstAlias<"strb${p} $Rt, $addr",
4263 (t2STRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4264 def : t2InstAlias<"strh${p} $Rt, $addr",
4265 (t2STRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4267 def : t2InstAlias<"str${p} $Rt, $addr",
4268 (t2STRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4269 def : t2InstAlias<"strb${p} $Rt, $addr",
4270 (t2STRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4271 def : t2InstAlias<"strh${p} $Rt, $addr",
4272 (t2STRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4274 // Extend instruction optional rotate operand.
4275 def : t2InstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4276 (t2SXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4277 def : t2InstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4278 (t2SXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4279 def : t2InstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4280 (t2SXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4282 def : t2InstAlias<"sxtb${p} $Rd, $Rm",
4283 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4284 def : t2InstAlias<"sxtb16${p} $Rd, $Rm",
4285 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4286 def : t2InstAlias<"sxth${p} $Rd, $Rm",
4287 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4288 def : t2InstAlias<"sxtb${p}.w $Rd, $Rm",
4289 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4290 def : t2InstAlias<"sxth${p}.w $Rd, $Rm",
4291 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4293 def : t2InstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4294 (t2UXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4295 def : t2InstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4296 (t2UXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4297 def : t2InstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4298 (t2UXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4299 def : t2InstAlias<"uxtb${p} $Rd, $Rm",
4300 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4301 def : t2InstAlias<"uxtb16${p} $Rd, $Rm",
4302 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4303 def : t2InstAlias<"uxth${p} $Rd, $Rm",
4304 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4306 def : t2InstAlias<"uxtb${p}.w $Rd, $Rm",
4307 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4308 def : t2InstAlias<"uxth${p}.w $Rd, $Rm",
4309 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4311 // Extend instruction w/o the ".w" optional width specifier.
4312 def : t2InstAlias<"uxtb${p} $Rd, $Rm$rot",
4313 (t2UXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4314 def : t2InstAlias<"uxtb16${p} $Rd, $Rm$rot",
4315 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4316 def : t2InstAlias<"uxth${p} $Rd, $Rm$rot",
4317 (t2UXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4319 def : t2InstAlias<"sxtb${p} $Rd, $Rm$rot",
4320 (t2SXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4321 def : t2InstAlias<"sxtb16${p} $Rd, $Rm$rot",
4322 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4323 def : t2InstAlias<"sxth${p} $Rd, $Rm$rot",
4324 (t2SXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4327 // "mov Rd, t2_so_imm_not" can be handled via "mvn" in assembly, just like
4329 def : t2InstAlias<"mov${p} $Rd, $imm",
4330 (t2MVNi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
4331 def : t2InstAlias<"mvn${p} $Rd, $imm",
4332 (t2MOVi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
4333 // Same for AND <--> BIC
4334 def : t2InstAlias<"bic${s}${p} $Rd, $Rn, $imm",
4335 (t2ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
4336 pred:$p, cc_out:$s)>;
4337 def : t2InstAlias<"bic${s}${p} $Rdn, $imm",
4338 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
4339 pred:$p, cc_out:$s)>;
4340 def : t2InstAlias<"and${s}${p} $Rd, $Rn, $imm",
4341 (t2BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
4342 pred:$p, cc_out:$s)>;
4343 def : t2InstAlias<"and${s}${p} $Rdn, $imm",
4344 (t2BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
4345 pred:$p, cc_out:$s)>;
4346 // Likewise, "add Rd, t2_so_imm_neg" -> sub
4347 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4348 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm,
4349 pred:$p, cc_out:$s)>;
4350 def : t2InstAlias<"add${s}${p} $Rd, $imm",
4351 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rd, t2_so_imm_neg:$imm,
4352 pred:$p, cc_out:$s)>;
4353 // Same for CMP <--> CMN via t2_so_imm_neg
4354 def : t2InstAlias<"cmp${p} $Rd, $imm",
4355 (t2CMNri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
4356 def : t2InstAlias<"cmn${p} $Rd, $imm",
4357 (t2CMPri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
4360 // Wide 'mul' encoding can be specified with only two operands.
4361 def : t2InstAlias<"mul${p} $Rn, $Rm",
4362 (t2MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p)>;
4364 // "neg" is and alias for "rsb rd, rn, #0"
4365 def : t2InstAlias<"neg${s}${p} $Rd, $Rm",
4366 (t2RSBri rGPR:$Rd, rGPR:$Rm, 0, pred:$p, cc_out:$s)>;
4368 // MOV so_reg assembler pseudos. InstAlias isn't expressive enough for
4369 // these, unfortunately.
4370 def t2MOVsi: t2AsmPseudo<"mov${p} $Rd, $shift",
4371 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
4372 def t2MOVSsi: t2AsmPseudo<"movs${p} $Rd, $shift",
4373 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
4375 def t2MOVsr: t2AsmPseudo<"mov${p} $Rd, $shift",
4376 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
4377 def t2MOVSsr: t2AsmPseudo<"movs${p} $Rd, $shift",
4378 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
4380 // ADR w/o the .w suffix
4381 def : t2InstAlias<"adr${p} $Rd, $addr",
4382 (t2ADR rGPR:$Rd, t2adrlabel:$addr, pred:$p)>;
4384 // LDR(literal) w/ alternate [pc, #imm] syntax.
4385 def t2LDRpcrel : t2AsmPseudo<"ldr${p} $Rt, $addr",
4386 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4387 def t2LDRBpcrel : t2AsmPseudo<"ldrb${p} $Rt, $addr",
4388 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4389 def t2LDRHpcrel : t2AsmPseudo<"ldrh${p} $Rt, $addr",
4390 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4391 def t2LDRSBpcrel : t2AsmPseudo<"ldrsb${p} $Rt, $addr",
4392 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4393 def t2LDRSHpcrel : t2AsmPseudo<"ldrsh${p} $Rt, $addr",
4394 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4395 // Version w/ the .w suffix.
4396 def : t2InstAlias<"ldr${p}.w $Rt, $addr",
4397 (t2LDRpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4398 def : t2InstAlias<"ldrb${p}.w $Rt, $addr",
4399 (t2LDRBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4400 def : t2InstAlias<"ldrh${p}.w $Rt, $addr",
4401 (t2LDRHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4402 def : t2InstAlias<"ldrsb${p}.w $Rt, $addr",
4403 (t2LDRSBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4404 def : t2InstAlias<"ldrsh${p}.w $Rt, $addr",
4405 (t2LDRSHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4407 def : t2InstAlias<"add${p} $Rd, pc, $imm",
4408 (t2ADR rGPR:$Rd, imm0_4095:$imm, pred:$p)>;