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 = "printThumbLdrLabelOperand";
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;
526 class T2MlaLong<bits<3> opc22_20, bits<4> opc7_4,
527 dag oops, dag iops, InstrItinClass itin,
528 string opc, string asm, list<dag> pattern>
529 : T2I<oops, iops, itin, opc, asm, pattern> {
535 let Inst{31-23} = 0b111110111;
536 let Inst{22-20} = opc22_20;
537 let Inst{19-16} = Rn;
538 let Inst{15-12} = RdLo;
539 let Inst{11-8} = RdHi;
540 let Inst{7-4} = opc7_4;
545 /// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
546 /// binary operation that produces a value. These are predicable and can be
547 /// changed to modify CPSR.
548 multiclass T2I_bin_irs<bits<4> opcod, string opc,
549 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
550 PatFrag opnode, bit Commutable = 0,
553 def ri : T2sTwoRegImm<
554 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
555 opc, "\t$Rd, $Rn, $imm",
556 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]> {
557 let Inst{31-27} = 0b11110;
559 let Inst{24-21} = opcod;
563 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
564 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
565 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
566 let isCommutable = Commutable;
567 let Inst{31-27} = 0b11101;
568 let Inst{26-25} = 0b01;
569 let Inst{24-21} = opcod;
570 let Inst{14-12} = 0b000; // imm3
571 let Inst{7-6} = 0b00; // imm2
572 let Inst{5-4} = 0b00; // type
575 def rs : T2sTwoRegShiftedReg<
576 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
577 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
578 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]> {
579 let Inst{31-27} = 0b11101;
580 let Inst{26-25} = 0b01;
581 let Inst{24-21} = opcod;
583 // Assembly aliases for optional destination operand when it's the same
584 // as the source operand.
585 def : t2InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
586 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn,
587 t2_so_imm:$imm, pred:$p,
589 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $Rm"),
590 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn,
593 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $shift"),
594 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn,
595 t2_so_reg:$shift, pred:$p,
599 /// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
600 // the ".w" suffix to indicate that they are wide.
601 multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
602 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
603 PatFrag opnode, bit Commutable = 0> :
604 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w"> {
605 // Assembler aliases w/ the ".w" suffix.
606 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rd, $Rn, $imm"),
607 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p,
609 // Assembler aliases w/o the ".w" suffix.
610 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
611 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
613 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $shift"),
614 (!cast<Instruction>(NAME#"rs") rGPR:$Rd, rGPR:$Rn, t2_so_reg:$shift,
615 pred:$p, cc_out:$s)>;
617 // and with the optional destination operand, too.
618 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rdn, $imm"),
619 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm,
620 pred:$p, cc_out:$s)>;
621 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
622 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
624 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $shift"),
625 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$shift,
626 pred:$p, cc_out:$s)>;
629 /// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
630 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
631 /// it is equivalent to the T2I_bin_irs counterpart.
632 multiclass T2I_rbin_irs<bits<4> opcod, string opc, PatFrag opnode> {
634 def ri : T2sTwoRegImm<
635 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
636 opc, ".w\t$Rd, $Rn, $imm",
637 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]> {
638 let Inst{31-27} = 0b11110;
640 let Inst{24-21} = opcod;
644 def rr : T2sThreeReg<
645 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
646 opc, "\t$Rd, $Rn, $Rm",
647 [/* For disassembly only; pattern left blank */]> {
648 let Inst{31-27} = 0b11101;
649 let Inst{26-25} = 0b01;
650 let Inst{24-21} = opcod;
651 let Inst{14-12} = 0b000; // imm3
652 let Inst{7-6} = 0b00; // imm2
653 let Inst{5-4} = 0b00; // type
656 def rs : T2sTwoRegShiftedReg<
657 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
658 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm",
659 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]> {
660 let Inst{31-27} = 0b11101;
661 let Inst{26-25} = 0b01;
662 let Inst{24-21} = opcod;
666 /// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
667 /// instruction modifies the CPSR register.
669 /// These opcodes will be converted to the real non-S opcodes by
670 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
671 let hasPostISelHook = 1, Defs = [CPSR] in {
672 multiclass T2I_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
673 InstrItinClass iis, PatFrag opnode,
674 bit Commutable = 0> {
676 def ri : t2PseudoInst<(outs rGPR:$Rd),
677 (ins GPRnopc:$Rn, t2_so_imm:$imm, pred:$p),
679 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
682 def rr : t2PseudoInst<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm, pred:$p),
684 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
686 let isCommutable = Commutable;
689 def rs : t2PseudoInst<(outs rGPR:$Rd),
690 (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
692 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
693 t2_so_reg:$ShiftedRm))]>;
697 /// T2I_rbin_s_is - Same as T2I_bin_s_irs, except selection DAG
698 /// operands are reversed.
699 let hasPostISelHook = 1, Defs = [CPSR] in {
700 multiclass T2I_rbin_s_is<PatFrag opnode> {
702 def ri : t2PseudoInst<(outs rGPR:$Rd),
703 (ins rGPR:$Rn, t2_so_imm:$imm, pred:$p),
705 [(set rGPR:$Rd, CPSR, (opnode t2_so_imm:$imm,
708 def rs : t2PseudoInst<(outs rGPR:$Rd),
709 (ins rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
711 [(set rGPR:$Rd, CPSR, (opnode t2_so_reg:$ShiftedRm,
716 /// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
717 /// patterns for a binary operation that produces a value.
718 multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, PatFrag opnode,
719 bit Commutable = 0> {
721 // The register-immediate version is re-materializable. This is useful
722 // in particular for taking the address of a local.
723 let isReMaterializable = 1 in {
724 def ri : T2sTwoRegImm<
725 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi,
726 opc, ".w\t$Rd, $Rn, $imm",
727 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]> {
728 let Inst{31-27} = 0b11110;
731 let Inst{23-21} = op23_21;
737 (outs GPRnopc:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
738 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
739 [(set GPRnopc:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> {
743 let Inst{31-27} = 0b11110;
744 let Inst{26} = imm{11};
745 let Inst{25-24} = 0b10;
746 let Inst{23-21} = op23_21;
747 let Inst{20} = 0; // The S bit.
748 let Inst{19-16} = Rn;
750 let Inst{14-12} = imm{10-8};
752 let Inst{7-0} = imm{7-0};
755 def rr : T2sThreeReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm),
756 IIC_iALUr, opc, ".w\t$Rd, $Rn, $Rm",
757 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]> {
758 let isCommutable = Commutable;
759 let Inst{31-27} = 0b11101;
760 let Inst{26-25} = 0b01;
762 let Inst{23-21} = op23_21;
763 let Inst{14-12} = 0b000; // imm3
764 let Inst{7-6} = 0b00; // imm2
765 let Inst{5-4} = 0b00; // type
768 def rs : T2sTwoRegShiftedReg<
769 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm),
770 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
771 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]> {
772 let Inst{31-27} = 0b11101;
773 let Inst{26-25} = 0b01;
775 let Inst{23-21} = op23_21;
779 /// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
780 /// for a binary operation that produces a value and use the carry
781 /// bit. It's not predicable.
782 let Defs = [CPSR], Uses = [CPSR] in {
783 multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
784 bit Commutable = 0> {
786 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
787 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
788 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_imm:$imm, CPSR))]>,
789 Requires<[IsThumb2]> {
790 let Inst{31-27} = 0b11110;
792 let Inst{24-21} = opcod;
796 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
797 opc, ".w\t$Rd, $Rn, $Rm",
798 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, rGPR:$Rm, CPSR))]>,
799 Requires<[IsThumb2]> {
800 let isCommutable = Commutable;
801 let Inst{31-27} = 0b11101;
802 let Inst{26-25} = 0b01;
803 let Inst{24-21} = opcod;
804 let Inst{14-12} = 0b000; // imm3
805 let Inst{7-6} = 0b00; // imm2
806 let Inst{5-4} = 0b00; // type
809 def rs : T2sTwoRegShiftedReg<
810 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
811 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
812 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm, CPSR))]>,
813 Requires<[IsThumb2]> {
814 let Inst{31-27} = 0b11101;
815 let Inst{26-25} = 0b01;
816 let Inst{24-21} = opcod;
821 /// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
822 // rotate operation that produces a value.
823 multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, PatFrag opnode> {
825 def ri : T2sTwoRegShiftImm<
826 (outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi,
827 opc, ".w\t$Rd, $Rm, $imm",
828 [(set rGPR:$Rd, (opnode rGPR:$Rm, (i32 ty:$imm)))]> {
829 let Inst{31-27} = 0b11101;
830 let Inst{26-21} = 0b010010;
831 let Inst{19-16} = 0b1111; // Rn
832 let Inst{5-4} = opcod;
835 def rr : T2sThreeReg<
836 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr,
837 opc, ".w\t$Rd, $Rn, $Rm",
838 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]> {
839 let Inst{31-27} = 0b11111;
840 let Inst{26-23} = 0b0100;
841 let Inst{22-21} = opcod;
842 let Inst{15-12} = 0b1111;
843 let Inst{7-4} = 0b0000;
846 // Optional destination register
847 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"),
848 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
850 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"),
851 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
854 // Assembler aliases w/o the ".w" suffix.
855 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $imm"),
856 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, ty:$imm, pred:$p,
858 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
859 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
862 // and with the optional destination operand, too.
863 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $imm"),
864 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
866 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
867 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
871 /// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
872 /// patterns. Similar to T2I_bin_irs except the instruction does not produce
873 /// a explicit result, only implicitly set CPSR.
874 multiclass T2I_cmp_irs<bits<4> opcod, string opc,
875 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
877 let isCompare = 1, Defs = [CPSR] in {
879 def ri : T2OneRegCmpImm<
880 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), iii,
881 opc, ".w\t$Rn, $imm",
882 [(opnode GPRnopc:$Rn, t2_so_imm:$imm)]> {
883 let Inst{31-27} = 0b11110;
885 let Inst{24-21} = opcod;
886 let Inst{20} = 1; // The S bit.
888 let Inst{11-8} = 0b1111; // Rd
891 def rr : T2TwoRegCmp<
892 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), iir,
894 [(opnode GPRnopc:$Rn, rGPR:$Rm)]> {
895 let Inst{31-27} = 0b11101;
896 let Inst{26-25} = 0b01;
897 let Inst{24-21} = opcod;
898 let Inst{20} = 1; // The S bit.
899 let Inst{14-12} = 0b000; // imm3
900 let Inst{11-8} = 0b1111; // Rd
901 let Inst{7-6} = 0b00; // imm2
902 let Inst{5-4} = 0b00; // type
905 def rs : T2OneRegCmpShiftedReg<
906 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), iis,
907 opc, ".w\t$Rn, $ShiftedRm",
908 [(opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]> {
909 let Inst{31-27} = 0b11101;
910 let Inst{26-25} = 0b01;
911 let Inst{24-21} = opcod;
912 let Inst{20} = 1; // The S bit.
913 let Inst{11-8} = 0b1111; // Rd
917 // Assembler aliases w/o the ".w" suffix.
918 // No alias here for 'rr' version as not all instantiations of this
919 // multiclass want one (CMP in particular, does not).
920 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $imm"),
921 (!cast<Instruction>(NAME#"ri") GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
922 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $shift"),
923 (!cast<Instruction>(NAME#"rs") GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
926 /// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
927 multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
928 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
930 def i12 : T2Ii12<(outs target:$Rt), (ins t2addrmode_imm12:$addr), iii,
931 opc, ".w\t$Rt, $addr",
932 [(set target:$Rt, (opnode t2addrmode_imm12:$addr))]> {
935 let Inst{31-25} = 0b1111100;
936 let Inst{24} = signed;
938 let Inst{22-21} = opcod;
939 let Inst{20} = 1; // load
940 let Inst{19-16} = addr{16-13}; // Rn
941 let Inst{15-12} = Rt;
942 let Inst{11-0} = addr{11-0}; // imm
944 def i8 : T2Ii8 <(outs target:$Rt), (ins t2addrmode_negimm8:$addr), iii,
946 [(set target:$Rt, (opnode t2addrmode_negimm8:$addr))]> {
949 let Inst{31-27} = 0b11111;
950 let Inst{26-25} = 0b00;
951 let Inst{24} = signed;
953 let Inst{22-21} = opcod;
954 let Inst{20} = 1; // load
955 let Inst{19-16} = addr{12-9}; // Rn
956 let Inst{15-12} = Rt;
958 // Offset: index==TRUE, wback==FALSE
959 let Inst{10} = 1; // The P bit.
960 let Inst{9} = addr{8}; // U
961 let Inst{8} = 0; // The W bit.
962 let Inst{7-0} = addr{7-0}; // imm
964 def s : T2Iso <(outs target:$Rt), (ins t2addrmode_so_reg:$addr), iis,
965 opc, ".w\t$Rt, $addr",
966 [(set target:$Rt, (opnode t2addrmode_so_reg:$addr))]> {
967 let Inst{31-27} = 0b11111;
968 let Inst{26-25} = 0b00;
969 let Inst{24} = signed;
971 let Inst{22-21} = opcod;
972 let Inst{20} = 1; // load
973 let Inst{11-6} = 0b000000;
976 let Inst{15-12} = Rt;
979 let Inst{19-16} = addr{9-6}; // Rn
980 let Inst{3-0} = addr{5-2}; // Rm
981 let Inst{5-4} = addr{1-0}; // imm
983 let DecoderMethod = "DecodeT2LoadShift";
986 // pci variant is very similar to i12, but supports negative offsets
988 def pci : T2Ipc <(outs target:$Rt), (ins t2ldrlabel:$addr), iii,
989 opc, ".w\t$Rt, $addr",
990 [(set target:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> {
991 let isReMaterializable = 1;
992 let Inst{31-27} = 0b11111;
993 let Inst{26-25} = 0b00;
994 let Inst{24} = signed;
995 let Inst{23} = ?; // add = (U == '1')
996 let Inst{22-21} = opcod;
997 let Inst{20} = 1; // load
998 let Inst{19-16} = 0b1111; // Rn
1001 let Inst{15-12} = Rt{3-0};
1002 let Inst{11-0} = addr{11-0};
1006 /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
1007 multiclass T2I_st<bits<2> opcod, string opc,
1008 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
1010 def i12 : T2Ii12<(outs), (ins target:$Rt, t2addrmode_imm12:$addr), iii,
1011 opc, ".w\t$Rt, $addr",
1012 [(opnode target:$Rt, t2addrmode_imm12:$addr)]> {
1013 let Inst{31-27} = 0b11111;
1014 let Inst{26-23} = 0b0001;
1015 let Inst{22-21} = opcod;
1016 let Inst{20} = 0; // !load
1019 let Inst{15-12} = Rt;
1022 let addr{12} = 1; // add = TRUE
1023 let Inst{19-16} = addr{16-13}; // Rn
1024 let Inst{23} = addr{12}; // U
1025 let Inst{11-0} = addr{11-0}; // imm
1027 def i8 : T2Ii8 <(outs), (ins target:$Rt, t2addrmode_negimm8:$addr), iii,
1028 opc, "\t$Rt, $addr",
1029 [(opnode target:$Rt, t2addrmode_negimm8:$addr)]> {
1030 let Inst{31-27} = 0b11111;
1031 let Inst{26-23} = 0b0000;
1032 let Inst{22-21} = opcod;
1033 let Inst{20} = 0; // !load
1035 // Offset: index==TRUE, wback==FALSE
1036 let Inst{10} = 1; // The P bit.
1037 let Inst{8} = 0; // The W bit.
1040 let Inst{15-12} = Rt;
1043 let Inst{19-16} = addr{12-9}; // Rn
1044 let Inst{9} = addr{8}; // U
1045 let Inst{7-0} = addr{7-0}; // imm
1047 def s : T2Iso <(outs), (ins target:$Rt, t2addrmode_so_reg:$addr), iis,
1048 opc, ".w\t$Rt, $addr",
1049 [(opnode target:$Rt, t2addrmode_so_reg:$addr)]> {
1050 let Inst{31-27} = 0b11111;
1051 let Inst{26-23} = 0b0000;
1052 let Inst{22-21} = opcod;
1053 let Inst{20} = 0; // !load
1054 let Inst{11-6} = 0b000000;
1057 let Inst{15-12} = Rt;
1060 let Inst{19-16} = addr{9-6}; // Rn
1061 let Inst{3-0} = addr{5-2}; // Rm
1062 let Inst{5-4} = addr{1-0}; // imm
1066 /// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
1067 /// register and one whose operand is a register rotated by 8/16/24.
1068 class T2I_ext_rrot<bits<3> opcod, string opc, PatFrag opnode>
1069 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1070 opc, ".w\t$Rd, $Rm$rot",
1071 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
1072 Requires<[IsThumb2]> {
1073 let Inst{31-27} = 0b11111;
1074 let Inst{26-23} = 0b0100;
1075 let Inst{22-20} = opcod;
1076 let Inst{19-16} = 0b1111; // Rn
1077 let Inst{15-12} = 0b1111;
1081 let Inst{5-4} = rot{1-0}; // rotate
1084 // UXTB16 - Requres T2ExtractPack, does not need the .w qualifier.
1085 class T2I_ext_rrot_uxtb16<bits<3> opcod, string opc, PatFrag opnode>
1086 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot),
1087 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1088 [(set rGPR:$Rd, (opnode (rotr rGPR:$Rm, rot_imm:$rot)))]>,
1089 Requires<[HasT2ExtractPack, IsThumb2]> {
1091 let Inst{31-27} = 0b11111;
1092 let Inst{26-23} = 0b0100;
1093 let Inst{22-20} = opcod;
1094 let Inst{19-16} = 0b1111; // Rn
1095 let Inst{15-12} = 0b1111;
1097 let Inst{5-4} = rot;
1100 // SXTB16 - Requres T2ExtractPack, does not need the .w qualifier, no pattern
1102 class T2I_ext_rrot_sxtb16<bits<3> opcod, string opc>
1103 : T2TwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm, rot_imm:$rot), IIC_iEXTr,
1104 opc, "\t$Rd, $Rm$rot", []>,
1105 Requires<[IsThumb2, HasT2ExtractPack]> {
1107 let Inst{31-27} = 0b11111;
1108 let Inst{26-23} = 0b0100;
1109 let Inst{22-20} = opcod;
1110 let Inst{19-16} = 0b1111; // Rn
1111 let Inst{15-12} = 0b1111;
1113 let Inst{5-4} = rot;
1116 /// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
1117 /// register and one whose operand is a register rotated by 8/16/24.
1118 class T2I_exta_rrot<bits<3> opcod, string opc, PatFrag opnode>
1119 : T2ThreeReg<(outs rGPR:$Rd),
1120 (ins rGPR:$Rn, rGPR:$Rm, rot_imm:$rot),
1121 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot",
1122 [(set rGPR:$Rd, (opnode rGPR:$Rn, (rotr rGPR:$Rm,rot_imm:$rot)))]>,
1123 Requires<[HasT2ExtractPack, IsThumb2]> {
1125 let Inst{31-27} = 0b11111;
1126 let Inst{26-23} = 0b0100;
1127 let Inst{22-20} = opcod;
1128 let Inst{15-12} = 0b1111;
1130 let Inst{5-4} = rot;
1133 class T2I_exta_rrot_np<bits<3> opcod, string opc>
1134 : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm,rot_imm:$rot),
1135 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot", []> {
1137 let Inst{31-27} = 0b11111;
1138 let Inst{26-23} = 0b0100;
1139 let Inst{22-20} = opcod;
1140 let Inst{15-12} = 0b1111;
1142 let Inst{5-4} = rot;
1145 //===----------------------------------------------------------------------===//
1147 //===----------------------------------------------------------------------===//
1149 //===----------------------------------------------------------------------===//
1150 // Miscellaneous Instructions.
1153 class T2PCOneRegImm<dag oops, dag iops, InstrItinClass itin,
1154 string asm, list<dag> pattern>
1155 : T2XI<oops, iops, itin, asm, pattern> {
1159 let Inst{11-8} = Rd;
1160 let Inst{26} = label{11};
1161 let Inst{14-12} = label{10-8};
1162 let Inst{7-0} = label{7-0};
1165 // LEApcrel - Load a pc-relative address into a register without offending the
1167 def t2ADR : T2PCOneRegImm<(outs rGPR:$Rd),
1168 (ins t2adrlabel:$addr, pred:$p),
1169 IIC_iALUi, "adr{$p}.w\t$Rd, $addr", []> {
1170 let Inst{31-27} = 0b11110;
1171 let Inst{25-24} = 0b10;
1172 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1175 let Inst{19-16} = 0b1111; // Rn
1180 let Inst{11-8} = Rd;
1181 let Inst{23} = addr{12};
1182 let Inst{21} = addr{12};
1183 let Inst{26} = addr{11};
1184 let Inst{14-12} = addr{10-8};
1185 let Inst{7-0} = addr{7-0};
1187 let DecoderMethod = "DecodeT2Adr";
1190 let neverHasSideEffects = 1, isReMaterializable = 1 in
1191 def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p),
1193 let hasSideEffects = 1 in
1194 def t2LEApcrelJT : t2PseudoInst<(outs rGPR:$Rd),
1195 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1200 //===----------------------------------------------------------------------===//
1201 // Load / store Instructions.
1205 let canFoldAsLoad = 1, isReMaterializable = 1 in
1206 defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si, GPR,
1207 UnOpFrag<(load node:$Src)>>;
1209 // Loads with zero extension
1210 defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1211 rGPR, UnOpFrag<(zextloadi16 node:$Src)>>;
1212 defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1213 rGPR, UnOpFrag<(zextloadi8 node:$Src)>>;
1215 // Loads with sign extension
1216 defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1217 rGPR, UnOpFrag<(sextloadi16 node:$Src)>>;
1218 defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1219 rGPR, UnOpFrag<(sextloadi8 node:$Src)>>;
1221 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1223 def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$Rt, rGPR:$Rt2),
1224 (ins t2addrmode_imm8s4:$addr),
1225 IIC_iLoad_d_i, "ldrd", "\t$Rt, $Rt2, $addr", "", []>;
1226 } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
1228 // zextload i1 -> zextload i8
1229 def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1230 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1231 def : T2Pat<(zextloadi1 t2addrmode_negimm8:$addr),
1232 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1233 def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1234 (t2LDRBs t2addrmode_so_reg:$addr)>;
1235 def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1236 (t2LDRBpci tconstpool:$addr)>;
1238 // extload -> zextload
1239 // FIXME: Reduce the number of patterns by legalizing extload to zextload
1241 def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1242 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1243 def : T2Pat<(extloadi1 t2addrmode_negimm8:$addr),
1244 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1245 def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1246 (t2LDRBs t2addrmode_so_reg:$addr)>;
1247 def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1248 (t2LDRBpci tconstpool:$addr)>;
1250 def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1251 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1252 def : T2Pat<(extloadi8 t2addrmode_negimm8:$addr),
1253 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1254 def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1255 (t2LDRBs t2addrmode_so_reg:$addr)>;
1256 def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1257 (t2LDRBpci tconstpool:$addr)>;
1259 def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1260 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1261 def : T2Pat<(extloadi16 t2addrmode_negimm8:$addr),
1262 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
1263 def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1264 (t2LDRHs t2addrmode_so_reg:$addr)>;
1265 def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1266 (t2LDRHpci tconstpool:$addr)>;
1268 // FIXME: The destination register of the loads and stores can't be PC, but
1269 // can be SP. We need another regclass (similar to rGPR) to represent
1270 // that. Not a pressing issue since these are selected manually,
1275 let mayLoad = 1, neverHasSideEffects = 1 in {
1276 def t2LDR_PRE : T2Ipreldst<0, 0b10, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1277 (ins t2addrmode_imm8:$addr),
1278 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
1279 "ldr", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1281 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1284 def t2LDR_POST : T2Ipostldst<0, 0b10, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1285 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1286 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
1287 "ldr", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1289 def t2LDRB_PRE : T2Ipreldst<0, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1290 (ins t2addrmode_imm8:$addr),
1291 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1292 "ldrb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1294 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1296 def t2LDRB_POST : T2Ipostldst<0, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1297 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1298 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1299 "ldrb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1301 def t2LDRH_PRE : T2Ipreldst<0, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1302 (ins t2addrmode_imm8:$addr),
1303 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1304 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1306 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1308 def t2LDRH_POST : T2Ipostldst<0, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1309 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1310 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1311 "ldrh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1313 def t2LDRSB_PRE : T2Ipreldst<1, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1314 (ins t2addrmode_imm8:$addr),
1315 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1316 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1318 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1320 def t2LDRSB_POST : T2Ipostldst<1, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1321 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1322 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1323 "ldrsb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1325 def t2LDRSH_PRE : T2Ipreldst<1, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1326 (ins t2addrmode_imm8:$addr),
1327 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1328 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1330 let AsmMatchConverter = "cvtLdWriteBackRegT2AddrModeImm8";
1332 def t2LDRSH_POST : T2Ipostldst<1, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1333 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1334 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1335 "ldrsh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>;
1336 } // mayLoad = 1, neverHasSideEffects = 1
1338 // LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110).
1339 // Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
1340 class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1341 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_posimm8:$addr), ii, opc,
1342 "\t$Rt, $addr", []> {
1345 let Inst{31-27} = 0b11111;
1346 let Inst{26-25} = 0b00;
1347 let Inst{24} = signed;
1349 let Inst{22-21} = type;
1350 let Inst{20} = 1; // load
1351 let Inst{19-16} = addr{12-9};
1352 let Inst{15-12} = Rt;
1354 let Inst{10-8} = 0b110; // PUW.
1355 let Inst{7-0} = addr{7-0};
1358 def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1359 def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1360 def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1361 def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1362 def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
1365 defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si, GPR,
1366 BinOpFrag<(store node:$LHS, node:$RHS)>>;
1367 defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
1368 rGPR, BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1369 defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
1370 rGPR, BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>;
1373 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
1374 def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
1375 (ins GPR:$Rt, GPR:$Rt2, t2addrmode_imm8s4:$addr),
1376 IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", "", []>;
1380 let mayStore = 1, neverHasSideEffects = 1 in {
1381 def t2STR_PRE : T2Ipreldst<0, 0b10, 0, 1, (outs GPRnopc:$Rn_wb),
1382 (ins GPRnopc:$Rt, t2addrmode_imm8:$addr),
1383 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1384 "str", "\t$Rt, $addr!",
1385 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1386 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1388 def t2STRH_PRE : T2Ipreldst<0, 0b01, 0, 1, (outs GPRnopc:$Rn_wb),
1389 (ins rGPR:$Rt, t2addrmode_imm8:$addr),
1390 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1391 "strh", "\t$Rt, $addr!",
1392 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1393 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1396 def t2STRB_PRE : T2Ipreldst<0, 0b00, 0, 1, (outs GPRnopc:$Rn_wb),
1397 (ins rGPR:$Rt, t2addrmode_imm8:$addr),
1398 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
1399 "strb", "\t$Rt, $addr!",
1400 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
1401 let AsmMatchConverter = "cvtStWriteBackRegT2AddrModeImm8";
1403 } // mayStore = 1, neverHasSideEffects = 1
1405 def t2STR_POST : T2Ipostldst<0, 0b10, 0, 0, (outs GPRnopc:$Rn_wb),
1406 (ins GPRnopc:$Rt, addr_offset_none:$Rn,
1407 t2am_imm8_offset:$offset),
1408 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
1409 "str", "\t$Rt, $Rn$offset",
1410 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1411 [(set GPRnopc:$Rn_wb,
1412 (post_store GPRnopc:$Rt, addr_offset_none:$Rn,
1413 t2am_imm8_offset:$offset))]>;
1415 def t2STRH_POST : T2Ipostldst<0, 0b01, 0, 0, (outs GPRnopc:$Rn_wb),
1416 (ins rGPR:$Rt, addr_offset_none:$Rn,
1417 t2am_imm8_offset:$offset),
1418 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1419 "strh", "\t$Rt, $Rn$offset",
1420 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1421 [(set GPRnopc:$Rn_wb,
1422 (post_truncsti16 rGPR:$Rt, addr_offset_none:$Rn,
1423 t2am_imm8_offset:$offset))]>;
1425 def t2STRB_POST : T2Ipostldst<0, 0b00, 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 "strb", "\t$Rt, $Rn$offset",
1430 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1431 [(set GPRnopc:$Rn_wb,
1432 (post_truncsti8 rGPR:$Rt, addr_offset_none:$Rn,
1433 t2am_imm8_offset:$offset))]>;
1435 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
1436 // put the patterns on the instruction definitions directly as ISel wants
1437 // the address base and offset to be separate operands, not a single
1438 // complex operand like we represent the instructions themselves. The
1439 // pseudos map between the two.
1440 let usesCustomInserter = 1,
1441 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
1442 def t2STR_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1443 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1445 [(set GPRnopc:$Rn_wb,
1446 (pre_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1447 def t2STRB_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1448 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1450 [(set GPRnopc:$Rn_wb,
1451 (pre_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1452 def t2STRH_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_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>;
1459 // STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1461 // Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
1462 class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1463 : T2Ii8<(outs rGPR:$Rt), (ins t2addrmode_imm8:$addr), ii, opc,
1464 "\t$Rt, $addr", []> {
1465 let Inst{31-27} = 0b11111;
1466 let Inst{26-25} = 0b00;
1467 let Inst{24} = 0; // not signed
1469 let Inst{22-21} = type;
1470 let Inst{20} = 0; // store
1472 let Inst{10-8} = 0b110; // PUW
1476 let Inst{15-12} = Rt;
1477 let Inst{19-16} = addr{12-9};
1478 let Inst{7-0} = addr{7-0};
1481 def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1482 def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1483 def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
1485 // ldrd / strd pre / post variants
1486 // For disassembly only.
1488 def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1489 (ins t2addrmode_imm8s4:$addr), IIC_iLoad_d_ru,
1490 "ldrd", "\t$Rt, $Rt2, $addr!", "$addr.base = $wb", []> {
1491 let AsmMatchConverter = "cvtT2LdrdPre";
1492 let DecoderMethod = "DecodeT2LDRDPreInstruction";
1495 def t2LDRD_POST : T2Ii8s4post<0, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1496 (ins addr_offset_none:$addr, t2am_imm8s4_offset:$imm),
1497 IIC_iLoad_d_ru, "ldrd", "\t$Rt, $Rt2, $addr$imm",
1498 "$addr.base = $wb", []>;
1500 def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs GPR:$wb),
1501 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr),
1502 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr!",
1503 "$addr.base = $wb", []> {
1504 let AsmMatchConverter = "cvtT2StrdPre";
1505 let DecoderMethod = "DecodeT2STRDPreInstruction";
1508 def t2STRD_POST : T2Ii8s4post<0, 1, 0, (outs GPR:$wb),
1509 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr,
1510 t2am_imm8s4_offset:$imm),
1511 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr$imm",
1512 "$addr.base = $wb", []>;
1514 // T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1515 // data/instruction access.
1516 // instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1517 // (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
1518 multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
1520 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
1522 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]> {
1523 let Inst{31-25} = 0b1111100;
1524 let Inst{24} = instr;
1526 let Inst{21} = write;
1528 let Inst{15-12} = 0b1111;
1531 let addr{12} = 1; // add = TRUE
1532 let Inst{19-16} = addr{16-13}; // Rn
1533 let Inst{23} = addr{12}; // U
1534 let Inst{11-0} = addr{11-0}; // imm12
1537 def i8 : T2Ii8<(outs), (ins t2addrmode_negimm8:$addr), IIC_Preload, opc,
1539 [(ARMPreload t2addrmode_negimm8:$addr, (i32 write), (i32 instr))]> {
1540 let Inst{31-25} = 0b1111100;
1541 let Inst{24} = instr;
1542 let Inst{23} = 0; // U = 0
1544 let Inst{21} = write;
1546 let Inst{15-12} = 0b1111;
1547 let Inst{11-8} = 0b1100;
1550 let Inst{19-16} = addr{12-9}; // Rn
1551 let Inst{7-0} = addr{7-0}; // imm8
1554 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
1556 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]> {
1557 let Inst{31-25} = 0b1111100;
1558 let Inst{24} = instr;
1559 let Inst{23} = 0; // add = TRUE for T1
1561 let Inst{21} = write;
1563 let Inst{15-12} = 0b1111;
1564 let Inst{11-6} = 0000000;
1567 let Inst{19-16} = addr{9-6}; // Rn
1568 let Inst{3-0} = addr{5-2}; // Rm
1569 let Inst{5-4} = addr{1-0}; // imm2
1571 let DecoderMethod = "DecodeT2LoadShift";
1573 // FIXME: We should have a separate 'pci' variant here. As-is we represent
1574 // it via the i12 variant, which it's related to, but that means we can
1575 // represent negative immediates, which aren't legal for anything except
1576 // the 'pci' case (Rn == 15).
1579 defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1580 defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1581 defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
1583 //===----------------------------------------------------------------------===//
1584 // Load / store multiple Instructions.
1587 multiclass thumb2_ld_mult<string asm, InstrItinClass itin,
1588 InstrItinClass itin_upd, bit L_bit> {
1590 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1591 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1595 let Inst{31-27} = 0b11101;
1596 let Inst{26-25} = 0b00;
1597 let Inst{24-23} = 0b01; // Increment After
1599 let Inst{21} = 0; // No writeback
1600 let Inst{20} = L_bit;
1601 let Inst{19-16} = Rn;
1602 let Inst{15-0} = regs;
1605 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1606 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1610 let Inst{31-27} = 0b11101;
1611 let Inst{26-25} = 0b00;
1612 let Inst{24-23} = 0b01; // Increment After
1614 let Inst{21} = 1; // Writeback
1615 let Inst{20} = L_bit;
1616 let Inst{19-16} = Rn;
1617 let Inst{15-0} = regs;
1620 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1621 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
1625 let Inst{31-27} = 0b11101;
1626 let Inst{26-25} = 0b00;
1627 let Inst{24-23} = 0b10; // Decrement Before
1629 let Inst{21} = 0; // No writeback
1630 let Inst{20} = L_bit;
1631 let Inst{19-16} = Rn;
1632 let Inst{15-0} = regs;
1635 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1636 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1640 let Inst{31-27} = 0b11101;
1641 let Inst{26-25} = 0b00;
1642 let Inst{24-23} = 0b10; // Decrement Before
1644 let Inst{21} = 1; // Writeback
1645 let Inst{20} = L_bit;
1646 let Inst{19-16} = Rn;
1647 let Inst{15-0} = regs;
1651 let neverHasSideEffects = 1 in {
1653 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1654 defm t2LDM : thumb2_ld_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
1656 multiclass thumb2_st_mult<string asm, InstrItinClass itin,
1657 InstrItinClass itin_upd, bit L_bit> {
1659 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1660 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
1664 let Inst{31-27} = 0b11101;
1665 let Inst{26-25} = 0b00;
1666 let Inst{24-23} = 0b01; // Increment After
1668 let Inst{21} = 0; // No writeback
1669 let Inst{20} = L_bit;
1670 let Inst{19-16} = Rn;
1672 let Inst{14} = regs{14};
1674 let Inst{12-0} = regs{12-0};
1677 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1678 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
1682 let Inst{31-27} = 0b11101;
1683 let Inst{26-25} = 0b00;
1684 let Inst{24-23} = 0b01; // Increment After
1686 let Inst{21} = 1; // Writeback
1687 let Inst{20} = L_bit;
1688 let Inst{19-16} = Rn;
1690 let Inst{14} = regs{14};
1692 let Inst{12-0} = regs{12-0};
1695 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1696 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
1700 let Inst{31-27} = 0b11101;
1701 let Inst{26-25} = 0b00;
1702 let Inst{24-23} = 0b10; // Decrement Before
1704 let Inst{21} = 0; // No writeback
1705 let Inst{20} = L_bit;
1706 let Inst{19-16} = Rn;
1708 let Inst{14} = regs{14};
1710 let Inst{12-0} = regs{12-0};
1713 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1714 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1718 let Inst{31-27} = 0b11101;
1719 let Inst{26-25} = 0b00;
1720 let Inst{24-23} = 0b10; // Decrement Before
1722 let Inst{21} = 1; // Writeback
1723 let Inst{20} = L_bit;
1724 let Inst{19-16} = Rn;
1726 let Inst{14} = regs{14};
1728 let Inst{12-0} = regs{12-0};
1733 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1734 defm t2STM : thumb2_st_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
1736 } // neverHasSideEffects
1739 //===----------------------------------------------------------------------===//
1740 // Move Instructions.
1743 let neverHasSideEffects = 1 in
1744 def t2MOVr : T2sTwoReg<(outs GPRnopc:$Rd), (ins GPR:$Rm), IIC_iMOVr,
1745 "mov", ".w\t$Rd, $Rm", []> {
1746 let Inst{31-27} = 0b11101;
1747 let Inst{26-25} = 0b01;
1748 let Inst{24-21} = 0b0010;
1749 let Inst{19-16} = 0b1111; // Rn
1750 let Inst{14-12} = 0b000;
1751 let Inst{7-4} = 0b0000;
1753 def : t2InstAlias<"mov${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1754 pred:$p, zero_reg)>;
1755 def : t2InstAlias<"movs${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1757 def : t2InstAlias<"movs${p} $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPR:$Rm,
1760 // AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
1761 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
1762 AddedComplexity = 1 in
1763 def t2MOVi : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), IIC_iMOVi,
1764 "mov", ".w\t$Rd, $imm",
1765 [(set rGPR:$Rd, t2_so_imm:$imm)]> {
1766 let Inst{31-27} = 0b11110;
1768 let Inst{24-21} = 0b0010;
1769 let Inst{19-16} = 0b1111; // Rn
1773 // cc_out is handled as part of the explicit mnemonic in the parser for 'mov'.
1774 // Use aliases to get that to play nice here.
1775 def : t2InstAlias<"movs${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1777 def : t2InstAlias<"movs${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1780 def : t2InstAlias<"mov${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1781 pred:$p, zero_reg)>;
1782 def : t2InstAlias<"mov${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
1783 pred:$p, zero_reg)>;
1785 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
1786 def t2MOVi16 : T2I<(outs rGPR:$Rd), (ins imm0_65535_expr:$imm), IIC_iMOVi,
1787 "movw", "\t$Rd, $imm",
1788 [(set rGPR:$Rd, imm0_65535:$imm)]> {
1789 let Inst{31-27} = 0b11110;
1791 let Inst{24-21} = 0b0010;
1792 let Inst{20} = 0; // The S bit.
1798 let Inst{11-8} = Rd;
1799 let Inst{19-16} = imm{15-12};
1800 let Inst{26} = imm{11};
1801 let Inst{14-12} = imm{10-8};
1802 let Inst{7-0} = imm{7-0};
1803 let DecoderMethod = "DecodeT2MOVTWInstruction";
1806 def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
1807 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1809 let Constraints = "$src = $Rd" in {
1810 def t2MOVTi16 : T2I<(outs rGPR:$Rd),
1811 (ins rGPR:$src, imm0_65535_expr:$imm), IIC_iMOVi,
1812 "movt", "\t$Rd, $imm",
1814 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]> {
1815 let Inst{31-27} = 0b11110;
1817 let Inst{24-21} = 0b0110;
1818 let Inst{20} = 0; // The S bit.
1824 let Inst{11-8} = Rd;
1825 let Inst{19-16} = imm{15-12};
1826 let Inst{26} = imm{11};
1827 let Inst{14-12} = imm{10-8};
1828 let Inst{7-0} = imm{7-0};
1829 let DecoderMethod = "DecodeT2MOVTWInstruction";
1832 def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
1833 (ins rGPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
1836 def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
1838 //===----------------------------------------------------------------------===//
1839 // Extend Instructions.
1844 def t2SXTB : T2I_ext_rrot<0b100, "sxtb",
1845 UnOpFrag<(sext_inreg node:$Src, i8)>>;
1846 def t2SXTH : T2I_ext_rrot<0b000, "sxth",
1847 UnOpFrag<(sext_inreg node:$Src, i16)>>;
1848 def t2SXTB16 : T2I_ext_rrot_sxtb16<0b010, "sxtb16">;
1850 def t2SXTAB : T2I_exta_rrot<0b100, "sxtab",
1851 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1852 def t2SXTAH : T2I_exta_rrot<0b000, "sxtah",
1853 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1854 def t2SXTAB16 : T2I_exta_rrot_np<0b010, "sxtab16">;
1858 let AddedComplexity = 16 in {
1859 def t2UXTB : T2I_ext_rrot<0b101, "uxtb",
1860 UnOpFrag<(and node:$Src, 0x000000FF)>>;
1861 def t2UXTH : T2I_ext_rrot<0b001, "uxth",
1862 UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1863 def t2UXTB16 : T2I_ext_rrot_uxtb16<0b011, "uxtb16",
1864 UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1866 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1867 // The transformation should probably be done as a combiner action
1868 // instead so we can include a check for masking back in the upper
1869 // eight bits of the source into the lower eight bits of the result.
1870 //def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
1871 // (t2UXTB16 rGPR:$Src, 3)>,
1872 // Requires<[HasT2ExtractPack, IsThumb2]>;
1873 def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
1874 (t2UXTB16 rGPR:$Src, 1)>,
1875 Requires<[HasT2ExtractPack, IsThumb2]>;
1877 def t2UXTAB : T2I_exta_rrot<0b101, "uxtab",
1878 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1879 def t2UXTAH : T2I_exta_rrot<0b001, "uxtah",
1880 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1881 def t2UXTAB16 : T2I_exta_rrot_np<0b011, "uxtab16">;
1884 //===----------------------------------------------------------------------===//
1885 // Arithmetic Instructions.
1888 defm t2ADD : T2I_bin_ii12rs<0b000, "add",
1889 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1890 defm t2SUB : T2I_bin_ii12rs<0b101, "sub",
1891 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1893 // ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
1895 // Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the
1896 // selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by
1897 // AdjustInstrPostInstrSelection where we determine whether or not to
1898 // set the "s" bit based on CPSR liveness.
1900 // FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen
1901 // support for an optional CPSR definition that corresponds to the DAG
1902 // node's second value. We can then eliminate the implicit def of CPSR.
1903 defm t2ADDS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi,
1904 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
1905 defm t2SUBS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi,
1906 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
1908 let hasPostISelHook = 1 in {
1909 defm t2ADC : T2I_adde_sube_irs<0b1010, "adc",
1910 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
1911 defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc",
1912 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
1916 defm t2RSB : T2I_rbin_irs <0b1110, "rsb",
1917 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1919 // FIXME: Eliminate them if we can write def : Pat patterns which defines
1920 // CPSR and the implicit def of CPSR is not needed.
1921 defm t2RSBS : T2I_rbin_s_is <BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
1923 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1924 // The assume-no-carry-in form uses the negation of the input since add/sub
1925 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
1926 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1928 // The AddedComplexity preferences the first variant over the others since
1929 // it can be shrunk to a 16-bit wide encoding, while the others cannot.
1930 let AddedComplexity = 1 in
1931 def : T2Pat<(add GPR:$src, imm0_255_neg:$imm),
1932 (t2SUBri GPR:$src, imm0_255_neg:$imm)>;
1933 def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm),
1934 (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>;
1935 def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm),
1936 (t2SUBri12 GPR:$src, imm0_4095_neg:$imm)>;
1937 def : T2Pat<(add GPR:$src, imm0_65535_neg:$imm),
1938 (t2SUBrr GPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
1940 let AddedComplexity = 1 in
1941 def : T2Pat<(ARMaddc rGPR:$src, imm0_255_neg:$imm),
1942 (t2SUBSri rGPR:$src, imm0_255_neg:$imm)>;
1943 def : T2Pat<(ARMaddc rGPR:$src, t2_so_imm_neg:$imm),
1944 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
1945 def : T2Pat<(ARMaddc rGPR:$src, imm0_65535_neg:$imm),
1946 (t2SUBSrr rGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
1947 // The with-carry-in form matches bitwise not instead of the negation.
1948 // Effectively, the inverse interpretation of the carry flag already accounts
1949 // for part of the negation.
1950 let AddedComplexity = 1 in
1951 def : T2Pat<(ARMadde rGPR:$src, imm0_255_not:$imm, CPSR),
1952 (t2SBCri rGPR:$src, imm0_255_not:$imm)>;
1953 def : T2Pat<(ARMadde rGPR:$src, t2_so_imm_not:$imm, CPSR),
1954 (t2SBCri rGPR:$src, t2_so_imm_not:$imm)>;
1955 def : T2Pat<(ARMadde rGPR:$src, imm0_65535_neg:$imm, CPSR),
1956 (t2SBCrr rGPR:$src, (t2MOVi16 (imm_not_XFORM imm:$imm)))>;
1958 // Select Bytes -- for disassembly only
1960 def t2SEL : T2ThreeReg<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1961 NoItinerary, "sel", "\t$Rd, $Rn, $Rm", []>,
1962 Requires<[IsThumb2, HasThumb2DSP]> {
1963 let Inst{31-27} = 0b11111;
1964 let Inst{26-24} = 0b010;
1966 let Inst{22-20} = 0b010;
1967 let Inst{15-12} = 0b1111;
1969 let Inst{6-4} = 0b000;
1972 // A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
1973 // And Miscellaneous operations -- for disassembly only
1974 class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
1975 list<dag> pat = [/* For disassembly only; pattern left blank */],
1976 dag iops = (ins rGPR:$Rn, rGPR:$Rm),
1977 string asm = "\t$Rd, $Rn, $Rm">
1978 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, pat>,
1979 Requires<[IsThumb2, HasThumb2DSP]> {
1980 let Inst{31-27} = 0b11111;
1981 let Inst{26-23} = 0b0101;
1982 let Inst{22-20} = op22_20;
1983 let Inst{15-12} = 0b1111;
1984 let Inst{7-4} = op7_4;
1990 let Inst{11-8} = Rd;
1991 let Inst{19-16} = Rn;
1995 // Saturating add/subtract -- for disassembly only
1997 def t2QADD : T2I_pam<0b000, 0b1000, "qadd",
1998 [(set rGPR:$Rd, (int_arm_qadd rGPR:$Rn, rGPR:$Rm))],
1999 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2000 def t2QADD16 : T2I_pam<0b001, 0b0001, "qadd16">;
2001 def t2QADD8 : T2I_pam<0b000, 0b0001, "qadd8">;
2002 def t2QASX : T2I_pam<0b010, 0b0001, "qasx">;
2003 def t2QDADD : T2I_pam<0b000, 0b1001, "qdadd", [],
2004 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2005 def t2QDSUB : T2I_pam<0b000, 0b1011, "qdsub", [],
2006 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2007 def t2QSAX : T2I_pam<0b110, 0b0001, "qsax">;
2008 def t2QSUB : T2I_pam<0b000, 0b1010, "qsub",
2009 [(set rGPR:$Rd, (int_arm_qsub rGPR:$Rn, rGPR:$Rm))],
2010 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2011 def t2QSUB16 : T2I_pam<0b101, 0b0001, "qsub16">;
2012 def t2QSUB8 : T2I_pam<0b100, 0b0001, "qsub8">;
2013 def t2UQADD16 : T2I_pam<0b001, 0b0101, "uqadd16">;
2014 def t2UQADD8 : T2I_pam<0b000, 0b0101, "uqadd8">;
2015 def t2UQASX : T2I_pam<0b010, 0b0101, "uqasx">;
2016 def t2UQSAX : T2I_pam<0b110, 0b0101, "uqsax">;
2017 def t2UQSUB16 : T2I_pam<0b101, 0b0101, "uqsub16">;
2018 def t2UQSUB8 : T2I_pam<0b100, 0b0101, "uqsub8">;
2020 // Signed/Unsigned add/subtract -- for disassembly only
2022 def t2SASX : T2I_pam<0b010, 0b0000, "sasx">;
2023 def t2SADD16 : T2I_pam<0b001, 0b0000, "sadd16">;
2024 def t2SADD8 : T2I_pam<0b000, 0b0000, "sadd8">;
2025 def t2SSAX : T2I_pam<0b110, 0b0000, "ssax">;
2026 def t2SSUB16 : T2I_pam<0b101, 0b0000, "ssub16">;
2027 def t2SSUB8 : T2I_pam<0b100, 0b0000, "ssub8">;
2028 def t2UASX : T2I_pam<0b010, 0b0100, "uasx">;
2029 def t2UADD16 : T2I_pam<0b001, 0b0100, "uadd16">;
2030 def t2UADD8 : T2I_pam<0b000, 0b0100, "uadd8">;
2031 def t2USAX : T2I_pam<0b110, 0b0100, "usax">;
2032 def t2USUB16 : T2I_pam<0b101, 0b0100, "usub16">;
2033 def t2USUB8 : T2I_pam<0b100, 0b0100, "usub8">;
2035 // Signed/Unsigned halving add/subtract -- for disassembly only
2037 def t2SHASX : T2I_pam<0b010, 0b0010, "shasx">;
2038 def t2SHADD16 : T2I_pam<0b001, 0b0010, "shadd16">;
2039 def t2SHADD8 : T2I_pam<0b000, 0b0010, "shadd8">;
2040 def t2SHSAX : T2I_pam<0b110, 0b0010, "shsax">;
2041 def t2SHSUB16 : T2I_pam<0b101, 0b0010, "shsub16">;
2042 def t2SHSUB8 : T2I_pam<0b100, 0b0010, "shsub8">;
2043 def t2UHASX : T2I_pam<0b010, 0b0110, "uhasx">;
2044 def t2UHADD16 : T2I_pam<0b001, 0b0110, "uhadd16">;
2045 def t2UHADD8 : T2I_pam<0b000, 0b0110, "uhadd8">;
2046 def t2UHSAX : T2I_pam<0b110, 0b0110, "uhsax">;
2047 def t2UHSUB16 : T2I_pam<0b101, 0b0110, "uhsub16">;
2048 def t2UHSUB8 : T2I_pam<0b100, 0b0110, "uhsub8">;
2050 // Helper class for disassembly only
2051 // A6.3.16 & A6.3.17
2052 // T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
2053 class T2ThreeReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2054 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2055 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2056 let Inst{31-27} = 0b11111;
2057 let Inst{26-24} = 0b011;
2058 let Inst{23} = long;
2059 let Inst{22-20} = op22_20;
2060 let Inst{7-4} = op7_4;
2063 class T2FourReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2064 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2065 : T2FourReg<oops, iops, itin, opc, asm, pattern> {
2066 let Inst{31-27} = 0b11111;
2067 let Inst{26-24} = 0b011;
2068 let Inst{23} = long;
2069 let Inst{22-20} = op22_20;
2070 let Inst{7-4} = op7_4;
2073 // Unsigned Sum of Absolute Differences [and Accumulate].
2074 def t2USAD8 : T2ThreeReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2075 (ins rGPR:$Rn, rGPR:$Rm),
2076 NoItinerary, "usad8", "\t$Rd, $Rn, $Rm", []>,
2077 Requires<[IsThumb2, HasThumb2DSP]> {
2078 let Inst{15-12} = 0b1111;
2080 def t2USADA8 : T2FourReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2081 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), NoItinerary,
2082 "usada8", "\t$Rd, $Rn, $Rm, $Ra", []>,
2083 Requires<[IsThumb2, HasThumb2DSP]>;
2085 // Signed/Unsigned saturate.
2086 class T2SatI<dag oops, dag iops, InstrItinClass itin,
2087 string opc, string asm, list<dag> pattern>
2088 : T2I<oops, iops, itin, opc, asm, pattern> {
2094 let Inst{11-8} = Rd;
2095 let Inst{19-16} = Rn;
2096 let Inst{4-0} = sat_imm;
2097 let Inst{21} = sh{5};
2098 let Inst{14-12} = sh{4-2};
2099 let Inst{7-6} = sh{1-0};
2104 (ins imm1_32:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
2105 NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
2106 let Inst{31-27} = 0b11110;
2107 let Inst{25-22} = 0b1100;
2113 def t2SSAT16: T2SatI<
2114 (outs rGPR:$Rd), (ins imm1_16:$sat_imm, rGPR:$Rn), NoItinerary,
2115 "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
2116 Requires<[IsThumb2, HasThumb2DSP]> {
2117 let Inst{31-27} = 0b11110;
2118 let Inst{25-22} = 0b1100;
2121 let Inst{21} = 1; // sh = '1'
2122 let Inst{14-12} = 0b000; // imm3 = '000'
2123 let Inst{7-6} = 0b00; // imm2 = '00'
2124 let Inst{5-4} = 0b00;
2129 (ins imm0_31:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
2130 NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
2131 let Inst{31-27} = 0b11110;
2132 let Inst{25-22} = 0b1110;
2137 def t2USAT16: T2SatI<(outs rGPR:$Rd), (ins imm0_15:$sat_imm, rGPR:$Rn),
2139 "usat16", "\t$Rd, $sat_imm, $Rn", []>,
2140 Requires<[IsThumb2, HasThumb2DSP]> {
2141 let Inst{31-22} = 0b1111001110;
2144 let Inst{21} = 1; // sh = '1'
2145 let Inst{14-12} = 0b000; // imm3 = '000'
2146 let Inst{7-6} = 0b00; // imm2 = '00'
2147 let Inst{5-4} = 0b00;
2150 def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>;
2151 def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>;
2153 //===----------------------------------------------------------------------===//
2154 // Shift and rotate Instructions.
2157 defm t2LSL : T2I_sh_ir<0b00, "lsl", imm0_31,
2158 BinOpFrag<(shl node:$LHS, node:$RHS)>>;
2159 defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr,
2160 BinOpFrag<(srl node:$LHS, node:$RHS)>>;
2161 defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr,
2162 BinOpFrag<(sra node:$LHS, node:$RHS)>>;
2163 defm t2ROR : T2I_sh_ir<0b11, "ror", imm0_31,
2164 BinOpFrag<(rotr node:$LHS, node:$RHS)>>;
2166 // (rotr x, (and y, 0x...1f)) ==> (ROR x, y)
2167 def : T2Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)),
2168 (t2RORrr rGPR:$lhs, rGPR:$rhs)>;
2170 let Uses = [CPSR] in {
2171 def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2172 "rrx", "\t$Rd, $Rm",
2173 [(set rGPR:$Rd, (ARMrrx rGPR:$Rm))]> {
2174 let Inst{31-27} = 0b11101;
2175 let Inst{26-25} = 0b01;
2176 let Inst{24-21} = 0b0010;
2177 let Inst{19-16} = 0b1111; // Rn
2178 let Inst{14-12} = 0b000;
2179 let Inst{7-4} = 0b0011;
2183 let isCodeGenOnly = 1, Defs = [CPSR] in {
2184 def t2MOVsrl_flag : T2TwoRegShiftImm<
2185 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2186 "lsrs", ".w\t$Rd, $Rm, #1",
2187 [(set rGPR:$Rd, (ARMsrl_flag rGPR:$Rm))]> {
2188 let Inst{31-27} = 0b11101;
2189 let Inst{26-25} = 0b01;
2190 let Inst{24-21} = 0b0010;
2191 let Inst{20} = 1; // The S bit.
2192 let Inst{19-16} = 0b1111; // Rn
2193 let Inst{5-4} = 0b01; // Shift type.
2194 // Shift amount = Inst{14-12:7-6} = 1.
2195 let Inst{14-12} = 0b000;
2196 let Inst{7-6} = 0b01;
2198 def t2MOVsra_flag : T2TwoRegShiftImm<
2199 (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2200 "asrs", ".w\t$Rd, $Rm, #1",
2201 [(set rGPR:$Rd, (ARMsra_flag rGPR:$Rm))]> {
2202 let Inst{31-27} = 0b11101;
2203 let Inst{26-25} = 0b01;
2204 let Inst{24-21} = 0b0010;
2205 let Inst{20} = 1; // The S bit.
2206 let Inst{19-16} = 0b1111; // Rn
2207 let Inst{5-4} = 0b10; // Shift type.
2208 // Shift amount = Inst{14-12:7-6} = 1.
2209 let Inst{14-12} = 0b000;
2210 let Inst{7-6} = 0b01;
2214 //===----------------------------------------------------------------------===//
2215 // Bitwise Instructions.
2218 defm t2AND : T2I_bin_w_irs<0b0000, "and",
2219 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2220 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
2221 defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
2222 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2223 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
2224 defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
2225 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2226 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
2228 defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
2229 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2230 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
2232 class T2BitFI<dag oops, dag iops, InstrItinClass itin,
2233 string opc, string asm, list<dag> pattern>
2234 : T2I<oops, iops, itin, opc, asm, pattern> {
2239 let Inst{11-8} = Rd;
2240 let Inst{4-0} = msb{4-0};
2241 let Inst{14-12} = lsb{4-2};
2242 let Inst{7-6} = lsb{1-0};
2245 class T2TwoRegBitFI<dag oops, dag iops, InstrItinClass itin,
2246 string opc, string asm, list<dag> pattern>
2247 : T2BitFI<oops, iops, itin, opc, asm, pattern> {
2250 let Inst{19-16} = Rn;
2253 let Constraints = "$src = $Rd" in
2254 def t2BFC : T2BitFI<(outs rGPR:$Rd), (ins rGPR:$src, bf_inv_mask_imm:$imm),
2255 IIC_iUNAsi, "bfc", "\t$Rd, $imm",
2256 [(set rGPR:$Rd, (and rGPR:$src, bf_inv_mask_imm:$imm))]> {
2257 let Inst{31-27} = 0b11110;
2258 let Inst{26} = 0; // should be 0.
2260 let Inst{24-20} = 0b10110;
2261 let Inst{19-16} = 0b1111; // Rn
2263 let Inst{5} = 0; // should be 0.
2266 let msb{4-0} = imm{9-5};
2267 let lsb{4-0} = imm{4-0};
2270 def t2SBFX: T2TwoRegBitFI<
2271 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2272 IIC_iUNAsi, "sbfx", "\t$Rd, $Rn, $lsb, $msb", []> {
2273 let Inst{31-27} = 0b11110;
2275 let Inst{24-20} = 0b10100;
2279 def t2UBFX: T2TwoRegBitFI<
2280 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2281 IIC_iUNAsi, "ubfx", "\t$Rd, $Rn, $lsb, $msb", []> {
2282 let Inst{31-27} = 0b11110;
2284 let Inst{24-20} = 0b11100;
2288 // A8.6.18 BFI - Bitfield insert (Encoding T1)
2289 let Constraints = "$src = $Rd" in {
2290 def t2BFI : T2TwoRegBitFI<(outs rGPR:$Rd),
2291 (ins rGPR:$src, rGPR:$Rn, bf_inv_mask_imm:$imm),
2292 IIC_iBITi, "bfi", "\t$Rd, $Rn, $imm",
2293 [(set rGPR:$Rd, (ARMbfi rGPR:$src, rGPR:$Rn,
2294 bf_inv_mask_imm:$imm))]> {
2295 let Inst{31-27} = 0b11110;
2296 let Inst{26} = 0; // should be 0.
2298 let Inst{24-20} = 0b10110;
2300 let Inst{5} = 0; // should be 0.
2303 let msb{4-0} = imm{9-5};
2304 let lsb{4-0} = imm{4-0};
2308 defm t2ORN : T2I_bin_irs<0b0011, "orn",
2309 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2310 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
2312 /// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
2313 /// unary operation that produces a value. These are predicable and can be
2314 /// changed to modify CPSR.
2315 multiclass T2I_un_irs<bits<4> opcod, string opc,
2316 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
2317 PatFrag opnode, bit Cheap = 0, bit ReMat = 0> {
2319 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii,
2321 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]> {
2322 let isAsCheapAsAMove = Cheap;
2323 let isReMaterializable = ReMat;
2324 let Inst{31-27} = 0b11110;
2326 let Inst{24-21} = opcod;
2327 let Inst{19-16} = 0b1111; // Rn
2331 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir,
2332 opc, ".w\t$Rd, $Rm",
2333 [(set rGPR:$Rd, (opnode rGPR:$Rm))]> {
2334 let Inst{31-27} = 0b11101;
2335 let Inst{26-25} = 0b01;
2336 let Inst{24-21} = opcod;
2337 let Inst{19-16} = 0b1111; // Rn
2338 let Inst{14-12} = 0b000; // imm3
2339 let Inst{7-6} = 0b00; // imm2
2340 let Inst{5-4} = 0b00; // type
2343 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis,
2344 opc, ".w\t$Rd, $ShiftedRm",
2345 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]> {
2346 let Inst{31-27} = 0b11101;
2347 let Inst{26-25} = 0b01;
2348 let Inst{24-21} = opcod;
2349 let Inst{19-16} = 0b1111; // Rn
2353 // Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
2354 let AddedComplexity = 1 in
2355 defm t2MVN : T2I_un_irs <0b0011, "mvn",
2356 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
2357 UnOpFrag<(not node:$Src)>, 1, 1>;
2359 let AddedComplexity = 1 in
2360 def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
2361 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
2363 // top16Zero - answer true if the upper 16 bits of $src are 0, false otherwise
2364 def top16Zero: PatLeaf<(i32 rGPR:$src), [{
2365 return CurDAG->MaskedValueIsZero(SDValue(N,0), APInt::getHighBitsSet(32, 16));
2368 // so_imm_notSext is needed instead of so_imm_not, as the value of imm
2369 // will match the extended, not the original bitWidth for $src.
2370 def : T2Pat<(and top16Zero:$src, t2_so_imm_notSext:$imm),
2371 (t2BICri rGPR:$src, t2_so_imm_notSext:$imm)>;
2374 // FIXME: Disable this pattern on Darwin to workaround an assembler bug.
2375 def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
2376 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
2377 Requires<[IsThumb2]>;
2379 def : T2Pat<(t2_so_imm_not:$src),
2380 (t2MVNi t2_so_imm_not:$src)>;
2382 //===----------------------------------------------------------------------===//
2383 // Multiply Instructions.
2385 let isCommutable = 1 in
2386 def t2MUL: T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2387 "mul", "\t$Rd, $Rn, $Rm",
2388 [(set rGPR:$Rd, (mul rGPR:$Rn, rGPR:$Rm))]> {
2389 let Inst{31-27} = 0b11111;
2390 let Inst{26-23} = 0b0110;
2391 let Inst{22-20} = 0b000;
2392 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2393 let Inst{7-4} = 0b0000; // Multiply
2396 def t2MLA: T2FourReg<
2397 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2398 "mla", "\t$Rd, $Rn, $Rm, $Ra",
2399 [(set rGPR:$Rd, (add (mul rGPR:$Rn, rGPR:$Rm), rGPR:$Ra))]>,
2400 Requires<[IsThumb2, UseMulOps]> {
2401 let Inst{31-27} = 0b11111;
2402 let Inst{26-23} = 0b0110;
2403 let Inst{22-20} = 0b000;
2404 let Inst{7-4} = 0b0000; // Multiply
2407 def t2MLS: T2FourReg<
2408 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2409 "mls", "\t$Rd, $Rn, $Rm, $Ra",
2410 [(set rGPR:$Rd, (sub rGPR:$Ra, (mul rGPR:$Rn, rGPR:$Rm)))]>,
2411 Requires<[IsThumb2, UseMulOps]> {
2412 let Inst{31-27} = 0b11111;
2413 let Inst{26-23} = 0b0110;
2414 let Inst{22-20} = 0b000;
2415 let Inst{7-4} = 0b0001; // Multiply and Subtract
2418 // Extra precision multiplies with low / high results
2419 let neverHasSideEffects = 1 in {
2420 let isCommutable = 1 in {
2421 def t2SMULL : T2MulLong<0b000, 0b0000,
2422 (outs rGPR:$RdLo, rGPR:$RdHi),
2423 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
2424 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2426 def t2UMULL : T2MulLong<0b010, 0b0000,
2427 (outs rGPR:$RdLo, rGPR:$RdHi),
2428 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
2429 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2432 // Multiply + accumulate
2433 def t2SMLAL : T2MlaLong<0b100, 0b0000,
2434 (outs rGPR:$RdLo, rGPR:$RdHi),
2435 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), IIC_iMAC64,
2436 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2437 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">;
2439 def t2UMLAL : T2MlaLong<0b110, 0b0000,
2440 (outs rGPR:$RdLo, rGPR:$RdHi),
2441 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), IIC_iMAC64,
2442 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2443 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">;
2445 def t2UMAAL : T2MulLong<0b110, 0b0110,
2446 (outs rGPR:$RdLo, rGPR:$RdHi),
2447 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64,
2448 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2449 Requires<[IsThumb2, HasThumb2DSP]>;
2450 } // neverHasSideEffects
2452 // Rounding variants of the below included for disassembly only
2454 // Most significant word multiply
2455 def t2SMMUL : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2456 "smmul", "\t$Rd, $Rn, $Rm",
2457 [(set rGPR:$Rd, (mulhs rGPR:$Rn, rGPR:$Rm))]>,
2458 Requires<[IsThumb2, HasThumb2DSP]> {
2459 let Inst{31-27} = 0b11111;
2460 let Inst{26-23} = 0b0110;
2461 let Inst{22-20} = 0b101;
2462 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2463 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2466 def t2SMMULR : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
2467 "smmulr", "\t$Rd, $Rn, $Rm", []>,
2468 Requires<[IsThumb2, HasThumb2DSP]> {
2469 let Inst{31-27} = 0b11111;
2470 let Inst{26-23} = 0b0110;
2471 let Inst{22-20} = 0b101;
2472 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2473 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2476 def t2SMMLA : T2FourReg<
2477 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2478 "smmla", "\t$Rd, $Rn, $Rm, $Ra",
2479 [(set rGPR:$Rd, (add (mulhs rGPR:$Rm, rGPR:$Rn), rGPR:$Ra))]>,
2480 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2481 let Inst{31-27} = 0b11111;
2482 let Inst{26-23} = 0b0110;
2483 let Inst{22-20} = 0b101;
2484 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2487 def t2SMMLAR: T2FourReg<
2488 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2489 "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
2490 Requires<[IsThumb2, HasThumb2DSP]> {
2491 let Inst{31-27} = 0b11111;
2492 let Inst{26-23} = 0b0110;
2493 let Inst{22-20} = 0b101;
2494 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2497 def t2SMMLS: T2FourReg<
2498 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2499 "smmls", "\t$Rd, $Rn, $Rm, $Ra",
2500 [(set rGPR:$Rd, (sub rGPR:$Ra, (mulhs rGPR:$Rn, rGPR:$Rm)))]>,
2501 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2502 let Inst{31-27} = 0b11111;
2503 let Inst{26-23} = 0b0110;
2504 let Inst{22-20} = 0b110;
2505 let Inst{7-4} = 0b0000; // No Rounding (Inst{4} = 0)
2508 def t2SMMLSR:T2FourReg<
2509 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
2510 "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
2511 Requires<[IsThumb2, HasThumb2DSP]> {
2512 let Inst{31-27} = 0b11111;
2513 let Inst{26-23} = 0b0110;
2514 let Inst{22-20} = 0b110;
2515 let Inst{7-4} = 0b0001; // Rounding (Inst{4} = 1)
2518 multiclass T2I_smul<string opc, PatFrag opnode> {
2519 def BB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2520 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
2521 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
2522 (sext_inreg rGPR:$Rm, i16)))]>,
2523 Requires<[IsThumb2, HasThumb2DSP]> {
2524 let Inst{31-27} = 0b11111;
2525 let Inst{26-23} = 0b0110;
2526 let Inst{22-20} = 0b001;
2527 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2528 let Inst{7-6} = 0b00;
2529 let Inst{5-4} = 0b00;
2532 def BT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2533 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
2534 [(set rGPR:$Rd, (opnode (sext_inreg rGPR:$Rn, i16),
2535 (sra rGPR:$Rm, (i32 16))))]>,
2536 Requires<[IsThumb2, HasThumb2DSP]> {
2537 let Inst{31-27} = 0b11111;
2538 let Inst{26-23} = 0b0110;
2539 let Inst{22-20} = 0b001;
2540 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2541 let Inst{7-6} = 0b00;
2542 let Inst{5-4} = 0b01;
2545 def TB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2546 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
2547 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
2548 (sext_inreg rGPR:$Rm, i16)))]>,
2549 Requires<[IsThumb2, HasThumb2DSP]> {
2550 let Inst{31-27} = 0b11111;
2551 let Inst{26-23} = 0b0110;
2552 let Inst{22-20} = 0b001;
2553 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2554 let Inst{7-6} = 0b00;
2555 let Inst{5-4} = 0b10;
2558 def TT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2559 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
2560 [(set rGPR:$Rd, (opnode (sra rGPR:$Rn, (i32 16)),
2561 (sra rGPR:$Rm, (i32 16))))]>,
2562 Requires<[IsThumb2, HasThumb2DSP]> {
2563 let Inst{31-27} = 0b11111;
2564 let Inst{26-23} = 0b0110;
2565 let Inst{22-20} = 0b001;
2566 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2567 let Inst{7-6} = 0b00;
2568 let Inst{5-4} = 0b11;
2571 def WB : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2572 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
2573 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
2574 (sext_inreg rGPR:$Rm, i16)), (i32 16)))]>,
2575 Requires<[IsThumb2, HasThumb2DSP]> {
2576 let Inst{31-27} = 0b11111;
2577 let Inst{26-23} = 0b0110;
2578 let Inst{22-20} = 0b011;
2579 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2580 let Inst{7-6} = 0b00;
2581 let Inst{5-4} = 0b00;
2584 def WT : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16,
2585 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
2586 [(set rGPR:$Rd, (sra (opnode rGPR:$Rn,
2587 (sra rGPR:$Rm, (i32 16))), (i32 16)))]>,
2588 Requires<[IsThumb2, HasThumb2DSP]> {
2589 let Inst{31-27} = 0b11111;
2590 let Inst{26-23} = 0b0110;
2591 let Inst{22-20} = 0b011;
2592 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
2593 let Inst{7-6} = 0b00;
2594 let Inst{5-4} = 0b01;
2599 multiclass T2I_smla<string opc, PatFrag opnode> {
2601 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2602 !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
2603 [(set rGPR:$Rd, (add rGPR:$Ra,
2604 (opnode (sext_inreg rGPR:$Rn, i16),
2605 (sext_inreg rGPR:$Rm, i16))))]>,
2606 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2607 let Inst{31-27} = 0b11111;
2608 let Inst{26-23} = 0b0110;
2609 let Inst{22-20} = 0b001;
2610 let Inst{7-6} = 0b00;
2611 let Inst{5-4} = 0b00;
2615 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2616 !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
2617 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sext_inreg rGPR:$Rn, i16),
2618 (sra rGPR:$Rm, (i32 16)))))]>,
2619 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2620 let Inst{31-27} = 0b11111;
2621 let Inst{26-23} = 0b0110;
2622 let Inst{22-20} = 0b001;
2623 let Inst{7-6} = 0b00;
2624 let Inst{5-4} = 0b01;
2628 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2629 !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
2630 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
2631 (sext_inreg rGPR:$Rm, i16))))]>,
2632 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2633 let Inst{31-27} = 0b11111;
2634 let Inst{26-23} = 0b0110;
2635 let Inst{22-20} = 0b001;
2636 let Inst{7-6} = 0b00;
2637 let Inst{5-4} = 0b10;
2641 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2642 !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
2643 [(set rGPR:$Rd, (add rGPR:$Ra, (opnode (sra rGPR:$Rn, (i32 16)),
2644 (sra rGPR:$Rm, (i32 16)))))]>,
2645 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2646 let Inst{31-27} = 0b11111;
2647 let Inst{26-23} = 0b0110;
2648 let Inst{22-20} = 0b001;
2649 let Inst{7-6} = 0b00;
2650 let Inst{5-4} = 0b11;
2654 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2655 !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
2656 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
2657 (sext_inreg rGPR:$Rm, i16)), (i32 16))))]>,
2658 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2659 let Inst{31-27} = 0b11111;
2660 let Inst{26-23} = 0b0110;
2661 let Inst{22-20} = 0b011;
2662 let Inst{7-6} = 0b00;
2663 let Inst{5-4} = 0b00;
2667 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC16,
2668 !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
2669 [(set rGPR:$Rd, (add rGPR:$Ra, (sra (opnode rGPR:$Rn,
2670 (sra rGPR:$Rm, (i32 16))), (i32 16))))]>,
2671 Requires<[IsThumb2, HasThumb2DSP, UseMulOps]> {
2672 let Inst{31-27} = 0b11111;
2673 let Inst{26-23} = 0b0110;
2674 let Inst{22-20} = 0b011;
2675 let Inst{7-6} = 0b00;
2676 let Inst{5-4} = 0b01;
2680 defm t2SMUL : T2I_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2681 defm t2SMLA : T2I_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2683 // Halfword multiple accumulate long: SMLAL<x><y>
2684 def t2SMLALBB : T2FourReg_mac<1, 0b100, 0b1000, (outs rGPR:$Ra,rGPR:$Rd),
2685 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbb", "\t$Ra, $Rd, $Rn, $Rm",
2686 [/* For disassembly only; pattern left blank */]>,
2687 Requires<[IsThumb2, HasThumb2DSP]>;
2688 def t2SMLALBT : T2FourReg_mac<1, 0b100, 0b1001, (outs rGPR:$Ra,rGPR:$Rd),
2689 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlalbt", "\t$Ra, $Rd, $Rn, $Rm",
2690 [/* For disassembly only; pattern left blank */]>,
2691 Requires<[IsThumb2, HasThumb2DSP]>;
2692 def t2SMLALTB : T2FourReg_mac<1, 0b100, 0b1010, (outs rGPR:$Ra,rGPR:$Rd),
2693 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltb", "\t$Ra, $Rd, $Rn, $Rm",
2694 [/* For disassembly only; pattern left blank */]>,
2695 Requires<[IsThumb2, HasThumb2DSP]>;
2696 def t2SMLALTT : T2FourReg_mac<1, 0b100, 0b1011, (outs rGPR:$Ra,rGPR:$Rd),
2697 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaltt", "\t$Ra, $Rd, $Rn, $Rm",
2698 [/* For disassembly only; pattern left blank */]>,
2699 Requires<[IsThumb2, HasThumb2DSP]>;
2701 // Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
2702 def t2SMUAD: T2ThreeReg_mac<
2703 0, 0b010, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2704 IIC_iMAC32, "smuad", "\t$Rd, $Rn, $Rm", []>,
2705 Requires<[IsThumb2, HasThumb2DSP]> {
2706 let Inst{15-12} = 0b1111;
2708 def t2SMUADX:T2ThreeReg_mac<
2709 0, 0b010, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2710 IIC_iMAC32, "smuadx", "\t$Rd, $Rn, $Rm", []>,
2711 Requires<[IsThumb2, HasThumb2DSP]> {
2712 let Inst{15-12} = 0b1111;
2714 def t2SMUSD: T2ThreeReg_mac<
2715 0, 0b100, 0b0000, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2716 IIC_iMAC32, "smusd", "\t$Rd, $Rn, $Rm", []>,
2717 Requires<[IsThumb2, HasThumb2DSP]> {
2718 let Inst{15-12} = 0b1111;
2720 def t2SMUSDX:T2ThreeReg_mac<
2721 0, 0b100, 0b0001, (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm),
2722 IIC_iMAC32, "smusdx", "\t$Rd, $Rn, $Rm", []>,
2723 Requires<[IsThumb2, HasThumb2DSP]> {
2724 let Inst{15-12} = 0b1111;
2726 def t2SMLAD : T2FourReg_mac<
2727 0, 0b010, 0b0000, (outs rGPR:$Rd),
2728 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlad",
2729 "\t$Rd, $Rn, $Rm, $Ra", []>,
2730 Requires<[IsThumb2, HasThumb2DSP]>;
2731 def t2SMLADX : T2FourReg_mac<
2732 0, 0b010, 0b0001, (outs rGPR:$Rd),
2733 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smladx",
2734 "\t$Rd, $Rn, $Rm, $Ra", []>,
2735 Requires<[IsThumb2, HasThumb2DSP]>;
2736 def t2SMLSD : T2FourReg_mac<0, 0b100, 0b0000, (outs rGPR:$Rd),
2737 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsd",
2738 "\t$Rd, $Rn, $Rm, $Ra", []>,
2739 Requires<[IsThumb2, HasThumb2DSP]>;
2740 def t2SMLSDX : T2FourReg_mac<0, 0b100, 0b0001, (outs rGPR:$Rd),
2741 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32, "smlsdx",
2742 "\t$Rd, $Rn, $Rm, $Ra", []>,
2743 Requires<[IsThumb2, HasThumb2DSP]>;
2744 def t2SMLALD : T2FourReg_mac<1, 0b100, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
2745 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMAC64, "smlald",
2746 "\t$Ra, $Rd, $Rn, $Rm", []>,
2747 Requires<[IsThumb2, HasThumb2DSP]>;
2748 def t2SMLALDX : T2FourReg_mac<1, 0b100, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2749 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlaldx",
2750 "\t$Ra, $Rd, $Rn, $Rm", []>,
2751 Requires<[IsThumb2, HasThumb2DSP]>;
2752 def t2SMLSLD : T2FourReg_mac<1, 0b101, 0b1100, (outs rGPR:$Ra,rGPR:$Rd),
2753 (ins rGPR:$Rn,rGPR:$Rm), IIC_iMAC64, "smlsld",
2754 "\t$Ra, $Rd, $Rn, $Rm", []>,
2755 Requires<[IsThumb2, HasThumb2DSP]>;
2756 def t2SMLSLDX : T2FourReg_mac<1, 0b101, 0b1101, (outs rGPR:$Ra,rGPR:$Rd),
2757 (ins rGPR:$Rm,rGPR:$Rn), IIC_iMAC64, "smlsldx",
2758 "\t$Ra, $Rd, $Rn, $Rm", []>,
2759 Requires<[IsThumb2, HasThumb2DSP]>;
2761 //===----------------------------------------------------------------------===//
2762 // Division Instructions.
2763 // Signed and unsigned division on v7-M
2765 def t2SDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV,
2766 "sdiv", "\t$Rd, $Rn, $Rm",
2767 [(set rGPR:$Rd, (sdiv rGPR:$Rn, rGPR:$Rm))]>,
2768 Requires<[HasDivide, IsThumb2]> {
2769 let Inst{31-27} = 0b11111;
2770 let Inst{26-21} = 0b011100;
2772 let Inst{15-12} = 0b1111;
2773 let Inst{7-4} = 0b1111;
2776 def t2UDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV,
2777 "udiv", "\t$Rd, $Rn, $Rm",
2778 [(set rGPR:$Rd, (udiv rGPR:$Rn, rGPR:$Rm))]>,
2779 Requires<[HasDivide, IsThumb2]> {
2780 let Inst{31-27} = 0b11111;
2781 let Inst{26-21} = 0b011101;
2783 let Inst{15-12} = 0b1111;
2784 let Inst{7-4} = 0b1111;
2787 //===----------------------------------------------------------------------===//
2788 // Misc. Arithmetic Instructions.
2791 class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
2792 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2793 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2794 let Inst{31-27} = 0b11111;
2795 let Inst{26-22} = 0b01010;
2796 let Inst{21-20} = op1;
2797 let Inst{15-12} = 0b1111;
2798 let Inst{7-6} = 0b10;
2799 let Inst{5-4} = op2;
2803 def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2804 "clz", "\t$Rd, $Rm", [(set rGPR:$Rd, (ctlz rGPR:$Rm))]>;
2806 def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2807 "rbit", "\t$Rd, $Rm",
2808 [(set rGPR:$Rd, (ARMrbit rGPR:$Rm))]>;
2810 def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2811 "rev", ".w\t$Rd, $Rm", [(set rGPR:$Rd, (bswap rGPR:$Rm))]>;
2813 def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2814 "rev16", ".w\t$Rd, $Rm",
2815 [(set rGPR:$Rd, (rotr (bswap rGPR:$Rm), (i32 16)))]>;
2817 def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
2818 "revsh", ".w\t$Rd, $Rm",
2819 [(set rGPR:$Rd, (sra (bswap rGPR:$Rm), (i32 16)))]>;
2821 def : T2Pat<(or (sra (shl rGPR:$Rm, (i32 24)), (i32 16)),
2822 (and (srl rGPR:$Rm, (i32 8)), 0xFF)),
2823 (t2REVSH rGPR:$Rm)>;
2825 def t2PKHBT : T2ThreeReg<
2826 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_lsl_amt:$sh),
2827 IIC_iBITsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
2828 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF),
2829 (and (shl rGPR:$Rm, pkh_lsl_amt:$sh),
2831 Requires<[HasT2ExtractPack, IsThumb2]> {
2832 let Inst{31-27} = 0b11101;
2833 let Inst{26-25} = 0b01;
2834 let Inst{24-20} = 0b01100;
2835 let Inst{5} = 0; // BT form
2839 let Inst{14-12} = sh{4-2};
2840 let Inst{7-6} = sh{1-0};
2843 // Alternate cases for PKHBT where identities eliminate some nodes.
2844 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
2845 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
2846 Requires<[HasT2ExtractPack, IsThumb2]>;
2847 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
2848 (t2PKHBT rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
2849 Requires<[HasT2ExtractPack, IsThumb2]>;
2851 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2852 // will match the pattern below.
2853 def t2PKHTB : T2ThreeReg<
2854 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_asr_amt:$sh),
2855 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
2856 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF0000),
2857 (and (sra rGPR:$Rm, pkh_asr_amt:$sh),
2859 Requires<[HasT2ExtractPack, IsThumb2]> {
2860 let Inst{31-27} = 0b11101;
2861 let Inst{26-25} = 0b01;
2862 let Inst{24-20} = 0b01100;
2863 let Inst{5} = 1; // TB form
2867 let Inst{14-12} = sh{4-2};
2868 let Inst{7-6} = sh{1-0};
2871 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
2872 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
2873 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16_31:$sh)),
2874 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
2875 Requires<[HasT2ExtractPack, IsThumb2]>;
2876 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
2877 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
2878 (t2PKHTB rGPR:$src1, rGPR:$src2, imm1_15:$sh)>,
2879 Requires<[HasT2ExtractPack, IsThumb2]>;
2881 //===----------------------------------------------------------------------===//
2882 // Comparison Instructions...
2884 defm t2CMP : T2I_cmp_irs<0b1101, "cmp",
2885 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi,
2886 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2888 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_imm:$imm),
2889 (t2CMPri GPRnopc:$lhs, t2_so_imm:$imm)>;
2890 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, rGPR:$rhs),
2891 (t2CMPrr GPRnopc:$lhs, rGPR:$rhs)>;
2892 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_reg:$rhs),
2893 (t2CMPrs GPRnopc:$lhs, t2_so_reg:$rhs)>;
2895 let isCompare = 1, Defs = [CPSR] in {
2897 def t2CMNri : T2OneRegCmpImm<
2898 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iCMPi,
2899 "cmn", ".w\t$Rn, $imm",
2900 [(ARMcmn GPRnopc:$Rn, (ineg t2_so_imm:$imm))]> {
2901 let Inst{31-27} = 0b11110;
2903 let Inst{24-21} = 0b1000;
2904 let Inst{20} = 1; // The S bit.
2906 let Inst{11-8} = 0b1111; // Rd
2909 def t2CMNzrr : T2TwoRegCmp<
2910 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iCMPr,
2911 "cmn", ".w\t$Rn, $Rm",
2912 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
2913 GPRnopc:$Rn, rGPR:$Rm)]> {
2914 let Inst{31-27} = 0b11101;
2915 let Inst{26-25} = 0b01;
2916 let Inst{24-21} = 0b1000;
2917 let Inst{20} = 1; // The S bit.
2918 let Inst{14-12} = 0b000; // imm3
2919 let Inst{11-8} = 0b1111; // Rd
2920 let Inst{7-6} = 0b00; // imm2
2921 let Inst{5-4} = 0b00; // type
2924 def t2CMNzrs : T2OneRegCmpShiftedReg<
2925 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), IIC_iCMPsi,
2926 "cmn", ".w\t$Rn, $ShiftedRm",
2927 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
2928 GPRnopc:$Rn, t2_so_reg:$ShiftedRm)]> {
2929 let Inst{31-27} = 0b11101;
2930 let Inst{26-25} = 0b01;
2931 let Inst{24-21} = 0b1000;
2932 let Inst{20} = 1; // The S bit.
2933 let Inst{11-8} = 0b1111; // Rd
2937 // Assembler aliases w/o the ".w" suffix.
2938 // No alias here for 'rr' version as not all instantiations of this multiclass
2939 // want one (CMP in particular, does not).
2940 def : t2InstAlias<"cmn${p} $Rn, $imm",
2941 (t2CMNri GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
2942 def : t2InstAlias<"cmn${p} $Rn, $shift",
2943 (t2CMNzrs GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
2945 def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
2946 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
2948 def : T2Pat<(ARMcmpZ GPRnopc:$src, t2_so_imm_neg:$imm),
2949 (t2CMNri GPRnopc:$src, t2_so_imm_neg:$imm)>;
2951 defm t2TST : T2I_cmp_irs<0b0000, "tst",
2952 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2953 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>;
2954 defm t2TEQ : T2I_cmp_irs<0b0100, "teq",
2955 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
2956 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>;
2958 // Conditional moves
2959 // FIXME: should be able to write a pattern for ARMcmov, but can't use
2960 // a two-value operand where a dag node expects two operands. :(
2961 let neverHasSideEffects = 1 in {
2963 let isCommutable = 1, isSelect = 1 in
2964 def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd),
2965 (ins rGPR:$false, rGPR:$Rm, pred:$p),
2967 [/*(set rGPR:$Rd, (ARMcmov rGPR:$false, rGPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
2968 RegConstraint<"$false = $Rd">;
2970 let isMoveImm = 1 in
2971 def t2MOVCCi : t2PseudoInst<(outs rGPR:$Rd),
2972 (ins rGPR:$false, t2_so_imm:$imm, pred:$p),
2974 [/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
2975 RegConstraint<"$false = $Rd">;
2977 // FIXME: Pseudo-ize these. For now, just mark codegen only.
2978 let isCodeGenOnly = 1 in {
2979 let isMoveImm = 1 in
2980 def t2MOVCCi16 : T2I<(outs rGPR:$Rd), (ins rGPR:$false, imm0_65535_expr:$imm),
2982 "movw", "\t$Rd, $imm", []>,
2983 RegConstraint<"$false = $Rd"> {
2984 let Inst{31-27} = 0b11110;
2986 let Inst{24-21} = 0b0010;
2987 let Inst{20} = 0; // The S bit.
2993 let Inst{11-8} = Rd;
2994 let Inst{19-16} = imm{15-12};
2995 let Inst{26} = imm{11};
2996 let Inst{14-12} = imm{10-8};
2997 let Inst{7-0} = imm{7-0};
3000 let isMoveImm = 1 in
3001 def t2MOVCCi32imm : PseudoInst<(outs rGPR:$dst),
3002 (ins rGPR:$false, i32imm:$src, pred:$p),
3003 IIC_iCMOVix2, []>, RegConstraint<"$false = $dst">;
3005 let isMoveImm = 1 in
3006 def t2MVNCCi : T2OneRegImm<(outs rGPR:$Rd), (ins rGPR:$false, t2_so_imm:$imm),
3007 IIC_iCMOVi, "mvn", "\t$Rd, $imm",
3008 [/*(set rGPR:$Rd,(ARMcmov rGPR:$false,t2_so_imm_not:$imm,
3009 imm:$cc, CCR:$ccr))*/]>,
3010 RegConstraint<"$false = $Rd"> {
3011 let Inst{31-27} = 0b11110;
3013 let Inst{24-21} = 0b0011;
3014 let Inst{20} = 0; // The S bit.
3015 let Inst{19-16} = 0b1111; // Rn
3019 class T2I_movcc_sh<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
3020 string opc, string asm, list<dag> pattern>
3021 : T2TwoRegShiftImm<oops, iops, itin, opc, asm, pattern> {
3022 let Inst{31-27} = 0b11101;
3023 let Inst{26-25} = 0b01;
3024 let Inst{24-21} = 0b0010;
3025 let Inst{20} = 0; // The S bit.
3026 let Inst{19-16} = 0b1111; // Rn
3027 let Inst{5-4} = opcod; // Shift type.
3029 def t2MOVCClsl : T2I_movcc_sh<0b00, (outs rGPR:$Rd),
3030 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3031 IIC_iCMOVsi, "lsl", ".w\t$Rd, $Rm, $imm", []>,
3032 RegConstraint<"$false = $Rd">;
3033 def t2MOVCClsr : T2I_movcc_sh<0b01, (outs rGPR:$Rd),
3034 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3035 IIC_iCMOVsi, "lsr", ".w\t$Rd, $Rm, $imm", []>,
3036 RegConstraint<"$false = $Rd">;
3037 def t2MOVCCasr : T2I_movcc_sh<0b10, (outs rGPR:$Rd),
3038 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3039 IIC_iCMOVsi, "asr", ".w\t$Rd, $Rm, $imm", []>,
3040 RegConstraint<"$false = $Rd">;
3041 def t2MOVCCror : T2I_movcc_sh<0b11, (outs rGPR:$Rd),
3042 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm),
3043 IIC_iCMOVsi, "ror", ".w\t$Rd, $Rm, $imm", []>,
3044 RegConstraint<"$false = $Rd">;
3045 } // isCodeGenOnly = 1
3047 } // neverHasSideEffects
3049 //===----------------------------------------------------------------------===//
3050 // Atomic operations intrinsics
3053 // memory barriers protect the atomic sequences
3054 let hasSideEffects = 1 in {
3055 def t2DMB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3056 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
3057 Requires<[IsThumb, HasDB]> {
3059 let Inst{31-4} = 0xf3bf8f5;
3060 let Inst{3-0} = opt;
3064 def t2DSB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3065 "dsb", "\t$opt", []>,
3066 Requires<[IsThumb, HasDB]> {
3068 let Inst{31-4} = 0xf3bf8f4;
3069 let Inst{3-0} = opt;
3072 def t2ISB : AInoP<(outs), (ins memb_opt:$opt), ThumbFrm, NoItinerary,
3074 []>, Requires<[IsThumb, HasDB]> {
3076 let Inst{31-4} = 0xf3bf8f6;
3077 let Inst{3-0} = opt;
3080 class T2I_ldrex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
3081 InstrItinClass itin, string opc, string asm, string cstr,
3082 list<dag> pattern, bits<4> rt2 = 0b1111>
3083 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3084 let Inst{31-27} = 0b11101;
3085 let Inst{26-20} = 0b0001101;
3086 let Inst{11-8} = rt2;
3087 let Inst{7-6} = 0b01;
3088 let Inst{5-4} = opcod;
3089 let Inst{3-0} = 0b1111;
3093 let Inst{19-16} = addr;
3094 let Inst{15-12} = Rt;
3096 class T2I_strex<bits<2> opcod, dag oops, dag iops, AddrMode am, int sz,
3097 InstrItinClass itin, string opc, string asm, string cstr,
3098 list<dag> pattern, bits<4> rt2 = 0b1111>
3099 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3100 let Inst{31-27} = 0b11101;
3101 let Inst{26-20} = 0b0001100;
3102 let Inst{11-8} = rt2;
3103 let Inst{7-6} = 0b01;
3104 let Inst{5-4} = opcod;
3110 let Inst{19-16} = addr;
3111 let Inst{15-12} = Rt;
3114 let mayLoad = 1 in {
3115 def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3116 AddrModeNone, 4, NoItinerary,
3117 "ldrexb", "\t$Rt, $addr", "", []>;
3118 def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3119 AddrModeNone, 4, NoItinerary,
3120 "ldrexh", "\t$Rt, $addr", "", []>;
3121 def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_imm0_1020s4:$addr),
3122 AddrModeNone, 4, NoItinerary,
3123 "ldrex", "\t$Rt, $addr", "", []> {
3126 let Inst{31-27} = 0b11101;
3127 let Inst{26-20} = 0b0000101;
3128 let Inst{19-16} = addr{11-8};
3129 let Inst{15-12} = Rt;
3130 let Inst{11-8} = 0b1111;
3131 let Inst{7-0} = addr{7-0};
3133 let hasExtraDefRegAllocReq = 1 in
3134 def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$Rt, rGPR:$Rt2),
3135 (ins addr_offset_none:$addr),
3136 AddrModeNone, 4, NoItinerary,
3137 "ldrexd", "\t$Rt, $Rt2, $addr", "",
3140 let Inst{11-8} = Rt2;
3144 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
3145 def t2STREXB : T2I_strex<0b00, (outs rGPR:$Rd),
3146 (ins rGPR:$Rt, addr_offset_none:$addr),
3147 AddrModeNone, 4, NoItinerary,
3148 "strexb", "\t$Rd, $Rt, $addr", "", []>;
3149 def t2STREXH : T2I_strex<0b01, (outs rGPR:$Rd),
3150 (ins rGPR:$Rt, addr_offset_none:$addr),
3151 AddrModeNone, 4, NoItinerary,
3152 "strexh", "\t$Rd, $Rt, $addr", "", []>;
3153 def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt,
3154 t2addrmode_imm0_1020s4:$addr),
3155 AddrModeNone, 4, NoItinerary,
3156 "strex", "\t$Rd, $Rt, $addr", "",
3161 let Inst{31-27} = 0b11101;
3162 let Inst{26-20} = 0b0000100;
3163 let Inst{19-16} = addr{11-8};
3164 let Inst{15-12} = Rt;
3165 let Inst{11-8} = Rd;
3166 let Inst{7-0} = addr{7-0};
3168 let hasExtraSrcRegAllocReq = 1 in
3169 def t2STREXD : T2I_strex<0b11, (outs rGPR:$Rd),
3170 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr),
3171 AddrModeNone, 4, NoItinerary,
3172 "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [],
3175 let Inst{11-8} = Rt2;
3179 def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "", []>,
3180 Requires<[IsThumb2, HasV7]> {
3181 let Inst{31-16} = 0xf3bf;
3182 let Inst{15-14} = 0b10;
3185 let Inst{11-8} = 0b1111;
3186 let Inst{7-4} = 0b0010;
3187 let Inst{3-0} = 0b1111;
3190 //===----------------------------------------------------------------------===//
3191 // SJLJ Exception handling intrinsics
3192 // eh_sjlj_setjmp() is an instruction sequence to store the return
3193 // address and save #0 in R0 for the non-longjmp case.
3194 // Since by its nature we may be coming from some other function to get
3195 // here, and we're using the stack frame for the containing function to
3196 // save/restore registers, we can't keep anything live in regs across
3197 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
3198 // when we get here from a longjmp(). We force everything out of registers
3199 // except for our own input by listing the relevant registers in Defs. By
3200 // doing so, we also cause the prologue/epilogue code to actively preserve
3201 // all of the callee-saved resgisters, which is exactly what we want.
3202 // $val is a scratch register for our use.
3204 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
3205 Q0, Q1, Q2, Q3, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15],
3206 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1,
3207 usesCustomInserter = 1 in {
3208 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
3209 AddrModeNone, 0, NoItinerary, "", "",
3210 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
3211 Requires<[IsThumb2, HasVFP2]>;
3215 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
3216 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1,
3217 usesCustomInserter = 1 in {
3218 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
3219 AddrModeNone, 0, NoItinerary, "", "",
3220 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
3221 Requires<[IsThumb2, NoVFP]>;
3225 //===----------------------------------------------------------------------===//
3226 // Control-Flow Instructions
3229 // FIXME: remove when we have a way to marking a MI with these properties.
3230 // FIXME: Should pc be an implicit operand like PICADD, etc?
3231 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3232 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3233 def t2LDMIA_RET: t2PseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3234 reglist:$regs, variable_ops),
3235 4, IIC_iLoad_mBr, [],
3236 (t2LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3237 RegConstraint<"$Rn = $wb">;
3239 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
3240 let isPredicable = 1 in
3241 def t2B : T2I<(outs), (ins uncondbrtarget:$target), IIC_Br,
3243 [(br bb:$target)]> {
3244 let Inst{31-27} = 0b11110;
3245 let Inst{15-14} = 0b10;
3249 let Inst{26} = target{19};
3250 let Inst{11} = target{18};
3251 let Inst{13} = target{17};
3252 let Inst{25-16} = target{20-11};
3253 let Inst{10-0} = target{10-0};
3254 let DecoderMethod = "DecodeT2BInstruction";
3257 let isNotDuplicable = 1, isIndirectBranch = 1 in {
3258 def t2BR_JT : t2PseudoInst<(outs),
3259 (ins GPR:$target, GPR:$index, i32imm:$jt, i32imm:$id),
3261 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt, imm:$id)]>;
3263 // FIXME: Add a non-pc based case that can be predicated.
3264 def t2TBB_JT : t2PseudoInst<(outs),
3265 (ins GPR:$index, i32imm:$jt, i32imm:$id), 0, IIC_Br, []>;
3267 def t2TBH_JT : t2PseudoInst<(outs),
3268 (ins GPR:$index, i32imm:$jt, i32imm:$id), 0, IIC_Br, []>;
3270 def t2TBB : T2I<(outs), (ins addrmode_tbb:$addr), IIC_Br,
3271 "tbb", "\t$addr", []> {
3274 let Inst{31-20} = 0b111010001101;
3275 let Inst{19-16} = Rn;
3276 let Inst{15-5} = 0b11110000000;
3277 let Inst{4} = 0; // B form
3280 let DecoderMethod = "DecodeThumbTableBranch";
3283 def t2TBH : T2I<(outs), (ins addrmode_tbh:$addr), IIC_Br,
3284 "tbh", "\t$addr", []> {
3287 let Inst{31-20} = 0b111010001101;
3288 let Inst{19-16} = Rn;
3289 let Inst{15-5} = 0b11110000000;
3290 let Inst{4} = 1; // H form
3293 let DecoderMethod = "DecodeThumbTableBranch";
3295 } // isNotDuplicable, isIndirectBranch
3297 } // isBranch, isTerminator, isBarrier
3299 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
3300 // a two-value operand where a dag node expects ", "two operands. :(
3301 let isBranch = 1, isTerminator = 1 in
3302 def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
3304 [/*(ARMbrcond bb:$target, imm:$cc)*/]> {
3305 let Inst{31-27} = 0b11110;
3306 let Inst{15-14} = 0b10;
3310 let Inst{25-22} = p;
3313 let Inst{26} = target{20};
3314 let Inst{11} = target{19};
3315 let Inst{13} = target{18};
3316 let Inst{21-16} = target{17-12};
3317 let Inst{10-0} = target{11-1};
3319 let DecoderMethod = "DecodeThumb2BCCInstruction";
3322 // Tail calls. The IOS version of thumb tail calls uses a t2 branch, so
3324 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
3327 def tTAILJMPd: tPseudoExpand<(outs),
3328 (ins uncondbrtarget:$dst, pred:$p),
3330 (t2B uncondbrtarget:$dst, pred:$p)>,
3331 Requires<[IsThumb2, IsIOS]>;
3335 let Defs = [ITSTATE] in
3336 def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
3337 AddrModeNone, 2, IIC_iALUx,
3338 "it$mask\t$cc", "", []> {
3339 // 16-bit instruction.
3340 let Inst{31-16} = 0x0000;
3341 let Inst{15-8} = 0b10111111;
3346 let Inst{3-0} = mask;
3348 let DecoderMethod = "DecodeIT";
3351 // Branch and Exchange Jazelle -- for disassembly only
3353 def t2BXJ : T2I<(outs), (ins rGPR:$func), NoItinerary, "bxj", "\t$func", []> {
3355 let Inst{31-27} = 0b11110;
3357 let Inst{25-20} = 0b111100;
3358 let Inst{19-16} = func;
3359 let Inst{15-0} = 0b1000111100000000;
3362 // Compare and branch on zero / non-zero
3363 let isBranch = 1, isTerminator = 1 in {
3364 def tCBZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3365 "cbz\t$Rn, $target", []>,
3366 T1Misc<{0,0,?,1,?,?,?}>,
3367 Requires<[IsThumb2]> {
3371 let Inst{9} = target{5};
3372 let Inst{7-3} = target{4-0};
3376 def tCBNZ : T1I<(outs), (ins tGPR:$Rn, t_cbtarget:$target), IIC_Br,
3377 "cbnz\t$Rn, $target", []>,
3378 T1Misc<{1,0,?,1,?,?,?}>,
3379 Requires<[IsThumb2]> {
3383 let Inst{9} = target{5};
3384 let Inst{7-3} = target{4-0};
3390 // Change Processor State is a system instruction.
3391 // FIXME: Since the asm parser has currently no clean way to handle optional
3392 // operands, create 3 versions of the same instruction. Once there's a clean
3393 // framework to represent optional operands, change this behavior.
3394 class t2CPS<dag iops, string asm_op> : T2XI<(outs), iops, NoItinerary,
3395 !strconcat("cps", asm_op), []> {
3401 let Inst{31-27} = 0b11110;
3403 let Inst{25-20} = 0b111010;
3404 let Inst{19-16} = 0b1111;
3405 let Inst{15-14} = 0b10;
3407 let Inst{10-9} = imod;
3409 let Inst{7-5} = iflags;
3410 let Inst{4-0} = mode;
3411 let DecoderMethod = "DecodeT2CPSInstruction";
3415 def t2CPS3p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags, i32imm:$mode),
3416 "$imod.w\t$iflags, $mode">;
3417 let mode = 0, M = 0 in
3418 def t2CPS2p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags),
3419 "$imod.w\t$iflags">;
3420 let imod = 0, iflags = 0, M = 1 in
3421 def t2CPS1p : t2CPS<(ins imm0_31:$mode), "\t$mode">;
3423 // A6.3.4 Branches and miscellaneous control
3424 // Table A6-14 Change Processor State, and hint instructions
3425 def t2HINT : T2I<(outs), (ins imm0_255:$imm), NoItinerary, "hint", "\t$imm",[]>{
3427 let Inst{31-8} = 0b111100111010111110000000;
3428 let Inst{7-0} = imm;
3431 def : t2InstAlias<"hint$p.w $imm", (t2HINT imm0_255:$imm, pred:$p)>;
3432 def : t2InstAlias<"nop$p.w", (t2HINT 0, pred:$p)>;
3433 def : t2InstAlias<"yield$p.w", (t2HINT 1, pred:$p)>;
3434 def : t2InstAlias<"wfe$p.w", (t2HINT 2, pred:$p)>;
3435 def : t2InstAlias<"wfi$p.w", (t2HINT 3, pred:$p)>;
3436 def : t2InstAlias<"sev$p.w", (t2HINT 4, pred:$p)>;
3438 def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt", []> {
3440 let Inst{31-20} = 0b111100111010;
3441 let Inst{19-16} = 0b1111;
3442 let Inst{15-8} = 0b10000000;
3443 let Inst{7-4} = 0b1111;
3444 let Inst{3-0} = opt;
3447 // Secure Monitor Call is a system instruction.
3448 // Option = Inst{19-16}
3449 def t2SMC : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt", []> {
3450 let Inst{31-27} = 0b11110;
3451 let Inst{26-20} = 0b1111111;
3452 let Inst{15-12} = 0b1000;
3455 let Inst{19-16} = opt;
3458 class T2SRS<bits<2> Op, bit W, dag oops, dag iops, InstrItinClass itin,
3459 string opc, string asm, list<dag> pattern>
3460 : T2I<oops, iops, itin, opc, asm, pattern> {
3462 let Inst{31-25} = 0b1110100;
3463 let Inst{24-23} = Op;
3466 let Inst{20-16} = 0b01101;
3467 let Inst{15-5} = 0b11000000000;
3468 let Inst{4-0} = mode{4-0};
3471 // Store Return State is a system instruction.
3472 def t2SRSDB_UPD : T2SRS<0b00, 1, (outs), (ins imm0_31:$mode), NoItinerary,
3473 "srsdb", "\tsp!, $mode", []>;
3474 def t2SRSDB : T2SRS<0b00, 0, (outs), (ins imm0_31:$mode), NoItinerary,
3475 "srsdb","\tsp, $mode", []>;
3476 def t2SRSIA_UPD : T2SRS<0b11, 1, (outs), (ins imm0_31:$mode), NoItinerary,
3477 "srsia","\tsp!, $mode", []>;
3478 def t2SRSIA : T2SRS<0b11, 0, (outs), (ins imm0_31:$mode), NoItinerary,
3479 "srsia","\tsp, $mode", []>;
3481 // Return From Exception is a system instruction.
3482 class T2RFE<bits<12> op31_20, dag oops, dag iops, InstrItinClass itin,
3483 string opc, string asm, list<dag> pattern>
3484 : T2I<oops, iops, itin, opc, asm, pattern> {
3485 let Inst{31-20} = op31_20{11-0};
3488 let Inst{19-16} = Rn;
3489 let Inst{15-0} = 0xc000;
3492 def t2RFEDBW : T2RFE<0b111010000011,
3493 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn!",
3494 [/* For disassembly only; pattern left blank */]>;
3495 def t2RFEDB : T2RFE<0b111010000001,
3496 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn",
3497 [/* For disassembly only; pattern left blank */]>;
3498 def t2RFEIAW : T2RFE<0b111010011011,
3499 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn!",
3500 [/* For disassembly only; pattern left blank */]>;
3501 def t2RFEIA : T2RFE<0b111010011001,
3502 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn",
3503 [/* For disassembly only; pattern left blank */]>;
3505 //===----------------------------------------------------------------------===//
3506 // Non-Instruction Patterns
3509 // 32-bit immediate using movw + movt.
3510 // This is a single pseudo instruction to make it re-materializable.
3511 // FIXME: Remove this when we can do generalized remat.
3512 let isReMaterializable = 1, isMoveImm = 1 in
3513 def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
3514 [(set rGPR:$dst, (i32 imm:$src))]>,
3515 Requires<[IsThumb, HasV6T2]>;
3517 // Pseudo instruction that combines movw + movt + add pc (if pic).
3518 // It also makes it possible to rematerialize the instructions.
3519 // FIXME: Remove this when we can do generalized remat and when machine licm
3520 // can properly the instructions.
3521 let isReMaterializable = 1 in {
3522 def t2MOV_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3524 [(set rGPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
3525 Requires<[IsThumb2, UseMovt]>;
3527 def t2MOV_ga_dyn : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
3529 [(set rGPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
3530 Requires<[IsThumb2, UseMovt]>;
3533 // ConstantPool, GlobalAddress, and JumpTable
3534 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2LEApcrel tglobaladdr :$dst)>,
3535 Requires<[IsThumb2, DontUseMovt]>;
3536 def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
3537 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
3538 Requires<[IsThumb2, UseMovt]>;
3540 def : T2Pat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3541 (t2LEApcrelJT tjumptable:$dst, imm:$id)>;
3543 // Pseudo instruction that combines ldr from constpool and add pc. This should
3544 // be expanded into two instructions late to allow if-conversion and
3546 let canFoldAsLoad = 1, isReMaterializable = 1 in
3547 def t2LDRpci_pic : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr, pclabel:$cp),
3549 [(set rGPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
3551 Requires<[IsThumb2]>;
3553 // Pseudo isntruction that combines movs + predicated rsbmi
3554 // to implement integer ABS
3555 let usesCustomInserter = 1, Defs = [CPSR] in {
3556 def t2ABS : PseudoInst<(outs rGPR:$dst), (ins rGPR:$src),
3557 NoItinerary, []>, Requires<[IsThumb2]>;
3560 //===----------------------------------------------------------------------===//
3561 // Coprocessor load/store -- for disassembly only
3563 class T2CI<bits<4> op31_28, dag oops, dag iops, string opc, string asm>
3564 : T2I<oops, iops, NoItinerary, opc, asm, []> {
3565 let Inst{31-28} = op31_28;
3566 let Inst{27-25} = 0b110;
3569 multiclass t2LdStCop<bits<4> op31_28, bit load, bit Dbit, string asm> {
3570 def _OFFSET : T2CI<op31_28,
3571 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
3572 asm, "\t$cop, $CRd, $addr"> {
3576 let Inst{24} = 1; // P = 1
3577 let Inst{23} = addr{8};
3578 let Inst{22} = Dbit;
3579 let Inst{21} = 0; // W = 0
3580 let Inst{20} = load;
3581 let Inst{19-16} = addr{12-9};
3582 let Inst{15-12} = CRd;
3583 let Inst{11-8} = cop;
3584 let Inst{7-0} = addr{7-0};
3585 let DecoderMethod = "DecodeCopMemInstruction";
3587 def _PRE : T2CI<op31_28,
3588 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
3589 asm, "\t$cop, $CRd, $addr!"> {
3593 let Inst{24} = 1; // P = 1
3594 let Inst{23} = addr{8};
3595 let Inst{22} = Dbit;
3596 let Inst{21} = 1; // W = 1
3597 let Inst{20} = load;
3598 let Inst{19-16} = addr{12-9};
3599 let Inst{15-12} = CRd;
3600 let Inst{11-8} = cop;
3601 let Inst{7-0} = addr{7-0};
3602 let DecoderMethod = "DecodeCopMemInstruction";
3604 def _POST: T2CI<op31_28,
3605 (outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
3606 postidx_imm8s4:$offset),
3607 asm, "\t$cop, $CRd, $addr, $offset"> {
3612 let Inst{24} = 0; // P = 0
3613 let Inst{23} = offset{8};
3614 let Inst{22} = Dbit;
3615 let Inst{21} = 1; // W = 1
3616 let Inst{20} = load;
3617 let Inst{19-16} = addr;
3618 let Inst{15-12} = CRd;
3619 let Inst{11-8} = cop;
3620 let Inst{7-0} = offset{7-0};
3621 let DecoderMethod = "DecodeCopMemInstruction";
3623 def _OPTION : T2CI<op31_28, (outs),
3624 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
3625 coproc_option_imm:$option),
3626 asm, "\t$cop, $CRd, $addr, $option"> {
3631 let Inst{24} = 0; // P = 0
3632 let Inst{23} = 1; // U = 1
3633 let Inst{22} = Dbit;
3634 let Inst{21} = 0; // W = 0
3635 let Inst{20} = load;
3636 let Inst{19-16} = addr;
3637 let Inst{15-12} = CRd;
3638 let Inst{11-8} = cop;
3639 let Inst{7-0} = option;
3640 let DecoderMethod = "DecodeCopMemInstruction";
3644 defm t2LDC : t2LdStCop<0b1110, 1, 0, "ldc">;
3645 defm t2LDCL : t2LdStCop<0b1110, 1, 1, "ldcl">;
3646 defm t2STC : t2LdStCop<0b1110, 0, 0, "stc">;
3647 defm t2STCL : t2LdStCop<0b1110, 0, 1, "stcl">;
3648 defm t2LDC2 : t2LdStCop<0b1111, 1, 0, "ldc2">;
3649 defm t2LDC2L : t2LdStCop<0b1111, 1, 1, "ldc2l">;
3650 defm t2STC2 : t2LdStCop<0b1111, 0, 0, "stc2">;
3651 defm t2STC2L : t2LdStCop<0b1111, 0, 1, "stc2l">;
3654 //===----------------------------------------------------------------------===//
3655 // Move between special register and ARM core register -- for disassembly only
3657 // Move to ARM core register from Special Register
3661 // A/R class can only move from CPSR or SPSR.
3662 def t2MRS_AR : T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, apsr",
3663 []>, Requires<[IsThumb2,IsARClass]> {
3665 let Inst{31-12} = 0b11110011111011111000;
3666 let Inst{11-8} = Rd;
3667 let Inst{7-0} = 0b0000;
3670 def : t2InstAlias<"mrs${p} $Rd, cpsr", (t2MRS_AR GPR:$Rd, pred:$p)>;
3672 def t2MRSsys_AR: T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, spsr",
3673 []>, Requires<[IsThumb2,IsARClass]> {
3675 let Inst{31-12} = 0b11110011111111111000;
3676 let Inst{11-8} = Rd;
3677 let Inst{7-0} = 0b0000;
3682 // This MRS has a mask field in bits 7-0 and can take more values than
3683 // the A/R class (a full msr_mask).
3684 def t2MRS_M : T2I<(outs rGPR:$Rd), (ins msr_mask:$mask), NoItinerary,
3685 "mrs", "\t$Rd, $mask", []>,
3686 Requires<[IsThumb,IsMClass]> {
3689 let Inst{31-12} = 0b11110011111011111000;
3690 let Inst{11-8} = Rd;
3691 let Inst{19-16} = 0b1111;
3692 let Inst{7-0} = mask;
3696 // Move from ARM core register to Special Register
3700 // No need to have both system and application versions, the encodings are the
3701 // same and the assembly parser has no way to distinguish between them. The mask
3702 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
3703 // the mask with the fields to be accessed in the special register.
3704 def t2MSR_AR : T2I<(outs), (ins msr_mask:$mask, rGPR:$Rn),
3705 NoItinerary, "msr", "\t$mask, $Rn", []>,
3706 Requires<[IsThumb2,IsARClass]> {
3709 let Inst{31-21} = 0b11110011100;
3710 let Inst{20} = mask{4}; // R Bit
3711 let Inst{19-16} = Rn;
3712 let Inst{15-12} = 0b1000;
3713 let Inst{11-8} = mask{3-0};
3719 // Move from ARM core register to Special Register
3720 def t2MSR_M : T2I<(outs), (ins msr_mask:$SYSm, rGPR:$Rn),
3721 NoItinerary, "msr", "\t$SYSm, $Rn", []>,
3722 Requires<[IsThumb,IsMClass]> {
3725 let Inst{31-21} = 0b11110011100;
3727 let Inst{19-16} = Rn;
3728 let Inst{15-12} = 0b1000;
3729 let Inst{11-0} = SYSm;
3733 //===----------------------------------------------------------------------===//
3734 // Move between coprocessor and ARM core register
3737 class t2MovRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops,
3739 : T2Cop<Op, oops, iops,
3740 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"),
3742 let Inst{27-24} = 0b1110;
3743 let Inst{20} = direction;
3753 let Inst{15-12} = Rt;
3754 let Inst{11-8} = cop;
3755 let Inst{23-21} = opc1;
3756 let Inst{7-5} = opc2;
3757 let Inst{3-0} = CRm;
3758 let Inst{19-16} = CRn;
3761 class t2MovRRCopro<bits<4> Op, string opc, bit direction,
3762 list<dag> pattern = []>
3764 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
3765 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
3766 let Inst{27-24} = 0b1100;
3767 let Inst{23-21} = 0b010;
3768 let Inst{20} = direction;
3776 let Inst{15-12} = Rt;
3777 let Inst{19-16} = Rt2;
3778 let Inst{11-8} = cop;
3779 let Inst{7-4} = opc1;
3780 let Inst{3-0} = CRm;
3783 /* from ARM core register to coprocessor */
3784 def t2MCR : t2MovRCopro<0b1110, "mcr", 0,
3786 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3787 c_imm:$CRm, imm0_7:$opc2),
3788 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3789 imm:$CRm, imm:$opc2)]>;
3790 def : t2InstAlias<"mcr $cop, $opc1, $Rt, $CRn, $CRm",
3791 (t2MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3793 def t2MCR2 : t2MovRCopro<0b1111, "mcr2", 0,
3794 (outs), (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3795 c_imm:$CRm, imm0_7:$opc2),
3796 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
3797 imm:$CRm, imm:$opc2)]>;
3798 def : t2InstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
3799 (t2MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
3802 /* from coprocessor to ARM core register */
3803 def t2MRC : t2MovRCopro<0b1110, "mrc", 1,
3804 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3805 c_imm:$CRm, imm0_7:$opc2), []>;
3806 def : t2InstAlias<"mrc $cop, $opc1, $Rt, $CRn, $CRm",
3807 (t2MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3810 def t2MRC2 : t2MovRCopro<0b1111, "mrc2", 1,
3811 (outs GPR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3812 c_imm:$CRm, imm0_7:$opc2), []>;
3813 def : t2InstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
3814 (t2MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
3817 def : T2v6Pat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3818 (t2MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3820 def : T2v6Pat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
3821 (t2MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
3824 /* from ARM core register to coprocessor */
3825 def t2MCRR : t2MovRRCopro<0b1110, "mcrr", 0,
3826 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
3828 def t2MCRR2 : t2MovRRCopro<0b1111, "mcrr2", 0,
3829 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt,
3830 GPR:$Rt2, imm:$CRm)]>;
3831 /* from coprocessor to ARM core register */
3832 def t2MRRC : t2MovRRCopro<0b1110, "mrrc", 1>;
3834 def t2MRRC2 : t2MovRRCopro<0b1111, "mrrc2", 1>;
3836 //===----------------------------------------------------------------------===//
3837 // Other Coprocessor Instructions.
3840 def tCDP : T2Cop<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
3841 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
3842 "cdp\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3843 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3844 imm:$CRm, imm:$opc2)]> {
3845 let Inst{27-24} = 0b1110;
3854 let Inst{3-0} = CRm;
3856 let Inst{7-5} = opc2;
3857 let Inst{11-8} = cop;
3858 let Inst{15-12} = CRd;
3859 let Inst{19-16} = CRn;
3860 let Inst{23-20} = opc1;
3863 def t2CDP2 : T2Cop<0b1111, (outs), (ins p_imm:$cop, imm0_15:$opc1,
3864 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
3865 "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
3866 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
3867 imm:$CRm, imm:$opc2)]> {
3868 let Inst{27-24} = 0b1110;
3877 let Inst{3-0} = CRm;
3879 let Inst{7-5} = opc2;
3880 let Inst{11-8} = cop;
3881 let Inst{15-12} = CRd;
3882 let Inst{19-16} = CRn;
3883 let Inst{23-20} = opc1;
3888 //===----------------------------------------------------------------------===//
3889 // Non-Instruction Patterns
3892 // SXT/UXT with no rotate
3893 let AddedComplexity = 16 in {
3894 def : T2Pat<(and rGPR:$Rm, 0x000000FF), (t2UXTB rGPR:$Rm, 0)>,
3895 Requires<[IsThumb2]>;
3896 def : T2Pat<(and rGPR:$Rm, 0x0000FFFF), (t2UXTH rGPR:$Rm, 0)>,
3897 Requires<[IsThumb2]>;
3898 def : T2Pat<(and rGPR:$Rm, 0x00FF00FF), (t2UXTB16 rGPR:$Rm, 0)>,
3899 Requires<[HasT2ExtractPack, IsThumb2]>;
3900 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0x00FF)),
3901 (t2UXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3902 Requires<[HasT2ExtractPack, IsThumb2]>;
3903 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0xFFFF)),
3904 (t2UXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3905 Requires<[HasT2ExtractPack, IsThumb2]>;
3908 def : T2Pat<(sext_inreg rGPR:$Src, i8), (t2SXTB rGPR:$Src, 0)>,
3909 Requires<[IsThumb2]>;
3910 def : T2Pat<(sext_inreg rGPR:$Src, i16), (t2SXTH rGPR:$Src, 0)>,
3911 Requires<[IsThumb2]>;
3912 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i8)),
3913 (t2SXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
3914 Requires<[HasT2ExtractPack, IsThumb2]>;
3915 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i16)),
3916 (t2SXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
3917 Requires<[HasT2ExtractPack, IsThumb2]>;
3919 // Atomic load/store patterns
3920 def : T2Pat<(atomic_load_8 t2addrmode_imm12:$addr),
3921 (t2LDRBi12 t2addrmode_imm12:$addr)>;
3922 def : T2Pat<(atomic_load_8 t2addrmode_negimm8:$addr),
3923 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
3924 def : T2Pat<(atomic_load_8 t2addrmode_so_reg:$addr),
3925 (t2LDRBs t2addrmode_so_reg:$addr)>;
3926 def : T2Pat<(atomic_load_16 t2addrmode_imm12:$addr),
3927 (t2LDRHi12 t2addrmode_imm12:$addr)>;
3928 def : T2Pat<(atomic_load_16 t2addrmode_negimm8:$addr),
3929 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
3930 def : T2Pat<(atomic_load_16 t2addrmode_so_reg:$addr),
3931 (t2LDRHs t2addrmode_so_reg:$addr)>;
3932 def : T2Pat<(atomic_load_32 t2addrmode_imm12:$addr),
3933 (t2LDRi12 t2addrmode_imm12:$addr)>;
3934 def : T2Pat<(atomic_load_32 t2addrmode_negimm8:$addr),
3935 (t2LDRi8 t2addrmode_negimm8:$addr)>;
3936 def : T2Pat<(atomic_load_32 t2addrmode_so_reg:$addr),
3937 (t2LDRs t2addrmode_so_reg:$addr)>;
3938 def : T2Pat<(atomic_store_8 t2addrmode_imm12:$addr, GPR:$val),
3939 (t2STRBi12 GPR:$val, t2addrmode_imm12:$addr)>;
3940 def : T2Pat<(atomic_store_8 t2addrmode_negimm8:$addr, GPR:$val),
3941 (t2STRBi8 GPR:$val, t2addrmode_negimm8:$addr)>;
3942 def : T2Pat<(atomic_store_8 t2addrmode_so_reg:$addr, GPR:$val),
3943 (t2STRBs GPR:$val, t2addrmode_so_reg:$addr)>;
3944 def : T2Pat<(atomic_store_16 t2addrmode_imm12:$addr, GPR:$val),
3945 (t2STRHi12 GPR:$val, t2addrmode_imm12:$addr)>;
3946 def : T2Pat<(atomic_store_16 t2addrmode_negimm8:$addr, GPR:$val),
3947 (t2STRHi8 GPR:$val, t2addrmode_negimm8:$addr)>;
3948 def : T2Pat<(atomic_store_16 t2addrmode_so_reg:$addr, GPR:$val),
3949 (t2STRHs GPR:$val, t2addrmode_so_reg:$addr)>;
3950 def : T2Pat<(atomic_store_32 t2addrmode_imm12:$addr, GPR:$val),
3951 (t2STRi12 GPR:$val, t2addrmode_imm12:$addr)>;
3952 def : T2Pat<(atomic_store_32 t2addrmode_negimm8:$addr, GPR:$val),
3953 (t2STRi8 GPR:$val, t2addrmode_negimm8:$addr)>;
3954 def : T2Pat<(atomic_store_32 t2addrmode_so_reg:$addr, GPR:$val),
3955 (t2STRs GPR:$val, t2addrmode_so_reg:$addr)>;
3958 //===----------------------------------------------------------------------===//
3959 // Assembler aliases
3962 // Aliases for ADC without the ".w" optional width specifier.
3963 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $Rm",
3964 (t2ADCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3965 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $ShiftedRm",
3966 (t2ADCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3967 pred:$p, cc_out:$s)>;
3969 // Aliases for SBC without the ".w" optional width specifier.
3970 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $Rm",
3971 (t2SBCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3972 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $ShiftedRm",
3973 (t2SBCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
3974 pred:$p, cc_out:$s)>;
3976 // Aliases for ADD without the ".w" optional width specifier.
3977 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
3978 (t2ADDri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
3979 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
3980 (t2ADDri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
3981 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm",
3982 (t2ADDrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3983 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm",
3984 (t2ADDrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
3985 pred:$p, cc_out:$s)>;
3986 // ... and with the destination and source register combined.
3987 def : t2InstAlias<"add${s}${p} $Rdn, $imm",
3988 (t2ADDri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
3989 def : t2InstAlias<"add${p} $Rdn, $imm",
3990 (t2ADDri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095:$imm, pred:$p)>;
3991 def : t2InstAlias<"add${s}${p} $Rdn, $Rm",
3992 (t2ADDrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
3993 def : t2InstAlias<"add${s}${p} $Rdn, $ShiftedRm",
3994 (t2ADDrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
3995 pred:$p, cc_out:$s)>;
3997 // add w/ negative immediates is just a sub.
3998 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
3999 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
4001 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
4002 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
4003 def : t2InstAlias<"add${s}${p} $Rdn, $imm",
4004 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm_neg:$imm, pred:$p,
4006 def : t2InstAlias<"add${p} $Rdn, $imm",
4007 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
4009 def : t2InstAlias<"add${s}${p}.w $Rd, $Rn, $imm",
4010 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
4012 def : t2InstAlias<"addw${p} $Rd, $Rn, $imm",
4013 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
4014 def : t2InstAlias<"add${s}${p}.w $Rdn, $imm",
4015 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm_neg:$imm, pred:$p,
4017 def : t2InstAlias<"addw${p} $Rdn, $imm",
4018 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
4021 // Aliases for SUB without the ".w" optional width specifier.
4022 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm",
4023 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4024 def : t2InstAlias<"sub${p} $Rd, $Rn, $imm",
4025 (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
4026 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $Rm",
4027 (t2SUBrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4028 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $ShiftedRm",
4029 (t2SUBrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
4030 pred:$p, cc_out:$s)>;
4031 // ... and with the destination and source register combined.
4032 def : t2InstAlias<"sub${s}${p} $Rdn, $imm",
4033 (t2SUBri GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4034 def : t2InstAlias<"sub${p} $Rdn, $imm",
4035 (t2SUBri12 GPRnopc:$Rdn, GPRnopc:$Rdn, imm0_4095:$imm, pred:$p)>;
4036 def : t2InstAlias<"sub${s}${p}.w $Rdn, $Rm",
4037 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4038 def : t2InstAlias<"sub${s}${p} $Rdn, $Rm",
4039 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4040 def : t2InstAlias<"sub${s}${p} $Rdn, $ShiftedRm",
4041 (t2SUBrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
4042 pred:$p, cc_out:$s)>;
4044 // Alias for compares without the ".w" optional width specifier.
4045 def : t2InstAlias<"cmn${p} $Rn, $Rm",
4046 (t2CMNzrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4047 def : t2InstAlias<"teq${p} $Rn, $Rm",
4048 (t2TEQrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4049 def : t2InstAlias<"tst${p} $Rn, $Rm",
4050 (t2TSTrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
4053 def : InstAlias<"dmb", (t2DMB 0xf)>, Requires<[IsThumb, HasDB]>;
4054 def : InstAlias<"dsb", (t2DSB 0xf)>, Requires<[IsThumb, HasDB]>;
4055 def : InstAlias<"isb", (t2ISB 0xf)>, Requires<[IsThumb, HasDB]>;
4057 // Alias for LDR, LDRB, LDRH, LDRSB, and LDRSH without the ".w" optional
4059 def : t2InstAlias<"ldr${p} $Rt, $addr",
4060 (t2LDRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4061 def : t2InstAlias<"ldrb${p} $Rt, $addr",
4062 (t2LDRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4063 def : t2InstAlias<"ldrh${p} $Rt, $addr",
4064 (t2LDRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4065 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4066 (t2LDRSBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4067 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4068 (t2LDRSHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4070 def : t2InstAlias<"ldr${p} $Rt, $addr",
4071 (t2LDRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4072 def : t2InstAlias<"ldrb${p} $Rt, $addr",
4073 (t2LDRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4074 def : t2InstAlias<"ldrh${p} $Rt, $addr",
4075 (t2LDRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4076 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4077 (t2LDRSBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4078 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4079 (t2LDRSHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4081 def : t2InstAlias<"ldr${p} $Rt, $addr",
4082 (t2LDRpci GPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4083 def : t2InstAlias<"ldrb${p} $Rt, $addr",
4084 (t2LDRBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4085 def : t2InstAlias<"ldrh${p} $Rt, $addr",
4086 (t2LDRHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4087 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
4088 (t2LDRSBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4089 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
4090 (t2LDRSHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
4092 // Alias for MVN with(out) the ".w" optional width specifier.
4093 def : t2InstAlias<"mvn${s}${p}.w $Rd, $imm",
4094 (t2MVNi rGPR:$Rd, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4095 def : t2InstAlias<"mvn${s}${p} $Rd, $Rm",
4096 (t2MVNr rGPR:$Rd, rGPR:$Rm, pred:$p, cc_out:$s)>;
4097 def : t2InstAlias<"mvn${s}${p} $Rd, $ShiftedRm",
4098 (t2MVNs rGPR:$Rd, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>;
4100 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4101 // shift amount is zero (i.e., unspecified).
4102 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4103 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>,
4104 Requires<[HasT2ExtractPack, IsThumb2]>;
4105 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4106 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>,
4107 Requires<[HasT2ExtractPack, IsThumb2]>;
4109 // PUSH/POP aliases for STM/LDM
4110 def : t2InstAlias<"push${p}.w $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
4111 def : t2InstAlias<"push${p} $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
4112 def : t2InstAlias<"pop${p}.w $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4113 def : t2InstAlias<"pop${p} $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4115 // STMIA/STMIA_UPD aliases w/o the optional .w suffix
4116 def : t2InstAlias<"stm${p} $Rn, $regs",
4117 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4118 def : t2InstAlias<"stm${p} $Rn!, $regs",
4119 (t2STMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4121 // LDMIA/LDMIA_UPD aliases w/o the optional .w suffix
4122 def : t2InstAlias<"ldm${p} $Rn, $regs",
4123 (t2LDMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4124 def : t2InstAlias<"ldm${p} $Rn!, $regs",
4125 (t2LDMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4127 // STMDB/STMDB_UPD aliases w/ the optional .w suffix
4128 def : t2InstAlias<"stmdb${p}.w $Rn, $regs",
4129 (t2STMDB GPR:$Rn, pred:$p, reglist:$regs)>;
4130 def : t2InstAlias<"stmdb${p}.w $Rn!, $regs",
4131 (t2STMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4133 // LDMDB/LDMDB_UPD aliases w/ the optional .w suffix
4134 def : t2InstAlias<"ldmdb${p}.w $Rn, $regs",
4135 (t2LDMDB GPR:$Rn, pred:$p, reglist:$regs)>;
4136 def : t2InstAlias<"ldmdb${p}.w $Rn!, $regs",
4137 (t2LDMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
4139 // Alias for REV/REV16/REVSH without the ".w" optional width specifier.
4140 def : t2InstAlias<"rev${p} $Rd, $Rm", (t2REV rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4141 def : t2InstAlias<"rev16${p} $Rd, $Rm", (t2REV16 rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4142 def : t2InstAlias<"revsh${p} $Rd, $Rm", (t2REVSH rGPR:$Rd, rGPR:$Rm, pred:$p)>;
4145 // Alias for RSB without the ".w" optional width specifier, and with optional
4146 // implied destination register.
4147 def : t2InstAlias<"rsb${s}${p} $Rd, $Rn, $imm",
4148 (t2RSBri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4149 def : t2InstAlias<"rsb${s}${p} $Rdn, $imm",
4150 (t2RSBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4151 def : t2InstAlias<"rsb${s}${p} $Rdn, $Rm",
4152 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4153 def : t2InstAlias<"rsb${s}${p} $Rdn, $ShiftedRm",
4154 (t2RSBrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p,
4157 // SSAT/USAT optional shift operand.
4158 def : t2InstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4159 (t2SSAT rGPR:$Rd, imm1_32:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
4160 def : t2InstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4161 (t2USAT rGPR:$Rd, imm0_31:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
4163 // STM w/o the .w suffix.
4164 def : t2InstAlias<"stm${p} $Rn, $regs",
4165 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
4167 // Alias for STR, STRB, and STRH without the ".w" optional
4169 def : t2InstAlias<"str${p} $Rt, $addr",
4170 (t2STRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4171 def : t2InstAlias<"strb${p} $Rt, $addr",
4172 (t2STRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4173 def : t2InstAlias<"strh${p} $Rt, $addr",
4174 (t2STRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
4176 def : t2InstAlias<"str${p} $Rt, $addr",
4177 (t2STRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4178 def : t2InstAlias<"strb${p} $Rt, $addr",
4179 (t2STRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4180 def : t2InstAlias<"strh${p} $Rt, $addr",
4181 (t2STRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
4183 // Extend instruction optional rotate operand.
4184 def : t2InstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4185 (t2SXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4186 def : t2InstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4187 (t2SXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4188 def : t2InstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4189 (t2SXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4191 def : t2InstAlias<"sxtb${p} $Rd, $Rm",
4192 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4193 def : t2InstAlias<"sxtb16${p} $Rd, $Rm",
4194 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4195 def : t2InstAlias<"sxth${p} $Rd, $Rm",
4196 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4197 def : t2InstAlias<"sxtb${p}.w $Rd, $Rm",
4198 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4199 def : t2InstAlias<"sxth${p}.w $Rd, $Rm",
4200 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4202 def : t2InstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4203 (t2UXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4204 def : t2InstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4205 (t2UXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4206 def : t2InstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4207 (t2UXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p)>;
4208 def : t2InstAlias<"uxtb${p} $Rd, $Rm",
4209 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4210 def : t2InstAlias<"uxtb16${p} $Rd, $Rm",
4211 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4212 def : t2InstAlias<"uxth${p} $Rd, $Rm",
4213 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4215 def : t2InstAlias<"uxtb${p}.w $Rd, $Rm",
4216 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4217 def : t2InstAlias<"uxth${p}.w $Rd, $Rm",
4218 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
4220 // Extend instruction w/o the ".w" optional width specifier.
4221 def : t2InstAlias<"uxtb${p} $Rd, $Rm$rot",
4222 (t2UXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4223 def : t2InstAlias<"uxtb16${p} $Rd, $Rm$rot",
4224 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4225 def : t2InstAlias<"uxth${p} $Rd, $Rm$rot",
4226 (t2UXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4228 def : t2InstAlias<"sxtb${p} $Rd, $Rm$rot",
4229 (t2SXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4230 def : t2InstAlias<"sxtb16${p} $Rd, $Rm$rot",
4231 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4232 def : t2InstAlias<"sxth${p} $Rd, $Rm$rot",
4233 (t2SXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
4236 // "mov Rd, t2_so_imm_not" can be handled via "mvn" in assembly, just like
4238 def : t2InstAlias<"mov${p} $Rd, $imm",
4239 (t2MVNi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
4240 def : t2InstAlias<"mvn${p} $Rd, $imm",
4241 (t2MOVi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
4242 // Same for AND <--> BIC
4243 def : t2InstAlias<"bic${s}${p} $Rd, $Rn, $imm",
4244 (t2ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
4245 pred:$p, cc_out:$s)>;
4246 def : t2InstAlias<"bic${s}${p} $Rdn, $imm",
4247 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
4248 pred:$p, cc_out:$s)>;
4249 def : t2InstAlias<"and${s}${p} $Rd, $Rn, $imm",
4250 (t2BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
4251 pred:$p, cc_out:$s)>;
4252 def : t2InstAlias<"and${s}${p} $Rdn, $imm",
4253 (t2BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
4254 pred:$p, cc_out:$s)>;
4255 // Likewise, "add Rd, t2_so_imm_neg" -> sub
4256 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4257 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm,
4258 pred:$p, cc_out:$s)>;
4259 def : t2InstAlias<"add${s}${p} $Rd, $imm",
4260 (t2SUBri GPRnopc:$Rd, GPRnopc:$Rd, t2_so_imm_neg:$imm,
4261 pred:$p, cc_out:$s)>;
4262 // Same for CMP <--> CMN via t2_so_imm_neg
4263 def : t2InstAlias<"cmp${p} $Rd, $imm",
4264 (t2CMNri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
4265 def : t2InstAlias<"cmn${p} $Rd, $imm",
4266 (t2CMPri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
4269 // Wide 'mul' encoding can be specified with only two operands.
4270 def : t2InstAlias<"mul${p} $Rn, $Rm",
4271 (t2MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p)>;
4273 // "neg" is and alias for "rsb rd, rn, #0"
4274 def : t2InstAlias<"neg${s}${p} $Rd, $Rm",
4275 (t2RSBri rGPR:$Rd, rGPR:$Rm, 0, pred:$p, cc_out:$s)>;
4277 // MOV so_reg assembler pseudos. InstAlias isn't expressive enough for
4278 // these, unfortunately.
4279 def t2MOVsi: t2AsmPseudo<"mov${p} $Rd, $shift",
4280 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
4281 def t2MOVSsi: t2AsmPseudo<"movs${p} $Rd, $shift",
4282 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
4284 def t2MOVsr: t2AsmPseudo<"mov${p} $Rd, $shift",
4285 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
4286 def t2MOVSsr: t2AsmPseudo<"movs${p} $Rd, $shift",
4287 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
4289 // ADR w/o the .w suffix
4290 def : t2InstAlias<"adr${p} $Rd, $addr",
4291 (t2ADR rGPR:$Rd, t2adrlabel:$addr, pred:$p)>;
4293 // LDR(literal) w/ alternate [pc, #imm] syntax.
4294 def t2LDRpcrel : t2AsmPseudo<"ldr${p} $Rt, $addr",
4295 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4296 def t2LDRBpcrel : t2AsmPseudo<"ldrb${p} $Rt, $addr",
4297 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4298 def t2LDRHpcrel : t2AsmPseudo<"ldrh${p} $Rt, $addr",
4299 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4300 def t2LDRSBpcrel : t2AsmPseudo<"ldrsb${p} $Rt, $addr",
4301 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4302 def t2LDRSHpcrel : t2AsmPseudo<"ldrsh${p} $Rt, $addr",
4303 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4304 // Version w/ the .w suffix.
4305 def : t2InstAlias<"ldr${p}.w $Rt, $addr",
4306 (t2LDRpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4307 def : t2InstAlias<"ldrb${p}.w $Rt, $addr",
4308 (t2LDRBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4309 def : t2InstAlias<"ldrh${p}.w $Rt, $addr",
4310 (t2LDRHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4311 def : t2InstAlias<"ldrsb${p}.w $Rt, $addr",
4312 (t2LDRSBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4313 def : t2InstAlias<"ldrsh${p}.w $Rt, $addr",
4314 (t2LDRSHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
4316 def : t2InstAlias<"add${p} $Rd, pc, $imm",
4317 (t2ADR rGPR:$Rd, imm0_4095:$imm, pred:$p)>;