1 //===-- ARMInstrThumb2.td - Thumb2 support for ARM ---------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the Thumb2 instruction set.
11 //===----------------------------------------------------------------------===//
13 // IT block predicate field
14 def it_pred_asmoperand : AsmOperandClass {
15 let Name = "ITCondCode";
16 let ParserMethod = "parseITCondCode";
18 def it_pred : Operand<i32> {
19 let PrintMethod = "printMandatoryPredicateOperand";
20 let ParserMatchClass = it_pred_asmoperand;
23 // IT block condition mask
24 def it_mask_asmoperand : AsmOperandClass { let Name = "ITMask"; }
25 def it_mask : Operand<i32> {
26 let PrintMethod = "printThumbITMask";
27 let ParserMatchClass = it_mask_asmoperand;
28 let EncoderMethod = "getITMaskOpValue";
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 def mve_shift_imm : AsmOperandClass {
44 let Name = "MVELongShift";
45 let RenderMethod = "addImmOperands";
46 let DiagnosticString = "operand must be an immediate in the range [1,32]";
48 def long_shift : Operand<i32>,
49 ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
50 let ParserMatchClass = mve_shift_imm;
51 let DecoderMethod = "DecodeLongShiftOperand";
54 // Shifted operands. No register controlled shifts for Thumb2.
55 // Note: We do not support rrx shifted operands yet.
56 def t2_so_reg : Operand<i32>, // reg imm
57 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
59 let EncoderMethod = "getT2SORegOpValue";
60 let PrintMethod = "printT2SOOperand";
61 let DecoderMethod = "DecodeSORegImmOperand";
62 let ParserMatchClass = ShiftedImmAsmOperand;
63 let MIOperandInfo = (ops rGPR, i32imm);
66 // Same as above, but only matching on a single use node.
67 def t2_so_reg_oneuse : Operand<i32>,
68 ComplexPattern<i32, 2,
69 "SelectShiftImmShifterOperandOneUse",
72 // t2_so_imm_not_XFORM - Return the complement of a t2_so_imm value
73 def t2_so_imm_not_XFORM : SDNodeXForm<imm, [{
74 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), SDLoc(N),
78 // t2_so_imm_neg_XFORM - Return the negation of a t2_so_imm value
79 def t2_so_imm_neg_XFORM : SDNodeXForm<imm, [{
80 return CurDAG->getSignedTargetConstant(-((int)N->getZExtValue()), SDLoc(N),
84 // so_imm_notSext_XFORM - Return a so_imm value packed into the format
85 // described for so_imm_notSext def below, with sign extension from 16
87 def t2_so_imm_notSext16_XFORM : SDNodeXForm<imm, [{
88 APInt apIntN = N->getAPIntValue();
89 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue();
90 return CurDAG->getTargetConstant(~N16bitSignExt, SDLoc(N), MVT::i32);
93 // t2_so_imm - Match a 32-bit immediate operand, which is an
94 // 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit
95 // immediate splatted into multiple bytes of the word.
96 def t2_so_imm_asmoperand : AsmOperandClass {
98 let RenderMethod = "addImmOperands";
101 def t2_so_imm : Operand<i32>, ImmLeaf<i32, [{
102 return ARM_AM::getT2SOImmVal(Imm) != -1;
104 let ParserMatchClass = t2_so_imm_asmoperand;
105 let EncoderMethod = "getT2SOImmOpValue";
106 let DecoderMethod = "DecodeT2SOImm";
109 // t2_so_imm_not - Match an immediate that is a complement
111 // Note: this pattern doesn't require an encoder method and such, as it's
112 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
113 // is handled by the destination instructions, which use t2_so_imm.
114 def t2_so_imm_not_asmoperand : AsmOperandClass { let Name = "T2SOImmNot"; }
115 def t2_so_imm_not : Operand<i32>, PatLeaf<(imm), [{
116 return ARM_AM::getT2SOImmVal(~((uint32_t)N->getZExtValue())) != -1;
117 }], t2_so_imm_not_XFORM> {
118 let ParserMatchClass = t2_so_imm_not_asmoperand;
121 // t2_so_imm_notSext - match an immediate that is a complement of a t2_so_imm
122 // if the upper 16 bits are zero.
123 def t2_so_imm_notSext : Operand<i32>, PatLeaf<(imm), [{
124 APInt apIntN = N->getAPIntValue();
125 if (!apIntN.isIntN(16)) return false;
126 unsigned N16bitSignExt = apIntN.trunc(16).sext(32).getZExtValue();
127 return ARM_AM::getT2SOImmVal(~N16bitSignExt) != -1;
128 }], t2_so_imm_notSext16_XFORM> {
129 let ParserMatchClass = t2_so_imm_not_asmoperand;
132 // t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
133 def t2_so_imm_neg_asmoperand : AsmOperandClass { let Name = "T2SOImmNeg"; }
134 def t2_so_imm_neg : Operand<i32>, ImmLeaf<i32, [{
135 return Imm && ARM_AM::getT2SOImmVal(-(uint32_t)Imm) != -1;
136 }], t2_so_imm_neg_XFORM> {
137 let ParserMatchClass = t2_so_imm_neg_asmoperand;
140 /// imm0_4095 predicate - True if the 32-bit immediate is in the range [0,4095].
141 def imm0_4095_asmoperand: ImmAsmOperand<0,4095> { let Name = "Imm0_4095"; }
142 def imm0_4095 : Operand<i32>, ImmLeaf<i32, [{
143 return Imm >= 0 && Imm < 4096;
145 let ParserMatchClass = imm0_4095_asmoperand;
148 def imm0_4095_neg_asmoperand: AsmOperandClass { let Name = "Imm0_4095Neg"; }
149 def imm0_4095_neg : Operand<i32>, PatLeaf<(i32 imm), [{
150 return (uint32_t)(-N->getZExtValue()) < 4096;
152 let ParserMatchClass = imm0_4095_neg_asmoperand;
155 def imm1_255_neg : PatLeaf<(i32 imm), [{
156 uint32_t Val = -N->getZExtValue();
157 return (Val > 0 && Val < 255);
160 def imm0_255_not : PatLeaf<(i32 imm), [{
161 return (uint32_t)(~N->getZExtValue()) < 255;
164 def lo5AllOne : PatLeaf<(i32 imm), [{
165 // Returns true if all low 5-bits are 1.
166 return (((uint32_t)N->getZExtValue()) & 0x1FUL) == 0x1FUL;
169 // Define Thumb2 specific addressing modes.
171 // t2_addr_offset_none := reg
172 def MemNoOffsetT2AsmOperand
173 : AsmOperandClass { let Name = "MemNoOffsetT2"; }
174 def t2_addr_offset_none : MemOperand {
175 let PrintMethod = "printAddrMode7Operand";
176 let DecoderMethod = "DecodeGPRnopcRegisterClass";
177 let ParserMatchClass = MemNoOffsetT2AsmOperand;
178 let MIOperandInfo = (ops GPRnopc:$base);
181 // t2_nosp_addr_offset_none := reg
182 def MemNoOffsetT2NoSpAsmOperand
183 : AsmOperandClass { let Name = "MemNoOffsetT2NoSp"; }
184 def t2_nosp_addr_offset_none : MemOperand {
185 let PrintMethod = "printAddrMode7Operand";
186 let DecoderMethod = "DecoderGPRRegisterClass";
187 let ParserMatchClass = MemNoOffsetT2NoSpAsmOperand;
188 let MIOperandInfo = (ops rGPR:$base);
191 // t2addrmode_imm12 := reg + imm12
192 def t2addrmode_imm12_asmoperand : AsmOperandClass {let Name="MemUImm12Offset";}
193 def t2addrmode_imm12 : MemOperand,
194 ComplexPattern<i32, 2, "SelectT2AddrModeImm12", []> {
195 let PrintMethod = "printAddrModeImm12Operand<false>";
196 let EncoderMethod = "getAddrModeImm12OpValue";
197 let DecoderMethod = "DecodeT2AddrModeImm12";
198 let ParserMatchClass = t2addrmode_imm12_asmoperand;
199 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
202 // t2ldrlabel := imm12
203 def t2ldrlabel : MemOperand {
204 let EncoderMethod = "getAddrModeImm12OpValue";
205 let PrintMethod = "printThumbLdrLabelOperand";
208 def t2ldr_pcrel_imm12_asmoperand : AsmOperandClass {let Name = "MemPCRelImm12";}
209 def t2ldr_pcrel_imm12 : Operand<i32> {
210 let ParserMatchClass = t2ldr_pcrel_imm12_asmoperand;
211 // used for assembler pseudo instruction and maps to t2ldrlabel, so
212 // doesn't need encoder or print methods of its own.
215 // ADR instruction labels.
216 def t2adrlabel : Operand<i32> {
217 let EncoderMethod = "getT2AdrLabelOpValue";
218 let PrintMethod = "printAdrLabelOperand<0>";
221 // t2addrmode_posimm8 := reg + imm8
222 def MemPosImm8OffsetAsmOperand : AsmOperandClass {
223 let Name="MemPosImm8Offset";
224 let RenderMethod = "addMemImmOffsetOperands";
226 def t2addrmode_posimm8 : MemOperand {
227 let PrintMethod = "printT2AddrModeImm8Operand<false>";
228 let EncoderMethod = "getT2AddrModeImmOpValue<8,0>";
229 let DecoderMethod = "DecodeT2AddrModeImm8";
230 let ParserMatchClass = MemPosImm8OffsetAsmOperand;
231 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
234 // t2addrmode_negimm8 := reg - imm8
235 def MemNegImm8OffsetAsmOperand : AsmOperandClass {
236 let Name="MemNegImm8Offset";
237 let RenderMethod = "addMemImmOffsetOperands";
239 def t2addrmode_negimm8 : MemOperand,
240 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
241 let PrintMethod = "printT2AddrModeImm8Operand<false>";
242 let EncoderMethod = "getT2AddrModeImmOpValue<8,0>";
243 let DecoderMethod = "DecodeT2AddrModeImm8";
244 let ParserMatchClass = MemNegImm8OffsetAsmOperand;
245 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
248 // t2addrmode_imm8 := reg +/- imm8
249 def MemImm8OffsetAsmOperand : AsmOperandClass {
250 let Name = "MemImm8Offset";
251 let RenderMethod = "addMemImmOffsetOperands";
253 class T2AddrMode_Imm8 : MemOperand,
254 ComplexPattern<i32, 2, "SelectT2AddrModeImm8", []> {
255 let EncoderMethod = "getT2AddrModeImmOpValue<8,0>";
256 let DecoderMethod = "DecodeT2AddrModeImm8";
257 let ParserMatchClass = MemImm8OffsetAsmOperand;
258 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
261 def t2addrmode_imm8 : T2AddrMode_Imm8 {
262 let PrintMethod = "printT2AddrModeImm8Operand<false>";
265 def t2addrmode_imm8_pre : T2AddrMode_Imm8 {
266 let PrintMethod = "printT2AddrModeImm8Operand<true>";
269 def t2am_imm8_offset : MemOperand,
270 ComplexPattern<i32, 1, "SelectT2AddrModeImm8Offset"> {
271 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
272 let EncoderMethod = "getT2AddrModeImm8OffsetOpValue";
273 let DecoderMethod = "DecodeT2Imm8";
274 let WantsRoot = true;
277 // t2addrmode_imm8s4 := reg +/- (imm8 << 2)
278 def MemImm8s4OffsetAsmOperand : AsmOperandClass {let Name = "MemImm8s4Offset";}
279 class T2AddrMode_Imm8s4 : MemOperand,
280 ComplexPattern<i32, 2, "SelectT2AddrModeImm8<2>", []> {
281 let EncoderMethod = "getT2AddrModeImm8s4OpValue";
282 let DecoderMethod = "DecodeT2AddrModeImm8s4";
283 let ParserMatchClass = MemImm8s4OffsetAsmOperand;
284 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
287 def t2addrmode_imm8s4 : T2AddrMode_Imm8s4 {
288 let PrintMethod = "printT2AddrModeImm8s4Operand<false>";
291 def t2addrmode_imm8s4_pre : T2AddrMode_Imm8s4 {
292 let PrintMethod = "printT2AddrModeImm8s4Operand<true>";
295 def t2am_imm8s4_offset_asmoperand : AsmOperandClass { let Name = "Imm8s4"; }
296 def t2am_imm8s4_offset : MemOperand {
297 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
298 let EncoderMethod = "getT2ScaledImmOpValue<8,2>";
299 let DecoderMethod = "DecodeT2Imm8S4";
302 // t2addrmode_imm7s4 := reg +/- (imm7 << 2)
303 def MemImm7s4OffsetAsmOperand : AsmOperandClass {let Name = "MemImm7s4Offset";}
304 class T2AddrMode_Imm7s4 : MemOperand {
305 let EncoderMethod = "getT2AddrModeImm7s4OpValue";
306 let DecoderMethod = "DecodeT2AddrModeImm7<2,0>";
307 let ParserMatchClass = MemImm7s4OffsetAsmOperand;
308 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
311 def t2addrmode_imm7s4 : T2AddrMode_Imm7s4 {
312 // They are printed the same way as the imm8 version
313 let PrintMethod = "printT2AddrModeImm8s4Operand<false>";
316 def t2addrmode_imm7s4_pre : T2AddrMode_Imm7s4 {
317 // They are printed the same way as the imm8 version
318 let PrintMethod = "printT2AddrModeImm8s4Operand<true>";
321 def t2am_imm7s4_offset_asmoperand : AsmOperandClass { let Name = "Imm7s4"; }
322 def t2am_imm7s4_offset : MemOperand {
323 // They are printed the same way as the imm8 version
324 let PrintMethod = "printT2AddrModeImm8s4OffsetOperand";
325 let ParserMatchClass = t2am_imm7s4_offset_asmoperand;
326 let EncoderMethod = "getT2ScaledImmOpValue<7,2>";
327 let DecoderMethod = "DecodeT2Imm7S4";
330 // t2addrmode_imm0_1020s4 := reg + (imm8 << 2)
331 def MemImm0_1020s4OffsetAsmOperand : AsmOperandClass {
332 let Name = "MemImm0_1020s4Offset";
334 def t2addrmode_imm0_1020s4 : MemOperand,
335 ComplexPattern<i32, 2, "SelectT2AddrModeExclusive"> {
336 let PrintMethod = "printT2AddrModeImm0_1020s4Operand";
337 let EncoderMethod = "getT2AddrModeImm0_1020s4OpValue";
338 let DecoderMethod = "DecodeT2AddrModeImm0_1020s4";
339 let ParserMatchClass = MemImm0_1020s4OffsetAsmOperand;
340 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
343 // t2addrmode_so_reg := reg + (reg << imm2)
344 def t2addrmode_so_reg_asmoperand : AsmOperandClass {let Name="T2MemRegOffset";}
345 def t2addrmode_so_reg : MemOperand,
346 ComplexPattern<i32, 3, "SelectT2AddrModeSoReg", []> {
347 let PrintMethod = "printT2AddrModeSoRegOperand";
348 let EncoderMethod = "getT2AddrModeSORegOpValue";
349 let DecoderMethod = "DecodeT2AddrModeSOReg";
350 let ParserMatchClass = t2addrmode_so_reg_asmoperand;
351 let MIOperandInfo = (ops GPRnopc:$base, rGPR:$offsreg, i32imm:$offsimm);
354 // Addresses for the TBB/TBH instructions.
355 def addrmode_tbb_asmoperand : AsmOperandClass { let Name = "MemTBB"; }
356 def addrmode_tbb : MemOperand {
357 let PrintMethod = "printAddrModeTBB";
358 let ParserMatchClass = addrmode_tbb_asmoperand;
359 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm);
361 def addrmode_tbh_asmoperand : AsmOperandClass { let Name = "MemTBH"; }
362 def addrmode_tbh : MemOperand {
363 let PrintMethod = "printAddrModeTBH";
364 let ParserMatchClass = addrmode_tbh_asmoperand;
365 let MIOperandInfo = (ops GPR:$Rn, rGPR:$Rm);
368 // Define ARMv8.1-M specific addressing modes.
370 // Label operands for BF/BFL/WLS/DLS/LE
371 class BFLabelOp<string signed, string isNeg, string zeroPermitted, string size,
374 let EncoderMethod = !strconcat("getBFTargetOpValue<", isNeg, ", ",
376 let OperandType = "OPERAND_PCREL";
377 let DecoderMethod = !strconcat("DecodeBFLabelOperand<", signed, ", ",
378 isNeg, ", ", zeroPermitted, ", ", size, ">");
380 def bflabel_u4 : BFLabelOp<"false", "false", "false", "4", "ARM::fixup_bf_branch">;
381 def bflabel_s12 : BFLabelOp<"true", "false", "true", "12", "ARM::fixup_bfc_target">;
382 def bflabel_s16 : BFLabelOp<"true", "false", "true", "16", "ARM::fixup_bf_target">;
383 def bflabel_s18 : BFLabelOp<"true", "false", "true", "18", "ARM::fixup_bfl_target">;
385 def wlslabel_u11_asmoperand : AsmOperandClass {
386 let Name = "WLSLabel";
387 let RenderMethod = "addImmOperands";
388 let PredicateMethod = "isUnsignedOffset<11, 1>";
389 let DiagnosticString =
390 "loop end is out of range or not a positive multiple of 2";
392 def wlslabel_u11 : BFLabelOp<"false", "false", "true", "11", "ARM::fixup_wls"> {
393 let ParserMatchClass = wlslabel_u11_asmoperand;
395 def lelabel_u11_asmoperand : AsmOperandClass {
396 let Name = "LELabel";
397 let RenderMethod = "addImmOperands";
398 let PredicateMethod = "isLEOffset";
399 let DiagnosticString =
400 "loop start is out of range or not a negative multiple of 2";
402 def lelabel_u11 : BFLabelOp<"false", "true", "true", "11", "ARM::fixup_le"> {
403 let ParserMatchClass = lelabel_u11_asmoperand;
406 def bfafter_target : Operand<OtherVT> {
407 let EncoderMethod = "getBFAfterTargetOpValue";
408 let OperandType = "OPERAND_PCREL";
409 let DecoderMethod = "DecodeBFAfterTargetOperand";
412 // pred operand excluding AL
413 def pred_noal_asmoperand : AsmOperandClass {
414 let Name = "CondCodeNoAL";
415 let RenderMethod = "addITCondCodeOperands";
416 let PredicateMethod = "isITCondCodeNoAL";
417 let ParserMethod = "parseITCondCode";
419 def pred_noal : Operand<i32> {
420 let PrintMethod = "printMandatoryPredicateOperand";
421 let ParserMatchClass = pred_noal_asmoperand;
422 let DecoderMethod = "DecodePredNoALOperand";
426 // CSEL aliases inverted predicate
427 def pred_noal_inv_asmoperand : AsmOperandClass {
428 let Name = "CondCodeNoALInv";
429 let RenderMethod = "addITCondCodeInvOperands";
430 let PredicateMethod = "isITCondCodeNoAL";
431 let ParserMethod = "parseITCondCode";
433 def pred_noal_inv : Operand<i32> {
434 let PrintMethod = "printMandatoryInvertedPredicateOperand";
435 let ParserMatchClass = pred_noal_inv_asmoperand;
437 //===----------------------------------------------------------------------===//
438 // Multiclass helpers...
442 class T2OneRegImm<dag oops, dag iops, InstrItinClass itin,
443 string opc, string asm, list<dag> pattern>
444 : T2I<oops, iops, itin, opc, asm, pattern> {
449 let Inst{26} = imm{11};
450 let Inst{14-12} = imm{10-8};
451 let Inst{7-0} = imm{7-0};
455 class T2sOneRegImm<dag oops, dag iops, InstrItinClass itin,
456 string opc, string asm, list<dag> pattern>
457 : T2sI<oops, iops, itin, opc, asm, pattern> {
463 let Inst{26} = imm{11};
464 let Inst{14-12} = imm{10-8};
465 let Inst{7-0} = imm{7-0};
468 class T2OneRegCmpImm<dag oops, dag iops, InstrItinClass itin,
469 string opc, string asm, list<dag> pattern>
470 : T2I<oops, iops, itin, opc, asm, pattern> {
474 let Inst{19-16} = Rn;
475 let Inst{26} = imm{11};
476 let Inst{14-12} = imm{10-8};
477 let Inst{7-0} = imm{7-0};
481 class T2OneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
482 string opc, string asm, list<dag> pattern>
483 : T2I<oops, iops, itin, opc, asm, pattern> {
488 let Inst{3-0} = ShiftedRm{3-0};
489 let Inst{5-4} = ShiftedRm{6-5};
490 let Inst{14-12} = ShiftedRm{11-9};
491 let Inst{7-6} = ShiftedRm{8-7};
494 class T2sOneRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
495 string opc, string asm, list<dag> pattern>
496 : T2sI<oops, iops, itin, opc, asm, pattern> {
501 let Inst{3-0} = ShiftedRm{3-0};
502 let Inst{5-4} = ShiftedRm{6-5};
503 let Inst{14-12} = ShiftedRm{11-9};
504 let Inst{7-6} = ShiftedRm{8-7};
507 class T2OneRegCmpShiftedReg<dag oops, dag iops, InstrItinClass itin,
508 string opc, string asm, list<dag> pattern>
509 : T2I<oops, iops, itin, opc, asm, pattern> {
513 let Inst{19-16} = Rn;
514 let Inst{3-0} = ShiftedRm{3-0};
515 let Inst{5-4} = ShiftedRm{6-5};
516 let Inst{14-12} = ShiftedRm{11-9};
517 let Inst{7-6} = ShiftedRm{8-7};
520 class T2TwoReg<dag oops, dag iops, InstrItinClass itin,
521 string opc, string asm, list<dag> pattern>
522 : T2I<oops, iops, itin, opc, asm, pattern> {
530 class T2sTwoReg<dag oops, dag iops, InstrItinClass itin,
531 string opc, string asm, list<dag> pattern>
532 : T2sI<oops, iops, itin, opc, asm, pattern> {
540 class T2TwoRegCmp<dag oops, dag iops, InstrItinClass itin,
541 string opc, string asm, list<dag> pattern>
542 : T2I<oops, iops, itin, opc, asm, pattern> {
546 let Inst{19-16} = Rn;
551 class T2TwoRegImm<dag oops, dag iops, InstrItinClass itin,
552 string opc, string asm, list<dag> pattern>
553 : T2I<oops, iops, itin, opc, asm, pattern> {
559 let Inst{19-16} = Rn;
560 let Inst{26} = imm{11};
561 let Inst{14-12} = imm{10-8};
562 let Inst{7-0} = imm{7-0};
565 class T2sTwoRegImm<dag oops, dag iops, InstrItinClass itin,
566 string opc, string asm, list<dag> pattern>
567 : T2sI<oops, iops, itin, opc, asm, pattern> {
573 let Inst{19-16} = Rn;
574 let Inst{26} = imm{11};
575 let Inst{14-12} = imm{10-8};
576 let Inst{7-0} = imm{7-0};
579 class T2TwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
580 string opc, string asm, list<dag> pattern>
581 : T2I<oops, iops, itin, opc, asm, pattern> {
588 let Inst{14-12} = imm{4-2};
589 let Inst{7-6} = imm{1-0};
592 class T2sTwoRegShiftImm<dag oops, dag iops, InstrItinClass itin,
593 string opc, string asm, list<dag> pattern>
594 : T2sI<oops, iops, itin, opc, asm, pattern> {
601 let Inst{14-12} = imm{4-2};
602 let Inst{7-6} = imm{1-0};
605 class T2ThreeReg<dag oops, dag iops, InstrItinClass itin,
606 string opc, string asm, list<dag> pattern>
607 : T2I<oops, iops, itin, opc, asm, pattern> {
613 let Inst{19-16} = Rn;
617 class T2ThreeRegNoP<dag oops, dag iops, InstrItinClass itin,
618 string asm, list<dag> pattern>
619 : T2XI<oops, iops, itin, asm, pattern> {
625 let Inst{19-16} = Rn;
629 class T2sThreeReg<dag oops, dag iops, InstrItinClass itin,
630 string opc, string asm, list<dag> pattern>
631 : T2sI<oops, iops, itin, opc, asm, pattern> {
637 let Inst{19-16} = Rn;
641 class T2TwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
642 string opc, string asm, list<dag> pattern>
643 : T2I<oops, iops, itin, opc, asm, pattern> {
649 let Inst{19-16} = Rn;
650 let Inst{3-0} = ShiftedRm{3-0};
651 let Inst{5-4} = ShiftedRm{6-5};
652 let Inst{14-12} = ShiftedRm{11-9};
653 let Inst{7-6} = ShiftedRm{8-7};
656 class T2sTwoRegShiftedReg<dag oops, dag iops, InstrItinClass itin,
657 string opc, string asm, list<dag> pattern>
658 : T2sI<oops, iops, itin, opc, asm, pattern> {
664 let Inst{19-16} = Rn;
665 let Inst{3-0} = ShiftedRm{3-0};
666 let Inst{5-4} = ShiftedRm{6-5};
667 let Inst{14-12} = ShiftedRm{11-9};
668 let Inst{7-6} = ShiftedRm{8-7};
671 class T2FourReg<dag oops, dag iops, InstrItinClass itin,
672 string opc, string asm, list<dag> pattern>
673 : T2I<oops, iops, itin, opc, asm, pattern> {
679 let Inst{19-16} = Rn;
680 let Inst{15-12} = Ra;
685 class T2MulLong<bits<3> opc22_20, bits<4> opc7_4,
686 string opc, list<dag> pattern>
687 : T2I<(outs rGPR:$RdLo, rGPR:$RdHi), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL64,
688 opc, "\t$RdLo, $RdHi, $Rn, $Rm", pattern>,
689 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]> {
695 let Inst{31-23} = 0b111110111;
696 let Inst{22-20} = opc22_20;
697 let Inst{19-16} = Rn;
698 let Inst{15-12} = RdLo;
699 let Inst{11-8} = RdHi;
700 let Inst{7-4} = opc7_4;
703 class T2MlaLong<bits<3> opc22_20, bits<4> opc7_4, string opc>
704 : T2I<(outs rGPR:$RdLo, rGPR:$RdHi),
705 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi), IIC_iMAC64,
706 opc, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
707 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
708 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
714 let Inst{31-23} = 0b111110111;
715 let Inst{22-20} = opc22_20;
716 let Inst{19-16} = Rn;
717 let Inst{15-12} = RdLo;
718 let Inst{11-8} = RdHi;
719 let Inst{7-4} = opc7_4;
724 /// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
725 /// binary operation that produces a value. These are predicable and can be
726 /// changed to modify CPSR.
727 multiclass T2I_bin_irs<bits<4> opcod, string opc,
728 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
729 SDPatternOperator opnode, bit Commutable = 0,
732 def ri : T2sTwoRegImm<
733 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), iii,
734 opc, "\t$Rd, $Rn, $imm",
735 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_imm:$imm))]>,
736 Sched<[WriteALU, ReadALU]> {
737 let Inst{31-27} = 0b11110;
739 let Inst{24-21} = opcod;
743 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), iir,
744 opc, !strconcat(wide, "\t$Rd, $Rn, $Rm"),
745 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
746 Sched<[WriteALU, ReadALU, ReadALU]> {
747 let isCommutable = Commutable;
748 let Inst{31-27} = 0b11101;
749 let Inst{26-25} = 0b01;
750 let Inst{24-21} = opcod;
752 // In most of these instructions, and most versions of the Arm
753 // architecture, bit 15 of this encoding is listed as (0) rather
754 // than 0, i.e. setting it to 1 is UNPREDICTABLE or a soft-fail
755 // rather than a hard failure. In v8.1-M, this requirement is
756 // upgraded to a hard one for ORR, so that the encodings with 1
757 // in this bit can be reused for other instructions (such as
758 // CSEL). Setting Unpredictable{15} = 1 here would reintroduce
759 // that encoding clash in the auto- generated MC decoder, so I
761 let Unpredictable{15} = !if(!eq(opcod, 0b0010), 0b0, 0b1);
762 let Inst{14-12} = 0b000; // imm3
763 let Inst{7-6} = 0b00; // imm2
764 let Inst{5-4} = 0b00; // type
767 def rs : T2sTwoRegShiftedReg<
768 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
769 opc, !strconcat(wide, "\t$Rd, $Rn, $ShiftedRm"),
770 [(set rGPR:$Rd, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
771 Sched<[WriteALUsi, ReadALU]> {
772 let Inst{31-27} = 0b11101;
773 let Inst{26-25} = 0b01;
774 let Inst{24-21} = opcod;
776 let Unpredictable{15} = !if(!eq(opcod, 0b0010), 0b0, 0b1); // see above
778 // Assembly aliases for optional destination operand when it's the same
779 // as the source operand.
780 def : t2InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
781 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn,
782 t2_so_imm:$imm, pred:$p,
784 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $Rm"),
785 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn,
788 def : t2InstAlias<!strconcat(opc, "${s}${p}", wide, " $Rdn, $shift"),
789 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn,
790 t2_so_reg:$shift, pred:$p,
794 /// T2I_bin_w_irs - Same as T2I_bin_irs except these operations need
795 // the ".w" suffix to indicate that they are wide.
796 multiclass T2I_bin_w_irs<bits<4> opcod, string opc,
797 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
798 SDPatternOperator opnode, bit Commutable = 0> :
799 T2I_bin_irs<opcod, opc, iii, iir, iis, opnode, Commutable, ".w"> {
800 // Assembler aliases w/ the ".w" suffix.
801 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rd, $Rn, $imm"),
802 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p,
804 // Assembler aliases w/o the ".w" suffix.
805 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
806 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
808 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $shift"),
809 (!cast<Instruction>(NAME#"rs") rGPR:$Rd, rGPR:$Rn, t2_so_reg:$shift,
810 pred:$p, cc_out:$s)>;
812 // and with the optional destination operand, too.
813 def : t2InstAlias<!strconcat(opc, "${s}${p}.w", " $Rdn, $imm"),
814 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm,
815 pred:$p, cc_out:$s)>;
816 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
817 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
819 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $shift"),
820 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$shift,
821 pred:$p, cc_out:$s)>;
824 /// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are
825 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
826 /// it is equivalent to the T2I_bin_irs counterpart.
827 multiclass T2I_rbin_irs<bits<4> opcod, string opc, SDNode opnode> {
829 def ri : T2sTwoRegImm<
830 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm), IIC_iALUi,
831 opc, ".w\t$Rd, $Rn, $imm",
832 [(set rGPR:$Rd, (opnode t2_so_imm:$imm, rGPR:$Rn))]>,
833 Sched<[WriteALU, ReadALU]> {
834 let Inst{31-27} = 0b11110;
836 let Inst{24-21} = opcod;
840 def rr : T2sThreeReg<
841 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
842 opc, "\t$Rd, $Rn, $Rm",
843 [/* For disassembly only; pattern left blank */]>,
844 Sched<[WriteALU, ReadALU, ReadALU]> {
845 let Inst{31-27} = 0b11101;
846 let Inst{26-25} = 0b01;
847 let Inst{24-21} = opcod;
848 let Inst{14-12} = 0b000; // imm3
849 let Inst{7-6} = 0b00; // imm2
850 let Inst{5-4} = 0b00; // type
853 def rs : T2sTwoRegShiftedReg<
854 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
855 IIC_iALUsir, opc, "\t$Rd, $Rn, $ShiftedRm",
856 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm, rGPR:$Rn))]>,
857 Sched<[WriteALUsi, ReadALU]> {
858 let Inst{31-27} = 0b11101;
859 let Inst{26-25} = 0b01;
860 let Inst{24-21} = opcod;
864 /// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the
865 /// instruction modifies the CPSR register.
867 /// These opcodes will be converted to the real non-S opcodes by
868 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
869 let hasPostISelHook = 1, Defs = [CPSR] in {
870 multiclass T2I_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
871 InstrItinClass iis, SDNode opnode,
872 bit Commutable = 0> {
874 def ri : t2PseudoInst<(outs rGPR:$Rd),
875 (ins GPRnopc:$Rn, t2_so_imm:$imm, pred:$p),
877 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
879 Sched<[WriteALU, ReadALU]>;
881 def rr : t2PseudoInst<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm, pred:$p),
883 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
885 Sched<[WriteALU, ReadALU, ReadALU]> {
886 let isCommutable = Commutable;
889 def rs : t2PseudoInst<(outs rGPR:$Rd),
890 (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
892 [(set rGPR:$Rd, CPSR, (opnode GPRnopc:$Rn,
893 t2_so_reg:$ShiftedRm))]>,
894 Sched<[WriteALUsi, ReadALUsr]>;
898 /// T2I_rbin_s_is - Same as T2I_bin_s_irs, except selection DAG
899 /// operands are reversed.
900 let hasPostISelHook = 1, Defs = [CPSR] in {
901 multiclass T2I_rbin_s_is<SDNode opnode> {
903 def ri : t2PseudoInst<(outs rGPR:$Rd),
904 (ins rGPR:$Rn, t2_so_imm:$imm, pred:$p),
906 [(set rGPR:$Rd, CPSR, (opnode t2_so_imm:$imm,
908 Sched<[WriteALU, ReadALU]>;
910 def rs : t2PseudoInst<(outs rGPR:$Rd),
911 (ins rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p),
913 [(set rGPR:$Rd, CPSR, (opnode t2_so_reg:$ShiftedRm,
915 Sched<[WriteALUsi, ReadALU]>;
919 /// T2I_bin_ii12rs - Defines a set of (op reg, {so_imm|imm0_4095|r|so_reg})
920 /// patterns for a binary operation that produces a value.
921 multiclass T2I_bin_ii12rs<bits<3> op23_21, string opc, SDNode opnode,
922 bit Commutable = 0> {
924 // The register-immediate version is re-materializable. This is useful
925 // in particular for taking the address of a local.
926 let isReMaterializable = 1 in {
927 def spImm : T2sTwoRegImm<
928 (outs GPRsp:$Rd), (ins GPRsp:$Rn, t2_so_imm:$imm), IIC_iALUi,
929 opc, ".w\t$Rd, $Rn, $imm",
931 Sched<[WriteALU, ReadALU]> {
935 let Inst{31-27} = 0b11110;
936 let Inst{25-24} = 0b01;
937 let Inst{23-21} = op23_21;
940 let DecoderMethod = "DecodeT2AddSubSPImm";
943 def ri : T2sTwoRegImm<
944 (outs rGPR:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi,
945 opc, ".w\t$Rd, $Rn, $imm",
946 [(set rGPR:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]>,
947 Sched<[WriteALU, ReadALU]> {
948 let Inst{31-27} = 0b11110;
951 let Inst{23-21} = op23_21;
957 (outs rGPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi,
958 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
959 [(set rGPR:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]>,
960 Sched<[WriteALU, ReadALU]> {
964 let Inst{31-27} = 0b11110;
965 let Inst{26} = imm{11};
966 let Inst{25-24} = 0b10;
967 let Inst{23-21} = op23_21;
968 let Inst{20} = 0; // The S bit.
969 let Inst{19-16} = Rn;
971 let Inst{14-12} = imm{10-8};
973 let Inst{7-0} = imm{7-0};
976 (outs GPRsp:$Rd), (ins GPRsp:$Rn, imm0_4095:$imm), IIC_iALUi,
977 !strconcat(opc, "w"), "\t$Rd, $Rn, $imm",
979 Sched<[WriteALU, ReadALU]> {
983 let Inst{31-27} = 0b11110;
984 let Inst{26} = imm{11};
985 let Inst{25-24} = 0b10;
986 let Inst{23-21} = op23_21;
987 let Inst{20} = 0; // The S bit.
988 let Inst{19-16} = Rn;
990 let Inst{14-12} = imm{10-8};
992 let Inst{7-0} = imm{7-0};
993 let DecoderMethod = "DecodeT2AddSubSPImm";
996 def rr : T2sThreeReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm),
997 IIC_iALUr, opc, ".w\t$Rd, $Rn, $Rm",
998 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]>,
999 Sched<[WriteALU, ReadALU, ReadALU]> {
1000 let isCommutable = Commutable;
1001 let Inst{31-27} = 0b11101;
1002 let Inst{26-25} = 0b01;
1004 let Inst{23-21} = op23_21;
1005 let Inst{14-12} = 0b000; // imm3
1006 let Inst{7-6} = 0b00; // imm2
1007 let Inst{5-4} = 0b00; // type
1010 def rs : T2sTwoRegShiftedReg<
1011 (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm),
1012 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
1013 [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]>,
1014 Sched<[WriteALUsi, ReadALU]> {
1015 let Inst{31-27} = 0b11101;
1016 let Inst{26-25} = 0b01;
1018 let Inst{23-21} = op23_21;
1022 /// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns
1023 /// for a binary operation that produces a value and use the carry
1024 /// bit. It's not predicable.
1025 multiclass T2I_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1026 bit Commutable = 0, bit PostISelHook = 0> {
1027 let Defs = [CPSR], Uses = [CPSR], hasPostISelHook = PostISelHook in {
1029 def ri : T2sTwoRegImm<(outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_imm:$imm),
1030 IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1031 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_imm:$imm, CPSR))]>,
1032 Requires<[IsThumb2]>, Sched<[WriteALU, ReadALU]> {
1033 let Inst{31-27} = 0b11110;
1035 let Inst{24-21} = opcod;
1039 def rr : T2sThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iALUr,
1040 opc, ".w\t$Rd, $Rn, $Rm",
1041 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, rGPR:$Rm, CPSR))]>,
1042 Requires<[IsThumb2]>, Sched<[WriteALU, ReadALU, ReadALU]> {
1043 let isCommutable = Commutable;
1044 let Inst{31-27} = 0b11101;
1045 let Inst{26-25} = 0b01;
1046 let Inst{24-21} = opcod;
1047 let Inst{14-12} = 0b000; // imm3
1048 let Inst{7-6} = 0b00; // imm2
1049 let Inst{5-4} = 0b00; // type
1052 def rs : T2sTwoRegShiftedReg<
1053 (outs rGPR:$Rd), (ins rGPR:$Rn, t2_so_reg:$ShiftedRm),
1054 IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm",
1055 [(set rGPR:$Rd, CPSR, (opnode rGPR:$Rn, t2_so_reg:$ShiftedRm, CPSR))]>,
1056 Requires<[IsThumb2]>, Sched<[WriteALUsi, ReadALU]> {
1057 let Inst{31-27} = 0b11101;
1058 let Inst{26-25} = 0b01;
1059 let Inst{24-21} = opcod;
1063 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"),
1064 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p,
1066 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"),
1067 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
1069 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $ShiftedRm"),
1070 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p,
1072 def : t2InstAlias<!strconcat(opc, "${s}${p}", "$Rdn, $imm"),
1073 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p,
1075 def : t2InstAlias<!strconcat(opc, "${s}${p}", "$Rdn, $Rm"),
1076 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
1078 def : t2InstAlias<!strconcat(opc, "${s}${p}", "$Rdn, $ShiftedRm"),
1079 (!cast<Instruction>(NAME#"rs") rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p,
1083 /// T2I_sh_ir - Defines a set of (op reg, {so_imm|r}) patterns for a shift /
1084 // rotate operation that produces a value.
1085 multiclass T2I_sh_ir<bits<2> opcod, string opc, Operand ty, SDNode opnode> {
1087 def ri : T2sTwoRegShiftImm<
1088 (outs rGPR:$Rd), (ins rGPR:$Rm, ty:$imm), IIC_iMOVsi,
1089 opc, ".w\t$Rd, $Rm, $imm",
1090 [(set rGPR:$Rd, (opnode rGPR:$Rm, (i32 ty:$imm)))]>,
1092 let Inst{31-27} = 0b11101;
1093 let Inst{26-21} = 0b010010;
1094 let Inst{19-16} = 0b1111; // Rn
1096 let Inst{5-4} = opcod;
1099 def rr : T2sThreeReg<
1100 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMOVsr,
1101 opc, ".w\t$Rd, $Rn, $Rm",
1102 [(set rGPR:$Rd, (opnode rGPR:$Rn, rGPR:$Rm))]>,
1104 let Inst{31-27} = 0b11111;
1105 let Inst{26-23} = 0b0100;
1106 let Inst{22-21} = opcod;
1107 let Inst{15-12} = 0b1111;
1108 let Inst{7-4} = 0b0000;
1111 // Optional destination register
1112 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $imm"),
1113 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
1115 def : t2InstAlias<!strconcat(opc, "${s}${p}", ".w $Rdn, $Rm"),
1116 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
1119 // Assembler aliases w/o the ".w" suffix.
1120 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $imm"),
1121 (!cast<Instruction>(NAME#"ri") rGPR:$Rd, rGPR:$Rn, ty:$imm, pred:$p,
1123 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rd, $Rn, $Rm"),
1124 (!cast<Instruction>(NAME#"rr") rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p,
1127 // and with the optional destination operand, too.
1128 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $imm"),
1129 (!cast<Instruction>(NAME#"ri") rGPR:$Rdn, rGPR:$Rdn, ty:$imm, pred:$p,
1131 def : t2InstAlias<!strconcat(opc, "${s}${p}", " $Rdn, $Rm"),
1132 (!cast<Instruction>(NAME#"rr") rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p,
1136 /// T2I_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1137 /// patterns. Similar to T2I_bin_irs except the instruction does not produce
1138 /// a explicit result, only implicitly set CPSR.
1139 multiclass T2I_cmp_irs<bits<4> opcod, string opc, RegisterClass LHSGPR,
1140 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1141 SDPatternOperator opnode> {
1142 let isCompare = 1, Defs = [CPSR] in {
1144 def ri : T2OneRegCmpImm<
1145 (outs), (ins LHSGPR:$Rn, t2_so_imm:$imm), iii,
1146 opc, ".w\t$Rn, $imm",
1147 [(set CPSR, (opnode LHSGPR:$Rn, t2_so_imm:$imm))]>,
1149 let Inst{31-27} = 0b11110;
1151 let Inst{24-21} = opcod;
1152 let Inst{20} = 1; // The S bit.
1154 let Inst{11-8} = 0b1111; // Rd
1157 def rr : T2TwoRegCmp<
1158 (outs), (ins LHSGPR:$Rn, rGPR:$Rm), iir,
1159 opc, ".w\t$Rn, $Rm",
1160 [(set CPSR, (opnode LHSGPR:$Rn, rGPR:$Rm))]>,
1162 let Inst{31-27} = 0b11101;
1163 let Inst{26-25} = 0b01;
1164 let Inst{24-21} = opcod;
1165 let Inst{20} = 1; // The S bit.
1166 let Inst{14-12} = 0b000; // imm3
1167 let Inst{11-8} = 0b1111; // Rd
1168 let Inst{7-6} = 0b00; // imm2
1169 let Inst{5-4} = 0b00; // type
1172 def rs : T2OneRegCmpShiftedReg<
1173 (outs), (ins LHSGPR:$Rn, t2_so_reg:$ShiftedRm), iis,
1174 opc, ".w\t$Rn, $ShiftedRm",
1175 [(set CPSR, (opnode LHSGPR:$Rn, t2_so_reg:$ShiftedRm))]>,
1176 Sched<[WriteCMPsi]> {
1177 let Inst{31-27} = 0b11101;
1178 let Inst{26-25} = 0b01;
1179 let Inst{24-21} = opcod;
1180 let Inst{20} = 1; // The S bit.
1181 let Inst{11-8} = 0b1111; // Rd
1185 // Assembler aliases w/o the ".w" suffix.
1186 // No alias here for 'rr' version as not all instantiations of this
1187 // multiclass want one (CMP in particular, does not).
1188 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $imm"),
1189 (!cast<Instruction>(NAME#"ri") LHSGPR:$Rn, t2_so_imm:$imm, pred:$p)>;
1190 def : t2InstAlias<!strconcat(opc, "${p}", " $Rn, $shift"),
1191 (!cast<Instruction>(NAME#"rs") LHSGPR:$Rn, t2_so_reg:$shift, pred:$p)>;
1194 /// T2I_ld - Defines a set of (op r, {imm12|imm8|so_reg}) load patterns.
1195 multiclass T2I_ld<bit signed, bits<2> opcod, string opc,
1196 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
1198 def i12 : T2Ii12<(outs target:$Rt), (ins t2addrmode_imm12:$addr), iii,
1199 opc, ".w\t$Rt, $addr",
1200 [(set target:$Rt, (opnode t2addrmode_imm12:$addr))]>,
1204 let Inst{31-25} = 0b1111100;
1205 let Inst{24} = signed;
1207 let Inst{22-21} = opcod;
1208 let Inst{20} = 1; // load
1209 let Inst{19-16} = addr{16-13}; // Rn
1210 let Inst{15-12} = Rt;
1211 let Inst{11-0} = addr{11-0}; // imm
1213 let DecoderMethod = "DecodeT2LoadImm12";
1215 def i8 : T2Ii8n <(outs target:$Rt), (ins t2addrmode_negimm8:$addr), iii,
1216 opc, "\t$Rt, $addr",
1217 [(set target:$Rt, (opnode t2addrmode_negimm8:$addr))]>,
1221 let Inst{31-27} = 0b11111;
1222 let Inst{26-25} = 0b00;
1223 let Inst{24} = signed;
1225 let Inst{22-21} = opcod;
1226 let Inst{20} = 1; // load
1227 let Inst{19-16} = addr{12-9}; // Rn
1228 let Inst{15-12} = Rt;
1230 // Offset: index==TRUE, wback==FALSE
1231 let Inst{10} = 1; // The P bit.
1232 let Inst{9} = addr{8}; // U
1233 let Inst{8} = 0; // The W bit.
1234 let Inst{7-0} = addr{7-0}; // imm
1236 let DecoderMethod = "DecodeT2LoadImm8";
1238 def s : T2Iso <(outs target:$Rt), (ins t2addrmode_so_reg:$addr), iis,
1239 opc, ".w\t$Rt, $addr",
1240 [(set target:$Rt, (opnode t2addrmode_so_reg:$addr))]>,
1242 let Inst{31-27} = 0b11111;
1243 let Inst{26-25} = 0b00;
1244 let Inst{24} = signed;
1246 let Inst{22-21} = opcod;
1247 let Inst{20} = 1; // load
1248 let Inst{11-6} = 0b000000;
1251 let Inst{15-12} = Rt;
1254 let Inst{19-16} = addr{9-6}; // Rn
1255 let Inst{3-0} = addr{5-2}; // Rm
1256 let Inst{5-4} = addr{1-0}; // imm
1258 let DecoderMethod = "DecodeT2LoadShift";
1261 // pci variant is very similar to i12, but supports negative offsets
1263 def pci : T2Ipc <(outs target:$Rt), (ins t2ldrlabel:$addr), iii,
1264 opc, ".w\t$Rt, $addr",
1265 [(set target:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]>,
1267 let isReMaterializable = 1;
1268 let Inst{31-27} = 0b11111;
1269 let Inst{26-25} = 0b00;
1270 let Inst{24} = signed;
1271 let Inst{22-21} = opcod;
1272 let Inst{20} = 1; // load
1273 let Inst{19-16} = 0b1111; // Rn
1276 let Inst{15-12} = Rt{3-0};
1279 let Inst{23} = addr{12}; // add = (U == '1')
1280 let Inst{11-0} = addr{11-0};
1282 let DecoderMethod = "DecodeT2LoadLabel";
1286 /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns.
1287 multiclass T2I_st<bits<2> opcod, string opc,
1288 InstrItinClass iii, InstrItinClass iis, RegisterClass target,
1290 def i12 : T2Ii12<(outs), (ins target:$Rt, t2addrmode_imm12:$addr), iii,
1291 opc, ".w\t$Rt, $addr",
1292 [(opnode target:$Rt, t2addrmode_imm12:$addr)]>,
1294 let Inst{31-27} = 0b11111;
1295 let Inst{26-23} = 0b0001;
1296 let Inst{22-21} = opcod;
1297 let Inst{20} = 0; // !load
1300 let Inst{15-12} = Rt;
1303 let addr{12} = 1; // add = TRUE
1304 let Inst{19-16} = addr{16-13}; // Rn
1305 let Inst{23} = addr{12}; // U
1306 let Inst{11-0} = addr{11-0}; // imm
1308 def i8 : T2Ii8n <(outs), (ins target:$Rt, t2addrmode_negimm8:$addr), iii,
1309 opc, "\t$Rt, $addr",
1310 [(opnode target:$Rt, t2addrmode_negimm8:$addr)]>,
1312 let Inst{31-27} = 0b11111;
1313 let Inst{26-23} = 0b0000;
1314 let Inst{22-21} = opcod;
1315 let Inst{20} = 0; // !load
1317 // Offset: index==TRUE, wback==FALSE
1318 let Inst{10} = 1; // The P bit.
1319 let Inst{8} = 0; // The W bit.
1322 let Inst{15-12} = Rt;
1325 let Inst{19-16} = addr{12-9}; // Rn
1326 let Inst{9} = addr{8}; // U
1327 let Inst{7-0} = addr{7-0}; // imm
1329 def s : T2Iso <(outs), (ins target:$Rt, t2addrmode_so_reg:$addr), iis,
1330 opc, ".w\t$Rt, $addr",
1331 [(opnode target:$Rt, t2addrmode_so_reg:$addr)]>,
1333 let Inst{31-27} = 0b11111;
1334 let Inst{26-23} = 0b0000;
1335 let Inst{22-21} = opcod;
1336 let Inst{20} = 0; // !load
1337 let Inst{11-6} = 0b000000;
1340 let Inst{15-12} = Rt;
1343 let Inst{19-16} = addr{9-6}; // Rn
1344 let Inst{3-0} = addr{5-2}; // Rm
1345 let Inst{5-4} = addr{1-0}; // imm
1349 /// T2I_ext_rrot - A unary operation with two forms: one whose operand is a
1350 /// register and one whose operand is a register rotated by 8/16/24.
1351 class T2I_ext_rrot_base<bits<3> opcod, dag iops, dag oops,
1352 string opc, string oprs,
1354 : T2TwoReg<iops, oops, IIC_iEXTr, opc, oprs, pattern> {
1356 let Inst{31-27} = 0b11111;
1357 let Inst{26-23} = 0b0100;
1358 let Inst{22-20} = opcod;
1359 let Inst{19-16} = 0b1111; // Rn
1360 let Inst{15-12} = 0b1111;
1362 let Inst{5-4} = rot; // rotate
1365 class T2I_ext_rrot<bits<3> opcod, string opc>
1366 : T2I_ext_rrot_base<opcod,
1368 (ins rGPR:$Rm, rot_imm:$rot),
1369 opc, ".w\t$Rd, $Rm$rot", []>,
1370 Requires<[IsThumb2]>,
1371 Sched<[WriteALU, ReadALU]>;
1373 // UXTB16, SXTB16 - Requires HasDSP, does not need the .w qualifier.
1374 class T2I_ext_rrot_xtb16<bits<3> opcod, string opc>
1375 : T2I_ext_rrot_base<opcod,
1377 (ins rGPR:$Rm, rot_imm:$rot),
1378 opc, "\t$Rd, $Rm$rot", []>,
1379 Requires<[HasDSP, IsThumb2]>,
1380 Sched<[WriteALU, ReadALU]>;
1382 /// T2I_exta_rrot - A binary operation with two forms: one whose operand is a
1383 /// register and one whose operand is a register rotated by 8/16/24.
1384 class T2I_exta_rrot<bits<3> opcod, string opc>
1385 : T2ThreeReg<(outs rGPR:$Rd),
1386 (ins rGPR:$Rn, rGPR:$Rm, rot_imm:$rot),
1387 IIC_iEXTAsr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1388 Requires<[HasDSP, IsThumb2]>,
1389 Sched<[WriteALU, ReadALU]> {
1391 let Inst{31-27} = 0b11111;
1392 let Inst{26-23} = 0b0100;
1393 let Inst{22-20} = opcod;
1394 let Inst{15-12} = 0b1111;
1396 let Inst{5-4} = rot;
1399 //===----------------------------------------------------------------------===//
1401 //===----------------------------------------------------------------------===//
1403 //===----------------------------------------------------------------------===//
1404 // Miscellaneous Instructions.
1407 class T2PCOneRegImm<dag oops, dag iops, InstrItinClass itin,
1408 string asm, list<dag> pattern>
1409 : T2XI<oops, iops, itin, asm, pattern> {
1413 let Inst{11-8} = Rd;
1414 let Inst{26} = label{11};
1415 let Inst{14-12} = label{10-8};
1416 let Inst{7-0} = label{7-0};
1419 // LEApcrel - Load a pc-relative address into a register without offending the
1421 def t2ADR : T2PCOneRegImm<(outs rGPR:$Rd),
1422 (ins t2adrlabel:$addr, pred:$p),
1423 IIC_iALUi, "adr{$p}.w\t$Rd, $addr", []>,
1424 Sched<[WriteALU, ReadALU]> {
1425 let Inst{31-27} = 0b11110;
1426 let Inst{25-24} = 0b10;
1427 // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE)
1430 let Inst{19-16} = 0b1111; // Rn
1435 let Inst{11-8} = Rd;
1436 let Inst{23} = addr{12};
1437 let Inst{21} = addr{12};
1438 let Inst{26} = addr{11};
1439 let Inst{14-12} = addr{10-8};
1440 let Inst{7-0} = addr{7-0};
1442 let DecoderMethod = "DecodeT2Adr";
1445 let hasSideEffects = 0, isReMaterializable = 1 in
1446 def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p),
1447 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
1448 let hasSideEffects = 1 in
1449 def t2LEApcrelJT : t2PseudoInst<(outs rGPR:$Rd),
1450 (ins i32imm:$label, pred:$p),
1452 []>, Sched<[WriteALU, ReadALU]>;
1455 //===----------------------------------------------------------------------===//
1456 // Load / store Instructions.
1460 let canFoldAsLoad = 1, isReMaterializable = 1 in
1461 defm t2LDR : T2I_ld<0, 0b10, "ldr", IIC_iLoad_i, IIC_iLoad_si, GPR, load>;
1463 // Loads with zero extension
1464 defm t2LDRH : T2I_ld<0, 0b01, "ldrh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1465 GPRnopc, zextloadi16>;
1466 defm t2LDRB : T2I_ld<0, 0b00, "ldrb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1467 GPRnopc, zextloadi8>;
1469 // Loads with sign extension
1470 defm t2LDRSH : T2I_ld<1, 0b01, "ldrsh", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1471 GPRnopc, sextloadi16>;
1472 defm t2LDRSB : T2I_ld<1, 0b00, "ldrsb", IIC_iLoad_bh_i, IIC_iLoad_bh_si,
1473 GPRnopc, sextloadi8>;
1475 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
1477 def t2LDRDi8 : T2Ii8s4<1, 0, 1, (outs rGPR:$Rt, rGPR:$Rt2),
1478 (ins t2addrmode_imm8s4:$addr),
1479 IIC_iLoad_d_i, "ldrd", "\t$Rt, $Rt2, $addr", "",
1480 [(set rGPR:$Rt, rGPR:$Rt2, (ARMldrd t2addrmode_imm8s4:$addr))]>,
1482 } // mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1
1484 // zextload i1 -> zextload i8
1485 def : T2Pat<(zextloadi1 t2addrmode_imm12:$addr),
1486 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1487 def : T2Pat<(zextloadi1 t2addrmode_negimm8:$addr),
1488 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1489 def : T2Pat<(zextloadi1 t2addrmode_so_reg:$addr),
1490 (t2LDRBs t2addrmode_so_reg:$addr)>;
1491 def : T2Pat<(zextloadi1 (ARMWrapper tconstpool:$addr)),
1492 (t2LDRBpci tconstpool:$addr)>;
1494 // extload -> zextload
1495 // FIXME: Reduce the number of patterns by legalizing extload to zextload
1497 def : T2Pat<(extloadi1 t2addrmode_imm12:$addr),
1498 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1499 def : T2Pat<(extloadi1 t2addrmode_negimm8:$addr),
1500 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1501 def : T2Pat<(extloadi1 t2addrmode_so_reg:$addr),
1502 (t2LDRBs t2addrmode_so_reg:$addr)>;
1503 def : T2Pat<(extloadi1 (ARMWrapper tconstpool:$addr)),
1504 (t2LDRBpci tconstpool:$addr)>;
1506 def : T2Pat<(extloadi8 t2addrmode_imm12:$addr),
1507 (t2LDRBi12 t2addrmode_imm12:$addr)>;
1508 def : T2Pat<(extloadi8 t2addrmode_negimm8:$addr),
1509 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
1510 def : T2Pat<(extloadi8 t2addrmode_so_reg:$addr),
1511 (t2LDRBs t2addrmode_so_reg:$addr)>;
1512 def : T2Pat<(extloadi8 (ARMWrapper tconstpool:$addr)),
1513 (t2LDRBpci tconstpool:$addr)>;
1515 def : T2Pat<(extloadi16 t2addrmode_imm12:$addr),
1516 (t2LDRHi12 t2addrmode_imm12:$addr)>;
1517 def : T2Pat<(extloadi16 t2addrmode_negimm8:$addr),
1518 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
1519 def : T2Pat<(extloadi16 t2addrmode_so_reg:$addr),
1520 (t2LDRHs t2addrmode_so_reg:$addr)>;
1521 def : T2Pat<(extloadi16 (ARMWrapper tconstpool:$addr)),
1522 (t2LDRHpci tconstpool:$addr)>;
1524 // FIXME: The destination register of the loads and stores can't be PC, but
1525 // can be SP. We need another regclass (similar to rGPR) to represent
1526 // that. Not a pressing issue since these are selected manually,
1531 let mayLoad = 1, hasSideEffects = 0 in {
1532 def t2LDR_PRE : T2Ipreldst<0, 0b10, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1533 (ins t2addrmode_imm8_pre:$addr),
1534 AddrModeT2_i8, IndexModePre, IIC_iLoad_iu,
1535 "ldr", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>,
1538 def t2LDR_POST : T2Ipostldst<0, 0b10, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1539 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1540 AddrModeT2_i8, IndexModePost, IIC_iLoad_iu,
1541 "ldr", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>,
1544 def t2LDRB_PRE : T2Ipreldst<0, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1545 (ins t2addrmode_imm8_pre:$addr),
1546 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1547 "ldrb", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>,
1550 def t2LDRB_POST : T2Ipostldst<0, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1551 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1552 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1553 "ldrb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>,
1556 def t2LDRH_PRE : T2Ipreldst<0, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1557 (ins t2addrmode_imm8_pre:$addr),
1558 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1559 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>,
1562 def t2LDRH_POST : T2Ipostldst<0, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1563 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1564 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1565 "ldrh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>,
1568 def t2LDRSB_PRE : T2Ipreldst<1, 0b00, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1569 (ins t2addrmode_imm8_pre:$addr),
1570 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1571 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1572 []>, Sched<[WriteLd]>;
1574 def t2LDRSB_POST : T2Ipostldst<1, 0b00, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1575 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1576 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1577 "ldrsb", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>,
1580 def t2LDRSH_PRE : T2Ipreldst<1, 0b01, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1581 (ins t2addrmode_imm8_pre:$addr),
1582 AddrModeT2_i8, IndexModePre, IIC_iLoad_bh_iu,
1583 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn_wb",
1584 []>, Sched<[WriteLd]>;
1586 def t2LDRSH_POST : T2Ipostldst<1, 0b01, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1587 (ins addr_offset_none:$Rn, t2am_imm8_offset:$offset),
1588 AddrModeT2_i8, IndexModePost, IIC_iLoad_bh_iu,
1589 "ldrsh", "\t$Rt, $Rn$offset", "$Rn = $Rn_wb", []>,
1591 } // mayLoad = 1, hasSideEffects = 0
1593 // F5.1.72 LDR (immediate) T4
1594 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1595 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1596 def t2LDR_PRE_imm : t2AsmPseudo<"ldr${p}.w $Rt, $addr!",
1597 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1598 def t2LDR_POST_imm : t2AsmPseudo<"ldr${p}.w $Rt, $Rn, $imm",
1599 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1601 // A7.7.46 LDRB (immediate) T3
1602 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1603 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1604 def t2LDRB_OFFSET_imm : t2AsmPseudo<"ldrb${p}.w $Rt, $addr",
1605 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1606 def t2LDRB_PRE_imm : t2AsmPseudo<"ldrb${p}.w $Rt, $addr!",
1607 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1608 def t2LDRB_POST_imm : t2AsmPseudo<"ldrb${p}.w $Rt, $Rn, $imm",
1609 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1611 // A7.7.55 LDRH (immediate) T3
1612 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1613 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1614 def t2LDRH_OFFSET_imm : t2AsmPseudo<"ldrh${p}.w $Rt, $addr",
1615 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1616 def t2LDRH_PRE_imm : t2AsmPseudo<"ldrh${p}.w $Rt, $addr!",
1617 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1618 def t2LDRH_POST_imm : t2AsmPseudo<"ldrh${p}.w $Rt, $Rn, $imm",
1619 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1621 // A7.7.59 LDRSB (immediate) T2
1622 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1623 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1624 def t2LDRSB_OFFSET_imm : t2AsmPseudo<"ldrsb${p}.w $Rt, $addr",
1625 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1626 def t2LDRSB_PRE_imm : t2AsmPseudo<"ldrsb${p}.w $Rt, $addr!",
1627 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1628 def t2LDRSB_POST_imm : t2AsmPseudo<"ldrsb${p}.w $Rt, $Rn, $imm",
1629 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1631 // A7.7.63 LDRSH (immediate) T2
1632 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1633 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1634 def t2LDRSH_OFFSET_imm : t2AsmPseudo<"ldrsh${p}.w $Rt, $addr",
1635 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1636 def t2LDRSH_PRE_imm : t2AsmPseudo<"ldrsh${p}.w $Rt, $addr!",
1637 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1638 def t2LDRSH_POST_imm : t2AsmPseudo<"ldrsh${p}.w $Rt, $Rn, $imm",
1639 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1641 // LDRT, LDRBT, LDRHT, LDRSBT, LDRSHT all have offset mode (PUW=0b110).
1642 // Ref: A8.6.57 LDR (immediate, Thumb) Encoding T4
1643 class T2IldT<bit signed, bits<2> type, string opc, InstrItinClass ii>
1644 : T2Ii8p<(outs rGPR:$Rt), (ins t2addrmode_posimm8:$addr), ii, opc,
1645 "\t$Rt, $addr", []>, Sched<[WriteLd]> {
1648 let Inst{31-27} = 0b11111;
1649 let Inst{26-25} = 0b00;
1650 let Inst{24} = signed;
1652 let Inst{22-21} = type;
1653 let Inst{20} = 1; // load
1654 let Inst{19-16} = addr{12-9};
1655 let Inst{15-12} = Rt;
1657 let Inst{10-8} = 0b110; // PUW.
1658 let Inst{7-0} = addr{7-0};
1660 let DecoderMethod = "DecodeT2LoadT";
1663 def t2LDRT : T2IldT<0, 0b10, "ldrt", IIC_iLoad_i>;
1664 def t2LDRBT : T2IldT<0, 0b00, "ldrbt", IIC_iLoad_bh_i>;
1665 def t2LDRHT : T2IldT<0, 0b01, "ldrht", IIC_iLoad_bh_i>;
1666 def t2LDRSBT : T2IldT<1, 0b00, "ldrsbt", IIC_iLoad_bh_i>;
1667 def t2LDRSHT : T2IldT<1, 0b01, "ldrsht", IIC_iLoad_bh_i>;
1669 class T2Ildacq<bits<4> bits23_20, bits<2> bit54, dag oops, dag iops,
1670 string opc, string asm, list<dag> pattern>
1671 : Thumb2I<oops, iops, AddrModeNone, 4, NoItinerary,
1672 opc, asm, "", pattern>, Requires<[IsThumb, HasAcquireRelease]> {
1676 let Inst{31-27} = 0b11101;
1677 let Inst{26-24} = 0b000;
1678 let Inst{23-20} = bits23_20;
1679 let Inst{11-6} = 0b111110;
1680 let Inst{5-4} = bit54;
1681 let Inst{3-0} = 0b1111;
1683 // Encode instruction operands
1684 let Inst{19-16} = addr;
1685 let Inst{15-12} = Rt;
1688 def t2LDA : T2Ildacq<0b1101, 0b10, (outs rGPR:$Rt),
1689 (ins addr_offset_none:$addr), "lda", "\t$Rt, $addr", []>,
1691 def t2LDAB : T2Ildacq<0b1101, 0b00, (outs rGPR:$Rt),
1692 (ins addr_offset_none:$addr), "ldab", "\t$Rt, $addr", []>,
1694 def t2LDAH : T2Ildacq<0b1101, 0b01, (outs rGPR:$Rt),
1695 (ins addr_offset_none:$addr), "ldah", "\t$Rt, $addr", []>,
1699 defm t2STR :T2I_st<0b10,"str", IIC_iStore_i, IIC_iStore_si, GPR, store>;
1700 defm t2STRB:T2I_st<0b00,"strb", IIC_iStore_bh_i, IIC_iStore_bh_si,
1701 rGPR, truncstorei8>;
1702 defm t2STRH:T2I_st<0b01,"strh", IIC_iStore_bh_i, IIC_iStore_bh_si,
1703 rGPR, truncstorei16>;
1706 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in
1707 def t2STRDi8 : T2Ii8s4<1, 0, 0, (outs),
1708 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr),
1709 IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", "",
1710 [(ARMstrd rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4:$addr)]>,
1715 let mayStore = 1, hasSideEffects = 0 in {
1716 def t2STR_PRE : T2Ipreldst<0, 0b10, 0, 1, (outs GPRnopc:$Rn_wb),
1717 (ins GPRnopc:$Rt, t2addrmode_imm8_pre:$addr),
1718 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1719 "str", "\t$Rt, $addr!",
1720 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []>,
1723 def t2STRH_PRE : T2Ipreldst<0, 0b01, 0, 1, (outs GPRnopc:$Rn_wb),
1724 (ins rGPR:$Rt, t2addrmode_imm8_pre:$addr),
1725 AddrModeT2_i8, IndexModePre, IIC_iStore_iu,
1726 "strh", "\t$Rt, $addr!",
1727 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []>,
1730 def t2STRB_PRE : T2Ipreldst<0, 0b00, 0, 1, (outs GPRnopc:$Rn_wb),
1731 (ins rGPR:$Rt, t2addrmode_imm8_pre:$addr),
1732 AddrModeT2_i8, IndexModePre, IIC_iStore_bh_iu,
1733 "strb", "\t$Rt, $addr!",
1734 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []>,
1736 } // mayStore = 1, hasSideEffects = 0
1738 def t2STR_POST : T2Ipostldst<0, 0b10, 0, 0, (outs GPRnopc:$Rn_wb),
1739 (ins GPRnopc:$Rt, addr_offset_none:$Rn,
1740 t2am_imm8_offset:$offset),
1741 AddrModeT2_i8, IndexModePost, IIC_iStore_iu,
1742 "str", "\t$Rt, $Rn$offset",
1743 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1744 [(set GPRnopc:$Rn_wb,
1745 (post_store GPRnopc:$Rt, addr_offset_none:$Rn,
1746 t2am_imm8_offset:$offset))]>,
1749 def t2STRH_POST : T2Ipostldst<0, 0b01, 0, 0, (outs GPRnopc:$Rn_wb),
1750 (ins rGPR:$Rt, addr_offset_none:$Rn,
1751 t2am_imm8_offset:$offset),
1752 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1753 "strh", "\t$Rt, $Rn$offset",
1754 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1755 [(set GPRnopc:$Rn_wb,
1756 (post_truncsti16 rGPR:$Rt, addr_offset_none:$Rn,
1757 t2am_imm8_offset:$offset))]>,
1760 def t2STRB_POST : T2Ipostldst<0, 0b00, 0, 0, (outs GPRnopc:$Rn_wb),
1761 (ins rGPR:$Rt, addr_offset_none:$Rn,
1762 t2am_imm8_offset:$offset),
1763 AddrModeT2_i8, IndexModePost, IIC_iStore_bh_iu,
1764 "strb", "\t$Rt, $Rn$offset",
1765 "$Rn = $Rn_wb,@earlyclobber $Rn_wb",
1766 [(set GPRnopc:$Rn_wb,
1767 (post_truncsti8 rGPR:$Rt, addr_offset_none:$Rn,
1768 t2am_imm8_offset:$offset))]>,
1771 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
1772 // put the patterns on the instruction definitions directly as ISel wants
1773 // the address base and offset to be separate operands, not a single
1774 // complex operand like we represent the instructions themselves. The
1775 // pseudos map between the two.
1776 let usesCustomInserter = 1,
1777 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
1778 def t2STR_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1779 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1781 [(set GPRnopc:$Rn_wb,
1782 (pre_store rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>,
1784 def t2STRB_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1785 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1787 [(set GPRnopc:$Rn_wb,
1788 (pre_truncsti8 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>,
1790 def t2STRH_preidx: t2PseudoInst<(outs GPRnopc:$Rn_wb),
1791 (ins rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset, pred:$p),
1793 [(set GPRnopc:$Rn_wb,
1794 (pre_truncsti16 rGPR:$Rt, GPRnopc:$Rn, t2am_imm8_offset:$offset))]>,
1798 let mayStore = 1, hasSideEffects = 0 in {
1800 // F5.1.229 STR (immediate) T4
1801 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1802 // "$Rn = $Rn_wb,@earlyclobber $Rn_wb" on POST or
1803 // "$addr.base = $Rn_wb,@earlyclobber $Rn_wb" on PRE.
1804 def t2STR_PRE_imm : t2AsmPseudo<"str${p}.w $Rt, $addr!",
1805 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1806 def t2STR_POST_imm : t2AsmPseudo<"str${p}.w $Rt, $Rn, $imm",
1807 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1809 // A7.7.163 STRB (immediate) T3
1810 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1811 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1812 def t2STRB_OFFSET_imm : t2AsmPseudo<"strb${p}.w $Rt, $addr",
1813 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1814 def t2STRB_PRE_imm : t2AsmPseudo<"strb${p}.w $Rt, $addr!",
1815 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1816 def t2STRB_POST_imm : t2AsmPseudo<"strb${p}.w $Rt, $Rn, $imm",
1817 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1819 // A7.7.170 STRH (immediate) T3
1820 // .w suffixes; Constraints can't be used on t2InstAlias to describe
1821 // "$Rn = $Rn_wb" on POST or "$addr.base = $Rn_wb" on PRE.
1822 def t2STRH_OFFSET_imm : t2AsmPseudo<"strh${p}.w $Rt, $addr",
1823 (ins GPR:$Rt, t2addrmode_negimm8:$addr, pred:$p)>;
1824 def t2STRH_PRE_imm : t2AsmPseudo<"strh${p}.w $Rt, $addr!",
1825 (ins GPR:$Rt, t2addrmode_imm8_pre:$addr, pred:$p)>;
1826 def t2STRH_POST_imm : t2AsmPseudo<"strh${p}.w $Rt, $Rn, $imm",
1827 (ins GPR:$Rt, addr_offset_none:$Rn, t2am_imm8_offset:$imm, pred:$p)>;
1829 // STRT, STRBT, STRHT all have offset mode (PUW=0b110) and are for disassembly
1831 // Ref: A8.6.193 STR (immediate, Thumb) Encoding T4
1832 class T2IstT<bits<2> type, string opc, InstrItinClass ii>
1833 : T2Ii8p<(outs), (ins rGPR:$Rt, t2addrmode_posimm8:$addr), ii, opc,
1834 "\t$Rt, $addr", []>, Sched<[WriteST]> {
1835 let Inst{31-27} = 0b11111;
1836 let Inst{26-25} = 0b00;
1837 let Inst{24} = 0; // not signed
1839 let Inst{22-21} = type;
1840 let Inst{20} = 0; // store
1842 let Inst{10-8} = 0b110; // PUW
1846 let Inst{15-12} = Rt;
1847 let Inst{19-16} = addr{12-9};
1848 let Inst{7-0} = addr{7-0};
1851 def t2STRT : T2IstT<0b10, "strt", IIC_iStore_i>;
1852 def t2STRBT : T2IstT<0b00, "strbt", IIC_iStore_bh_i>;
1853 def t2STRHT : T2IstT<0b01, "strht", IIC_iStore_bh_i>;
1855 } // mayStore = 1, hasSideEffects = 0
1857 // ldrd / strd pre / post variants
1859 let mayLoad = 1, hasSideEffects = 0 in
1860 def t2LDRD_PRE : T2Ii8s4<1, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1861 (ins t2addrmode_imm8s4_pre:$addr), IIC_iLoad_d_ru,
1862 "ldrd", "\t$Rt, $Rt2, $addr!", "$addr.base = $wb", []>,
1864 let DecoderMethod = "DecodeT2LDRDPreInstruction";
1867 let mayLoad = 1, hasSideEffects = 0 in
1868 def t2LDRD_POST : T2Ii8s4post<0, 1, 1, (outs rGPR:$Rt, rGPR:$Rt2, GPR:$wb),
1869 (ins addr_offset_none:$addr, t2am_imm8s4_offset:$imm),
1870 IIC_iLoad_d_ru, "ldrd", "\t$Rt, $Rt2, $addr$imm",
1871 "$addr.base = $wb", []>, Sched<[WriteLd]>;
1873 let mayStore = 1, hasSideEffects = 0 in
1874 def t2STRD_PRE : T2Ii8s4<1, 1, 0, (outs GPR:$wb),
1875 (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_imm8s4_pre:$addr),
1876 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr!",
1877 "$addr.base = $wb", []>, Sched<[WriteST]> {
1878 let DecoderMethod = "DecodeT2STRDPreInstruction";
1881 let mayStore = 1, hasSideEffects = 0 in
1882 def t2STRD_POST : T2Ii8s4post<0, 1, 0, (outs GPR:$wb),
1883 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr,
1884 t2am_imm8s4_offset:$imm),
1885 IIC_iStore_d_ru, "strd", "\t$Rt, $Rt2, $addr$imm",
1886 "$addr.base = $wb", []>, Sched<[WriteST]>;
1888 class T2Istrrel<bits<2> bit54, dag oops, dag iops,
1889 string opc, string asm, list<dag> pattern>
1890 : Thumb2I<oops, iops, AddrModeNone, 4, NoItinerary, opc,
1891 asm, "", pattern>, Requires<[IsThumb, HasAcquireRelease]>,
1896 let Inst{31-27} = 0b11101;
1897 let Inst{26-20} = 0b0001100;
1898 let Inst{11-6} = 0b111110;
1899 let Inst{5-4} = bit54;
1900 let Inst{3-0} = 0b1111;
1902 // Encode instruction operands
1903 let Inst{19-16} = addr;
1904 let Inst{15-12} = Rt;
1907 def t2STL : T2Istrrel<0b10, (outs), (ins rGPR:$Rt, addr_offset_none:$addr),
1908 "stl", "\t$Rt, $addr", []>;
1909 def t2STLB : T2Istrrel<0b00, (outs), (ins rGPR:$Rt, addr_offset_none:$addr),
1910 "stlb", "\t$Rt, $addr", []>;
1911 def t2STLH : T2Istrrel<0b01, (outs), (ins rGPR:$Rt, addr_offset_none:$addr),
1912 "stlh", "\t$Rt, $addr", []>;
1914 // T2Ipl (Preload Data/Instruction) signals the memory system of possible future
1915 // data/instruction access.
1916 // instr_write is inverted for Thumb mode: (prefetch 3) -> (preload 0),
1917 // (prefetch 1) -> (preload 2), (prefetch 2) -> (preload 1).
1918 multiclass T2Ipl<bits<1> write, bits<1> instr, string opc> {
1920 def i12 : T2Ii12<(outs), (ins t2addrmode_imm12:$addr), IIC_Preload, opc,
1922 [(ARMPreload t2addrmode_imm12:$addr, (i32 write), (i32 instr))]>,
1923 Sched<[WritePreLd]> {
1924 let Inst{31-25} = 0b1111100;
1925 let Inst{24} = instr;
1928 let Inst{21} = write;
1930 let Inst{15-12} = 0b1111;
1933 let Inst{19-16} = addr{16-13}; // Rn
1934 let Inst{11-0} = addr{11-0}; // imm12
1936 let DecoderMethod = "DecodeT2LoadImm12";
1939 def i8 : T2Ii8n<(outs), (ins t2addrmode_negimm8:$addr), IIC_Preload, opc,
1941 [(ARMPreload t2addrmode_negimm8:$addr, (i32 write), (i32 instr))]>,
1942 Sched<[WritePreLd]> {
1943 let Inst{31-25} = 0b1111100;
1944 let Inst{24} = instr;
1945 let Inst{23} = 0; // U = 0
1947 let Inst{21} = write;
1949 let Inst{15-12} = 0b1111;
1950 let Inst{11-8} = 0b1100;
1953 let Inst{19-16} = addr{12-9}; // Rn
1954 let Inst{7-0} = addr{7-0}; // imm8
1956 let DecoderMethod = "DecodeT2LoadImm8";
1959 def s : T2Iso<(outs), (ins t2addrmode_so_reg:$addr), IIC_Preload, opc,
1961 [(ARMPreload t2addrmode_so_reg:$addr, (i32 write), (i32 instr))]>,
1962 Sched<[WritePreLd]> {
1963 let Inst{31-25} = 0b1111100;
1964 let Inst{24} = instr;
1965 let Inst{23} = 0; // add = TRUE for T1
1967 let Inst{21} = write;
1969 let Inst{15-12} = 0b1111;
1970 let Inst{11-6} = 0b000000;
1973 let Inst{19-16} = addr{9-6}; // Rn
1974 let Inst{3-0} = addr{5-2}; // Rm
1975 let Inst{5-4} = addr{1-0}; // imm2
1977 let DecoderMethod = "DecodeT2LoadShift";
1981 defm t2PLD : T2Ipl<0, 0, "pld">, Requires<[IsThumb2]>;
1982 defm t2PLDW : T2Ipl<1, 0, "pldw">, Requires<[IsThumb2,HasV7,HasMP]>;
1983 defm t2PLI : T2Ipl<0, 1, "pli">, Requires<[IsThumb2,HasV7]>;
1985 // PLD/PLDW/PLI aliases w/ the optional .w suffix
1986 def : t2InstAlias<"pld${p}.w\t$addr",
1987 (t2PLDi12 t2addrmode_imm12:$addr, pred:$p)>;
1988 def : t2InstAlias<"pld${p}.w\t$addr",
1989 (t2PLDi8 t2addrmode_negimm8:$addr, pred:$p)>;
1990 def : t2InstAlias<"pld${p}.w\t$addr",
1991 (t2PLDs t2addrmode_so_reg:$addr, pred:$p)>;
1993 def : InstAlias<"pldw${p}.w\t$addr",
1994 (t2PLDWi12 t2addrmode_imm12:$addr, pred:$p), 0>,
1995 Requires<[IsThumb2,HasV7,HasMP]>;
1996 def : InstAlias<"pldw${p}.w\t$addr",
1997 (t2PLDWi8 t2addrmode_negimm8:$addr, pred:$p), 0>,
1998 Requires<[IsThumb2,HasV7,HasMP]>;
1999 def : InstAlias<"pldw${p}.w\t$addr",
2000 (t2PLDWs t2addrmode_so_reg:$addr, pred:$p), 0>,
2001 Requires<[IsThumb2,HasV7,HasMP]>;
2003 def : InstAlias<"pli${p}.w\t$addr",
2004 (t2PLIi12 t2addrmode_imm12:$addr, pred:$p), 0>,
2005 Requires<[IsThumb2,HasV7]>;
2006 def : InstAlias<"pli${p}.w\t$addr",
2007 (t2PLIi8 t2addrmode_negimm8:$addr, pred:$p), 0>,
2008 Requires<[IsThumb2,HasV7]>;
2009 def : InstAlias<"pli${p}.w\t$addr",
2010 (t2PLIs t2addrmode_so_reg:$addr, pred:$p), 0>,
2011 Requires<[IsThumb2,HasV7]>;
2013 // pci variant is very similar to i12, but supports negative offsets
2014 // from the PC. Only PLD and PLI have pci variants (not PLDW)
2015 class T2Iplpci<bits<1> inst, string opc> : T2Ipc<(outs), (ins t2ldrlabel:$addr),
2016 IIC_Preload, opc, "\t$addr",
2017 [(ARMPreload (ARMWrapper tconstpool:$addr),
2018 (i32 0), (i32 inst))]>, Sched<[WritePreLd]> {
2019 let Inst{31-25} = 0b1111100;
2020 let Inst{24} = inst;
2021 let Inst{22-20} = 0b001;
2022 let Inst{19-16} = 0b1111;
2023 let Inst{15-12} = 0b1111;
2026 let Inst{23} = addr{12}; // add = (U == '1')
2027 let Inst{11-0} = addr{11-0}; // imm12
2029 let DecoderMethod = "DecodeT2LoadLabel";
2032 def t2PLDpci : T2Iplpci<0, "pld">, Requires<[IsThumb2]>;
2033 def t2PLIpci : T2Iplpci<1, "pli">, Requires<[IsThumb2,HasV7]>;
2035 def : t2InstAlias<"pld${p}.w $addr",
2036 (t2PLDpci t2ldrlabel:$addr, pred:$p)>;
2037 def : InstAlias<"pli${p}.w $addr",
2038 (t2PLIpci t2ldrlabel:$addr, pred:$p), 0>,
2039 Requires<[IsThumb2,HasV7]>;
2041 // PLD/PLI with alternate literal form.
2042 def : t2InstAlias<"pld${p} $addr",
2043 (t2PLDpci t2ldr_pcrel_imm12:$addr, pred:$p)>;
2044 def : InstAlias<"pli${p} $addr",
2045 (t2PLIpci t2ldr_pcrel_imm12:$addr, pred:$p), 0>,
2046 Requires<[IsThumb2,HasV7]>;
2047 def : t2InstAlias<"pld${p}.w $addr",
2048 (t2PLDpci t2ldr_pcrel_imm12:$addr, pred:$p)>;
2049 def : InstAlias<"pli${p}.w $addr",
2050 (t2PLIpci t2ldr_pcrel_imm12:$addr, pred:$p), 0>,
2051 Requires<[IsThumb2,HasV7]>;
2053 //===----------------------------------------------------------------------===//
2054 // Load / store multiple Instructions.
2057 multiclass thumb2_ld_mult<string asm, InstrItinClass itin,
2058 InstrItinClass itin_upd, bit L_bit> {
2060 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2061 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
2065 let Inst{31-27} = 0b11101;
2066 let Inst{26-25} = 0b00;
2067 let Inst{24-23} = 0b01; // Increment After
2069 let Inst{21} = 0; // No writeback
2070 let Inst{20} = L_bit;
2071 let Inst{19-16} = Rn;
2072 let Inst{15-0} = regs;
2075 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2076 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
2080 let Inst{31-27} = 0b11101;
2081 let Inst{26-25} = 0b00;
2082 let Inst{24-23} = 0b01; // Increment After
2084 let Inst{21} = 1; // Writeback
2085 let Inst{20} = L_bit;
2086 let Inst{19-16} = Rn;
2087 let Inst{15-0} = regs;
2090 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2091 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
2095 let Inst{31-27} = 0b11101;
2096 let Inst{26-25} = 0b00;
2097 let Inst{24-23} = 0b10; // Decrement Before
2099 let Inst{21} = 0; // No writeback
2100 let Inst{20} = L_bit;
2101 let Inst{19-16} = Rn;
2102 let Inst{15-0} = regs;
2105 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2106 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2110 let Inst{31-27} = 0b11101;
2111 let Inst{26-25} = 0b00;
2112 let Inst{24-23} = 0b10; // Decrement Before
2114 let Inst{21} = 1; // Writeback
2115 let Inst{20} = L_bit;
2116 let Inst{19-16} = Rn;
2117 let Inst{15-0} = regs;
2121 let hasSideEffects = 0 in {
2123 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
2124 defm t2LDM : thumb2_ld_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, 1>;
2126 multiclass thumb2_st_mult<string asm, InstrItinClass itin,
2127 InstrItinClass itin_upd, bit L_bit> {
2129 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2130 itin, !strconcat(asm, "${p}.w\t$Rn, $regs"), []> {
2134 let Inst{31-27} = 0b11101;
2135 let Inst{26-25} = 0b00;
2136 let Inst{24-23} = 0b01; // Increment After
2138 let Inst{21} = 0; // No writeback
2139 let Inst{20} = L_bit;
2140 let Inst{19-16} = Rn;
2142 let Inst{14} = regs{14};
2144 let Inst{12-0} = regs{12-0};
2147 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2148 itin_upd, !strconcat(asm, "${p}.w\t$Rn!, $regs"), "$Rn = $wb", []> {
2152 let Inst{31-27} = 0b11101;
2153 let Inst{26-25} = 0b00;
2154 let Inst{24-23} = 0b01; // Increment After
2156 let Inst{21} = 1; // Writeback
2157 let Inst{20} = L_bit;
2158 let Inst{19-16} = Rn;
2160 let Inst{14} = regs{14};
2162 let Inst{12-0} = regs{12-0};
2165 T2XI<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2166 itin, !strconcat(asm, "db${p}\t$Rn, $regs"), []> {
2170 let Inst{31-27} = 0b11101;
2171 let Inst{26-25} = 0b00;
2172 let Inst{24-23} = 0b10; // Decrement Before
2174 let Inst{21} = 0; // No writeback
2175 let Inst{20} = L_bit;
2176 let Inst{19-16} = Rn;
2178 let Inst{14} = regs{14};
2180 let Inst{12-0} = regs{12-0};
2183 T2XIt<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2184 itin_upd, !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2188 let Inst{31-27} = 0b11101;
2189 let Inst{26-25} = 0b00;
2190 let Inst{24-23} = 0b10; // Decrement Before
2192 let Inst{21} = 1; // Writeback
2193 let Inst{20} = L_bit;
2194 let Inst{19-16} = Rn;
2196 let Inst{14} = regs{14};
2198 let Inst{12-0} = regs{12-0};
2203 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2204 defm t2STM : thumb2_st_mult<"stm", IIC_iStore_m, IIC_iStore_mu, 0>;
2209 //===----------------------------------------------------------------------===//
2210 // Move Instructions.
2213 let hasSideEffects = 0 in
2214 def t2MOVr : T2sTwoReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rm), IIC_iMOVr,
2215 "mov", ".w\t$Rd, $Rm", []>, Sched<[WriteALU]> {
2216 let Inst{31-27} = 0b11101;
2217 let Inst{26-25} = 0b01;
2218 let Inst{24-21} = 0b0010;
2219 let Inst{19-16} = 0b1111; // Rn
2221 let Inst{14-12} = 0b000;
2222 let Inst{7-4} = 0b0000;
2224 def : t2InstAlias<"mov${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm,
2225 pred:$p, zero_reg)>;
2226 def : t2InstAlias<"movs${p}.w $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm,
2228 def : t2InstAlias<"movs${p} $Rd, $Rm", (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm,
2231 // AddedComplexity to ensure isel tries t2MOVi before t2MOVi16.
2232 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1,
2233 AddedComplexity = 1 in
2234 def t2MOVi : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), IIC_iMOVi,
2235 "mov", ".w\t$Rd, $imm",
2236 [(set rGPR:$Rd, t2_so_imm:$imm)]>, Sched<[WriteALU]> {
2237 let Inst{31-27} = 0b11110;
2239 let Inst{24-21} = 0b0010;
2240 let Inst{19-16} = 0b1111; // Rn
2244 // cc_out is handled as part of the explicit mnemonic in the parser for 'mov'.
2245 // Use aliases to get that to play nice here.
2246 def : t2InstAlias<"movs${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
2248 def : t2InstAlias<"movs${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
2251 def : t2InstAlias<"mov${p}.w $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
2252 pred:$p, zero_reg)>;
2253 def : t2InstAlias<"mov${p} $Rd, $imm", (t2MOVi rGPR:$Rd, t2_so_imm:$imm,
2254 pred:$p, zero_reg)>;
2256 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2257 def t2MOVi16 : T2I<(outs rGPR:$Rd), (ins imm0_65535_expr:$imm), IIC_iMOVi,
2258 "movw", "\t$Rd, $imm",
2259 [(set rGPR:$Rd, imm0_65535:$imm)]>, Sched<[WriteALU]>,
2260 Requires<[IsThumb, HasV8MBaseline]> {
2261 let Inst{31-27} = 0b11110;
2263 let Inst{24-21} = 0b0010;
2264 let Inst{20} = 0; // The S bit.
2270 let Inst{11-8} = Rd;
2271 let Inst{19-16} = imm{15-12};
2272 let Inst{26} = imm{11};
2273 let Inst{14-12} = imm{10-8};
2274 let Inst{7-0} = imm{7-0};
2275 let DecoderMethod = "DecodeT2MOVTWInstruction";
2278 def : InstAlias<"mov${p} $Rd, $imm",
2279 (t2MOVi16 rGPR:$Rd, imm256_65535_expr:$imm, pred:$p), 0>,
2280 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteALU]>;
2282 // This gets lowered to a single 4-byte instructions
2284 def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
2285 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
2288 let Constraints = "$src = $Rd" in {
2289 def t2MOVTi16 : T2I<(outs rGPR:$Rd),
2290 (ins rGPR:$src, imm0_65535_expr:$imm), IIC_iMOVi,
2291 "movt", "\t$Rd, $imm",
2293 (or (and rGPR:$src, 0xffff), lo16AllZero:$imm))]>,
2295 Requires<[IsThumb, HasV8MBaseline]> {
2296 let Inst{31-27} = 0b11110;
2298 let Inst{24-21} = 0b0110;
2299 let Inst{20} = 0; // The S bit.
2305 let Inst{11-8} = Rd;
2306 let Inst{19-16} = imm{15-12};
2307 let Inst{26} = imm{11};
2308 let Inst{14-12} = imm{10-8};
2309 let Inst{7-0} = imm{7-0};
2310 let DecoderMethod = "DecodeT2MOVTWInstruction";
2313 // This gets lowered to a single 4-byte instructions
2315 def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd),
2316 (ins rGPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
2317 Sched<[WriteALU]>, Requires<[IsThumb, HasV8MBaseline]>;
2320 def : T2Pat<(or rGPR:$src, 0xffff0000), (t2MOVTi16 rGPR:$src, 0xffff)>;
2322 //===----------------------------------------------------------------------===//
2323 // Extend Instructions.
2328 def t2SXTB : T2I_ext_rrot<0b100, "sxtb">;
2329 def t2SXTH : T2I_ext_rrot<0b000, "sxth">;
2330 def t2SXTB16 : T2I_ext_rrot_xtb16<0b010, "sxtb16">;
2332 def t2SXTAB : T2I_exta_rrot<0b100, "sxtab">;
2333 def t2SXTAH : T2I_exta_rrot<0b000, "sxtah">;
2334 def t2SXTAB16 : T2I_exta_rrot<0b010, "sxtab16">;
2336 def : T2Pat<(sext_inreg (rotr rGPR:$Rn, rot_imm:$rot), i8),
2337 (t2SXTB rGPR:$Rn, rot_imm:$rot)>;
2338 def : T2Pat<(sext_inreg (rotr rGPR:$Rn, rot_imm:$rot), i16),
2339 (t2SXTH rGPR:$Rn, rot_imm:$rot)>;
2340 def : Thumb2DSPPat<(add rGPR:$Rn,
2341 (sext_inreg (rotr rGPR:$Rm, rot_imm:$rot), i8)),
2342 (t2SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2343 def : Thumb2DSPPat<(add rGPR:$Rn,
2344 (sext_inreg (rotr rGPR:$Rm, rot_imm:$rot), i16)),
2345 (t2SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2346 def : Thumb2DSPPat<(int_arm_sxtb16 rGPR:$Rn),
2347 (t2SXTB16 rGPR:$Rn, 0)>;
2348 def : Thumb2DSPPat<(int_arm_sxtab16 rGPR:$Rn, rGPR:$Rm),
2349 (t2SXTAB16 rGPR:$Rn, rGPR:$Rm, 0)>;
2350 def : Thumb2DSPPat<(int_arm_sxtb16 (rotr rGPR:$Rn, rot_imm:$rot)),
2351 (t2SXTB16 rGPR:$Rn, rot_imm:$rot)>;
2352 def : Thumb2DSPPat<(int_arm_sxtab16 rGPR:$Rn, (rotr rGPR:$Rm, rot_imm:$rot)),
2353 (t2SXTAB16 rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2356 // A simple right-shift can also be used in most cases (the exception is the
2357 // SXTH operations with a rotate of 24: there the non-contiguous bits are
2359 def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg
2360 (srl rGPR:$Rm, rot_imm:$rot), i8)),
2361 (t2SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2362 def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg
2363 (srl rGPR:$Rm, imm8_or_16:$rot), i16)),
2364 (t2SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2365 def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg
2366 (rotr rGPR:$Rm, (i32 24)), i16)),
2367 (t2SXTAH rGPR:$Rn, rGPR:$Rm, (i32 3))>;
2368 def : Thumb2DSPPat<(add rGPR:$Rn, (sext_inreg
2369 (or (srl rGPR:$Rm, (i32 24)),
2370 (shl rGPR:$Rm, (i32 8))), i16)),
2371 (t2SXTAH rGPR:$Rn, rGPR:$Rm, (i32 3))>;
2375 let AddedComplexity = 16 in {
2376 def t2UXTB : T2I_ext_rrot<0b101, "uxtb">;
2377 def t2UXTH : T2I_ext_rrot<0b001, "uxth">;
2378 def t2UXTB16 : T2I_ext_rrot_xtb16<0b011, "uxtb16">;
2380 def : Thumb2DSPPat<(and (rotr rGPR:$Rm, rot_imm:$rot), 0x000000FF),
2381 (t2UXTB rGPR:$Rm, rot_imm:$rot)>;
2382 def : Thumb2DSPPat<(and (rotr rGPR:$Rm, rot_imm:$rot), 0x0000FFFF),
2383 (t2UXTH rGPR:$Rm, rot_imm:$rot)>;
2384 def : Thumb2DSPPat<(and (rotr rGPR:$Rm, rot_imm:$rot), 0x00FF00FF),
2385 (t2UXTB16 rGPR:$Rm, rot_imm:$rot)>;
2387 def : Thumb2DSPPat<(int_arm_uxtb16 rGPR:$Rm),
2388 (t2UXTB16 rGPR:$Rm, 0)>;
2389 def : Thumb2DSPPat<(int_arm_uxtb16 (rotr rGPR:$Rn, rot_imm:$rot)),
2390 (t2UXTB16 rGPR:$Rn, rot_imm:$rot)>;
2392 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
2393 // The transformation should probably be done as a combiner action
2394 // instead so we can include a check for masking back in the upper
2395 // eight bits of the source into the lower eight bits of the result.
2396 //def : T2Pat<(and (shl rGPR:$Src, (i32 8)), 0xFF00FF),
2397 // (t2UXTB16 rGPR:$Src, 3)>,
2398 // Requires<[HasDSP, IsThumb2]>;
2399 def : T2Pat<(and (srl rGPR:$Src, (i32 8)), 0xFF00FF),
2400 (t2UXTB16 rGPR:$Src, 1)>,
2401 Requires<[HasDSP, IsThumb2]>;
2403 def t2UXTAB : T2I_exta_rrot<0b101, "uxtab">;
2404 def t2UXTAH : T2I_exta_rrot<0b001, "uxtah">;
2405 def t2UXTAB16 : T2I_exta_rrot<0b011, "uxtab16">;
2407 def : Thumb2DSPPat<(add rGPR:$Rn, (and (rotr rGPR:$Rm, rot_imm:$rot),
2409 (t2UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2410 def : Thumb2DSPPat<(add rGPR:$Rn, (and (rotr rGPR:$Rm, rot_imm:$rot),
2412 (t2UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2413 def : Thumb2DSPPat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot),
2415 (t2UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2416 def : Thumb2DSPPat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot),
2418 (t2UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2419 def : Thumb2DSPPat<(int_arm_uxtab16 rGPR:$Rn, rGPR:$Rm),
2420 (t2UXTAB16 rGPR:$Rn, rGPR:$Rm, 0)>;
2421 def : Thumb2DSPPat<(int_arm_uxtab16 rGPR:$Rn, (rotr rGPR:$Rm, rot_imm:$rot)),
2422 (t2UXTAB16 rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
2426 //===----------------------------------------------------------------------===//
2427 // Arithmetic Instructions.
2431 defm t2ADD : T2I_bin_ii12rs<0b000, "add", add, 1>;
2432 defm t2SUB : T2I_bin_ii12rs<0b101, "sub", sub>;
2434 // ADD and SUB with 's' bit set. No 12-bit immediate (T4) variants.
2436 // Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the
2437 // selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by
2438 // AdjustInstrPostInstrSelection where we determine whether or not to
2439 // set the "s" bit based on CPSR liveness.
2441 // FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen
2442 // support for an optional CPSR definition that corresponds to the DAG
2443 // node's second value. We can then eliminate the implicit def of CPSR.
2444 defm t2ADDS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi, ARMaddc, 1>;
2445 defm t2SUBS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi, ARMsubc>;
2447 defm t2ADC : T2I_adde_sube_irs<0b1010, "adc", ARMadde, 1, 1>;
2448 defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc", ARMsube, 0, 1>;
2450 def : t2InstSubst<"adc${s}${p} $rd, $rn, $imm",
2451 (t2SBCri rGPR:$rd, rGPR:$rn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>;
2452 def : t2InstSubst<"adc${s}${p} $rdn, $imm",
2453 (t2SBCri rGPR:$rdn, rGPR:$rdn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>;
2454 def : t2InstSubst<"sbc${s}${p} $rd, $rn, $imm",
2455 (t2ADCri rGPR:$rd, rGPR:$rn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>;
2456 def : t2InstSubst<"sbc${s}${p} $rdn, $imm",
2457 (t2ADCri rGPR:$rdn, rGPR:$rdn, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>;
2459 def : t2InstSubst<"add${s}${p}.w $rd, $rn, $imm",
2460 (t2SUBri rGPR:$rd, GPRnopc:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>;
2461 def : t2InstSubst<"sub${s}${p}.w $rd, $rn, $imm",
2462 (t2ADDri rGPR:$rd, GPRnopc:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>;
2463 def : t2InstSubst<"subw${p} $Rd, $Rn, $imm",
2464 (t2ADDri12 rGPR:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
2465 def : t2InstSubst<"sub${s}${p} $rd, $rn, $imm",
2466 (t2ADDri rGPR:$rd, GPRnopc:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>;
2467 def : t2InstSubst<"sub${p} $rd, $rn, $imm",
2468 (t2ADDri12 rGPR:$rd, GPR:$rn, imm0_4095_neg:$imm, pred:$p)>;
2471 def : t2InstSubst<"add${s}${p}.w $rd, $rn, $imm",
2472 (t2SUBspImm GPRsp:$rd, GPRsp:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>;
2473 def : t2InstSubst<"sub${s}${p}.w $rd, $rn, $imm",
2474 (t2ADDspImm GPRsp:$rd, GPRsp:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>;
2475 def : t2InstSubst<"subw${p} $Rd, $Rn, $imm",
2476 (t2ADDspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095_neg:$imm, pred:$p)>;
2477 def : t2InstSubst<"sub${s}${p} $rd, $rn, $imm",
2478 (t2ADDspImm GPRsp:$rd, GPRsp:$rn, t2_so_imm_neg:$imm, pred:$p, s_cc_out:$s)>;
2479 def : t2InstSubst<"sub${p} $rd, $rn, $imm",
2480 (t2ADDspImm12 GPRsp:$rd, GPRsp:$rn, imm0_4095_neg:$imm, pred:$p)>;
2484 defm t2RSB : T2I_rbin_irs <0b1110, "rsb", sub>;
2486 // FIXME: Eliminate them if we can write def : Pat patterns which defines
2487 // CPSR and the implicit def of CPSR is not needed.
2488 defm t2RSBS : T2I_rbin_s_is <ARMsubc>;
2490 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
2491 // The assume-no-carry-in form uses the negation of the input since add/sub
2492 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
2493 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
2495 // The AddedComplexity preferences the first variant over the others since
2496 // it can be shrunk to a 16-bit wide encoding, while the others cannot.
2497 let AddedComplexity = 1 in
2498 def : T2Pat<(add rGPR:$src, imm1_255_neg:$imm),
2499 (t2SUBri rGPR:$src, imm1_255_neg:$imm)>;
2500 def : T2Pat<(add rGPR:$src, t2_so_imm_neg:$imm),
2501 (t2SUBri rGPR:$src, t2_so_imm_neg:$imm)>;
2502 def : T2Pat<(add rGPR:$src, imm0_4095_neg:$imm),
2503 (t2SUBri12 rGPR:$src, imm0_4095_neg:$imm)>;
2504 def : T2Pat<(add GPR:$src, imm0_65535_neg:$imm),
2505 (t2SUBrr GPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
2507 // Do the same for v8m targets since they support movw with a 16-bit value.
2508 def : T1Pat<(add tGPR:$src, imm0_65535_neg:$imm),
2509 (tSUBrr tGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>,
2510 Requires<[HasV8MBaseline]>;
2512 let AddedComplexity = 1 in
2513 def : T2Pat<(ARMaddc rGPR:$src, imm1_255_neg:$imm),
2514 (t2SUBSri rGPR:$src, imm1_255_neg:$imm)>;
2515 def : T2Pat<(ARMaddc rGPR:$src, t2_so_imm_neg:$imm),
2516 (t2SUBSri rGPR:$src, t2_so_imm_neg:$imm)>;
2517 def : T2Pat<(ARMaddc rGPR:$src, imm0_65535_neg:$imm),
2518 (t2SUBSrr rGPR:$src, (t2MOVi16 (imm_neg_XFORM imm:$imm)))>;
2519 // The with-carry-in form matches bitwise not instead of the negation.
2520 // Effectively, the inverse interpretation of the carry flag already accounts
2521 // for part of the negation.
2522 let AddedComplexity = 1 in
2523 def : T2Pat<(ARMadde rGPR:$src, imm0_255_not:$imm, CPSR),
2524 (t2SBCri rGPR:$src, imm0_255_not:$imm)>;
2525 def : T2Pat<(ARMadde rGPR:$src, t2_so_imm_not:$imm, CPSR),
2526 (t2SBCri rGPR:$src, t2_so_imm_not:$imm)>;
2527 def : T2Pat<(ARMadde rGPR:$src, imm0_65535_neg:$imm, CPSR),
2528 (t2SBCrr rGPR:$src, (t2MOVi16 (imm_not_XFORM imm:$imm)))>;
2530 def t2SEL : T2ThreeReg<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2531 NoItinerary, "sel", "\t$Rd, $Rn, $Rm",
2532 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2533 Requires<[IsThumb2, HasDSP]> {
2534 let Inst{31-27} = 0b11111;
2535 let Inst{26-24} = 0b010;
2537 let Inst{22-20} = 0b010;
2538 let Inst{15-12} = 0b1111;
2540 let Inst{6-4} = 0b000;
2543 // A6.3.13, A6.3.14, A6.3.15 Parallel addition and subtraction (signed/unsigned)
2544 // And Miscellaneous operations -- for disassembly only
2545 class T2I_pam<bits<3> op22_20, bits<4> op7_4, string opc,
2546 list<dag> pat, dag iops, string asm>
2547 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, pat>,
2548 Requires<[IsThumb2, HasDSP]> {
2549 let Inst{31-27} = 0b11111;
2550 let Inst{26-23} = 0b0101;
2551 let Inst{22-20} = op22_20;
2552 let Inst{15-12} = 0b1111;
2553 let Inst{7-4} = op7_4;
2559 let Inst{11-8} = Rd;
2560 let Inst{19-16} = Rn;
2564 class T2I_pam_intrinsics<bits<3> op22_20, bits<4> op7_4, string opc,
2565 Intrinsic intrinsic>
2566 : T2I_pam<op22_20, op7_4, opc,
2567 [(set rGPR:$Rd, (intrinsic rGPR:$Rn, rGPR:$Rm))],
2568 (ins rGPR:$Rn, rGPR:$Rm), "\t$Rd, $Rn, $Rm">;
2570 class T2I_pam_intrinsics_rev<bits<3> op22_20, bits<4> op7_4, string opc>
2571 : T2I_pam<op22_20, op7_4, opc, [],
2572 (ins rGPR:$Rm, rGPR:$Rn), "\t$Rd, $Rm, $Rn">;
2574 // Saturating add/subtract
2575 def t2QADD16 : T2I_pam_intrinsics<0b001, 0b0001, "qadd16", int_arm_qadd16>;
2576 def t2QADD8 : T2I_pam_intrinsics<0b000, 0b0001, "qadd8", int_arm_qadd8>;
2577 def t2QASX : T2I_pam_intrinsics<0b010, 0b0001, "qasx", int_arm_qasx>;
2578 def t2UQSUB8 : T2I_pam_intrinsics<0b100, 0b0101, "uqsub8", int_arm_uqsub8>;
2579 def t2QSAX : T2I_pam_intrinsics<0b110, 0b0001, "qsax", int_arm_qsax>;
2580 def t2QSUB16 : T2I_pam_intrinsics<0b101, 0b0001, "qsub16", int_arm_qsub16>;
2581 def t2QSUB8 : T2I_pam_intrinsics<0b100, 0b0001, "qsub8", int_arm_qsub8>;
2582 def t2UQADD16 : T2I_pam_intrinsics<0b001, 0b0101, "uqadd16", int_arm_uqadd16>;
2583 def t2UQADD8 : T2I_pam_intrinsics<0b000, 0b0101, "uqadd8", int_arm_uqadd8>;
2584 def t2UQASX : T2I_pam_intrinsics<0b010, 0b0101, "uqasx", int_arm_uqasx>;
2585 def t2UQSAX : T2I_pam_intrinsics<0b110, 0b0101, "uqsax", int_arm_uqsax>;
2586 def t2UQSUB16 : T2I_pam_intrinsics<0b101, 0b0101, "uqsub16", int_arm_uqsub16>;
2587 def t2QADD : T2I_pam_intrinsics_rev<0b000, 0b1000, "qadd">;
2588 def t2QSUB : T2I_pam_intrinsics_rev<0b000, 0b1010, "qsub">;
2589 def t2QDADD : T2I_pam_intrinsics_rev<0b000, 0b1001, "qdadd">;
2590 def t2QDSUB : T2I_pam_intrinsics_rev<0b000, 0b1011, "qdsub">;
2592 def : Thumb2DSPPat<(int_arm_qadd rGPR:$Rm, rGPR:$Rn),
2593 (t2QADD rGPR:$Rm, rGPR:$Rn)>;
2594 def : Thumb2DSPPat<(int_arm_qsub rGPR:$Rm, rGPR:$Rn),
2595 (t2QSUB rGPR:$Rm, rGPR:$Rn)>;
2596 def : Thumb2DSPPat<(int_arm_qadd rGPR:$Rm, (int_arm_qadd rGPR:$Rn, rGPR:$Rn)),
2597 (t2QDADD rGPR:$Rm, rGPR:$Rn)>;
2598 def : Thumb2DSPPat<(int_arm_qsub rGPR:$Rm, (int_arm_qadd rGPR:$Rn, rGPR:$Rn)),
2599 (t2QDSUB rGPR:$Rm, rGPR:$Rn)>;
2601 def : Thumb2DSPPat<(saddsat rGPR:$Rm, rGPR:$Rn),
2602 (t2QADD rGPR:$Rm, rGPR:$Rn)>;
2603 def : Thumb2DSPPat<(ssubsat rGPR:$Rm, rGPR:$Rn),
2604 (t2QSUB rGPR:$Rm, rGPR:$Rn)>;
2605 def : Thumb2DSPPat<(saddsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)),
2606 (t2QDADD rGPR:$Rm, rGPR:$Rn)>;
2607 def : Thumb2DSPPat<(ssubsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)),
2608 (t2QDSUB rGPR:$Rm, rGPR:$Rn)>;
2610 def : Thumb2DSPPat<(ARMqadd8b rGPR:$Rm, rGPR:$Rn),
2611 (t2QADD8 rGPR:$Rm, rGPR:$Rn)>;
2612 def : Thumb2DSPPat<(ARMqsub8b rGPR:$Rm, rGPR:$Rn),
2613 (t2QSUB8 rGPR:$Rm, rGPR:$Rn)>;
2614 def : Thumb2DSPPat<(ARMqadd16b rGPR:$Rm, rGPR:$Rn),
2615 (t2QADD16 rGPR:$Rm, rGPR:$Rn)>;
2616 def : Thumb2DSPPat<(ARMqsub16b rGPR:$Rm, rGPR:$Rn),
2617 (t2QSUB16 rGPR:$Rm, rGPR:$Rn)>;
2619 def : Thumb2DSPPat<(ARMuqadd8b rGPR:$Rm, rGPR:$Rn),
2620 (t2UQADD8 rGPR:$Rm, rGPR:$Rn)>;
2621 def : Thumb2DSPPat<(ARMuqsub8b rGPR:$Rm, rGPR:$Rn),
2622 (t2UQSUB8 rGPR:$Rm, rGPR:$Rn)>;
2623 def : Thumb2DSPPat<(ARMuqadd16b rGPR:$Rm, rGPR:$Rn),
2624 (t2UQADD16 rGPR:$Rm, rGPR:$Rn)>;
2625 def : Thumb2DSPPat<(ARMuqsub16b rGPR:$Rm, rGPR:$Rn),
2626 (t2UQSUB16 rGPR:$Rm, rGPR:$Rn)>;
2628 // Signed/Unsigned add/subtract
2630 def t2SASX : T2I_pam_intrinsics<0b010, 0b0000, "sasx", int_arm_sasx>;
2631 def t2SADD16 : T2I_pam_intrinsics<0b001, 0b0000, "sadd16", int_arm_sadd16>;
2632 def t2SADD8 : T2I_pam_intrinsics<0b000, 0b0000, "sadd8", int_arm_sadd8>;
2633 def t2SSAX : T2I_pam_intrinsics<0b110, 0b0000, "ssax", int_arm_ssax>;
2634 def t2SSUB16 : T2I_pam_intrinsics<0b101, 0b0000, "ssub16", int_arm_ssub16>;
2635 def t2SSUB8 : T2I_pam_intrinsics<0b100, 0b0000, "ssub8", int_arm_ssub8>;
2636 def t2UASX : T2I_pam_intrinsics<0b010, 0b0100, "uasx", int_arm_uasx>;
2637 def t2UADD16 : T2I_pam_intrinsics<0b001, 0b0100, "uadd16", int_arm_uadd16>;
2638 def t2UADD8 : T2I_pam_intrinsics<0b000, 0b0100, "uadd8", int_arm_uadd8>;
2639 def t2USAX : T2I_pam_intrinsics<0b110, 0b0100, "usax", int_arm_usax>;
2640 def t2USUB16 : T2I_pam_intrinsics<0b101, 0b0100, "usub16", int_arm_usub16>;
2641 def t2USUB8 : T2I_pam_intrinsics<0b100, 0b0100, "usub8", int_arm_usub8>;
2643 // Signed/Unsigned halving add/subtract
2645 def t2SHASX : T2I_pam_intrinsics<0b010, 0b0010, "shasx", int_arm_shasx>;
2646 def t2SHADD16 : T2I_pam_intrinsics<0b001, 0b0010, "shadd16", int_arm_shadd16>;
2647 def t2SHADD8 : T2I_pam_intrinsics<0b000, 0b0010, "shadd8", int_arm_shadd8>;
2648 def t2SHSAX : T2I_pam_intrinsics<0b110, 0b0010, "shsax", int_arm_shsax>;
2649 def t2SHSUB16 : T2I_pam_intrinsics<0b101, 0b0010, "shsub16", int_arm_shsub16>;
2650 def t2SHSUB8 : T2I_pam_intrinsics<0b100, 0b0010, "shsub8", int_arm_shsub8>;
2651 def t2UHASX : T2I_pam_intrinsics<0b010, 0b0110, "uhasx", int_arm_uhasx>;
2652 def t2UHADD16 : T2I_pam_intrinsics<0b001, 0b0110, "uhadd16", int_arm_uhadd16>;
2653 def t2UHADD8 : T2I_pam_intrinsics<0b000, 0b0110, "uhadd8", int_arm_uhadd8>;
2654 def t2UHSAX : T2I_pam_intrinsics<0b110, 0b0110, "uhsax", int_arm_uhsax>;
2655 def t2UHSUB16 : T2I_pam_intrinsics<0b101, 0b0110, "uhsub16", int_arm_uhsub16>;
2656 def t2UHSUB8 : T2I_pam_intrinsics<0b100, 0b0110, "uhsub8", int_arm_uhsub8>;
2658 // Helper class for disassembly only
2659 // A6.3.16 & A6.3.17
2660 // T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
2661 class T2ThreeReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2662 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2663 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
2664 let Inst{31-27} = 0b11111;
2665 let Inst{26-24} = 0b011;
2666 let Inst{23} = long;
2667 let Inst{22-20} = op22_20;
2668 let Inst{7-4} = op7_4;
2671 class T2FourReg_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops,
2672 dag iops, InstrItinClass itin, string opc, string asm, list<dag> pattern>
2673 : T2FourReg<oops, iops, itin, opc, asm, pattern> {
2674 let Inst{31-27} = 0b11111;
2675 let Inst{26-24} = 0b011;
2676 let Inst{23} = long;
2677 let Inst{22-20} = op22_20;
2678 let Inst{7-4} = op7_4;
2681 // Unsigned Sum of Absolute Differences [and Accumulate].
2682 def t2USAD8 : T2ThreeReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2683 (ins rGPR:$Rn, rGPR:$Rm),
2684 NoItinerary, "usad8", "\t$Rd, $Rn, $Rm",
2685 [(set rGPR:$Rd, (int_arm_usad8 rGPR:$Rn, rGPR:$Rm))]>,
2686 Requires<[IsThumb2, HasDSP]> {
2687 let Inst{15-12} = 0b1111;
2689 def t2USADA8 : T2FourReg_mac<0, 0b111, 0b0000, (outs rGPR:$Rd),
2690 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), NoItinerary,
2691 "usada8", "\t$Rd, $Rn, $Rm, $Ra",
2692 [(set rGPR:$Rd, (int_arm_usada8 rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>,
2693 Requires<[IsThumb2, HasDSP]>;
2695 // Signed/Unsigned saturate.
2696 class T2SatI<dag iops, string opc, string asm>
2697 : T2I<(outs rGPR:$Rd), iops, NoItinerary, opc, asm, []> {
2703 let Inst{31-24} = 0b11110011;
2704 let Inst{21} = sh{5};
2706 let Inst{19-16} = Rn;
2708 let Inst{14-12} = sh{4-2};
2709 let Inst{11-8} = Rd;
2710 let Inst{7-6} = sh{1-0};
2712 let Inst{4-0} = sat_imm;
2715 def t2SSAT: T2SatI<(ins imm1_32:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
2716 "ssat", "\t$Rd, $sat_imm, $Rn$sh">,
2717 Requires<[IsThumb2]>, Sched<[WriteALU]> {
2718 let Inst{23-22} = 0b00;
2722 def t2SSAT16: T2SatI<(ins imm1_16:$sat_imm, rGPR:$Rn),
2723 "ssat16", "\t$Rd, $sat_imm, $Rn">,
2724 Requires<[IsThumb2, HasDSP]>, Sched<[WriteALU]> {
2725 let Inst{23-22} = 0b00;
2730 def t2USAT: T2SatI<(ins imm0_31:$sat_imm, rGPR:$Rn, t2_shift_imm:$sh),
2731 "usat", "\t$Rd, $sat_imm, $Rn$sh">,
2732 Requires<[IsThumb2]>, Sched<[WriteALU]> {
2733 let Inst{23-22} = 0b10;
2736 def t2USAT16: T2SatI<(ins imm0_15:$sat_imm, rGPR:$Rn),
2737 "usat16", "\t$Rd, $sat_imm, $Rn">,
2738 Requires<[IsThumb2, HasDSP]>, Sched<[WriteALU]> {
2739 let Inst{23-22} = 0b10;
2744 def : T2Pat<(ARMssat GPRnopc:$Rn, imm0_31:$imm),
2745 (t2SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
2746 def : T2Pat<(ARMusat GPRnopc:$Rn, imm0_31:$imm),
2747 (t2USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
2748 def : T2Pat<(int_arm_ssat GPR:$a, imm1_32:$pos),
2749 (t2SSAT imm1_32:$pos, GPR:$a, 0)>;
2750 def : T2Pat<(int_arm_usat GPR:$a, imm0_31:$pos),
2751 (t2USAT imm0_31:$pos, GPR:$a, 0)>;
2752 def : T2Pat<(int_arm_ssat16 GPR:$a, imm1_16:$pos),
2753 (t2SSAT16 imm1_16:$pos, GPR:$a)>;
2754 def : T2Pat<(int_arm_usat16 GPR:$a, imm0_15:$pos),
2755 (t2USAT16 imm0_15:$pos, GPR:$a)>;
2756 def : T2Pat<(int_arm_ssat (shl GPRnopc:$a, imm0_31:$shft), imm1_32:$pos),
2757 (t2SSAT imm1_32:$pos, GPRnopc:$a, imm0_31:$shft)>;
2758 def : T2Pat<(int_arm_ssat (sra GPRnopc:$a, asr_imm:$shft), imm1_32:$pos),
2759 (t2SSAT imm1_32:$pos, GPRnopc:$a, asr_imm:$shft)>;
2760 def : T2Pat<(int_arm_usat (shl GPRnopc:$a, imm0_31:$shft), imm0_31:$pos),
2761 (t2USAT imm0_31:$pos, GPRnopc:$a, imm0_31:$shft)>;
2762 def : T2Pat<(int_arm_usat (sra GPRnopc:$a, asr_imm:$shft), imm0_31:$pos),
2763 (t2USAT imm0_31:$pos, GPRnopc:$a, asr_imm:$shft)>;
2764 def : T2Pat<(ARMssat (shl GPRnopc:$a, imm0_31:$shft), imm0_31:$pos),
2765 (t2SSAT imm0_31:$pos, GPRnopc:$a, imm0_31:$shft)>;
2766 def : T2Pat<(ARMssat (sra GPRnopc:$Rn, asr_imm:$shft), imm0_31:$pos),
2767 (t2SSAT imm0_31:$pos, GPRnopc:$Rn, asr_imm:$shft)>;
2768 def : T2Pat<(ARMusat (shl GPRnopc:$a, imm0_31:$shft), imm0_31:$pos),
2769 (t2USAT imm0_31:$pos, GPRnopc:$a, imm0_31:$shft)>;
2770 def : T2Pat<(ARMusat (sra GPRnopc:$Rn, asr_imm:$shft), imm0_31:$pos),
2771 (t2USAT imm0_31:$pos, GPRnopc:$Rn, asr_imm:$shft)>;
2774 //===----------------------------------------------------------------------===//
2775 // Shift and rotate Instructions.
2778 defm t2LSL : T2I_sh_ir<0b00, "lsl", imm1_31, shl>;
2779 defm t2LSR : T2I_sh_ir<0b01, "lsr", imm_sr, srl>;
2780 defm t2ASR : T2I_sh_ir<0b10, "asr", imm_sr, sra>;
2781 defm t2ROR : T2I_sh_ir<0b11, "ror", imm1_31, rotr>;
2783 // LSL #0 is actually MOV, and has slightly different permitted registers to
2784 // LSL with non-zero shift
2785 def : t2InstAlias<"lsl${s}${p} $Rd, $Rm, #0",
2786 (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
2787 def : t2InstAlias<"lsl${s}${p}.w $Rd, $Rm, #0",
2788 (t2MOVr GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
2790 // (rotr x, (and y, 0x...1f)) ==> (ROR x, y)
2791 def : T2Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)),
2792 (t2RORrr rGPR:$lhs, rGPR:$rhs)>;
2794 let Uses = [CPSR] in {
2795 def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2796 "rrx", "\t$Rd, $Rm",
2797 [(set rGPR:$Rd, (ARMrrx rGPR:$Rm, CPSR))]>,
2799 let Inst{31-27} = 0b11101;
2800 let Inst{26-25} = 0b01;
2801 let Inst{24-21} = 0b0010;
2802 let Inst{19-16} = 0b1111; // Rn
2804 let Unpredictable{15} = 0b1;
2805 let Inst{14-12} = 0b000;
2806 let Inst{7-4} = 0b0011;
2810 // These differ from t2LSRri / t2ASRri in that they are flag-setting
2811 // and have a hardcoded shift amount = 1.
2812 let isCodeGenOnly = 1, Defs = [CPSR] in {
2813 def t2LSRs1 : T2TwoRegShiftImm<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2814 "lsrs", ".w\t$Rd, $Rm, #1",
2815 [(set rGPR:$Rd, CPSR, (ARMlsrs1 rGPR:$Rm))]>,
2817 let Inst{31-27} = 0b11101;
2818 let Inst{26-25} = 0b01;
2819 let Inst{24-21} = 0b0010;
2820 let Inst{20} = 1; // The S bit.
2821 let Inst{19-16} = 0b1111; // Rn
2822 let Inst{5-4} = 0b01; // Shift type.
2823 // Shift amount = Inst{14-12:7-6} = 1.
2824 let Inst{14-12} = 0b000;
2825 let Inst{7-6} = 0b01;
2827 def t2ASRs1 : T2TwoRegShiftImm<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi,
2828 "asrs", ".w\t$Rd, $Rm, #1",
2829 [(set rGPR:$Rd, CPSR, (ARMasrs1 rGPR:$Rm))]>,
2831 let Inst{31-27} = 0b11101;
2832 let Inst{26-25} = 0b01;
2833 let Inst{24-21} = 0b0010;
2834 let Inst{20} = 1; // The S bit.
2835 let Inst{19-16} = 0b1111; // Rn
2836 let Inst{5-4} = 0b10; // Shift type.
2837 // Shift amount = Inst{14-12:7-6} = 1.
2838 let Inst{14-12} = 0b000;
2839 let Inst{7-6} = 0b01;
2843 //===----------------------------------------------------------------------===//
2844 // Bitwise Instructions.
2847 defm t2AND : T2I_bin_w_irs<0b0000, "and",
2848 IIC_iBITi, IIC_iBITr, IIC_iBITsi, and, 1>;
2849 defm t2ORR : T2I_bin_w_irs<0b0010, "orr",
2850 IIC_iBITi, IIC_iBITr, IIC_iBITsi, or, 1>;
2851 defm t2EOR : T2I_bin_w_irs<0b0100, "eor",
2852 IIC_iBITi, IIC_iBITr, IIC_iBITsi, xor, 1>;
2854 defm t2BIC : T2I_bin_w_irs<0b0001, "bic",
2855 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2856 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
2858 class T2BitFI<dag oops, dag iops, InstrItinClass itin,
2859 string opc, string asm, list<dag> pattern>
2860 : T2I<oops, iops, itin, opc, asm, pattern> {
2865 let Inst{11-8} = Rd;
2866 let Inst{4-0} = msb{4-0};
2867 let Inst{14-12} = lsb{4-2};
2868 let Inst{7-6} = lsb{1-0};
2871 class T2TwoRegBitFI<dag oops, dag iops, InstrItinClass itin,
2872 string opc, string asm, list<dag> pattern>
2873 : T2BitFI<oops, iops, itin, opc, asm, pattern> {
2876 let Inst{19-16} = Rn;
2879 let Constraints = "$src = $Rd" in
2880 def t2BFC : T2BitFI<(outs rGPR:$Rd), (ins rGPR:$src, bf_inv_mask_imm:$imm),
2881 IIC_iUNAsi, "bfc", "\t$Rd, $imm",
2882 [(set rGPR:$Rd, (and rGPR:$src, bf_inv_mask_imm:$imm))]>, Sched<[WriteALU]> {
2883 let Inst{31-27} = 0b11110;
2884 let Inst{26} = 0; // should be 0.
2886 let Inst{24-20} = 0b10110;
2887 let Inst{19-16} = 0b1111; // Rn
2889 let Inst{5} = 0; // should be 0.
2892 let msb{4-0} = imm{9-5};
2893 let lsb{4-0} = imm{4-0};
2896 def t2SBFX: T2TwoRegBitFI<
2897 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2898 IIC_iUNAsi, "sbfx", "\t$Rd, $Rn, $lsb, $msb", []>, Sched<[WriteALU]> {
2899 let Inst{31-27} = 0b11110;
2901 let Inst{24-20} = 0b10100;
2904 let hasSideEffects = 0;
2907 def t2UBFX: T2TwoRegBitFI<
2908 (outs rGPR:$Rd), (ins rGPR:$Rn, imm0_31:$lsb, imm1_32:$msb),
2909 IIC_iUNAsi, "ubfx", "\t$Rd, $Rn, $lsb, $msb", []>, Sched<[WriteALU]> {
2910 let Inst{31-27} = 0b11110;
2912 let Inst{24-20} = 0b11100;
2915 let hasSideEffects = 0;
2918 // A8.8.247 UDF - Undefined (Encoding T2)
2919 def t2UDF : T2XI<(outs), (ins imm0_65535:$imm16), IIC_Br, "udf.w\t$imm16",
2920 [(int_arm_undefined imm0_65535:$imm16)]> {
2922 let Inst{31-29} = 0b111;
2923 let Inst{28-27} = 0b10;
2924 let Inst{26-20} = 0b1111111;
2925 let Inst{19-16} = imm16{15-12};
2927 let Inst{14-12} = 0b010;
2928 let Inst{11-0} = imm16{11-0};
2931 // A8.6.18 BFI - Bitfield insert (Encoding T1)
2932 let Constraints = "$src = $Rd" in {
2933 def t2BFI : T2TwoRegBitFI<(outs rGPR:$Rd),
2934 (ins rGPR:$src, rGPR:$Rn, bf_inv_mask_imm:$imm),
2935 IIC_iBITi, "bfi", "\t$Rd, $Rn, $imm",
2936 [(set rGPR:$Rd, (ARMbfi rGPR:$src, rGPR:$Rn,
2937 bf_inv_mask_imm:$imm))]>, Sched<[WriteALU]> {
2938 let Inst{31-27} = 0b11110;
2939 let Inst{26} = 0; // should be 0.
2941 let Inst{24-20} = 0b10110;
2943 let Inst{5} = 0; // should be 0.
2946 let msb{4-0} = imm{9-5};
2947 let lsb{4-0} = imm{4-0};
2951 defm t2ORN : T2I_bin_irs<0b0011, "orn",
2952 IIC_iBITi, IIC_iBITr, IIC_iBITsi,
2953 BinOpFrag<(or node:$LHS, (not node:$RHS))>, 0, "">;
2954 def : t2InstAlias<"orn${s}${p}.w $Rd, $Rn, $imm",
2955 (t2ORNri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
2956 def : t2InstAlias<"orn${s}${p}.w $Rd, $Rn, $Rm",
2957 (t2ORNrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
2958 def : t2InstAlias<"orn${s}${p}.w $Rd, $Rn, $ShiftedRm",
2959 (t2ORNrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>;
2961 /// T2I_un_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a
2962 /// unary operation that produces a value. These are predicable and can be
2963 /// changed to modify CPSR.
2964 multiclass T2I_un_irs<bits<4> opcod, string opc,
2965 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
2967 bit Cheap = 0, bit ReMat = 0, bit MoveImm = 0> {
2969 def i : T2sOneRegImm<(outs rGPR:$Rd), (ins t2_so_imm:$imm), iii,
2971 [(set rGPR:$Rd, (opnode t2_so_imm:$imm))]>, Sched<[WriteALU]> {
2972 let isAsCheapAsAMove = Cheap;
2973 let isReMaterializable = ReMat;
2974 let isMoveImm = MoveImm;
2975 let Inst{31-27} = 0b11110;
2977 let Inst{24-21} = opcod;
2978 let Inst{19-16} = 0b1111; // Rn
2982 def r : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), iir,
2983 opc, ".w\t$Rd, $Rm",
2984 [(set rGPR:$Rd, (opnode rGPR:$Rm))]>, Sched<[WriteALU]> {
2985 let Inst{31-27} = 0b11101;
2986 let Inst{26-25} = 0b01;
2987 let Inst{24-21} = opcod;
2988 let Inst{19-16} = 0b1111; // Rn
2989 let Inst{14-12} = 0b000; // imm3
2990 let Inst{7-6} = 0b00; // imm2
2991 let Inst{5-4} = 0b00; // type
2994 def s : T2sOneRegShiftedReg<(outs rGPR:$Rd), (ins t2_so_reg:$ShiftedRm), iis,
2995 opc, ".w\t$Rd, $ShiftedRm",
2996 [(set rGPR:$Rd, (opnode t2_so_reg:$ShiftedRm))]>,
2998 let Inst{31-27} = 0b11101;
2999 let Inst{26-25} = 0b01;
3000 let Inst{24-21} = opcod;
3001 let Inst{19-16} = 0b1111; // Rn
3005 // Prefer over of t2EORri ra, rb, -1 because mvn has 16-bit version
3006 let AddedComplexity = 1 in
3007 defm t2MVN : T2I_un_irs <0b0011, "mvn",
3008 IIC_iMVNi, IIC_iMVNr, IIC_iMVNsi,
3011 let AddedComplexity = 1 in
3012 def : T2Pat<(and rGPR:$src, t2_so_imm_not:$imm),
3013 (t2BICri rGPR:$src, t2_so_imm_not:$imm)>;
3015 // so_imm_notSext is needed instead of so_imm_not, as the value of imm
3016 // will match the extended, not the original bitWidth for $src.
3017 def : T2Pat<(and top16Zero:$src, t2_so_imm_notSext:$imm),
3018 (t2BICri rGPR:$src, t2_so_imm_notSext:$imm)>;
3020 // FIXME: Disable this pattern on Darwin to workaround an assembler bug.
3021 def : T2Pat<(or rGPR:$src, t2_so_imm_not:$imm),
3022 (t2ORNri rGPR:$src, t2_so_imm_not:$imm)>,
3023 Requires<[IsThumb2]>;
3025 def : T2Pat<(t2_so_imm_not:$src),
3026 (t2MVNi t2_so_imm_not:$src)>;
3028 // There are shorter Thumb encodings for ADD than ORR, so to increase
3029 // Thumb2SizeReduction's chances later on we select a t2ADD for an or where
3031 def : T2Pat<(or AddLikeOrOp:$Rn, t2_so_imm:$imm),
3032 (t2ADDri rGPR:$Rn, t2_so_imm:$imm)>;
3034 def : T2Pat<(or AddLikeOrOp:$Rn, imm0_4095:$Rm),
3035 (t2ADDri12 rGPR:$Rn, imm0_4095:$Rm)>;
3037 def : T2Pat<(or AddLikeOrOp:$Rn, non_imm32:$Rm),
3038 (t2ADDrr $Rn, $Rm)>;
3040 //===----------------------------------------------------------------------===//
3041 // Multiply Instructions.
3043 let isCommutable = 1 in
3044 def t2MUL: T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
3045 "mul", "\t$Rd, $Rn, $Rm",
3046 [(set rGPR:$Rd, (mul rGPR:$Rn, rGPR:$Rm))]>,
3047 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
3048 let Inst{31-27} = 0b11111;
3049 let Inst{26-23} = 0b0110;
3050 let Inst{22-20} = 0b000;
3051 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
3052 let Inst{7-4} = 0b0000; // Multiply
3055 class T2FourRegMLA<bits<4> op7_4, string opc, list<dag> pattern>
3056 : T2FourReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
3057 opc, "\t$Rd, $Rn, $Rm, $Ra", pattern>,
3058 Requires<[IsThumb2, UseMulOps]>,
3059 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
3060 let Inst{31-27} = 0b11111;
3061 let Inst{26-23} = 0b0110;
3062 let Inst{22-20} = 0b000;
3063 let Inst{7-4} = op7_4;
3066 def t2MLA : T2FourRegMLA<0b0000, "mla",
3067 [(set rGPR:$Rd, (add (mul rGPR:$Rn, rGPR:$Rm),
3069 def t2MLS: T2FourRegMLA<0b0001, "mls",
3070 [(set rGPR:$Rd, (sub rGPR:$Ra, (mul rGPR:$Rn,
3073 // Extra precision multiplies with low / high results
3074 let hasSideEffects = 0 in {
3075 let isCommutable = 1 in {
3076 def t2SMULL : T2MulLong<0b000, 0b0000, "smull",
3077 [(set rGPR:$RdLo, rGPR:$RdHi,
3078 (smullohi rGPR:$Rn, rGPR:$Rm))]>;
3079 def t2UMULL : T2MulLong<0b010, 0b0000, "umull",
3080 [(set rGPR:$RdLo, rGPR:$RdHi,
3081 (umullohi rGPR:$Rn, rGPR:$Rm))]>;
3084 // Multiply + accumulate
3085 def t2SMLAL : T2MlaLong<0b100, 0b0000, "smlal">;
3086 def t2UMLAL : T2MlaLong<0b110, 0b0000, "umlal">;
3087 def t2UMAAL : T2MlaLong<0b110, 0b0110, "umaal">, Requires<[IsThumb2, HasDSP]>;
3090 // Rounding variants of the below included for disassembly only
3092 // Most significant word multiply
3093 class T2SMMUL<bits<4> op7_4, string opc, list<dag> pattern>
3094 : T2ThreeReg<(outs rGPR:$Rd),
3095 (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL32,
3096 opc, "\t$Rd, $Rn, $Rm", pattern>,
3097 Requires<[IsThumb2, HasDSP]>,
3098 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
3099 let Inst{31-27} = 0b11111;
3100 let Inst{26-23} = 0b0110;
3101 let Inst{22-20} = 0b101;
3102 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
3103 let Inst{7-4} = op7_4;
3105 def t2SMMUL : T2SMMUL<0b0000, "smmul", [(set rGPR:$Rd, (mulhs rGPR:$Rn,
3108 T2SMMUL<0b0001, "smmulr",
3109 [(set rGPR:$Rd, (ARMsmmlar rGPR:$Rn, rGPR:$Rm, (i32 0)))]>;
3111 class T2FourRegSMMLA<bits<3> op22_20, bits<4> op7_4, string opc,
3113 : T2FourReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMAC32,
3114 opc, "\t$Rd, $Rn, $Rm, $Ra", pattern>,
3115 Requires<[IsThumb2, HasDSP, UseMulOps]>,
3116 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
3117 let Inst{31-27} = 0b11111;
3118 let Inst{26-23} = 0b0110;
3119 let Inst{22-20} = op22_20;
3120 let Inst{7-4} = op7_4;
3123 def t2SMMLA : T2FourRegSMMLA<0b101, 0b0000, "smmla",
3124 [(set rGPR:$Rd, (add (mulhs rGPR:$Rm, rGPR:$Rn), rGPR:$Ra))]>;
3125 def t2SMMLAR: T2FourRegSMMLA<0b101, 0b0001, "smmlar",
3126 [(set rGPR:$Rd, (ARMsmmlar rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>;
3127 def t2SMMLS: T2FourRegSMMLA<0b110, 0b0000, "smmls", []>;
3128 def t2SMMLSR: T2FourRegSMMLA<0b110, 0b0001, "smmlsr",
3129 [(set rGPR:$Rd, (ARMsmmlsr rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>;
3131 class T2ThreeRegSMUL<bits<3> op22_20, bits<2> op5_4, string opc,
3133 : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iMUL16, opc,
3134 "\t$Rd, $Rn, $Rm", pattern>,
3135 Requires<[IsThumb2, HasDSP]>,
3136 Sched<[WriteMUL16, ReadMUL, ReadMUL]> {
3137 let Inst{31-27} = 0b11111;
3138 let Inst{26-23} = 0b0110;
3139 let Inst{22-20} = op22_20;
3140 let Inst{15-12} = 0b1111; // Ra = 0b1111 (no accumulate)
3141 let Inst{7-6} = 0b00;
3142 let Inst{5-4} = op5_4;
3145 def t2SMULBB : T2ThreeRegSMUL<0b001, 0b00, "smulbb",
3146 [(set rGPR:$Rd, (bb_mul rGPR:$Rn, rGPR:$Rm))]>;
3147 def t2SMULBT : T2ThreeRegSMUL<0b001, 0b01, "smulbt",
3148 [(set rGPR:$Rd, (bt_mul rGPR:$Rn, rGPR:$Rm))]>;
3149 def t2SMULTB : T2ThreeRegSMUL<0b001, 0b10, "smultb",
3150 [(set rGPR:$Rd, (tb_mul rGPR:$Rn, rGPR:$Rm))]>;
3151 def t2SMULTT : T2ThreeRegSMUL<0b001, 0b11, "smultt",
3152 [(set rGPR:$Rd, (tt_mul rGPR:$Rn, rGPR:$Rm))]>;
3153 def t2SMULWB : T2ThreeRegSMUL<0b011, 0b00, "smulwb",
3154 [(set rGPR:$Rd, (ARMsmulwb rGPR:$Rn, rGPR:$Rm))]>;
3155 def t2SMULWT : T2ThreeRegSMUL<0b011, 0b01, "smulwt",
3156 [(set rGPR:$Rd, (ARMsmulwt rGPR:$Rn, rGPR:$Rm))]>;
3158 def : Thumb2DSPPat<(mul sext_16_node:$Rn, (sext_bottom_16 rGPR:$Rm)),
3159 (t2SMULBB rGPR:$Rn, rGPR:$Rm)>;
3160 def : Thumb2DSPPat<(mul sext_16_node:$Rn, (sext_top_16 rGPR:$Rm)),
3161 (t2SMULBT rGPR:$Rn, rGPR:$Rm)>;
3162 def : Thumb2DSPPat<(mul (sext_top_16 rGPR:$Rn), sext_16_node:$Rm),
3163 (t2SMULTB rGPR:$Rn, rGPR:$Rm)>;
3165 def : Thumb2DSPPat<(int_arm_smulbb rGPR:$Rn, rGPR:$Rm),
3166 (t2SMULBB rGPR:$Rn, rGPR:$Rm)>;
3167 def : Thumb2DSPPat<(int_arm_smulbt rGPR:$Rn, rGPR:$Rm),
3168 (t2SMULBT rGPR:$Rn, rGPR:$Rm)>;
3169 def : Thumb2DSPPat<(int_arm_smultb rGPR:$Rn, rGPR:$Rm),
3170 (t2SMULTB rGPR:$Rn, rGPR:$Rm)>;
3171 def : Thumb2DSPPat<(int_arm_smultt rGPR:$Rn, rGPR:$Rm),
3172 (t2SMULTT rGPR:$Rn, rGPR:$Rm)>;
3173 def : Thumb2DSPPat<(int_arm_smulwb rGPR:$Rn, rGPR:$Rm),
3174 (t2SMULWB rGPR:$Rn, rGPR:$Rm)>;
3175 def : Thumb2DSPPat<(int_arm_smulwt rGPR:$Rn, rGPR:$Rm),
3176 (t2SMULWT rGPR:$Rn, rGPR:$Rm)>;
3178 class T2FourRegSMLA<bits<3> op22_20, bits<2> op5_4, string opc,
3180 : T2FourReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra), IIC_iMUL16,
3181 opc, "\t$Rd, $Rn, $Rm, $Ra", pattern>,
3182 Requires<[IsThumb2, HasDSP, UseMulOps]>,
3183 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]> {
3184 let Inst{31-27} = 0b11111;
3185 let Inst{26-23} = 0b0110;
3186 let Inst{22-20} = op22_20;
3187 let Inst{7-6} = 0b00;
3188 let Inst{5-4} = op5_4;
3191 def t2SMLABB : T2FourRegSMLA<0b001, 0b00, "smlabb",
3192 [(set rGPR:$Rd, (add rGPR:$Ra, (bb_mul rGPR:$Rn, rGPR:$Rm)))]>;
3193 def t2SMLABT : T2FourRegSMLA<0b001, 0b01, "smlabt",
3194 [(set rGPR:$Rd, (add rGPR:$Ra, (bt_mul rGPR:$Rn, rGPR:$Rm)))]>;
3195 def t2SMLATB : T2FourRegSMLA<0b001, 0b10, "smlatb",
3196 [(set rGPR:$Rd, (add rGPR:$Ra, (tb_mul rGPR:$Rn, rGPR:$Rm)))]>;
3197 def t2SMLATT : T2FourRegSMLA<0b001, 0b11, "smlatt",
3198 [(set rGPR:$Rd, (add rGPR:$Ra, (tt_mul rGPR:$Rn, rGPR:$Rm)))]>;
3199 def t2SMLAWB : T2FourRegSMLA<0b011, 0b00, "smlawb",
3200 [(set rGPR:$Rd, (add rGPR:$Ra, (ARMsmulwb rGPR:$Rn, rGPR:$Rm)))]>;
3201 def t2SMLAWT : T2FourRegSMLA<0b011, 0b01, "smlawt",
3202 [(set rGPR:$Rd, (add rGPR:$Ra, (ARMsmulwt rGPR:$Rn, rGPR:$Rm)))]>;
3204 def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul sext_16_node:$Rn, sext_16_node:$Rm)),
3205 (t2SMLABB rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>;
3206 def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul sext_16_node:$Rn,
3207 (sext_bottom_16 rGPR:$Rm))),
3208 (t2SMLABB rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>;
3209 def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul sext_16_node:$Rn,
3210 (sext_top_16 rGPR:$Rm))),
3211 (t2SMLABT rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>;
3212 def : Thumb2DSPMulPat<(add rGPR:$Ra, (mul (sext_top_16 rGPR:$Rn),
3214 (t2SMLATB rGPR:$Rn, rGPR:$Rm, rGPR:$Ra)>;
3216 def : Thumb2DSPPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
3217 (t2SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3218 def : Thumb2DSPPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
3219 (t2SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3220 def : Thumb2DSPPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
3221 (t2SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3222 def : Thumb2DSPPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
3223 (t2SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
3224 def : Thumb2DSPPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
3225 (t2SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3226 def : Thumb2DSPPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
3227 (t2SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
3229 // Halfword multiple accumulate long: SMLAL<x><y>
3230 def t2SMLALBB : T2MlaLong<0b100, 0b1000, "smlalbb">,
3231 Requires<[IsThumb2, HasDSP]>;
3232 def t2SMLALBT : T2MlaLong<0b100, 0b1001, "smlalbt">,
3233 Requires<[IsThumb2, HasDSP]>;
3234 def t2SMLALTB : T2MlaLong<0b100, 0b1010, "smlaltb">,
3235 Requires<[IsThumb2, HasDSP]>;
3236 def t2SMLALTT : T2MlaLong<0b100, 0b1011, "smlaltt">,
3237 Requires<[IsThumb2, HasDSP]>;
3239 def : Thumb2DSPPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
3240 (t2SMLALBB $Rn, $Rm, $RLo, $RHi)>;
3241 def : Thumb2DSPPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
3242 (t2SMLALBT $Rn, $Rm, $RLo, $RHi)>;
3243 def : Thumb2DSPPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
3244 (t2SMLALTB $Rn, $Rm, $RLo, $RHi)>;
3245 def : Thumb2DSPPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
3246 (t2SMLALTT $Rn, $Rm, $RLo, $RHi)>;
3248 class T2DualHalfMul<bits<3> op22_20, bits<4> op7_4, string opc,
3249 Intrinsic intrinsic>
3250 : T2ThreeReg_mac<0, op22_20, op7_4,
3252 (ins rGPR:$Rn, rGPR:$Rm),
3253 IIC_iMAC32, opc, "\t$Rd, $Rn, $Rm",
3254 [(set rGPR:$Rd, (intrinsic rGPR:$Rn, rGPR:$Rm))]>,
3255 Requires<[IsThumb2, HasDSP]>,
3256 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
3257 let Inst{15-12} = 0b1111;
3260 // Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
3261 def t2SMUAD: T2DualHalfMul<0b010, 0b0000, "smuad", int_arm_smuad>;
3262 def t2SMUADX: T2DualHalfMul<0b010, 0b0001, "smuadx", int_arm_smuadx>;
3263 def t2SMUSD: T2DualHalfMul<0b100, 0b0000, "smusd", int_arm_smusd>;
3264 def t2SMUSDX: T2DualHalfMul<0b100, 0b0001, "smusdx", int_arm_smusdx>;
3266 class T2DualHalfMulAdd<bits<3> op22_20, bits<4> op7_4, string opc,
3267 Intrinsic intrinsic>
3268 : T2FourReg_mac<0, op22_20, op7_4,
3270 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$Ra),
3271 IIC_iMAC32, opc, "\t$Rd, $Rn, $Rm, $Ra",
3272 [(set rGPR:$Rd, (intrinsic rGPR:$Rn, rGPR:$Rm, rGPR:$Ra))]>,
3273 Requires<[IsThumb2, HasDSP]>;
3275 def t2SMLAD : T2DualHalfMulAdd<0b010, 0b0000, "smlad", int_arm_smlad>;
3276 def t2SMLADX : T2DualHalfMulAdd<0b010, 0b0001, "smladx", int_arm_smladx>;
3277 def t2SMLSD : T2DualHalfMulAdd<0b100, 0b0000, "smlsd", int_arm_smlsd>;
3278 def t2SMLSDX : T2DualHalfMulAdd<0b100, 0b0001, "smlsdx", int_arm_smlsdx>;
3280 class T2DualHalfMulAddLong<bits<3> op22_20, bits<4> op7_4, string opc>
3281 : T2FourReg_mac<1, op22_20, op7_4,
3282 (outs rGPR:$Ra, rGPR:$Rd),
3283 (ins rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi),
3284 IIC_iMAC64, opc, "\t$Ra, $Rd, $Rn, $Rm", []>,
3285 RegConstraint<"$Ra = $RLo, $Rd = $RHi">,
3286 Requires<[IsThumb2, HasDSP]>,
3287 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
3289 def t2SMLALD : T2DualHalfMulAddLong<0b100, 0b1100, "smlald">;
3290 def t2SMLALDX : T2DualHalfMulAddLong<0b100, 0b1101, "smlaldx">;
3291 def t2SMLSLD : T2DualHalfMulAddLong<0b101, 0b1100, "smlsld">;
3292 def t2SMLSLDX : T2DualHalfMulAddLong<0b101, 0b1101, "smlsldx">;
3294 def : Thumb2DSPPat<(ARMSmlald rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi),
3295 (t2SMLALD rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>;
3296 def : Thumb2DSPPat<(ARMSmlaldx rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi),
3297 (t2SMLALDX rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>;
3298 def : Thumb2DSPPat<(ARMSmlsld rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi),
3299 (t2SMLSLD rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>;
3300 def : Thumb2DSPPat<(ARMSmlsldx rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi),
3301 (t2SMLSLDX rGPR:$Rn, rGPR:$Rm, rGPR:$RLo, rGPR:$RHi)>;
3303 //===----------------------------------------------------------------------===//
3304 // Division Instructions.
3305 // Signed and unsigned division on v7-M
3307 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
3308 def t2SDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV,
3309 "sdiv", "\t$Rd, $Rn, $Rm",
3310 [(set rGPR:$Rd, (sdiv rGPR:$Rn, rGPR:$Rm))]>,
3311 Requires<[HasDivideInThumb, IsThumb, HasV8MBaseline]>,
3313 let Inst{31-27} = 0b11111;
3314 let Inst{26-21} = 0b011100;
3316 let Inst{15-12} = 0b1111;
3317 let Inst{7-4} = 0b1111;
3320 def t2UDIV : T2ThreeReg<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), IIC_iDIV,
3321 "udiv", "\t$Rd, $Rn, $Rm",
3322 [(set rGPR:$Rd, (udiv rGPR:$Rn, rGPR:$Rm))]>,
3323 Requires<[HasDivideInThumb, IsThumb, HasV8MBaseline]>,
3325 let Inst{31-27} = 0b11111;
3326 let Inst{26-21} = 0b011101;
3328 let Inst{15-12} = 0b1111;
3329 let Inst{7-4} = 0b1111;
3333 //===----------------------------------------------------------------------===//
3334 // Misc. Arithmetic Instructions.
3337 class T2I_misc<bits<2> op1, bits<2> op2, dag oops, dag iops,
3338 InstrItinClass itin, string opc, string asm, list<dag> pattern>
3339 : T2ThreeReg<oops, iops, itin, opc, asm, pattern> {
3340 let Inst{31-27} = 0b11111;
3341 let Inst{26-22} = 0b01010;
3342 let Inst{21-20} = op1;
3343 let Inst{15-12} = 0b1111;
3344 let Inst{7-6} = 0b10;
3345 let Inst{5-4} = op2;
3349 def t2CLZ : T2I_misc<0b11, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
3350 "clz", "\t$Rd, $Rm", [(set rGPR:$Rd, (ctlz rGPR:$Rm))]>,
3353 def t2RBIT : T2I_misc<0b01, 0b10, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
3354 "rbit", "\t$Rd, $Rm",
3355 [(set rGPR:$Rd, (bitreverse rGPR:$Rm))]>,
3358 def t2REV : T2I_misc<0b01, 0b00, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
3359 "rev", ".w\t$Rd, $Rm", [(set rGPR:$Rd, (bswap rGPR:$Rm))]>,
3362 def t2REV16 : T2I_misc<0b01, 0b01, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
3363 "rev16", ".w\t$Rd, $Rm",
3364 [(set rGPR:$Rd, (rotr (bswap rGPR:$Rm), (i32 16)))]>,
3367 def : T2Pat<(srl (bswap top16Zero:$Rn), (i32 16)),
3368 (t2REV16 rGPR:$Rn)>;
3370 def t2REVSH : T2I_misc<0b01, 0b11, (outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iUNAr,
3371 "revsh", ".w\t$Rd, $Rm",
3372 [(set rGPR:$Rd, (sra (bswap rGPR:$Rm), (i32 16)))]>,
3375 def : T2Pat<(or (sra (shl rGPR:$Rm, (i32 24)), (i32 16)),
3376 (and (srl rGPR:$Rm, (i32 8)), 0xFF)),
3377 (t2REVSH rGPR:$Rm)>;
3379 def t2PKHBT : T2ThreeReg<
3380 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_lsl_amt:$sh),
3381 IIC_iBITsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3382 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF),
3383 (and (shl rGPR:$Rm, pkh_lsl_amt:$sh),
3385 Requires<[HasDSP, IsThumb2]>,
3386 Sched<[WriteALUsi, ReadALU]> {
3387 let Inst{31-27} = 0b11101;
3388 let Inst{26-25} = 0b01;
3389 let Inst{24-20} = 0b01100;
3390 let Inst{5} = 0; // BT form
3394 let Inst{14-12} = sh{4-2};
3395 let Inst{7-6} = sh{1-0};
3398 // Alternate cases for PKHBT where identities eliminate some nodes.
3399 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (and rGPR:$src2, 0xFFFF0000)),
3400 (t2PKHBT rGPR:$src1, rGPR:$src2, 0)>,
3401 Requires<[HasDSP, IsThumb2]>;
3402 def : T2Pat<(or (and rGPR:$src1, 0xFFFF), (shl rGPR:$src2, imm16_31:$sh)),
3403 (t2PKHBT rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
3404 Requires<[HasDSP, IsThumb2]>;
3406 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3407 // will match the pattern below.
3408 def t2PKHTB : T2ThreeReg<
3409 (outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm, pkh_asr_amt:$sh),
3410 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3411 [(set rGPR:$Rd, (or (and rGPR:$Rn, 0xFFFF0000),
3412 (and (sra rGPR:$Rm, pkh_asr_amt:$sh),
3414 Requires<[HasDSP, IsThumb2]>,
3415 Sched<[WriteALUsi, ReadALU]> {
3416 let Inst{31-27} = 0b11101;
3417 let Inst{26-25} = 0b01;
3418 let Inst{24-20} = 0b01100;
3419 let Inst{5} = 1; // TB form
3423 let Inst{14-12} = sh{4-2};
3424 let Inst{7-6} = sh{1-0};
3427 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3428 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3429 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
3430 // pkhtb src1, src2, asr (17..31).
3431 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (srl rGPR:$src2, imm16:$sh)),
3432 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16:$sh)>,
3433 Requires<[HasDSP, IsThumb2]>;
3434 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000), (sra rGPR:$src2, imm16_31:$sh)),
3435 (t2PKHTB rGPR:$src1, rGPR:$src2, imm16_31:$sh)>,
3436 Requires<[HasDSP, IsThumb2]>;
3437 def : T2Pat<(or (and rGPR:$src1, 0xFFFF0000),
3438 (and (srl rGPR:$src2, imm1_15:$sh), 0xFFFF)),
3439 (t2PKHTB rGPR:$src1, rGPR:$src2, imm1_15:$sh)>,
3440 Requires<[HasDSP, IsThumb2]>;
3442 //===----------------------------------------------------------------------===//
3443 // CRC32 Instructions
3446 // + CRC32{B,H,W} 0x04C11DB7
3447 // + CRC32C{B,H,W} 0x1EDC6F41
3450 class T2I_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
3451 : T2ThreeRegNoP<(outs rGPR:$Rd), (ins rGPR:$Rn, rGPR:$Rm), NoItinerary,
3452 !strconcat("crc32", suffix, "\t$Rd, $Rn, $Rm"),
3453 [(set rGPR:$Rd, (builtin rGPR:$Rn, rGPR:$Rm))]>,
3454 Requires<[IsThumb2, HasCRC]> {
3455 let Inst{31-27} = 0b11111;
3456 let Inst{26-21} = 0b010110;
3458 let Inst{15-12} = 0b1111;
3459 let Inst{7-6} = 0b10;
3463 def t2CRC32B : T2I_crc32<0, 0b00, "b", int_arm_crc32b>;
3464 def t2CRC32CB : T2I_crc32<1, 0b00, "cb", int_arm_crc32cb>;
3465 def t2CRC32H : T2I_crc32<0, 0b01, "h", int_arm_crc32h>;
3466 def t2CRC32CH : T2I_crc32<1, 0b01, "ch", int_arm_crc32ch>;
3467 def t2CRC32W : T2I_crc32<0, 0b10, "w", int_arm_crc32w>;
3468 def t2CRC32CW : T2I_crc32<1, 0b10, "cw", int_arm_crc32cw>;
3470 //===----------------------------------------------------------------------===//
3471 // Comparison Instructions...
3473 defm t2CMP : T2I_cmp_irs<0b1101, "cmp", GPRnopc,
3474 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi, ARMcmp>;
3476 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_imm:$imm),
3477 (t2CMPri GPRnopc:$lhs, t2_so_imm:$imm)>;
3478 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, rGPR:$rhs),
3479 (t2CMPrr GPRnopc:$lhs, rGPR:$rhs)>;
3480 def : T2Pat<(ARMcmpZ GPRnopc:$lhs, t2_so_reg_oneuse:$rhs),
3481 (t2CMPrs GPRnopc:$lhs, t2_so_reg_oneuse:$rhs)>;
3483 let isCompare = 1, Defs = [CPSR] in {
3485 def t2CMNri : T2OneRegCmpImm<
3486 (outs), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iCMPi,
3487 "cmn", ".w\t$Rn, $imm",
3488 [(set CPSR, (ARMcmn GPRnopc:$Rn, (ineg t2_so_imm:$imm)))]>,
3489 Sched<[WriteCMP, ReadALU]> {
3490 let Inst{31-27} = 0b11110;
3492 let Inst{24-21} = 0b1000;
3493 let Inst{20} = 1; // The S bit.
3495 let Inst{11-8} = 0b1111; // Rd
3498 def t2CMNzrr : T2TwoRegCmp<
3499 (outs), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iCMPr,
3500 "cmn", ".w\t$Rn, $Rm",
3501 [(set CPSR, (BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3502 GPRnopc:$Rn, rGPR:$Rm))]>,
3503 Sched<[WriteCMP, ReadALU, ReadALU]> {
3504 let Inst{31-27} = 0b11101;
3505 let Inst{26-25} = 0b01;
3506 let Inst{24-21} = 0b1000;
3507 let Inst{20} = 1; // The S bit.
3508 let Inst{14-12} = 0b000; // imm3
3509 let Inst{11-8} = 0b1111; // Rd
3510 let Inst{7-6} = 0b00; // imm2
3511 let Inst{5-4} = 0b00; // type
3514 def t2CMNzrs : T2OneRegCmpShiftedReg<
3515 (outs), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), IIC_iCMPsi,
3516 "cmn", ".w\t$Rn, $ShiftedRm",
3517 [(set CPSR, (BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3518 GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]>,
3519 Sched<[WriteCMPsi, ReadALU, ReadALU]> {
3520 let Inst{31-27} = 0b11101;
3521 let Inst{26-25} = 0b01;
3522 let Inst{24-21} = 0b1000;
3523 let Inst{20} = 1; // The S bit.
3524 let Inst{11-8} = 0b1111; // Rd
3528 // Assembler aliases w/o the ".w" suffix.
3529 // No alias here for 'rr' version as not all instantiations of this multiclass
3530 // want one (CMP in particular, does not).
3531 def : t2InstAlias<"cmn${p} $Rn, $imm",
3532 (t2CMNri GPRnopc:$Rn, t2_so_imm:$imm, pred:$p)>;
3533 def : t2InstAlias<"cmn${p} $Rn, $shift",
3534 (t2CMNzrs GPRnopc:$Rn, t2_so_reg:$shift, pred:$p)>;
3536 def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
3537 (t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
3539 def : T2Pat<(ARMcmpZ GPRnopc:$src, t2_so_imm_neg:$imm),
3540 (t2CMNri GPRnopc:$src, t2_so_imm_neg:$imm)>;
3542 defm t2TST : T2I_cmp_irs<0b0000, "tst", rGPR,
3543 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
3544 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>>;
3545 defm t2TEQ : T2I_cmp_irs<0b0100, "teq", rGPR,
3546 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsi,
3547 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>>;
3549 // Conditional moves
3550 let hasSideEffects = 0 in {
3552 let isCommutable = 1, isSelect = 1 in
3553 def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd),
3554 (ins rGPR:$false, rGPR:$Rm, pred:$p),
3556 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
3558 let isMoveImm = 1 in
3560 : t2PseudoInst<(outs rGPR:$Rd),
3561 (ins rGPR:$false, t2_so_imm:$imm, pred:$p),
3563 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
3565 let isCodeGenOnly = 1 in {
3566 let isMoveImm = 1 in
3568 : t2PseudoInst<(outs rGPR:$Rd),
3569 (ins rGPR:$false, imm0_65535_expr:$imm, pred:$p),
3571 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
3573 let isMoveImm = 1 in
3575 : t2PseudoInst<(outs rGPR:$Rd),
3576 (ins rGPR:$false, t2_so_imm:$imm, pred:$p),
3578 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
3581 : t2PseudoInst<(outs rGPR:$Rd),
3582 (ins rGPR:$false, rGPR:$Rm, i32imm:$imm, pred:$p),
3583 4, IIC_iCMOVsi, []>,
3584 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
3586 def t2MOVCClsl : MOVCCShPseudo;
3587 def t2MOVCClsr : MOVCCShPseudo;
3588 def t2MOVCCasr : MOVCCShPseudo;
3589 def t2MOVCCror : MOVCCShPseudo;
3591 let isMoveImm = 1 in
3593 : t2PseudoInst<(outs rGPR:$dst),
3594 (ins rGPR:$false, i32imm:$src, pred:$p),
3595 8, IIC_iCMOVix2, []>,
3596 RegConstraint<"$false = $dst">;
3597 } // isCodeGenOnly = 1
3601 // The following patterns have to be defined out-of-line because the number
3602 // of instruction operands does not match the number of SDNode operands
3603 // (`pred` counts as one operand).
3605 def : T2Pat<(ARMcmov i32:$false, i32:$Rm, imm:$cc, CPSR),
3606 (t2MOVCCr $false, $Rm, imm:$cc, CPSR)>;
3608 def : T2Pat<(ARMcmov i32:$false, t2_so_imm:$imm, imm:$cc, CPSR),
3609 (t2MOVCCi $false, t2_so_imm:$imm, imm:$cc, CPSR)>;
3611 def : T2Pat<(ARMcmov i32:$false, imm0_65535:$imm, imm:$cc, CPSR),
3612 (t2MOVCCi16 $false, imm0_65535:$imm, imm:$cc, CPSR)>;
3614 def : T2Pat<(ARMcmov i32:$false, t2_so_imm_not:$imm, imm:$cc, CPSR),
3615 (t2MVNCCi $false, t2_so_imm_not:$imm, imm:$cc, CPSR)>;
3617 def : T2Pat<(ARMcmov i32:$false, (shl i32:$Rm, imm0_31:$imm), imm:$cc, CPSR),
3618 (t2MOVCClsl $false, $Rm, imm0_31:$imm, imm:$cc, CPSR)>;
3620 def : T2Pat<(ARMcmov i32:$false, (srl i32:$Rm, imm_sr:$imm), imm:$cc, CPSR),
3621 (t2MOVCClsr $false, $Rm, imm_sr:$imm, imm:$cc, CPSR)>;
3623 def : T2Pat<(ARMcmov i32:$false, (sra i32:$Rm, imm_sr:$imm), imm:$cc, CPSR),
3624 (t2MOVCCasr $false, $Rm, imm_sr:$imm, imm:$cc, CPSR)>;
3626 def : T2Pat<(ARMcmov i32:$false, (rotr i32:$Rm, imm0_31:$imm), imm:$cc, CPSR),
3627 (t2MOVCCror $false, $Rm, imm0_31:$imm, imm:$cc, CPSR)>;
3629 def : T2Pat<(ARMcmov i32:$false, imm:$src, imm:$cc, CPSR),
3630 (t2MOVCCi32imm $false, imm:$src, imm:$cc, CPSR)>;
3632 //===----------------------------------------------------------------------===//
3633 // Atomic operations intrinsics
3636 // memory barriers protect the atomic sequences
3637 let hasSideEffects = 1 in {
3638 def t2DMB : T2I<(outs), (ins memb_opt:$opt), NoItinerary,
3639 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
3640 Requires<[IsThumb, HasDB]> {
3642 let Inst{31-4} = 0xf3bf8f5;
3643 let Inst{3-0} = opt;
3646 def t2DSB : T2I<(outs), (ins memb_opt:$opt), NoItinerary,
3647 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
3648 Requires<[IsThumb, HasDB]> {
3650 let Inst{31-4} = 0xf3bf8f4;
3651 let Inst{3-0} = opt;
3654 def t2ISB : T2I<(outs), (ins instsyncb_opt:$opt), NoItinerary,
3655 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
3656 Requires<[IsThumb, HasDB]> {
3658 let Inst{31-4} = 0xf3bf8f6;
3659 let Inst{3-0} = opt;
3662 let hasNoSchedulingInfo = 1 in
3663 def t2TSB : T2I<(outs), (ins tsb_opt:$opt), NoItinerary,
3664 "tsb", "\t$opt", []>, Requires<[IsThumb, HasV8_4a]> {
3665 let Inst{31-0} = 0xf3af8012;
3666 let DecoderMethod = "DecodeTSBInstruction";
3670 // Armv8.5-A speculation barrier
3671 def t2SB : Thumb2XI<(outs), (ins), AddrModeNone, 4, NoItinerary, "sb", "", []>,
3672 Requires<[IsThumb2, HasSB]>, Sched<[]> {
3673 let Inst{31-0} = 0xf3bf8f70;
3674 let Unpredictable = 0x000f2f0f;
3675 let hasSideEffects = 1;
3678 class T2I_ldrex<bits<4> opcod, dag oops, dag iops, AddrMode am, int sz,
3679 InstrItinClass itin, string opc, string asm, string cstr,
3680 list<dag> pattern, bits<4> rt2 = 0b1111>
3681 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3682 let Inst{31-27} = 0b11101;
3683 let Inst{26-20} = 0b0001101;
3684 let Inst{11-8} = rt2;
3685 let Inst{7-4} = opcod;
3686 let Inst{3-0} = 0b1111;
3690 let Inst{19-16} = addr;
3691 let Inst{15-12} = Rt;
3693 class T2I_strex<bits<4> opcod, dag oops, dag iops, AddrMode am, int sz,
3694 InstrItinClass itin, string opc, string asm, string cstr,
3695 list<dag> pattern, bits<4> rt2 = 0b1111>
3696 : Thumb2I<oops, iops, am, sz, itin, opc, asm, cstr, pattern> {
3697 let Inst{31-27} = 0b11101;
3698 let Inst{26-20} = 0b0001100;
3699 let Inst{11-8} = rt2;
3700 let Inst{7-4} = opcod;
3706 let Inst{19-16} = addr;
3707 let Inst{15-12} = Rt;
3710 let mayLoad = 1 in {
3711 def t2LDREXB : T2I_ldrex<0b0100, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3712 AddrModeNone, 4, NoItinerary,
3713 "ldrexb", "\t$Rt, $addr", "",
3714 [(set rGPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>,
3715 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteLd]>;
3716 def t2LDREXH : T2I_ldrex<0b0101, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3717 AddrModeNone, 4, NoItinerary,
3718 "ldrexh", "\t$Rt, $addr", "",
3719 [(set rGPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>,
3720 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteLd]>;
3721 def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_imm0_1020s4:$addr),
3722 AddrModeT2_ldrex, 4, NoItinerary,
3723 "ldrex", "\t$Rt, $addr", "",
3724 [(set rGPR:$Rt, (ldrex_4 t2addrmode_imm0_1020s4:$addr))]>,
3725 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteLd]> {
3728 let Inst{31-27} = 0b11101;
3729 let Inst{26-20} = 0b0000101;
3730 let Inst{19-16} = addr{11-8};
3731 let Inst{15-12} = Rt;
3732 let Inst{11-8} = 0b1111;
3733 let Inst{7-0} = addr{7-0};
3735 let hasExtraDefRegAllocReq = 1 in
3736 def t2LDREXD : T2I_ldrex<0b0111, (outs rGPR:$Rt, rGPR:$Rt2),
3737 (ins addr_offset_none:$addr),
3738 AddrModeNone, 4, NoItinerary,
3739 "ldrexd", "\t$Rt, $Rt2, $addr", "",
3741 Requires<[IsThumb2, IsNotMClass]>, Sched<[WriteLd]> {
3743 let Inst{11-8} = Rt2;
3745 def t2LDAEXB : T2I_ldrex<0b1100, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3746 AddrModeNone, 4, NoItinerary,
3747 "ldaexb", "\t$Rt, $addr", "",
3748 [(set rGPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>,
3749 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, Sched<[WriteLd]>;
3750 def t2LDAEXH : T2I_ldrex<0b1101, (outs rGPR:$Rt), (ins addr_offset_none:$addr),
3751 AddrModeNone, 4, NoItinerary,
3752 "ldaexh", "\t$Rt, $addr", "",
3753 [(set rGPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>,
3754 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, Sched<[WriteLd]>;
3755 def t2LDAEX : Thumb2I<(outs rGPR:$Rt), (ins addr_offset_none:$addr),
3756 AddrModeNone, 4, NoItinerary,
3757 "ldaex", "\t$Rt, $addr", "",
3758 [(set rGPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>,
3759 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>, Sched<[WriteLd]> {
3762 let Inst{31-27} = 0b11101;
3763 let Inst{26-20} = 0b0001101;
3764 let Inst{19-16} = addr;
3765 let Inst{15-12} = Rt;
3766 let Inst{11-8} = 0b1111;
3767 let Inst{7-0} = 0b11101111;
3769 let hasExtraDefRegAllocReq = 1 in
3770 def t2LDAEXD : T2I_ldrex<0b1111, (outs rGPR:$Rt, rGPR:$Rt2),
3771 (ins addr_offset_none:$addr),
3772 AddrModeNone, 4, NoItinerary,
3773 "ldaexd", "\t$Rt, $Rt2, $addr", "",
3774 [], {?, ?, ?, ?}>, Requires<[IsThumb,
3775 HasAcquireRelease, HasV7Clrex, IsNotMClass]>, Sched<[WriteLd]> {
3777 let Inst{11-8} = Rt2;
3783 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
3784 def t2STREXB : T2I_strex<0b0100, (outs rGPR:$Rd),
3785 (ins rGPR:$Rt, addr_offset_none:$addr),
3786 AddrModeNone, 4, NoItinerary,
3787 "strexb", "\t$Rd, $Rt, $addr", "",
3789 (strex_1 rGPR:$Rt, addr_offset_none:$addr))]>,
3790 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteST]>;
3791 def t2STREXH : T2I_strex<0b0101, (outs rGPR:$Rd),
3792 (ins rGPR:$Rt, addr_offset_none:$addr),
3793 AddrModeNone, 4, NoItinerary,
3794 "strexh", "\t$Rd, $Rt, $addr", "",
3796 (strex_2 rGPR:$Rt, addr_offset_none:$addr))]>,
3797 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteST]>;
3799 def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt,
3800 t2addrmode_imm0_1020s4:$addr),
3801 AddrModeT2_ldrex, 4, NoItinerary,
3802 "strex", "\t$Rd, $Rt, $addr", "",
3804 (strex_4 rGPR:$Rt, t2addrmode_imm0_1020s4:$addr))]>,
3805 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteST]> {
3809 let Inst{31-27} = 0b11101;
3810 let Inst{26-20} = 0b0000100;
3811 let Inst{19-16} = addr{11-8};
3812 let Inst{15-12} = Rt;
3813 let Inst{11-8} = Rd;
3814 let Inst{7-0} = addr{7-0};
3816 let hasExtraSrcRegAllocReq = 1 in
3817 def t2STREXD : T2I_strex<0b0111, (outs rGPR:$Rd),
3818 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr),
3819 AddrModeNone, 4, NoItinerary,
3820 "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [],
3822 Requires<[IsThumb2, IsNotMClass]>, Sched<[WriteST]> {
3824 let Inst{11-8} = Rt2;
3826 def t2STLEXB : T2I_strex<0b1100, (outs rGPR:$Rd),
3827 (ins rGPR:$Rt, addr_offset_none:$addr),
3828 AddrModeNone, 4, NoItinerary,
3829 "stlexb", "\t$Rd, $Rt, $addr", "",
3831 (stlex_1 rGPR:$Rt, addr_offset_none:$addr))]>,
3832 Requires<[IsThumb, HasAcquireRelease,
3833 HasV7Clrex]>, Sched<[WriteST]>;
3835 def t2STLEXH : T2I_strex<0b1101, (outs rGPR:$Rd),
3836 (ins rGPR:$Rt, addr_offset_none:$addr),
3837 AddrModeNone, 4, NoItinerary,
3838 "stlexh", "\t$Rd, $Rt, $addr", "",
3840 (stlex_2 rGPR:$Rt, addr_offset_none:$addr))]>,
3841 Requires<[IsThumb, HasAcquireRelease,
3842 HasV7Clrex]>, Sched<[WriteST]>;
3844 def t2STLEX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt,
3845 addr_offset_none:$addr),
3846 AddrModeNone, 4, NoItinerary,
3847 "stlex", "\t$Rd, $Rt, $addr", "",
3849 (stlex_4 rGPR:$Rt, addr_offset_none:$addr))]>,
3850 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>,
3855 let Inst{31-27} = 0b11101;
3856 let Inst{26-20} = 0b0001100;
3857 let Inst{19-16} = addr;
3858 let Inst{15-12} = Rt;
3859 let Inst{11-4} = 0b11111110;
3862 let hasExtraSrcRegAllocReq = 1 in
3863 def t2STLEXD : T2I_strex<0b1111, (outs rGPR:$Rd),
3864 (ins rGPR:$Rt, rGPR:$Rt2, addr_offset_none:$addr),
3865 AddrModeNone, 4, NoItinerary,
3866 "stlexd", "\t$Rd, $Rt, $Rt2, $addr", "", [],
3867 {?, ?, ?, ?}>, Requires<[IsThumb, HasAcquireRelease,
3868 HasV7Clrex, IsNotMClass]>, Sched<[WriteST]> {
3870 let Inst{11-8} = Rt2;
3874 def t2CLREX : T2I<(outs), (ins), NoItinerary, "clrex", "", [(int_arm_clrex)]>,
3875 Requires<[IsThumb, HasV7Clrex]> {
3876 let Inst{31-16} = 0xf3bf;
3877 let Inst{15-14} = 0b10;
3880 let Inst{11-8} = 0b1111;
3881 let Inst{7-4} = 0b0010;
3882 let Inst{3-0} = 0b1111;
3885 def : T2Pat<(and (ldrex_1 addr_offset_none:$addr), 0xff),
3886 (t2LDREXB addr_offset_none:$addr)>,
3887 Requires<[IsThumb, HasV8MBaseline]>;
3888 def : T2Pat<(and (ldrex_2 addr_offset_none:$addr), 0xffff),
3889 (t2LDREXH addr_offset_none:$addr)>,
3890 Requires<[IsThumb, HasV8MBaseline]>;
3891 def : T2Pat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
3892 (t2STREXB GPR:$Rt, addr_offset_none:$addr)>,
3893 Requires<[IsThumb, HasV8MBaseline]>;
3894 def : T2Pat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
3895 (t2STREXH GPR:$Rt, addr_offset_none:$addr)>,
3896 Requires<[IsThumb, HasV8MBaseline]>;
3898 def : T2Pat<(and (ldaex_1 addr_offset_none:$addr), 0xff),
3899 (t2LDAEXB addr_offset_none:$addr)>,
3900 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>;
3901 def : T2Pat<(and (ldaex_2 addr_offset_none:$addr), 0xffff),
3902 (t2LDAEXH addr_offset_none:$addr)>,
3903 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>;
3904 def : T2Pat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
3905 (t2STLEXB GPR:$Rt, addr_offset_none:$addr)>,
3906 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>;
3907 def : T2Pat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
3908 (t2STLEXH GPR:$Rt, addr_offset_none:$addr)>,
3909 Requires<[IsThumb, HasAcquireRelease, HasV7Clrex]>;
3911 //===----------------------------------------------------------------------===//
3912 // SJLJ Exception handling intrinsics
3913 // eh_sjlj_setjmp() is an instruction sequence to store the return
3914 // address and save #0 in R0 for the non-longjmp case.
3915 // Since by its nature we may be coming from some other function to get
3916 // here, and we're using the stack frame for the containing function to
3917 // save/restore registers, we can't keep anything live in regs across
3918 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
3919 // when we get here from a longjmp(). We force everything out of registers
3920 // except for our own input by listing the relevant registers in Defs. By
3921 // doing so, we also cause the prologue/epilogue code to actively preserve
3922 // all of the callee-saved registers, which is exactly what we want.
3923 // $val is a scratch register for our use.
3924 // This gets lowered to an instruction sequence of 12 bytes
3926 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
3927 Q0, Q1, Q2, Q3, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15],
3928 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1, Size = 12,
3929 usesCustomInserter = 1 in {
3930 def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
3931 AddrModeNone, 0, NoItinerary, "", "",
3932 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
3933 Requires<[IsThumb2, HasVFP2]>;
3936 // This gets lowered to an instruction sequence of 12 bytes
3938 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
3939 hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1, Size = 12,
3940 usesCustomInserter = 1 in {
3941 def t2Int_eh_sjlj_setjmp_nofp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val),
3942 AddrModeNone, 0, NoItinerary, "", "",
3943 [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>,
3944 Requires<[IsThumb2, NoVFP]>;
3948 //===----------------------------------------------------------------------===//
3949 // Control-Flow Instructions
3952 // FIXME: remove when we have a way to marking a MI with these properties.
3953 // FIXME: Should pc be an implicit operand like PICADD, etc?
3954 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3955 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3956 def t2LDMIA_RET: t2PseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3957 reglist:$regs, variable_ops),
3958 4, IIC_iLoad_mBr, [],
3959 (t2LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3960 RegConstraint<"$Rn = $wb">;
3962 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
3963 let isPredicable = 1 in
3964 def t2B : T2I<(outs), (ins thumb_br_target:$target), IIC_Br,
3966 [(br bb:$target)]>, Sched<[WriteBr]>,
3967 Requires<[IsThumb, HasV8MBaseline]> {
3968 let Inst{31-27} = 0b11110;
3969 let Inst{15-14} = 0b10;
3973 let Inst{26} = target{23};
3974 let Inst{13} = target{22};
3975 let Inst{11} = target{21};
3976 let Inst{25-16} = target{20-11};
3977 let Inst{10-0} = target{10-0};
3978 let DecoderMethod = "DecodeT2BInstruction";
3979 let AsmMatchConverter = "cvtThumbBranches";
3982 let Size = 4, isNotDuplicable = 1, isBranch = 1, isTerminator = 1,
3983 isBarrier = 1, isIndirectBranch = 1 in {
3985 // available in both v8-M.Baseline and Thumb2 targets
3986 def t2BR_JT : t2basePseudoInst<(outs),
3987 (ins GPR:$target, GPR:$index, i32imm:$jt),
3989 [(ARMbr2jt GPR:$target, GPR:$index, tjumptable:$jt)]>,
3992 // FIXME: Add a case that can be predicated.
3993 def t2TBB_JT : t2PseudoInst<(outs),
3994 (ins GPR:$base, GPR:$index, i32imm:$jt, i32imm:$pclbl), 0, IIC_Br, []>,
3997 def t2TBH_JT : t2PseudoInst<(outs),
3998 (ins GPR:$base, GPR:$index, i32imm:$jt, i32imm:$pclbl), 0, IIC_Br, []>,
4001 def t2TBB : T2I<(outs), (ins (addrmode_tbb $Rn, $Rm):$addr), IIC_Br,
4002 "tbb", "\t$addr", []>, Sched<[WriteBrTbl]> {
4005 let Inst{31-20} = 0b111010001101;
4006 let Inst{19-16} = Rn;
4007 let Inst{15-5} = 0b11110000000;
4008 let Inst{4} = 0; // B form
4011 let DecoderMethod = "DecodeThumbTableBranch";
4014 def t2TBH : T2I<(outs), (ins (addrmode_tbh $Rn, $Rm):$addr), IIC_Br,
4015 "tbh", "\t$addr", []>, Sched<[WriteBrTbl]> {
4018 let Inst{31-20} = 0b111010001101;
4019 let Inst{19-16} = Rn;
4020 let Inst{15-5} = 0b11110000000;
4021 let Inst{4} = 1; // H form
4024 let DecoderMethod = "DecodeThumbTableBranch";
4026 } // isNotDuplicable, isIndirectBranch
4028 } // isBranch, isTerminator, isBarrier
4030 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
4031 // a two-value operand where a dag node expects ", "two operands. :(
4032 let isBranch = 1, isTerminator = 1 in
4033 def t2Bcc : T2I<(outs), (ins brtarget:$target), IIC_Br,
4035 [/*(ARMbrcond bb:$target, imm:$cc)*/]>, Sched<[WriteBr]> {
4036 let Inst{31-27} = 0b11110;
4037 let Inst{15-14} = 0b10;
4041 let Inst{25-22} = p;
4044 let Inst{26} = target{20};
4045 let Inst{11} = target{19};
4046 let Inst{13} = target{18};
4047 let Inst{21-16} = target{17-12};
4048 let Inst{10-0} = target{11-1};
4050 let DecoderMethod = "DecodeThumb2BCCInstruction";
4051 let AsmMatchConverter = "cvtThumbBranches";
4054 // Tail calls. The MachO version of thumb tail calls uses a t2 branch, so
4056 // Windows SEH unwinding also needs a strict t2 branch for tail calls.
4057 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
4060 def tTAILJMPd: tPseudoExpand<(outs),
4061 (ins thumb_br_target:$dst, pred:$p),
4063 (t2B thumb_br_target:$dst, pred:$p)>,
4064 Requires<[IsThumb2]>, Sched<[WriteBr]>;
4068 let Defs = [ITSTATE] in
4069 def t2IT : Thumb2XI<(outs), (ins it_pred:$cc, it_mask:$mask),
4070 AddrModeNone, 2, IIC_iALUx,
4071 "it$mask\t$cc", "", []> {
4072 // 16-bit instruction.
4073 let Inst{31-16} = 0x0000;
4074 let Inst{15-8} = 0b10111111;
4079 let Inst{3-0} = mask;
4081 let DecoderMethod = "DecodeIT";
4084 // Branch and Exchange Jazelle -- for disassembly only
4086 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4087 def t2BXJ : T2I<(outs), (ins GPRnopc:$func), NoItinerary, "bxj", "\t$func", []>,
4088 Sched<[WriteBr]>, Requires<[IsThumb2, IsNotMClass]> {
4090 let Inst{31-27} = 0b11110;
4092 let Inst{25-20} = 0b111100;
4093 let Inst{19-16} = func;
4094 let Inst{15-0} = 0b1000111100000000;
4097 def : t2InstAlias<"bl${p}.w $func", (tBL pred:$p, thumb_bl_target:$func), 0>;
4099 // Compare and branch on zero / non-zero
4100 let isBranch = 1, isTerminator = 1 in {
4101 def tCBZ : T1I<(outs), (ins tGPR:$Rn, thumb_cb_target:$target), IIC_Br,
4102 "cbz\t$Rn, $target", []>,
4103 T1Misc<{0,0,?,1,?,?,?}>,
4104 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteBr]> {
4108 let Inst{9} = target{5};
4109 let Inst{7-3} = target{4-0};
4113 def tCBNZ : T1I<(outs), (ins tGPR:$Rn, thumb_cb_target:$target), IIC_Br,
4114 "cbnz\t$Rn, $target", []>,
4115 T1Misc<{1,0,?,1,?,?,?}>,
4116 Requires<[IsThumb, HasV8MBaseline]>, Sched<[WriteBr]> {
4120 let Inst{9} = target{5};
4121 let Inst{7-3} = target{4-0};
4127 // Change Processor State is a system instruction.
4128 // FIXME: Since the asm parser has currently no clean way to handle optional
4129 // operands, create 3 versions of the same instruction. Once there's a clean
4130 // framework to represent optional operands, change this behavior.
4131 class t2CPS<dag iops, string asm_op> : T2XI<(outs), iops, NoItinerary,
4132 !strconcat("cps", asm_op), []>,
4133 Requires<[IsThumb2, IsNotMClass]> {
4139 let Inst{31-11} = 0b111100111010111110000;
4140 let Inst{10-9} = imod;
4142 let Inst{7-5} = iflags;
4143 let Inst{4-0} = mode;
4144 let DecoderMethod = "DecodeT2CPSInstruction";
4148 def t2CPS3p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags, i32imm:$mode),
4149 "$imod\t$iflags, $mode">;
4150 let mode = 0, M = 0 in
4151 def t2CPS2p : t2CPS<(ins imod_op:$imod, iflags_op:$iflags),
4152 "$imod.w\t$iflags">;
4153 let imod = 0, iflags = 0, M = 1 in
4154 def t2CPS1p : t2CPS<(ins imm0_31:$mode), "\t$mode">;
4156 def : t2InstAlias<"cps$imod.w $iflags, $mode",
4157 (t2CPS3p imod_op:$imod, iflags_op:$iflags, i32imm:$mode), 0>;
4158 def : t2InstAlias<"cps.w $mode", (t2CPS1p imm0_31:$mode), 0>;
4160 // A6.3.4 Branches and miscellaneous control
4161 // Table A6-14 Change Processor State, and hint instructions
4162 def t2HINT : T2I<(outs), (ins imm0_239:$imm), NoItinerary, "hint", ".w\t$imm",
4163 [(int_arm_hint imm0_239:$imm)]> {
4165 let Inst{31-3} = 0b11110011101011111000000000000;
4166 let Inst{7-0} = imm;
4168 let DecoderMethod = "DecodeT2HintSpaceInstruction";
4171 def : t2InstAlias<"hint$p $imm", (t2HINT imm0_239:$imm, pred:$p), 0>;
4172 def : t2InstAlias<"nop$p.w", (t2HINT 0, pred:$p), 1>;
4173 def : t2InstAlias<"yield$p.w", (t2HINT 1, pred:$p), 1>;
4174 def : t2InstAlias<"wfe$p.w", (t2HINT 2, pred:$p), 1>;
4175 def : t2InstAlias<"wfi$p.w", (t2HINT 3, pred:$p), 1>;
4176 def : t2InstAlias<"sev$p.w", (t2HINT 4, pred:$p), 1>;
4177 def : t2InstAlias<"sevl$p.w", (t2HINT 5, pred:$p), 1> {
4178 let Predicates = [IsThumb2, HasV8];
4180 def : t2InstAlias<"esb$p.w", (t2HINT 16, pred:$p), 1> {
4181 let Predicates = [IsThumb2, HasRAS];
4183 def : t2InstAlias<"esb$p", (t2HINT 16, pred:$p), 0> {
4184 let Predicates = [IsThumb2, HasRAS];
4186 def : t2InstAlias<"csdb$p.w", (t2HINT 20, pred:$p), 0>;
4187 def : t2InstAlias<"csdb$p", (t2HINT 20, pred:$p), 1>;
4189 def : t2InstAlias<"pacbti$p r12,lr,sp", (t2HINT 13, pred:$p), 1>;
4190 def : t2InstAlias<"bti$p", (t2HINT 15, pred:$p), 1>;
4191 def : t2InstAlias<"pac$p r12,lr,sp", (t2HINT 29, pred:$p), 1>;
4192 def : t2InstAlias<"aut$p r12,lr,sp", (t2HINT 45, pred:$p), 1>;
4194 // Clear BHB instruction
4195 def : InstAlias<"clrbhb$p", (t2HINT 22, pred:$p), 0>, Requires<[IsThumb2, HasV8]>;
4196 def : InstAlias<"clrbhb$p", (t2HINT 22, pred:$p), 1>, Requires<[IsThumb2, HasV8, HasCLRBHB]>;
4198 def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt",
4199 [(int_arm_dbg imm0_15:$opt)]> {
4201 let Inst{31-20} = 0b111100111010;
4202 let Inst{19-16} = 0b1111;
4203 let Inst{15-8} = 0b10000000;
4204 let Inst{7-4} = 0b1111;
4205 let Inst{3-0} = opt;
4207 def : t2InstAlias<"dbg${p}.w $opt", (t2DBG imm0_15:$opt, pred:$p), 0>;
4209 // Secure Monitor Call is a system instruction.
4210 // Option = Inst{19-16}
4211 let isCall = 1, Uses = [SP] in
4212 def t2SMC : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
4213 []>, Requires<[IsThumb2, HasTrustZone]> {
4214 let Inst{31-27} = 0b11110;
4215 let Inst{26-20} = 0b1111111;
4216 let Inst{15-12} = 0b1000;
4219 let Inst{19-16} = opt;
4222 class T2DCPS<bits<2> opt, string opc>
4223 : T2I<(outs), (ins), NoItinerary, opc, "", []>, Requires<[IsThumb2, HasV8]> {
4224 let Inst{31-27} = 0b11110;
4225 let Inst{26-20} = 0b1111000;
4226 let Inst{19-16} = 0b1111;
4227 let Inst{15-12} = 0b1000;
4228 let Inst{11-2} = 0b0000000000;
4229 let Inst{1-0} = opt;
4232 def t2DCPS1 : T2DCPS<0b01, "dcps1">;
4233 def t2DCPS2 : T2DCPS<0b10, "dcps2">;
4234 def t2DCPS3 : T2DCPS<0b11, "dcps3">;
4236 class T2SRS<bits<2> Op, bit W, dag oops, dag iops, InstrItinClass itin,
4237 string opc, string asm, list<dag> pattern>
4238 : T2I<oops, iops, itin, opc, asm, pattern>,
4239 Requires<[IsThumb2,IsNotMClass]> {
4241 let Inst{31-25} = 0b1110100;
4242 let Inst{24-23} = Op;
4245 let Inst{20-16} = 0b01101;
4246 let Inst{15-5} = 0b11000000000;
4247 let Inst{4-0} = mode{4-0};
4250 // Store Return State is a system instruction.
4251 def t2SRSDB_UPD : T2SRS<0b00, 1, (outs), (ins imm0_31:$mode), NoItinerary,
4252 "srsdb", "\tsp!, $mode", []>;
4253 def t2SRSDB : T2SRS<0b00, 0, (outs), (ins imm0_31:$mode), NoItinerary,
4254 "srsdb","\tsp, $mode", []>;
4255 def t2SRSIA_UPD : T2SRS<0b11, 1, (outs), (ins imm0_31:$mode), NoItinerary,
4256 "srsia","\tsp!, $mode", []>;
4257 def t2SRSIA : T2SRS<0b11, 0, (outs), (ins imm0_31:$mode), NoItinerary,
4258 "srsia","\tsp, $mode", []>;
4261 def : t2InstAlias<"srsdb${p} $mode", (t2SRSDB imm0_31:$mode, pred:$p)>;
4262 def : t2InstAlias<"srsdb${p} $mode!", (t2SRSDB_UPD imm0_31:$mode, pred:$p)>;
4264 def : t2InstAlias<"srsia${p} $mode", (t2SRSIA imm0_31:$mode, pred:$p)>;
4265 def : t2InstAlias<"srsia${p} $mode!", (t2SRSIA_UPD imm0_31:$mode, pred:$p)>;
4267 // Return From Exception is a system instruction.
4268 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
4269 class T2RFE<bits<12> op31_20, dag oops, dag iops, InstrItinClass itin,
4270 string opc, string asm, list<dag> pattern>
4271 : T2I<oops, iops, itin, opc, asm, pattern>,
4272 Requires<[IsThumb2,IsNotMClass]> {
4273 let Inst{31-20} = op31_20{11-0};
4276 let Inst{19-16} = Rn;
4277 let Inst{15-0} = 0xc000;
4280 def t2RFEDBW : T2RFE<0b111010000011,
4281 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn!",
4282 [/* For disassembly only; pattern left blank */]>;
4283 def t2RFEDB : T2RFE<0b111010000001,
4284 (outs), (ins GPR:$Rn), NoItinerary, "rfedb", "\t$Rn",
4285 [/* For disassembly only; pattern left blank */]>;
4286 def t2RFEIAW : T2RFE<0b111010011011,
4287 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn!",
4288 [/* For disassembly only; pattern left blank */]>;
4289 def t2RFEIA : T2RFE<0b111010011001,
4290 (outs), (ins GPR:$Rn), NoItinerary, "rfeia", "\t$Rn",
4291 [/* For disassembly only; pattern left blank */]>;
4293 // B9.3.19 SUBS PC, LR, #imm (Thumb2) system instruction.
4294 // Exception return instruction is "subs pc, lr, #imm".
4295 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
4296 def t2SUBS_PC_LR : T2I <(outs), (ins imm0_255:$imm), NoItinerary,
4297 "subs", "\tpc, lr, $imm",
4298 [(ARMintretglue imm0_255:$imm)]>,
4299 Requires<[IsThumb2,IsNotMClass]> {
4300 let Inst{31-8} = 0b111100111101111010001111;
4303 let Inst{7-0} = imm;
4306 // B9.3.19 SUBS PC, LR (Thumb)
4307 // In the Thumb instruction set, MOVS{<c>}{<q>} PC, LR is a pseudo-instruction
4308 // for SUBS{<c>}{<q>} PC, LR, #0.
4309 def : t2InstAlias<"movs${p}\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>;
4310 def : t2InstAlias<"movs${p}.w\tpc, lr", (t2SUBS_PC_LR 0, pred:$p)>;
4312 // ERET - Return from exception in Hypervisor mode.
4313 // B9.3.3, B9.3.20: ERET is an alias for "SUBS PC, LR, #0" in an implementation that
4314 // includes virtualization extensions.
4315 def t2ERET : InstAlias<"eret${p}", (t2SUBS_PC_LR 0, pred:$p), 1>,
4316 Requires<[IsThumb2, HasVirtualization]>;
4318 // Hypervisor Call is a system instruction.
4320 def t2HVC : T2XI <(outs), (ins imm0_65535:$imm16), IIC_Br, "hvc.w\t$imm16", []>,
4321 Requires<[IsThumb2, HasVirtualization]>, Sched<[WriteBr]> {
4323 let Inst{31-20} = 0b111101111110;
4324 let Inst{19-16} = imm16{15-12};
4325 let Inst{15-12} = 0b1000;
4326 let Inst{11-0} = imm16{11-0};
4330 // Alias for HVC without the ".w" optional width specifier
4331 def : t2InstAlias<"hvc\t$imm16", (t2HVC imm0_65535:$imm16)>;
4333 //===----------------------------------------------------------------------===//
4334 // Non-Instruction Patterns
4337 // 32-bit immediate using movw + movt.
4338 // This is a single pseudo instruction to make it re-materializable.
4339 // FIXME: Remove this when we can do generalized remat.
4340 let isReMaterializable = 1, isMoveImm = 1, Size = 8 in
4341 def t2MOVi32imm : PseudoInst<(outs rGPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4342 [(set rGPR:$dst, (i32 imm:$src))]>,
4343 Requires<[IsThumb, UseMovt]>;
4345 // Pseudo instruction that combines movw + movt + add pc (if pic).
4346 // It also makes it possible to rematerialize the instructions.
4347 // FIXME: Remove this when we can do generalized remat and when machine licm
4348 // can properly the instructions.
4349 let isReMaterializable = 1 in {
4350 def t2MOV_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
4352 [(set rGPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4353 Requires<[IsThumb, HasV8MBaseline, UseMovtInPic]>;
4357 def : T2Pat<(ARMWrapperPIC tglobaltlsaddr :$dst),
4358 (t2MOV_ga_pcrel tglobaltlsaddr:$dst)>,
4359 Requires<[IsThumb2, UseMovtInPic]>;
4360 def : T2Pat<(ARMWrapper tglobaltlsaddr:$dst),
4361 (t2MOVi32imm tglobaltlsaddr:$dst)>,
4362 Requires<[IsThumb2, UseMovt]>;
4364 // ConstantPool, GlobalAddress, and JumpTable
4365 def : T2Pat<(ARMWrapper tconstpool :$dst), (t2LEApcrel tconstpool :$dst)>;
4366 def : T2Pat<(ARMWrapper texternalsym :$dst), (t2MOVi32imm texternalsym :$dst)>,
4367 Requires<[IsThumb, HasV8MBaseline, UseMovt]>;
4368 def : T2Pat<(ARMWrapper tglobaladdr :$dst), (t2MOVi32imm tglobaladdr :$dst)>,
4369 Requires<[IsThumb, HasV8MBaseline, UseMovt]>;
4371 def : T2Pat<(ARMWrapperJT tjumptable:$dst), (t2LEApcrelJT tjumptable:$dst)>;
4373 let hasNoSchedulingInfo = 1 in {
4374 def t2LDRLIT_ga_pcrel : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr),
4377 (ARMWrapperPIC tglobaladdr:$addr))]>,
4378 Requires<[IsThumb, HasV8MBaseline, DontUseMovtInPic]>;
4382 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
4383 (t2LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
4384 Requires<[IsThumb, HasV8MBaseline, DontUseMovtInPic]>;
4386 // Pseudo instruction that combines ldr from constpool and add pc. This should
4387 // be expanded into two instructions late to allow if-conversion and
4389 let canFoldAsLoad = 1, isReMaterializable = 1 in
4390 def t2LDRpci_pic : PseudoInst<(outs rGPR:$dst), (ins i32imm:$addr, pclabel:$cp),
4392 [(set rGPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)),
4394 Requires<[IsThumb2]>;
4396 // Pseudo instruction that combines movs + predicated rsbmi
4397 // to implement integer ABS
4398 let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in {
4399 def t2ABS : PseudoInst<(outs rGPR:$dst), (ins rGPR:$src),
4400 NoItinerary, []>, Requires<[IsThumb2]>;
4403 //===----------------------------------------------------------------------===//
4404 // Coprocessor load/store -- for disassembly only
4406 class T2CI<bits<4> op31_28, dag oops, dag iops, string opc, string asm,
4407 list<dag> pattern, AddrMode am = AddrModeNone>
4408 : T2I<oops, iops, NoItinerary, opc, asm, pattern, am> {
4409 let Inst{31-28} = op31_28;
4410 let Inst{27-25} = 0b110;
4413 multiclass t2LdStCop<bits<4> op31_28, bit load, bit Dbit, string asm, list<dag> pattern> {
4414 def _OFFSET : T2CI<op31_28,
4415 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4416 asm, "\t$cop, $CRd, $addr", pattern, AddrMode5> {
4420 let Inst{24} = 1; // P = 1
4421 let Inst{23} = addr{8};
4422 let Inst{22} = Dbit;
4423 let Inst{21} = 0; // W = 0
4424 let Inst{20} = load;
4425 let Inst{19-16} = addr{12-9};
4426 let Inst{15-12} = CRd;
4427 let Inst{11-8} = cop;
4428 let Inst{7-0} = addr{7-0};
4429 let DecoderMethod = "DecodeCopMemInstruction";
4431 def _PRE : T2CI<op31_28,
4432 (outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4433 asm, "\t$cop, $CRd, $addr!", []> {
4437 let Inst{24} = 1; // P = 1
4438 let Inst{23} = addr{8};
4439 let Inst{22} = Dbit;
4440 let Inst{21} = 1; // W = 1
4441 let Inst{20} = load;
4442 let Inst{19-16} = addr{12-9};
4443 let Inst{15-12} = CRd;
4444 let Inst{11-8} = cop;
4445 let Inst{7-0} = addr{7-0};
4446 let DecoderMethod = "DecodeCopMemInstruction";
4448 def _POST: T2CI<op31_28,
4449 (outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4450 postidx_imm8s4:$offset),
4451 asm, "\t$cop, $CRd, $addr, $offset", []> {
4456 let Inst{24} = 0; // P = 0
4457 let Inst{23} = offset{8};
4458 let Inst{22} = Dbit;
4459 let Inst{21} = 1; // W = 1
4460 let Inst{20} = load;
4461 let Inst{19-16} = addr;
4462 let Inst{15-12} = CRd;
4463 let Inst{11-8} = cop;
4464 let Inst{7-0} = offset{7-0};
4465 let DecoderMethod = "DecodeCopMemInstruction";
4467 def _OPTION : T2CI<op31_28, (outs),
4468 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4469 coproc_option_imm:$option),
4470 asm, "\t$cop, $CRd, $addr, $option", []> {
4475 let Inst{24} = 0; // P = 0
4476 let Inst{23} = 1; // U = 1
4477 let Inst{22} = Dbit;
4478 let Inst{21} = 0; // W = 0
4479 let Inst{20} = load;
4480 let Inst{19-16} = addr;
4481 let Inst{15-12} = CRd;
4482 let Inst{11-8} = cop;
4483 let Inst{7-0} = option;
4484 let DecoderMethod = "DecodeCopMemInstruction";
4488 let DecoderNamespace = "Thumb2CoProc" in {
4489 let mayLoad = 1 in {
4490 defm t2LDC : t2LdStCop<0b1110, 1, 0, "ldc", [(int_arm_ldc timm:$cop, timm:$CRd, addrmode5:$addr)]>;
4491 defm t2LDCL : t2LdStCop<0b1110, 1, 1, "ldcl", [(int_arm_ldcl timm:$cop, timm:$CRd, addrmode5:$addr)]>;
4492 defm t2LDC2 : t2LdStCop<0b1111, 1, 0, "ldc2", [(int_arm_ldc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>;
4493 defm t2LDC2L : t2LdStCop<0b1111, 1, 1, "ldc2l", [(int_arm_ldc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>;
4495 let mayStore = 1 in {
4496 defm t2STC : t2LdStCop<0b1110, 0, 0, "stc", [(int_arm_stc timm:$cop, timm:$CRd, addrmode5:$addr)]>;
4497 defm t2STCL : t2LdStCop<0b1110, 0, 1, "stcl", [(int_arm_stcl timm:$cop, timm:$CRd, addrmode5:$addr)]>;
4498 defm t2STC2 : t2LdStCop<0b1111, 0, 0, "stc2", [(int_arm_stc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>;
4499 defm t2STC2L : t2LdStCop<0b1111, 0, 1, "stc2l", [(int_arm_stc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[PreV8,IsThumb2]>;
4504 //===----------------------------------------------------------------------===//
4505 // Move between special register and ARM core register -- for disassembly only
4507 // Move to ARM core register from Special Register
4511 // A/R class can only move from CPSR or SPSR.
4512 def t2MRS_AR : T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, apsr",
4513 []>, Requires<[IsThumb2,IsNotMClass]> {
4515 let Inst{31-12} = 0b11110011111011111000;
4516 let Inst{11-8} = Rd;
4517 let Inst{7-0} = 0b00000000;
4520 def : t2InstAlias<"mrs${p} $Rd, cpsr", (t2MRS_AR GPR:$Rd, pred:$p)>;
4522 def t2MRSsys_AR: T2I<(outs GPR:$Rd), (ins), NoItinerary, "mrs", "\t$Rd, spsr",
4523 []>, Requires<[IsThumb2,IsNotMClass]> {
4525 let Inst{31-12} = 0b11110011111111111000;
4526 let Inst{11-8} = Rd;
4527 let Inst{7-0} = 0b00000000;
4530 def t2MRSbanked : T2I<(outs rGPR:$Rd), (ins banked_reg:$banked),
4531 NoItinerary, "mrs", "\t$Rd, $banked", []>,
4532 Requires<[IsThumb, HasVirtualization]> {
4536 let Inst{31-21} = 0b11110011111;
4537 let Inst{20} = banked{5}; // R bit
4538 let Inst{19-16} = banked{3-0};
4539 let Inst{15-12} = 0b1000;
4540 let Inst{11-8} = Rd;
4541 let Inst{7-5} = 0b001;
4542 let Inst{4} = banked{4};
4543 let Inst{3-0} = 0b0000;
4549 // This MRS has a mask field in bits 7-0 and can take more values than
4550 // the A/R class (a full msr_mask).
4551 def t2MRS_M : T2I<(outs rGPR:$Rd), (ins msr_mask:$SYSm), NoItinerary,
4552 "mrs", "\t$Rd, $SYSm", []>,
4553 Requires<[IsThumb,IsMClass]> {
4556 let Inst{31-12} = 0b11110011111011111000;
4557 let Inst{11-8} = Rd;
4558 let Inst{7-0} = SYSm;
4560 let Unpredictable{20-16} = 0b11111;
4561 let Unpredictable{13} = 0b1;
4565 // Move from ARM core register to Special Register
4569 // No need to have both system and application versions, the encodings are the
4570 // same and the assembly parser has no way to distinguish between them. The mask
4571 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4572 // the mask with the fields to be accessed in the special register.
4573 let Defs = [CPSR] in
4574 def t2MSR_AR : T2I<(outs), (ins msr_mask:$mask, rGPR:$Rn),
4575 NoItinerary, "msr", "\t$mask, $Rn", []>,
4576 Requires<[IsThumb2,IsNotMClass]> {
4579 let Inst{31-21} = 0b11110011100;
4580 let Inst{20} = mask{4}; // R Bit
4581 let Inst{19-16} = Rn;
4582 let Inst{15-12} = 0b1000;
4583 let Inst{11-8} = mask{3-0};
4587 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
4588 // separate encoding (distinguished by bit 5.
4589 def t2MSRbanked : T2I<(outs), (ins banked_reg:$banked, rGPR:$Rn),
4590 NoItinerary, "msr", "\t$banked, $Rn", []>,
4591 Requires<[IsThumb, HasVirtualization]> {
4595 let Inst{31-21} = 0b11110011100;
4596 let Inst{20} = banked{5}; // R bit
4597 let Inst{19-16} = Rn;
4598 let Inst{15-12} = 0b1000;
4599 let Inst{11-8} = banked{3-0};
4600 let Inst{7-5} = 0b001;
4601 let Inst{4} = banked{4};
4602 let Inst{3-0} = 0b0000;
4608 // Move from ARM core register to Special Register
4609 let Defs = [CPSR] in
4610 def t2MSR_M : T2I<(outs), (ins msr_mask:$SYSm, rGPR:$Rn),
4611 NoItinerary, "msr", "\t$SYSm, $Rn", []>,
4612 Requires<[IsThumb,IsMClass]> {
4615 let Inst{31-21} = 0b11110011100;
4617 let Inst{19-16} = Rn;
4618 let Inst{15-12} = 0b1000;
4619 let Inst{11-10} = SYSm{11-10};
4620 let Inst{9-8} = 0b00;
4621 let Inst{7-0} = SYSm{7-0};
4623 let Unpredictable{20} = 0b1;
4624 let Unpredictable{13} = 0b1;
4625 let Unpredictable{9-8} = 0b11;
4629 //===----------------------------------------------------------------------===//
4630 // Move between coprocessor and ARM core register
4633 class t2MovRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops,
4635 : T2Cop<Op, oops, iops, opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2",
4637 let Inst{27-24} = 0b1110;
4638 let Inst{20} = direction;
4648 let Inst{15-12} = Rt;
4649 let Inst{11-8} = cop;
4650 let Inst{23-21} = opc1;
4651 let Inst{7-5} = opc2;
4652 let Inst{3-0} = CRm;
4653 let Inst{19-16} = CRn;
4655 let DecoderNamespace = "Thumb2CoProc";
4658 class t2MovRRCopro<bits<4> Op, string opc, bit direction, dag oops, dag iops,
4659 list<dag> pattern = []>
4660 : T2Cop<Op, oops, iops, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4661 let Inst{27-24} = 0b1100;
4662 let Inst{23-21} = 0b010;
4663 let Inst{20} = direction;
4671 let Inst{15-12} = Rt;
4672 let Inst{19-16} = Rt2;
4673 let Inst{11-8} = cop;
4674 let Inst{7-4} = opc1;
4675 let Inst{3-0} = CRm;
4677 let DecoderNamespace = "Thumb2CoProc";
4680 /* from ARM core register to coprocessor */
4681 def t2MCR : t2MovRCopro<0b1110, "mcr", 0,
4683 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4684 c_imm:$CRm, imm0_7:$opc2),
4685 [(int_arm_mcr timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn,
4686 timm:$CRm, timm:$opc2)]>,
4687 ComplexDeprecationPredicate<"MCR">;
4688 def : t2InstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4689 (t2MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4690 c_imm:$CRm, 0, pred:$p)>;
4691 def t2MCR2 : t2MovRCopro<0b1111, "mcr2", 0,
4692 (outs), (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4693 c_imm:$CRm, imm0_7:$opc2),
4694 [(int_arm_mcr2 timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn,
4695 timm:$CRm, timm:$opc2)]> {
4696 let Predicates = [IsThumb2, PreV8];
4698 def : t2InstAlias<"mcr2${p} $cop, $opc1, $Rt, $CRn, $CRm",
4699 (t2MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4700 c_imm:$CRm, 0, pred:$p)>;
4702 /* from coprocessor to ARM core register */
4703 def t2MRC : t2MovRCopro<0b1110, "mrc", 1,
4704 (outs GPRwithAPSR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4705 c_imm:$CRm, imm0_7:$opc2), []>;
4706 def : t2InstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4707 (t2MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4708 c_imm:$CRm, 0, pred:$p)>;
4710 def t2MRC2 : t2MovRCopro<0b1111, "mrc2", 1,
4711 (outs GPRwithAPSR:$Rt), (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4712 c_imm:$CRm, imm0_7:$opc2), []> {
4713 let Predicates = [IsThumb2, PreV8];
4715 def : t2InstAlias<"mrc2${p} $cop, $opc1, $Rt, $CRn, $CRm",
4716 (t2MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4717 c_imm:$CRm, 0, pred:$p)>;
4719 def : T2v6Pat<(int_arm_mrc timm:$cop, timm:$opc1, timm:$CRn, timm:$CRm, timm:$opc2),
4720 (t2MRC p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>;
4722 def : T2v6Pat<(int_arm_mrc2 timm:$cop, timm:$opc1, timm:$CRn, timm:$CRm, timm:$opc2),
4723 (t2MRC2 p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>;
4726 /* from ARM core register to coprocessor */
4727 def t2MCRR : t2MovRRCopro<0b1110, "mcrr", 0, (outs),
4728 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2,
4730 [(int_arm_mcrr timm:$cop, timm:$opc1, GPR:$Rt, GPR:$Rt2,
4732 def t2MCRR2 : t2MovRRCopro<0b1111, "mcrr2", 0, (outs),
4733 (ins p_imm:$cop, imm0_15:$opc1, GPR:$Rt, GPR:$Rt2,
4735 [(int_arm_mcrr2 timm:$cop, timm:$opc1, GPR:$Rt,
4736 GPR:$Rt2, timm:$CRm)]> {
4737 let Predicates = [IsThumb2, PreV8];
4740 /* from coprocessor to ARM core register */
4741 def t2MRRC : t2MovRRCopro<0b1110, "mrrc", 1, (outs GPR:$Rt, GPR:$Rt2),
4742 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm)>;
4744 def t2MRRC2 : t2MovRRCopro<0b1111, "mrrc2", 1, (outs GPR:$Rt, GPR:$Rt2),
4745 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm)> {
4746 let Predicates = [IsThumb2, PreV8];
4749 //===----------------------------------------------------------------------===//
4750 // Other Coprocessor Instructions.
4753 def t2CDP : T2Cop<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4754 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4755 "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4756 [(int_arm_cdp timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn,
4757 timm:$CRm, timm:$opc2)]> {
4758 let Inst{27-24} = 0b1110;
4767 let Inst{3-0} = CRm;
4769 let Inst{7-5} = opc2;
4770 let Inst{11-8} = cop;
4771 let Inst{15-12} = CRd;
4772 let Inst{19-16} = CRn;
4773 let Inst{23-20} = opc1;
4775 let Predicates = [IsThumb2, PreV8];
4776 let DecoderNamespace = "Thumb2CoProc";
4779 def t2CDP2 : T2Cop<0b1111, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4780 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4781 "cdp2", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4782 [(int_arm_cdp2 timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn,
4783 timm:$CRm, timm:$opc2)]> {
4784 let Inst{27-24} = 0b1110;
4793 let Inst{3-0} = CRm;
4795 let Inst{7-5} = opc2;
4796 let Inst{11-8} = cop;
4797 let Inst{15-12} = CRd;
4798 let Inst{19-16} = CRn;
4799 let Inst{23-20} = opc1;
4801 let Predicates = [IsThumb2, PreV8];
4802 let DecoderNamespace = "Thumb2CoProc";
4806 // Reading thread pointer from coprocessor register
4807 def : T2Pat<(ARMthread_pointer), (t2MRC 15, 0, 13, 0, 2)>,
4808 Requires<[IsThumb2, IsReadTPTPIDRURW]>;
4809 def : T2Pat<(ARMthread_pointer), (t2MRC 15, 0, 13, 0, 3)>,
4810 Requires<[IsThumb2, IsReadTPTPIDRURO]>;
4811 def : T2Pat<(ARMthread_pointer), (t2MRC 15, 0, 13, 0, 4)>,
4812 Requires<[IsThumb2, IsReadTPTPIDRPRW]>;
4814 //===----------------------------------------------------------------------===//
4815 // ARMv8.1 Privilege Access Never extension
4819 def t2SETPAN : T1I<(outs), (ins imm0_1:$imm), NoItinerary, "setpan\t$imm", []>,
4820 T1Misc<0b0110000>, Requires<[IsThumb2, HasV8, HasV8_1a]> {
4825 let Inst{2-0} = 0b000;
4827 let Unpredictable{4} = 0b1;
4828 let Unpredictable{2-0} = 0b111;
4831 //===----------------------------------------------------------------------===//
4832 // ARMv8-M Security Extensions instructions
4835 let hasSideEffects = 1 in
4836 def t2SG : T2I<(outs), (ins), NoItinerary, "sg", "", []>,
4837 Requires<[Has8MSecExt]> {
4838 let Inst = 0xe97fe97f;
4841 class T2TT<bits<2> at, string asm, list<dag> pattern>
4842 : T2I<(outs rGPR:$Rt), (ins GPRnopc:$Rn), NoItinerary, asm, "\t$Rt, $Rn",
4847 let Inst{31-20} = 0b111010000100;
4848 let Inst{19-16} = Rn;
4849 let Inst{15-12} = 0b1111;
4850 let Inst{11-8} = Rt;
4852 let Inst{5-0} = 0b000000;
4854 let Unpredictable{5-0} = 0b111111;
4857 def t2TT : T2TT<0b00, "tt",
4858 [(set rGPR:$Rt, (int_arm_cmse_tt GPRnopc:$Rn))]>,
4859 Requires<[IsThumb, Has8MSecExt]>;
4860 def t2TTT : T2TT<0b01, "ttt",
4861 [(set rGPR:$Rt, (int_arm_cmse_ttt GPRnopc:$Rn))]>,
4862 Requires<[IsThumb, Has8MSecExt]>;
4863 def t2TTA : T2TT<0b10, "tta",
4864 [(set rGPR:$Rt, (int_arm_cmse_tta GPRnopc:$Rn))]>,
4865 Requires<[IsThumb, Has8MSecExt]>;
4866 def t2TTAT : T2TT<0b11, "ttat",
4867 [(set rGPR:$Rt, (int_arm_cmse_ttat GPRnopc:$Rn))]>,
4868 Requires<[IsThumb, Has8MSecExt]>;
4870 //===----------------------------------------------------------------------===//
4871 // Non-Instruction Patterns
4874 // SXT/UXT with no rotate
4875 let AddedComplexity = 16 in {
4876 def : T2Pat<(and rGPR:$Rm, 0x000000FF), (t2UXTB rGPR:$Rm, 0)>,
4877 Requires<[IsThumb2]>;
4878 def : T2Pat<(and rGPR:$Rm, 0x0000FFFF), (t2UXTH rGPR:$Rm, 0)>,
4879 Requires<[IsThumb2]>;
4880 def : T2Pat<(and rGPR:$Rm, 0x00FF00FF), (t2UXTB16 rGPR:$Rm, 0)>,
4881 Requires<[HasDSP, IsThumb2]>;
4882 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0x00FF)),
4883 (t2UXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
4884 Requires<[HasDSP, IsThumb2]>;
4885 def : T2Pat<(add rGPR:$Rn, (and rGPR:$Rm, 0xFFFF)),
4886 (t2UXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
4887 Requires<[HasDSP, IsThumb2]>;
4890 def : T2Pat<(sext_inreg rGPR:$Src, i8), (t2SXTB rGPR:$Src, 0)>,
4891 Requires<[IsThumb2]>;
4892 def : T2Pat<(sext_inreg rGPR:$Src, i16), (t2SXTH rGPR:$Src, 0)>,
4893 Requires<[IsThumb2]>;
4894 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i8)),
4895 (t2SXTAB rGPR:$Rn, rGPR:$Rm, 0)>,
4896 Requires<[HasDSP, IsThumb2]>;
4897 def : T2Pat<(add rGPR:$Rn, (sext_inreg rGPR:$Rm, i16)),
4898 (t2SXTAH rGPR:$Rn, rGPR:$Rm, 0)>,
4899 Requires<[HasDSP, IsThumb2]>;
4901 // Atomic load/store patterns
4902 def : T2Pat<(atomic_load_8 t2addrmode_imm12:$addr),
4903 (t2LDRBi12 t2addrmode_imm12:$addr)>;
4904 def : T2Pat<(atomic_load_8 t2addrmode_negimm8:$addr),
4905 (t2LDRBi8 t2addrmode_negimm8:$addr)>;
4906 def : T2Pat<(atomic_load_8 t2addrmode_so_reg:$addr),
4907 (t2LDRBs t2addrmode_so_reg:$addr)>;
4908 def : T2Pat<(atomic_load_16 t2addrmode_imm12:$addr),
4909 (t2LDRHi12 t2addrmode_imm12:$addr)>;
4910 def : T2Pat<(atomic_load_16 t2addrmode_negimm8:$addr),
4911 (t2LDRHi8 t2addrmode_negimm8:$addr)>;
4912 def : T2Pat<(atomic_load_16 t2addrmode_so_reg:$addr),
4913 (t2LDRHs t2addrmode_so_reg:$addr)>;
4914 def : T2Pat<(atomic_load_32 t2addrmode_imm12:$addr),
4915 (t2LDRi12 t2addrmode_imm12:$addr)>;
4916 def : T2Pat<(atomic_load_32 t2addrmode_negimm8:$addr),
4917 (t2LDRi8 t2addrmode_negimm8:$addr)>;
4918 def : T2Pat<(atomic_load_32 t2addrmode_so_reg:$addr),
4919 (t2LDRs t2addrmode_so_reg:$addr)>;
4920 def : T2Pat<(atomic_store_8 GPR:$val, t2addrmode_imm12:$addr),
4921 (t2STRBi12 GPR:$val, t2addrmode_imm12:$addr)>;
4922 def : T2Pat<(atomic_store_8 GPR:$val, t2addrmode_negimm8:$addr),
4923 (t2STRBi8 GPR:$val, t2addrmode_negimm8:$addr)>;
4924 def : T2Pat<(atomic_store_8 GPR:$val, t2addrmode_so_reg:$addr),
4925 (t2STRBs GPR:$val, t2addrmode_so_reg:$addr)>;
4926 def : T2Pat<(atomic_store_16 GPR:$val, t2addrmode_imm12:$addr),
4927 (t2STRHi12 GPR:$val, t2addrmode_imm12:$addr)>;
4928 def : T2Pat<(atomic_store_16 GPR:$val, t2addrmode_negimm8:$addr),
4929 (t2STRHi8 GPR:$val, t2addrmode_negimm8:$addr)>;
4930 def : T2Pat<(atomic_store_16 GPR:$val, t2addrmode_so_reg:$addr),
4931 (t2STRHs GPR:$val, t2addrmode_so_reg:$addr)>;
4932 def : T2Pat<(atomic_store_32 GPR:$val,t2addrmode_imm12:$addr),
4933 (t2STRi12 GPR:$val, t2addrmode_imm12:$addr)>;
4934 def : T2Pat<(atomic_store_32 GPR:$val, t2addrmode_negimm8:$addr),
4935 (t2STRi8 GPR:$val, t2addrmode_negimm8:$addr)>;
4936 def : T2Pat<(atomic_store_32 GPR:$val, t2addrmode_so_reg:$addr),
4937 (t2STRs GPR:$val, t2addrmode_so_reg:$addr)>;
4939 let AddedComplexity = 8, Predicates = [IsThumb, HasAcquireRelease, HasV7Clrex] in {
4940 def : Pat<(atomic_load_acquire_8 addr_offset_none:$addr), (t2LDAB addr_offset_none:$addr)>;
4941 def : Pat<(atomic_load_acquire_16 addr_offset_none:$addr), (t2LDAH addr_offset_none:$addr)>;
4942 def : Pat<(atomic_load_acquire_32 addr_offset_none:$addr), (t2LDA addr_offset_none:$addr)>;
4943 def : Pat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (t2STLB GPR:$val, addr_offset_none:$addr)>;
4944 def : Pat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (t2STLH GPR:$val, addr_offset_none:$addr)>;
4945 def : Pat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (t2STL GPR:$val, addr_offset_none:$addr)>;
4949 //===----------------------------------------------------------------------===//
4950 // Assembler aliases
4953 // Aliases for ADC without the ".w" optional width specifier.
4954 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $Rm",
4955 (t2ADCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4956 def : t2InstAlias<"adc${s}${p} $Rd, $Rn, $ShiftedRm",
4957 (t2ADCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
4958 pred:$p, cc_out:$s)>;
4959 def : t2InstAlias<"adc${s}${p} $Rdn, $Rm",
4960 (t2ADCrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4961 def : t2InstAlias<"adc${s}${p} $Rdn, $ShiftedRm",
4962 (t2ADCrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm,
4963 pred:$p, cc_out:$s)>;
4965 // Aliases for SBC without the ".w" optional width specifier.
4966 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $Rm",
4967 (t2SBCrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4968 def : t2InstAlias<"sbc${s}${p} $Rd, $Rn, $ShiftedRm",
4969 (t2SBCrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm,
4970 pred:$p, cc_out:$s)>;
4972 // Aliases for ADD without the ".w" optional width specifier.
4973 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
4974 (t2ADDri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p,
4976 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
4977 (t2ADDri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
4978 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm",
4979 (t2ADDrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4980 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm",
4981 (t2ADDrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
4982 pred:$p, cc_out:$s)>;
4983 // ... and with the destination and source register combined.
4984 def : t2InstAlias<"add${s}${p} $Rdn, $imm",
4985 (t2ADDri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
4986 def : t2InstAlias<"add${p} $Rdn, $imm",
4987 (t2ADDri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>;
4988 def : t2InstAlias<"addw${p} $Rdn, $imm",
4989 (t2ADDri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>;
4990 def : t2InstAlias<"add${s}${p} $Rdn, $Rm",
4991 (t2ADDrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
4992 def : t2InstAlias<"add${s}${p} $Rdn, $ShiftedRm",
4993 (t2ADDrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
4994 pred:$p, cc_out:$s)>;
4996 // add w/ negative immediates is just a sub.
4997 def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm",
4998 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
5000 def : t2InstSubst<"add${p} $Rd, $Rn, $imm",
5001 (t2SUBri12 rGPR:$Rd, GPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
5002 def : t2InstSubst<"add${s}${p} $Rdn, $imm",
5003 (t2SUBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_neg:$imm, pred:$p,
5005 def : t2InstSubst<"add${p} $Rdn, $imm",
5006 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
5008 def : t2InstSubst<"add${s}${p}.w $Rd, $Rn, $imm",
5009 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm, pred:$p,
5011 def : t2InstSubst<"addw${p} $Rd, $Rn, $imm",
5012 (t2SUBri12 rGPR:$Rd, rGPR:$Rn, imm0_4095_neg:$imm, pred:$p)>;
5013 def : t2InstSubst<"add${s}${p}.w $Rdn, $imm",
5014 (t2SUBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_neg:$imm, pred:$p,
5016 def : t2InstSubst<"addw${p} $Rdn, $imm",
5017 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
5020 // Aliases for SUB without the ".w" optional width specifier.
5021 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm",
5022 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5023 def : t2InstAlias<"sub${p} $Rd, $Rn, $imm",
5024 (t2SUBri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>;
5025 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $Rm",
5026 (t2SUBrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
5027 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $ShiftedRm",
5028 (t2SUBrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm,
5029 pred:$p, cc_out:$s)>;
5030 // ... and with the destination and source register combined.
5031 def : t2InstAlias<"sub${s}${p} $Rdn, $imm",
5032 (t2SUBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5033 def : t2InstAlias<"sub${p} $Rdn, $imm",
5034 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>;
5035 def : t2InstAlias<"subw${p} $Rdn, $imm",
5036 (t2SUBri12 rGPR:$Rdn, rGPR:$Rdn, imm0_4095:$imm, pred:$p)>;
5037 def : t2InstAlias<"sub${s}${p}.w $Rdn, $Rm",
5038 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
5039 def : t2InstAlias<"sub${s}${p} $Rdn, $Rm",
5040 (t2SUBrr GPRnopc:$Rdn, GPRnopc:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
5041 def : t2InstAlias<"sub${s}${p} $Rdn, $ShiftedRm",
5042 (t2SUBrs GPRnopc:$Rdn, GPRnopc:$Rdn, t2_so_reg:$ShiftedRm,
5043 pred:$p, cc_out:$s)>;
5045 // SP to SP alike aliases
5046 // Aliases for ADD without the ".w" optional width specifier.
5047 def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm",
5048 (t2ADDspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm:$imm, pred:$p,
5050 def : t2InstAlias<"add${p} $Rd, $Rn, $imm",
5051 (t2ADDspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095:$imm, pred:$p)>;
5052 // ... and with the destination and source register combined.
5053 def : t2InstAlias<"add${s}${p} $Rdn, $imm",
5054 (t2ADDspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5056 def : t2InstAlias<"add${s}${p}.w $Rdn, $imm",
5057 (t2ADDspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5059 def : t2InstAlias<"add${p} $Rdn, $imm",
5060 (t2ADDspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>;
5062 def : t2InstAlias<"addw${p} $Rdn, $imm",
5063 (t2ADDspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>;
5065 // add w/ negative immediates is just a sub.
5066 def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm",
5067 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm_neg:$imm, pred:$p,
5069 def : t2InstSubst<"add${p} $Rd, $Rn, $imm",
5070 (t2SUBspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095_neg:$imm, pred:$p)>;
5071 def : t2InstSubst<"add${s}${p} $Rdn, $imm",
5072 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm_neg:$imm, pred:$p,
5074 def : t2InstSubst<"add${p} $Rdn, $imm",
5075 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
5077 def : t2InstSubst<"add${s}${p}.w $Rd, $Rn, $imm",
5078 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm_neg:$imm, pred:$p,
5080 def : t2InstSubst<"addw${p} $Rd, $Rn, $imm",
5081 (t2SUBspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095_neg:$imm, pred:$p)>;
5082 def : t2InstSubst<"add${s}${p}.w $Rdn, $imm",
5083 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm_neg:$imm, pred:$p,
5085 def : t2InstSubst<"addw${p} $Rdn, $imm",
5086 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095_neg:$imm, pred:$p)>;
5089 // Aliases for SUB without the ".w" optional width specifier.
5090 def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm",
5091 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5092 def : t2InstAlias<"sub${p} $Rd, $Rn, $imm",
5093 (t2SUBspImm12 GPRsp:$Rd, GPRsp:$Rn, imm0_4095:$imm, pred:$p)>;
5094 // ... and with the destination and source register combined.
5095 def : t2InstAlias<"sub${s}${p} $Rdn, $imm",
5096 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5097 def : t2InstAlias<"sub${s}${p}.w $Rdn, $imm",
5098 (t2SUBspImm GPRsp:$Rdn, GPRsp:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5099 def : t2InstAlias<"sub${p} $Rdn, $imm",
5100 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>;
5101 def : t2InstAlias<"subw${p} $Rdn, $imm",
5102 (t2SUBspImm12 GPRsp:$Rdn, GPRsp:$Rdn, imm0_4095:$imm, pred:$p)>;
5104 // Alias for compares without the ".w" optional width specifier.
5105 def : t2InstAlias<"cmn${p} $Rn, $Rm",
5106 (t2CMNzrr GPRnopc:$Rn, rGPR:$Rm, pred:$p)>;
5107 def : t2InstAlias<"teq${p} $Rn, $Rm",
5108 (t2TEQrr rGPR:$Rn, rGPR:$Rm, pred:$p)>;
5109 def : t2InstAlias<"tst${p} $Rn, $Rm",
5110 (t2TSTrr rGPR:$Rn, rGPR:$Rm, pred:$p)>;
5113 def : InstAlias<"dmb${p}.w\t$opt", (t2DMB memb_opt:$opt, pred:$p), 0>, Requires<[HasDB]>;
5114 def : InstAlias<"dmb${p}", (t2DMB 0xf, pred:$p), 0>, Requires<[HasDB]>;
5115 def : InstAlias<"dmb${p}.w", (t2DMB 0xf, pred:$p), 0>, Requires<[HasDB]>;
5116 def : InstAlias<"dsb${p}.w\t$opt", (t2DSB memb_opt:$opt, pred:$p), 0>, Requires<[HasDB]>;
5117 def : InstAlias<"dsb${p}", (t2DSB 0xf, pred:$p), 0>, Requires<[HasDB]>;
5118 def : InstAlias<"dsb${p}.w", (t2DSB 0xf, pred:$p), 0>, Requires<[HasDB]>;
5119 def : InstAlias<"isb${p}.w\t$opt", (t2ISB instsyncb_opt:$opt, pred:$p), 0>, Requires<[HasDB]>;
5120 def : InstAlias<"isb${p}", (t2ISB 0xf, pred:$p), 0>, Requires<[HasDB]>;
5121 def : InstAlias<"isb${p}.w", (t2ISB 0xf, pred:$p), 0>, Requires<[HasDB]>;
5123 // Non-predicable aliases of a predicable DSB: the predicate is (14, zero_reg) where
5124 // 14 = AL (always execute) and zero_reg = "instruction doesn't read the CPSR".
5125 def : InstAlias<"ssbb", (t2DSB 0x0, 14, zero_reg), 1>, Requires<[HasDB, IsThumb2]>;
5126 def : InstAlias<"pssbb", (t2DSB 0x4, 14, zero_reg), 1>, Requires<[HasDB, IsThumb2]>;
5128 // Armv8-R 'Data Full Barrier'
5129 def : InstAlias<"dfb${p}", (t2DSB 0xc, pred:$p), 1>, Requires<[HasDFB]>;
5131 // SpeculationBarrierEndBB must only be used after an unconditional control
5132 // flow, i.e. after a terminator for which isBarrier is True.
5133 let hasSideEffects = 1, isCodeGenOnly = 1, isTerminator = 1, isBarrier = 1 in {
5134 // This gets lowered to a pair of 4-byte instructions
5136 def t2SpeculationBarrierISBDSBEndBB
5137 : PseudoInst<(outs), (ins), NoItinerary, []>, Sched<[]>;
5138 // This gets lowered to a single 4-byte instructions
5140 def t2SpeculationBarrierSBEndBB
5141 : PseudoInst<(outs), (ins), NoItinerary, []>, Sched<[]>;
5144 // Alias for LDR, LDRB, LDRH, LDRSB, and LDRSH without the ".w" optional
5146 def : t2InstAlias<"ldr${p} $Rt, $addr",
5147 (t2LDRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5148 def : t2InstAlias<"ldrb${p} $Rt, $addr",
5149 (t2LDRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5150 def : t2InstAlias<"ldrh${p} $Rt, $addr",
5151 (t2LDRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5152 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
5153 (t2LDRSBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5154 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
5155 (t2LDRSHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5157 def : t2InstAlias<"ldr${p} $Rt, $addr",
5158 (t2LDRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5159 def : t2InstAlias<"ldrb${p} $Rt, $addr",
5160 (t2LDRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5161 def : t2InstAlias<"ldrh${p} $Rt, $addr",
5162 (t2LDRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5163 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
5164 (t2LDRSBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5165 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
5166 (t2LDRSHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5168 def : t2InstAlias<"ldr${p} $Rt, $addr",
5169 (t2LDRpci GPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
5170 def : t2InstAlias<"ldrb${p} $Rt, $addr",
5171 (t2LDRBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
5172 def : t2InstAlias<"ldrh${p} $Rt, $addr",
5173 (t2LDRHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
5174 def : t2InstAlias<"ldrsb${p} $Rt, $addr",
5175 (t2LDRSBpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
5176 def : t2InstAlias<"ldrsh${p} $Rt, $addr",
5177 (t2LDRSHpci rGPR:$Rt, t2ldrlabel:$addr, pred:$p)>;
5179 // Alias for MVN with(out) the ".w" optional width specifier.
5180 def : t2InstAlias<"mvn${s}${p}.w $Rd, $imm",
5181 (t2MVNi rGPR:$Rd, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5182 def : t2InstAlias<"mvn${s}${p} $Rd, $Rm",
5183 (t2MVNr rGPR:$Rd, rGPR:$Rm, pred:$p, cc_out:$s)>;
5184 def : t2InstAlias<"mvn${s}${p} $Rd, $ShiftedRm",
5185 (t2MVNs rGPR:$Rd, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>;
5187 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5188 // input operands swapped when the shift amount is zero (i.e., unspecified).
5189 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5190 (t2PKHBT rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5191 Requires<[HasDSP, IsThumb2]>;
5192 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5193 (t2PKHBT rGPR:$Rd, rGPR:$Rm, rGPR:$Rn, 0, pred:$p), 0>,
5194 Requires<[HasDSP, IsThumb2]>;
5196 // PUSH/POP aliases for STM/LDM
5197 def : t2InstAlias<"push${p}.w $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
5198 def : t2InstAlias<"push${p} $regs", (t2STMDB_UPD SP, pred:$p, reglist:$regs)>;
5199 def : t2InstAlias<"pop${p}.w $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5200 def : t2InstAlias<"pop${p} $regs", (t2LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5202 // STMIA/STMIA_UPD aliases w/o the optional .w suffix
5203 def : t2InstAlias<"stm${p} $Rn, $regs",
5204 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
5205 def : t2InstAlias<"stm${p} $Rn!, $regs",
5206 (t2STMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
5208 // LDMIA/LDMIA_UPD aliases w/o the optional .w suffix
5209 def : t2InstAlias<"ldm${p} $Rn, $regs",
5210 (t2LDMIA GPR:$Rn, pred:$p, reglist:$regs)>;
5211 def : t2InstAlias<"ldm${p} $Rn!, $regs",
5212 (t2LDMIA_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
5214 // STMDB/STMDB_UPD aliases w/ the optional .w suffix
5215 def : t2InstAlias<"stmdb${p}.w $Rn, $regs",
5216 (t2STMDB GPR:$Rn, pred:$p, reglist:$regs)>;
5217 def : t2InstAlias<"stmdb${p}.w $Rn!, $regs",
5218 (t2STMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
5220 // LDMDB/LDMDB_UPD aliases w/ the optional .w suffix
5221 def : t2InstAlias<"ldmdb${p}.w $Rn, $regs",
5222 (t2LDMDB GPR:$Rn, pred:$p, reglist:$regs)>;
5223 def : t2InstAlias<"ldmdb${p}.w $Rn!, $regs",
5224 (t2LDMDB_UPD GPR:$Rn, pred:$p, reglist:$regs)>;
5226 // Alias for REV/REV16/REVSH without the ".w" optional width specifier.
5227 def : t2InstAlias<"rev${p} $Rd, $Rm", (t2REV rGPR:$Rd, rGPR:$Rm, pred:$p)>;
5228 def : t2InstAlias<"rev16${p} $Rd, $Rm", (t2REV16 rGPR:$Rd, rGPR:$Rm, pred:$p)>;
5229 def : t2InstAlias<"revsh${p} $Rd, $Rm", (t2REVSH rGPR:$Rd, rGPR:$Rm, pred:$p)>;
5232 // Alias for RSB with and without the ".w" optional width specifier, with and
5233 // without explicit destination register.
5234 def : t2InstAlias<"rsb${s}${p} $Rd, $Rn, $imm",
5235 (t2RSBri rGPR:$Rd, rGPR:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5236 def : t2InstAlias<"rsb${s}${p} $Rdn, $imm",
5237 (t2RSBri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm:$imm, pred:$p, cc_out:$s)>;
5238 def : t2InstAlias<"rsb${s}${p} $Rdn, $Rm",
5239 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
5240 def : t2InstAlias<"rsb${s}${p} $Rdn, $ShiftedRm",
5241 (t2RSBrs rGPR:$Rdn, rGPR:$Rdn, t2_so_reg:$ShiftedRm, pred:$p,
5243 def : t2InstAlias<"rsb${s}${p}.w $Rdn, $Rm",
5244 (t2RSBrr rGPR:$Rdn, rGPR:$Rdn, rGPR:$Rm, pred:$p, cc_out:$s)>;
5245 def : t2InstAlias<"rsb${s}${p}.w $Rd, $Rn, $Rm",
5246 (t2RSBrr rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>;
5247 def : t2InstAlias<"rsb${s}${p}.w $Rd, $Rn, $ShiftedRm",
5248 (t2RSBrs rGPR:$Rd, rGPR:$Rn, t2_so_reg:$ShiftedRm, pred:$p,
5251 // SSAT/USAT optional shift operand.
5252 def : t2InstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5253 (t2SSAT rGPR:$Rd, imm1_32:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
5254 def : t2InstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5255 (t2USAT rGPR:$Rd, imm0_31:$sat_imm, rGPR:$Rn, 0, pred:$p)>;
5257 // STM w/o the .w suffix.
5258 def : t2InstAlias<"stm${p} $Rn, $regs",
5259 (t2STMIA GPR:$Rn, pred:$p, reglist:$regs)>;
5261 // Alias for STR, STRB, and STRH without the ".w" optional
5263 def : t2InstAlias<"str${p} $Rt, $addr",
5264 (t2STRi12 GPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5265 def : t2InstAlias<"strb${p} $Rt, $addr",
5266 (t2STRBi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5267 def : t2InstAlias<"strh${p} $Rt, $addr",
5268 (t2STRHi12 rGPR:$Rt, t2addrmode_imm12:$addr, pred:$p)>;
5270 def : t2InstAlias<"str${p} $Rt, $addr",
5271 (t2STRs GPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5272 def : t2InstAlias<"strb${p} $Rt, $addr",
5273 (t2STRBs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5274 def : t2InstAlias<"strh${p} $Rt, $addr",
5275 (t2STRHs rGPR:$Rt, t2addrmode_so_reg:$addr, pred:$p)>;
5277 // Extend instruction optional rotate operand.
5278 def : InstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5279 (t2SXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5280 Requires<[HasDSP, IsThumb2]>;
5281 def : InstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5282 (t2SXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5283 Requires<[HasDSP, IsThumb2]>;
5284 def : InstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5285 (t2SXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5286 Requires<[HasDSP, IsThumb2]>;
5287 def : InstAlias<"sxtb16${p} $Rd, $Rm",
5288 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p), 0>,
5289 Requires<[HasDSP, IsThumb2]>;
5291 def : t2InstAlias<"sxtb${p} $Rd, $Rm",
5292 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5293 def : t2InstAlias<"sxth${p} $Rd, $Rm",
5294 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5295 def : t2InstAlias<"sxtb${p}.w $Rd, $Rm",
5296 (t2SXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5297 def : t2InstAlias<"sxth${p}.w $Rd, $Rm",
5298 (t2SXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5300 def : InstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5301 (t2UXTAB rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5302 Requires<[HasDSP, IsThumb2]>;
5303 def : InstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5304 (t2UXTAH rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5305 Requires<[HasDSP, IsThumb2]>;
5306 def : InstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5307 (t2UXTAB16 rGPR:$Rd, rGPR:$Rn, rGPR:$Rm, 0, pred:$p), 0>,
5308 Requires<[HasDSP, IsThumb2]>;
5309 def : InstAlias<"uxtb16${p} $Rd, $Rm",
5310 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, 0, pred:$p), 0>,
5311 Requires<[HasDSP, IsThumb2]>;
5313 def : t2InstAlias<"uxtb${p} $Rd, $Rm",
5314 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5315 def : t2InstAlias<"uxth${p} $Rd, $Rm",
5316 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5317 def : t2InstAlias<"uxtb${p}.w $Rd, $Rm",
5318 (t2UXTB rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5319 def : t2InstAlias<"uxth${p}.w $Rd, $Rm",
5320 (t2UXTH rGPR:$Rd, rGPR:$Rm, 0, pred:$p)>;
5322 // Extend instruction w/o the ".w" optional width specifier.
5323 def : t2InstAlias<"uxtb${p} $Rd, $Rm$rot",
5324 (t2UXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
5325 def : InstAlias<"uxtb16${p} $Rd, $Rm$rot",
5326 (t2UXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p), 0>,
5327 Requires<[HasDSP, IsThumb2]>;
5328 def : t2InstAlias<"uxth${p} $Rd, $Rm$rot",
5329 (t2UXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
5331 def : t2InstAlias<"sxtb${p} $Rd, $Rm$rot",
5332 (t2SXTB rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
5333 def : InstAlias<"sxtb16${p} $Rd, $Rm$rot",
5334 (t2SXTB16 rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p), 0>,
5335 Requires<[HasDSP, IsThumb2]>;
5336 def : t2InstAlias<"sxth${p} $Rd, $Rm$rot",
5337 (t2SXTH rGPR:$Rd, rGPR:$Rm, rot_imm:$rot, pred:$p)>;
5340 // "mov Rd, t2_so_imm_not" can be handled via "mvn" in assembly, just like
5342 def : t2InstSubst<"mov${p} $Rd, $imm",
5343 (t2MVNi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, zero_reg)>;
5344 def : t2InstSubst<"mvn${s}${p} $Rd, $imm",
5345 (t2MOVi rGPR:$Rd, t2_so_imm_not:$imm, pred:$p, s_cc_out:$s)>;
5346 // Same for AND <--> BIC
5347 def : t2InstSubst<"bic${s}${p} $Rd, $Rn, $imm",
5348 (t2ANDri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm,
5349 pred:$p, cc_out:$s)>;
5350 def : t2InstSubst<"bic${s}${p} $Rdn, $imm",
5351 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm,
5352 pred:$p, cc_out:$s)>;
5353 def : t2InstSubst<"bic${s}${p}.w $Rd, $Rn, $imm",
5354 (t2ANDri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm,
5355 pred:$p, cc_out:$s)>;
5356 def : t2InstSubst<"bic${s}${p}.w $Rdn, $imm",
5357 (t2ANDri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm,
5358 pred:$p, cc_out:$s)>;
5359 def : t2InstSubst<"and${s}${p} $Rd, $Rn, $imm",
5360 (t2BICri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm,
5361 pred:$p, cc_out:$s)>;
5362 def : t2InstSubst<"and${s}${p} $Rdn, $imm",
5363 (t2BICri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm,
5364 pred:$p, cc_out:$s)>;
5365 def : t2InstSubst<"and${s}${p}.w $Rd, $Rn, $imm",
5366 (t2BICri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm,
5367 pred:$p, cc_out:$s)>;
5368 def : t2InstSubst<"and${s}${p}.w $Rdn, $imm",
5369 (t2BICri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm,
5370 pred:$p, cc_out:$s)>;
5372 def : t2InstSubst<"orn${s}${p} $Rd, $Rn, $imm",
5373 (t2ORRri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm,
5374 pred:$p, cc_out:$s)>;
5375 def : t2InstSubst<"orn${s}${p} $Rdn, $imm",
5376 (t2ORRri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm,
5377 pred:$p, cc_out:$s)>;
5378 def : t2InstSubst<"orr${s}${p} $Rd, $Rn, $imm",
5379 (t2ORNri rGPR:$Rd, rGPR:$Rn, t2_so_imm_not:$imm,
5380 pred:$p, cc_out:$s)>;
5381 def : t2InstSubst<"orr${s}${p} $Rdn, $imm",
5382 (t2ORNri rGPR:$Rdn, rGPR:$Rdn, t2_so_imm_not:$imm,
5383 pred:$p, cc_out:$s)>;
5384 // Likewise, "add Rd, t2_so_imm_neg" -> sub
5385 def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm",
5386 (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm_neg:$imm,
5387 pred:$p, cc_out:$s)>;
5388 def : t2InstSubst<"add${s}${p} $Rd, $Rn, $imm",
5389 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rn, t2_so_imm_neg:$imm,
5390 pred:$p, cc_out:$s)>;
5391 def : t2InstSubst<"add${s}${p} $Rd, $imm",
5392 (t2SUBri rGPR:$Rd, rGPR:$Rd, t2_so_imm_neg:$imm,
5393 pred:$p, cc_out:$s)>;
5394 def : t2InstSubst<"add${s}${p} $Rd, $imm",
5395 (t2SUBspImm GPRsp:$Rd, GPRsp:$Rd, t2_so_imm_neg:$imm,
5396 pred:$p, cc_out:$s)>;
5397 // Same for CMP <--> CMN via t2_so_imm_neg
5398 def : t2InstSubst<"cmp${p} $Rd, $imm",
5399 (t2CMNri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
5400 def : t2InstSubst<"cmn${p} $Rd, $imm",
5401 (t2CMPri rGPR:$Rd, t2_so_imm_neg:$imm, pred:$p)>;
5404 // Wide 'mul' encoding can be specified with only two operands.
5405 def : t2InstAlias<"mul${p} $Rn, $Rm",
5406 (t2MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p)>;
5408 // "neg" is and alias for "rsb rd, rn, #0"
5409 def : t2InstAlias<"neg${s}${p} $Rd, $Rm",
5410 (t2RSBri rGPR:$Rd, rGPR:$Rm, 0, pred:$p, cc_out:$s)>;
5412 // MOV so_reg assembler pseudos. InstAlias isn't expressive enough for
5413 // these, unfortunately.
5414 // FIXME: LSL #0 in the shift should allow SP to be used as either the
5415 // source or destination (but not both).
5416 def t2MOVsi: t2AsmPseudo<"mov${p} $Rd, $shift",
5417 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
5418 def t2MOVSsi: t2AsmPseudo<"movs${p} $Rd, $shift",
5419 (ins rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
5421 def t2MOVsr: t2AsmPseudo<"mov${p} $Rd, $shift",
5422 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
5423 def t2MOVSsr: t2AsmPseudo<"movs${p} $Rd, $shift",
5424 (ins rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
5426 // Aliases for the above with the .w qualifier
5427 def : t2InstAlias<"mov${p}.w $Rd, $shift",
5428 (t2MOVsi rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
5429 def : t2InstAlias<"movs${p}.w $Rd, $shift",
5430 (t2MOVSsi rGPR:$Rd, t2_so_reg:$shift, pred:$p)>;
5431 def : t2InstAlias<"mov${p}.w $Rd, $shift",
5432 (t2MOVsr rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
5433 def : t2InstAlias<"movs${p}.w $Rd, $shift",
5434 (t2MOVSsr rGPR:$Rd, so_reg_reg:$shift, pred:$p)>;
5436 // ADR w/o the .w suffix
5437 def : t2InstAlias<"adr${p} $Rd, $addr",
5438 (t2ADR rGPR:$Rd, t2adrlabel:$addr, pred:$p)>;
5440 // LDR(literal) w/ alternate [pc, #imm] syntax.
5441 def t2LDRpcrel : t2AsmPseudo<"ldr${p} $Rt, $addr",
5442 (ins GPR:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5443 def t2LDRBpcrel : t2AsmPseudo<"ldrb${p} $Rt, $addr",
5444 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5445 def t2LDRHpcrel : t2AsmPseudo<"ldrh${p} $Rt, $addr",
5446 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5447 def t2LDRSBpcrel : t2AsmPseudo<"ldrsb${p} $Rt, $addr",
5448 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5449 def t2LDRSHpcrel : t2AsmPseudo<"ldrsh${p} $Rt, $addr",
5450 (ins GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5451 // Version w/ the .w suffix.
5452 def : t2InstAlias<"ldr${p}.w $Rt, $addr",
5453 (t2LDRpcrel GPR:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p), 0>;
5454 def : t2InstAlias<"ldrb${p}.w $Rt, $addr",
5455 (t2LDRBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5456 def : t2InstAlias<"ldrh${p}.w $Rt, $addr",
5457 (t2LDRHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5458 def : t2InstAlias<"ldrsb${p}.w $Rt, $addr",
5459 (t2LDRSBpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5460 def : t2InstAlias<"ldrsh${p}.w $Rt, $addr",
5461 (t2LDRSHpcrel GPRnopc:$Rt, t2ldr_pcrel_imm12:$addr, pred:$p)>;
5463 def : t2InstAlias<"add${p} $Rd, pc, $imm",
5464 (t2ADR rGPR:$Rd, imm0_4095:$imm, pred:$p)>;
5466 // Pseudo instruction ldr Rt, =immediate
5468 : t2AsmPseudo<"ldr${p} $Rt, $immediate",
5469 (ins GPR:$Rt, const_pool_asm_imm:$immediate, pred:$p)>;
5470 // Version w/ the .w suffix.
5471 def : t2InstAlias<"ldr${p}.w $Rt, $immediate",
5472 (t2LDRConstPool GPRnopc:$Rt,
5473 const_pool_asm_imm:$immediate, pred:$p)>;
5475 //===----------------------------------------------------------------------===//
5476 // ARMv8.1m instructions
5479 class V8_1MI<dag oops, dag iops, AddrMode am, InstrItinClass itin, string asm,
5480 string ops, string cstr, list<dag> pattern>
5481 : Thumb2XI<oops, iops, am, 4, itin, !strconcat(asm, "\t", ops), cstr,
5483 Requires<[HasV8_1MMainline]>;
5485 def t2CLRM : V8_1MI<(outs),
5486 (ins pred:$p, reglist_with_apsr:$regs, variable_ops),
5487 AddrModeNone, NoItinerary, "clrm${p}", "$regs", "", []> {
5490 let Inst{31-16} = 0b1110100010011111;
5491 let Inst{15-14} = regs{15-14};
5493 let Inst{12-0} = regs{12-0};
5496 class t2BF<dag iops, string asm, string ops>
5497 : V8_1MI<(outs ), iops, AddrModeNone, NoItinerary, asm, ops, "", []> {
5499 let Inst{31-27} = 0b11110;
5500 let Inst{15-14} = 0b11;
5504 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB];
5507 def t2BF_LabelPseudo
5508 : t2PseudoInst<(outs ), (ins pclabel:$cp), 0, NoItinerary, []> {
5509 let isTerminator = 1;
5510 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB];
5511 let hasNoSchedulingInfo = 1;
5514 def t2BFi : t2BF<(ins bflabel_u4:$b_label, bflabel_s16:$label, pred:$p),
5515 !strconcat("bf", "${p}"), "$b_label, $label"> {
5519 let Inst{26-23} = b_label{3-0};
5520 let Inst{22-21} = 0b10;
5521 let Inst{20-16} = label{15-11};
5523 let Inst{11} = label{0};
5524 let Inst{10-1} = label{10-1};
5527 def t2BFic : t2BF<(ins bflabel_u4:$b_label, bflabel_s12:$label,
5528 bfafter_target:$ba_label, pred_noal:$bcond), "bfcsel",
5529 "$b_label, $label, $ba_label, $bcond"> {
5535 let Inst{26-23} = b_label{3-0};
5537 let Inst{21-18} = bcond{3-0};
5538 let Inst{17} = ba_label{0};
5539 let Inst{16} = label{11};
5541 let Inst{11} = label{0};
5542 let Inst{10-1} = label{10-1};
5545 def t2BFr : t2BF<(ins bflabel_u4:$b_label, rGPR:$Rn, pred:$p),
5546 !strconcat("bfx", "${p}"), "$b_label, $Rn"> {
5550 let Inst{26-23} = b_label{3-0};
5551 let Inst{22-20} = 0b110;
5552 let Inst{19-16} = Rn{3-0};
5553 let Inst{13-1} = 0b1000000000000;
5556 def t2BFLi : t2BF<(ins bflabel_u4:$b_label, bflabel_s18:$label, pred:$p),
5557 !strconcat("bfl", "${p}"), "$b_label, $label"> {
5561 let Inst{26-23} = b_label{3-0};
5562 let Inst{22-16} = label{17-11};
5564 let Inst{11} = label{0};
5565 let Inst{10-1} = label{10-1};
5568 def t2BFLr : t2BF<(ins bflabel_u4:$b_label, rGPR:$Rn, pred:$p),
5569 !strconcat("bflx", "${p}"), "$b_label, $Rn"> {
5573 let Inst{26-23} = b_label{3-0};
5574 let Inst{22-20} = 0b111;
5575 let Inst{19-16} = Rn{3-0};
5576 let Inst{13-1} = 0b1000000000000;
5579 class t2LOL<dag oops, dag iops, string asm, string ops>
5580 : V8_1MI<oops, iops, AddrModeNone, NoItinerary, asm, ops, "", [] > {
5581 let Inst{31-23} = 0b111100000;
5582 let Inst{15-14} = 0b11;
5584 let DecoderMethod = "DecodeLOLoop";
5585 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB];
5588 let isNotDuplicable = 1 in {
5589 def t2WLS : t2LOL<(outs GPRlr:$LR),
5590 (ins rGPR:$Rn, wlslabel_u11:$label),
5591 "wls", "$LR, $Rn, $label"> {
5594 let Inst{22-20} = 0b100;
5595 let Inst{19-16} = Rn{3-0};
5596 let Inst{13-12} = 0b00;
5597 let Inst{11} = label{0};
5598 let Inst{10-1} = label{10-1};
5599 let usesCustomInserter = 1;
5601 let isTerminator = 1;
5604 def t2DLS : t2LOL<(outs GPRlr:$LR), (ins rGPR:$Rn),
5605 "dls", "$LR, $Rn"> {
5607 let Inst{22-20} = 0b100;
5608 let Inst{19-16} = Rn{3-0};
5609 let Inst{13-1} = 0b1000000000000;
5610 let usesCustomInserter = 1;
5613 def t2LEUpdate : t2LOL<(outs GPRlr:$LRout),
5614 (ins GPRlr:$LRin, lelabel_u11:$label),
5615 "le", "$LRin, $label"> {
5617 let Inst{22-16} = 0b0001111;
5618 let Inst{13-12} = 0b00;
5619 let Inst{11} = label{0};
5620 let Inst{10-1} = label{10-1};
5621 let usesCustomInserter = 1;
5623 let isTerminator = 1;
5626 def t2LE : t2LOL<(outs ), (ins lelabel_u11:$label), "le", "$label"> {
5628 let Inst{22-16} = 0b0101111;
5629 let Inst{13-12} = 0b00;
5630 let Inst{11} = label{0};
5631 let Inst{10-1} = label{10-1};
5633 let isTerminator = 1;
5636 let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB] in {
5638 // t2DoLoopStart a pseudo for DLS hardware loops. Lowered into a DLS in
5639 // ARMLowOverheadLoops if possible, or reverted to a Mov if not.
5641 t2PseudoInst<(outs GPRlr:$X), (ins rGPR:$tc), 4, IIC_Br,
5642 [(set GPRlr:$X, (int_start_loop_iterations rGPR:$tc))]>;
5644 // A pseudo for a DLSTP, created in the MVETPAndVPTOptimizationPass from a
5645 // t2DoLoopStart if the loops is tail predicated. Holds both the element
5646 // count and trip count of the loop, picking the correct one during
5647 // ARMLowOverheadLoops when it is converted to a DLSTP or DLS as required.
5648 let isTerminator = 1, hasSideEffects = 1 in
5649 def t2DoLoopStartTP :
5650 t2PseudoInst<(outs GPRlr:$X), (ins rGPR:$tc, rGPR:$elts), 4, IIC_Br, []>;
5652 // Setup for a t2WhileLoopStart. A pair of t2WhileLoopSetup and t2WhileLoopStart
5653 // will be created post-ISel from a llvm.test.start.loop.iterations. This
5654 // t2WhileLoopSetup to setup LR and t2WhileLoopStart to perform the branch. Not
5655 // valid after reg alloc, as it should be lowered during MVETPAndVPTOptimisations
5656 // into a t2WhileLoopStartLR (or expanded).
5657 def t2WhileLoopSetup :
5658 t2PseudoInst<(outs GPRlr:$lr), (ins rGPR:$tc), 4, IIC_Br, []>;
5660 // A pseudo to represent the decrement in a low overhead loop. A t2LoopDec and
5661 // t2LoopEnd together represent a LE instruction. Ideally these are converted
5662 // to a t2LoopEndDec which is lowered as a single instruction.
5663 let hasSideEffects = 0 in
5665 t2PseudoInst<(outs GPRlr:$Rm), (ins GPRlr:$Rn, imm0_7:$size),
5666 4, IIC_Br, []>, Sched<[WriteBr]>;
5668 let isBranch = 1, isTerminator = 1, hasSideEffects = 1, Defs = [CPSR] in {
5669 // The branch in a t2WhileLoopSetup/t2WhileLoopStart pair, eventually turned
5670 // into a t2WhileLoopStartLR that does both the LR setup and branch.
5671 def t2WhileLoopStart :
5672 t2PseudoInst<(outs),
5673 (ins GPRlr:$tc, brtarget:$target),
5677 // WhileLoopStartLR that sets up LR and branches on zero, equivalent to WLS. It
5678 // is lowered in the ARMLowOverheadLoops pass providing the branches are within
5679 // range. WhileLoopStartLR and LoopEnd to occupy 8 bytes because they may get
5680 // converted into t2CMP and t2Bcc.
5681 def t2WhileLoopStartLR :
5682 t2PseudoInst<(outs GPRlr:$lr),
5683 (ins rGPR:$tc, brtarget:$target),
5687 // Similar to a t2DoLoopStartTP, a t2WhileLoopStartTP is a pseudo for a WLSTP
5688 // holding both the element count and the tripcount of the loop.
5689 def t2WhileLoopStartTP :
5690 t2PseudoInst<(outs GPRlr:$lr),
5691 (ins rGPR:$tc, rGPR:$elts, brtarget:$target),
5695 // t2LoopEnd - the branch half of a t2LoopDec/t2LoopEnd pair.
5697 t2PseudoInst<(outs), (ins GPRlr:$tc, brtarget:$target),
5698 8, IIC_Br, []>, Sched<[WriteBr]>;
5700 // The combination of a t2LoopDec and t2LoopEnd, performing both the LR
5701 // decrement and branch as a single instruction. Is lowered to a LE or
5702 // LETP in ARMLowOverheadLoops as appropriate, or converted to t2CMP/t2Bcc
5703 // if the branches are out of range.
5705 t2PseudoInst<(outs GPRlr:$Rm), (ins GPRlr:$tc, brtarget:$target),
5706 8, IIC_Br, []>, Sched<[WriteBr]>;
5708 } // end isBranch, isTerminator, hasSideEffects
5712 } // end isNotDuplicable
5714 class CS<string iname, bits<4> opcode, list<dag> pattern=[]>
5715 : V8_1MI<(outs rGPR:$Rd), (ins GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rm, pred_noal:$fcond),
5716 AddrModeNone, NoItinerary, iname, "$Rd, $Rn, $Rm, $fcond", "", pattern> {
5722 let Inst{31-20} = 0b111010100101;
5723 let Inst{19-16} = Rn{3-0};
5724 let Inst{15-12} = opcode;
5725 let Inst{11-8} = Rd{3-0};
5726 let Inst{7-4} = fcond{3-0};
5727 let Inst{3-0} = Rm{3-0};
5730 let hasSideEffects = 0;
5733 def t2CSEL : CS<"csel", 0b1000>;
5734 def t2CSINC : CS<"csinc", 0b1001>;
5735 def t2CSINV : CS<"csinv", 0b1010>;
5736 def t2CSNEG : CS<"csneg", 0b1011>;
5739 : PatFrag<(ops node:$lhs, node:$rhs, node:$cc, node:$flags),
5740 (ARMcsinc node:$lhs, node:$rhs, node:$cc, node:$flags), [{
5741 return N->hasOneUse();
5744 let Predicates = [HasV8_1MMainline] in {
5745 multiclass CSPats<SDNode Node, Instruction Insn> {
5746 def : T2Pat<(Node GPRwithZR:$tval, GPRwithZR:$fval, imm:$cc, CPSR),
5747 (Insn GPRwithZR:$tval, GPRwithZR:$fval, imm:$cc)>;
5748 def : T2Pat<(Node (i32 0), GPRwithZR:$fval, imm:$cc, CPSR),
5749 (Insn ZR, GPRwithZR:$fval, imm:$cc)>;
5750 def : T2Pat<(Node GPRwithZR:$tval, (i32 0), imm:$cc, CPSR),
5751 (Insn GPRwithZR:$tval, ZR, imm:$cc)>;
5752 def : T2Pat<(Node (i32 0), (i32 0), imm:$cc, CPSR),
5753 (Insn ZR, ZR, imm:$cc)>;
5756 defm : CSPats<ARMcsinc, t2CSINC>;
5757 defm : CSPats<ARMcsinv, t2CSINV>;
5758 defm : CSPats<ARMcsneg, t2CSNEG>;
5760 def : T2Pat<(ARMcmov (i32 1), (i32 0), imm:$cc, CPSR),
5761 (t2CSINC ZR, ZR, imm:$cc)>;
5762 def : T2Pat<(ARMcmov (i32 -1), (i32 0), imm:$cc, CPSR),
5763 (t2CSINV ZR, ZR, imm:$cc)>;
5764 def : T2Pat<(ARMcmov (i32 0), (i32 1), imm:$cc, CPSR),
5765 (t2CSINC ZR, ZR, (inv_cond_XFORM imm:$cc))>;
5766 def : T2Pat<(ARMcmov (i32 0), (i32 -1), imm:$cc, CPSR),
5767 (t2CSINV ZR, ZR, (inv_cond_XFORM imm:$cc))>;
5769 multiclass ModifiedV8_1CSEL<Instruction Insn, dag modvalue> {
5770 def : T2Pat<(ARMcmov modvalue, GPRwithZR:$tval, imm:$cc, CPSR),
5771 (Insn GPRwithZR:$tval, GPRwithZR:$fval, imm:$cc)>;
5772 def : T2Pat<(ARMcmov GPRwithZR:$tval, modvalue, imm:$cc, CPSR),
5773 (Insn GPRwithZR:$tval, GPRwithZR:$fval,
5774 (i32 (inv_cond_XFORM imm:$cc)))>;
5776 defm : ModifiedV8_1CSEL<t2CSINC, (add rGPR:$fval, 1)>;
5777 defm : ModifiedV8_1CSEL<t2CSINV, (xor rGPR:$fval, -1)>;
5778 defm : ModifiedV8_1CSEL<t2CSNEG, (sub 0, rGPR:$fval)>;
5780 def : T2Pat<(ARMcmov (topbitsallzero32:$Rn), (i32 1), imm:$cc, CPSR),
5781 (t2CSINC $Rn, ZR, (inv_cond_XFORM imm:$cc))>;
5782 def : T2Pat<(and (topbitsallzero32:$Rn),
5783 (ARMcsinc_su (i32 0), (i32 0), imm:$cc, CPSR)),
5784 (t2CSEL ZR, $Rn, imm:$cc)>;
5788 let Predicates = [HasV8_1MMainline] in {
5789 def : InstAlias<"csetm\t$Rd, $fcond",
5790 (t2CSINV rGPR:$Rd, ZR, ZR, pred_noal_inv:$fcond)>;
5792 def : InstAlias<"cset\t$Rd, $fcond",
5793 (t2CSINC rGPR:$Rd, ZR, ZR, pred_noal_inv:$fcond)>;
5795 def : InstAlias<"cinc\t$Rd, $Rn, $fcond",
5796 (t2CSINC rGPR:$Rd, GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rn, pred_noal_inv:$fcond)>;
5798 def : InstAlias<"cinv\t$Rd, $Rn, $fcond",
5799 (t2CSINV rGPR:$Rd, GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rn, pred_noal_inv:$fcond)>;
5801 def : InstAlias<"cneg\t$Rd, $Rn, $fcond",
5802 (t2CSNEG rGPR:$Rd, GPRwithZRnosp:$Rn, GPRwithZRnosp:$Rn, pred_noal_inv:$fcond)>;
5807 let Predicates = [IsThumb2, HasV8_1MMainline, HasPACBTI] in {
5808 def t2PACG : V8_1MI<(outs rGPR:$Rd),
5809 (ins pred:$p, GPRnopc:$Rn, GPRnopc:$Rm),
5810 AddrModeNone, NoItinerary, "pacg${p}", "$Rd, $Rn, $Rm", "", []> {
5814 let Inst{31-20} = 0b111110110110;
5815 let Inst{19-16} = Rn;
5816 let Inst{15-12} = 0b1111;
5817 let Inst{11-8} = Rd;
5818 let Inst{7-4} = 0b0000;
5822 let hasSideEffects = 1 in {
5823 class PACBTIAut<dag iops, string asm, bit b>
5824 : V8_1MI<(outs), iops,
5825 AddrModeNone, NoItinerary, asm, "$Ra, $Rn, $Rm", "", []> {
5829 let Inst{31-20} = 0b111110110101;
5830 let Inst{19-16} = Rn;
5831 let Inst{15-12} = Ra;
5832 let Inst{11-5} = 0b1111000;
5838 def t2AUTG : PACBTIAut<(ins pred:$p, GPRnosp:$Ra, GPRnopc:$Rn, GPRnopc:$Rm),
5841 let isBranch = 1, isTerminator = 1, isIndirectBranch = 1 in {
5842 def t2BXAUT : PACBTIAut<(ins pred:$p, GPRnosp:$Ra, rGPR:$Rn, GPRnopc:$Rm),
5848 class PACBTIHintSpaceInst<string asm, string ops, bits<8> imm>
5849 : Thumb2XI<(outs), (ins), AddrModeNone, 4, NoItinerary, !strconcat(asm, "\t", ops), "", []>,
5850 Requires<[HasV7, IsMClass]> {
5851 let Inst{31-8} = 0b111100111010111110000000;
5852 let Inst{7-0} = imm;
5854 let Unpredictable{19-16} = 0b1111;
5855 let Unpredictable{13-11} = 0b101;
5857 let DecoderMethod = "DecodeT2HintSpaceInstruction";
5860 class PACBTIHintSpaceNoOpsInst<string asm, bits<8> imm>
5861 : PACBTIHintSpaceInst<asm, "", imm>;
5863 class PACBTIHintSpaceDefInst<string asm, bits<8> imm>
5864 : PACBTIHintSpaceInst<asm, "r12, lr, sp", imm> {
5866 let Uses = [LR, SP];
5869 class PACBTIHintSpaceUseInst<string asm, bits<8> imm>
5870 : PACBTIHintSpaceInst<asm, "r12, lr, sp", imm> {
5871 let Uses = [R12, LR, SP];
5874 def t2PAC : PACBTIHintSpaceDefInst<"pac", 0b00011101>;
5875 def t2PACBTI : PACBTIHintSpaceDefInst<"pacbti", 0b00001101>;
5876 def t2BTI : PACBTIHintSpaceNoOpsInst<"bti", 0b00001111>;
5877 def t2AUT : PACBTIHintSpaceUseInst<"aut", 0b00101101> {
5878 let hasSideEffects = 1;
5881 def ARMt2CallBTI : SDNode<"ARMISD::t2CALL_BTI", SDT_ARMcall,
5882 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, SDNPVariadic]>;
5884 let Defs = [LR], Uses = [SP] in
5885 def t2CALL_BTI : PseudoInst<(outs), (ins pred:$p, thumb_bl_target:$func),
5886 IIC_Br, [(ARMt2CallBTI tglobaladdr:$func)]>,
5887 Requires<[IsThumb2]>, Sched<[WriteBrL]>;