1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
22 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
24 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
26 def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
30 def SDT_ARMBrcond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
33 def SDT_ARMBrJT : SDTypeProfile<0, 3,
34 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
37 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
38 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
39 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
41 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
43 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
44 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
45 SDTCisVT<5, OtherVT>]>;
47 def SDT_ARMAnd : SDTypeProfile<1, 2,
48 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
51 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
53 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
54 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
56 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
57 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
59 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
61 def SDT_ARMEH_SJLJ_DispatchSetup: SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
63 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 0, []>;
64 def SDT_ARMSYNCBARRIER : SDTypeProfile<0, 0, []>;
65 def SDT_ARMMEMBARRIERMCR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
66 def SDT_ARMSYNCBARRIERMCR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
68 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
70 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
71 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
74 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
75 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
77 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
78 [SDNPHasChain, SDNPOutFlag]>;
79 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
80 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
82 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
83 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag,
85 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
86 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag,
88 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
89 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag,
92 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
93 [SDNPHasChain, SDNPOptInFlag]>;
95 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
97 def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
100 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
101 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
103 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
105 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
108 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
111 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
114 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
115 [SDNPOutFlag, SDNPCommutative]>;
117 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
119 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
120 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
121 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
123 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
124 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
125 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
126 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
127 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
128 def ARMeh_sjlj_dispatchsetup: SDNode<"ARMISD::EH_SJLJ_DISPATCHSETUP",
129 SDT_ARMEH_SJLJ_DispatchSetup, [SDNPHasChain]>;
132 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
134 def ARMSyncBarrier : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIER,
136 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERMCR,
138 def ARMSyncBarrierMCR : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERMCR,
141 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
143 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
144 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
147 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
149 //===----------------------------------------------------------------------===//
150 // ARM Instruction Predicate Definitions.
152 def HasV4T : Predicate<"Subtarget->hasV4TOps()">;
153 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
154 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
155 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
156 def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
157 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">;
158 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
159 def HasV7 : Predicate<"Subtarget->hasV7Ops()">;
160 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
161 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">;
162 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">;
163 def HasNEON : Predicate<"Subtarget->hasNEON()">;
164 def HasDivide : Predicate<"Subtarget->hasDivide()">;
165 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">;
166 def HasDB : Predicate<"Subtarget->hasDataBarrier()">;
167 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
168 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
169 def IsThumb : Predicate<"Subtarget->isThumb()">;
170 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
171 def IsThumb2 : Predicate<"Subtarget->isThumb2()">;
172 def IsARM : Predicate<"!Subtarget->isThumb()">;
173 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
174 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
176 // FIXME: Eventually this will be just "hasV6T2Ops".
177 def UseMovt : Predicate<"Subtarget->useMovt()">;
178 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
179 def UseVMLx : Predicate<"Subtarget->useVMLx()">;
181 //===----------------------------------------------------------------------===//
182 // ARM Flag Definitions.
184 class RegConstraint<string C> {
185 string Constraints = C;
188 //===----------------------------------------------------------------------===//
189 // ARM specific transformation functions and pattern fragments.
192 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
193 // so_imm_neg def below.
194 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
195 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
198 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
199 // so_imm_not def below.
200 def so_imm_not_XFORM : SDNodeXForm<imm, [{
201 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
204 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
205 def imm1_15 : PatLeaf<(i32 imm), [{
206 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
209 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
210 def imm16_31 : PatLeaf<(i32 imm), [{
211 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
216 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
217 }], so_imm_neg_XFORM>;
221 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
222 }], so_imm_not_XFORM>;
224 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
225 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
226 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
229 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
231 def bf_inv_mask_imm : Operand<i32>,
233 return ARM::isBitFieldInvertedMask(N->getZExtValue());
235 string EncoderMethod = "getBitfieldInvertedMaskOpValue";
236 let PrintMethod = "printBitfieldInvMaskImmOperand";
239 /// Split a 32-bit immediate into two 16 bit parts.
240 def hi16 : SDNodeXForm<imm, [{
241 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
244 def lo16AllZero : PatLeaf<(i32 imm), [{
245 // Returns true if all low 16-bits are 0.
246 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
249 /// imm0_65535 predicate - True if the 32-bit immediate is in the range
251 def imm0_65535 : PatLeaf<(i32 imm), [{
252 return (uint32_t)N->getZExtValue() < 65536;
255 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
256 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
258 /// adde and sube predicates - True based on whether the carry flag output
259 /// will be needed or not.
260 def adde_dead_carry :
261 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
262 [{return !N->hasAnyUseOfValue(1);}]>;
263 def sube_dead_carry :
264 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
265 [{return !N->hasAnyUseOfValue(1);}]>;
266 def adde_live_carry :
267 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
268 [{return N->hasAnyUseOfValue(1);}]>;
269 def sube_live_carry :
270 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
271 [{return N->hasAnyUseOfValue(1);}]>;
273 //===----------------------------------------------------------------------===//
274 // Operand Definitions.
278 def brtarget : Operand<OtherVT>;
280 // A list of registers separated by comma. Used by load/store multiple.
281 def reglist : Operand<i32> {
282 let PrintMethod = "printRegisterList";
285 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
286 def cpinst_operand : Operand<i32> {
287 let PrintMethod = "printCPInstOperand";
290 def jtblock_operand : Operand<i32> {
291 let PrintMethod = "printJTBlockOperand";
293 def jt2block_operand : Operand<i32> {
294 let PrintMethod = "printJT2BlockOperand";
298 def pclabel : Operand<i32> {
299 let PrintMethod = "printPCLabel";
302 def neon_vcvt_imm32 : Operand<i32> {
303 string EncoderMethod = "getNEONVcvtImm32";
306 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
307 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
308 int32_t v = (int32_t)N->getZExtValue();
309 return v == 8 || v == 16 || v == 24; }]> {
310 string EncoderMethod = "getRotImmOpValue";
313 // shift_imm: An integer that encodes a shift amount and the type of shift
314 // (currently either asr or lsl) using the same encoding used for the
315 // immediates in so_reg operands.
316 def shift_imm : Operand<i32> {
317 let PrintMethod = "printShiftImmOperand";
320 // shifter_operand operands: so_reg and so_imm.
321 def so_reg : Operand<i32>, // reg reg imm
322 ComplexPattern<i32, 3, "SelectShifterOperandReg",
323 [shl,srl,sra,rotr]> {
324 string EncoderMethod = "getSORegOpValue";
325 let PrintMethod = "printSORegOperand";
326 let MIOperandInfo = (ops GPR, GPR, i32imm);
328 def shift_so_reg : Operand<i32>, // reg reg imm
329 ComplexPattern<i32, 3, "SelectShiftShifterOperandReg",
330 [shl,srl,sra,rotr]> {
331 string EncoderMethod = "getSORegOpValue";
332 let PrintMethod = "printSORegOperand";
333 let MIOperandInfo = (ops GPR, GPR, i32imm);
336 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
337 // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
338 // represented in the imm field in the same 12-bit form that they are encoded
339 // into so_imm instructions: the 8-bit immediate is the least significant bits
340 // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
341 def so_imm : Operand<i32>, PatLeaf<(imm), [{ return Pred_so_imm(N); }]> {
342 string EncoderMethod = "getSOImmOpValue";
343 let PrintMethod = "printSOImmOperand";
346 // Break so_imm's up into two pieces. This handles immediates with up to 16
347 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
348 // get the first/second pieces.
349 def so_imm2part : Operand<i32>,
351 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
353 let PrintMethod = "printSOImm2PartOperand";
356 def so_imm2part_1 : SDNodeXForm<imm, [{
357 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
358 return CurDAG->getTargetConstant(V, MVT::i32);
361 def so_imm2part_2 : SDNodeXForm<imm, [{
362 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
363 return CurDAG->getTargetConstant(V, MVT::i32);
366 def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
367 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
369 let PrintMethod = "printSOImm2PartOperand";
372 def so_neg_imm2part_1 : SDNodeXForm<imm, [{
373 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
374 return CurDAG->getTargetConstant(V, MVT::i32);
377 def so_neg_imm2part_2 : SDNodeXForm<imm, [{
378 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
379 return CurDAG->getTargetConstant(V, MVT::i32);
382 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
383 def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
384 return (int32_t)N->getZExtValue() < 32;
387 /// imm0_31_m1 - Matches and prints like imm0_31, but encodes as 'value - 1'.
388 def imm0_31_m1 : Operand<i32>, PatLeaf<(imm), [{
389 return (int32_t)N->getZExtValue() < 32;
391 string EncoderMethod = "getImmMinusOneOpValue";
394 // Define ARM specific addressing modes.
397 // addrmode_imm12 := reg +/- imm12
399 def addrmode_imm12 : Operand<i32>,
400 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
401 // 12-bit immediate operand. Note that instructions using this encode
402 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
403 // immediate values are as normal.
405 string EncoderMethod = "getAddrModeImm12OpValue";
406 let PrintMethod = "printAddrModeImm12Operand";
407 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
409 // ldst_so_reg := reg +/- reg shop imm
411 def ldst_so_reg : Operand<i32>,
412 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
413 // FIXME: Simplify the printer
414 // FIXME: Add EncoderMethod for this addressing mode
415 let PrintMethod = "printAddrMode2Operand";
416 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
419 // addrmode2 := reg +/- imm12
420 // := reg +/- reg shop imm
422 def addrmode2 : Operand<i32>,
423 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
424 let PrintMethod = "printAddrMode2Operand";
425 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
428 def am2offset : Operand<i32>,
429 ComplexPattern<i32, 2, "SelectAddrMode2Offset",
430 [], [SDNPWantRoot]> {
431 let PrintMethod = "printAddrMode2OffsetOperand";
432 let MIOperandInfo = (ops GPR, i32imm);
435 // addrmode3 := reg +/- reg
436 // addrmode3 := reg +/- imm8
438 def addrmode3 : Operand<i32>,
439 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
440 let PrintMethod = "printAddrMode3Operand";
441 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
444 def am3offset : Operand<i32>,
445 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
446 [], [SDNPWantRoot]> {
447 let PrintMethod = "printAddrMode3OffsetOperand";
448 let MIOperandInfo = (ops GPR, i32imm);
451 // addrmode4 := reg, <mode|W>
453 def addrmode4 : Operand<i32>,
454 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
455 let PrintMethod = "printAddrMode4Operand";
456 let MIOperandInfo = (ops GPR:$addr, i32imm);
459 def ARMMemMode5AsmOperand : AsmOperandClass {
460 let Name = "MemMode5";
461 let SuperClasses = [];
464 // addrmode5 := reg +/- imm8*4
466 def addrmode5 : Operand<i32>,
467 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
468 let PrintMethod = "printAddrMode5Operand";
469 let MIOperandInfo = (ops GPR:$base, i32imm);
470 let ParserMatchClass = ARMMemMode5AsmOperand;
473 // addrmode6 := reg with optional writeback
475 def addrmode6 : Operand<i32>,
476 ComplexPattern<i32, 2, "SelectAddrMode6", []> {
477 let PrintMethod = "printAddrMode6Operand";
478 let MIOperandInfo = (ops GPR:$addr, i32imm);
481 def am6offset : Operand<i32> {
482 let PrintMethod = "printAddrMode6OffsetOperand";
483 let MIOperandInfo = (ops GPR);
486 // addrmodepc := pc + reg
488 def addrmodepc : Operand<i32>,
489 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
490 let PrintMethod = "printAddrModePCOperand";
491 let MIOperandInfo = (ops GPR, i32imm);
494 def nohash_imm : Operand<i32> {
495 let PrintMethod = "printNoHashImmediate";
498 //===----------------------------------------------------------------------===//
500 include "ARMInstrFormats.td"
502 //===----------------------------------------------------------------------===//
503 // Multiclass helpers...
506 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
507 /// binop that produces a value.
508 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
509 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
510 PatFrag opnode, bit Commutable = 0> {
511 // The register-immediate version is re-materializable. This is useful
512 // in particular for taking the address of a local.
513 let isReMaterializable = 1 in {
514 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
515 iii, opc, "\t$Rd, $Rn, $imm",
516 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
521 let Inst{15-12} = Rd;
522 let Inst{19-16} = Rn;
523 let Inst{11-0} = imm;
526 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
527 iir, opc, "\t$Rd, $Rn, $Rm",
528 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
532 let Inst{11-4} = 0b00000000;
534 let isCommutable = Commutable;
536 let Inst{15-12} = Rd;
537 let Inst{19-16} = Rn;
539 def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm,
540 iis, opc, "\t$Rd, $Rn, $shift",
541 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> {
546 let Inst{11-0} = shift;
547 let Inst{15-12} = Rd;
548 let Inst{19-16} = Rn;
552 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
553 /// instruction modifies the CPSR register.
554 let Defs = [CPSR] in {
555 multiclass AI1_bin_s_irs<bits<4> opcod, string opc,
556 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
557 PatFrag opnode, bit Commutable = 0> {
558 def ri : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
559 iii, opc, "\t$Rd, $Rn, $imm",
560 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
565 let Inst{15-12} = Rd;
566 let Inst{19-16} = Rn;
567 let Inst{11-0} = imm;
570 def rr : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
571 iir, opc, "\t$Rd, $Rn, $Rm",
572 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
576 let Inst{11-4} = 0b00000000;
578 let isCommutable = Commutable;
580 let Inst{15-12} = Rd;
581 let Inst{19-16} = Rn;
584 def rs : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm,
585 iis, opc, "\t$Rd, $Rn, $shift",
586 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> {
591 let Inst{11-0} = shift;
592 let Inst{15-12} = Rd;
593 let Inst{19-16} = Rn;
599 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
600 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
601 /// a explicit result, only implicitly set CPSR.
602 let isCompare = 1, Defs = [CPSR] in {
603 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
604 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
605 PatFrag opnode, bit Commutable = 0> {
606 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
608 [(opnode GPR:$Rn, so_imm:$imm)]> {
612 let Inst{15-12} = 0b0000;
613 let Inst{19-16} = Rn;
614 let Inst{11-0} = imm;
618 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
620 [(opnode GPR:$Rn, GPR:$Rm)]> {
623 let Inst{11-4} = 0b00000000;
625 let isCommutable = Commutable;
627 let Inst{15-12} = 0b0000;
628 let Inst{19-16} = Rn;
631 def rs : AI1<opcod, (outs), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, iis,
632 opc, "\t$Rn, $shift",
633 [(opnode GPR:$Rn, so_reg:$shift)]> {
637 let Inst{11-0} = shift;
638 let Inst{15-12} = 0b0000;
639 let Inst{19-16} = Rn;
645 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
646 /// register and one whose operand is a register rotated by 8/16/24.
647 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
648 multiclass AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode> {
649 def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm),
650 IIC_iEXTr, opc, "\t$Rd, $Rm",
651 [(set GPR:$Rd, (opnode GPR:$Rm))]>,
652 Requires<[IsARM, HasV6]> {
655 let Inst{15-12} = Rd;
657 let Inst{11-10} = 0b00;
658 let Inst{19-16} = 0b1111;
660 def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot),
661 IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot",
662 [(set GPR:$Rd, (opnode (rotr GPR:$Rm, rot_imm:$rot)))]>,
663 Requires<[IsARM, HasV6]> {
667 let Inst{15-12} = Rd;
668 let Inst{11-10} = rot;
670 let Inst{19-16} = 0b1111;
674 multiclass AI_ext_rrot_np<bits<8> opcod, string opc> {
675 def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm),
676 IIC_iEXTr, opc, "\t$Rd, $Rm",
677 [/* For disassembly only; pattern left blank */]>,
678 Requires<[IsARM, HasV6]> {
679 let Inst{11-10} = 0b00;
680 let Inst{19-16} = 0b1111;
682 def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot),
683 IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot",
684 [/* For disassembly only; pattern left blank */]>,
685 Requires<[IsARM, HasV6]> {
687 let Inst{11-10} = rot;
688 let Inst{19-16} = 0b1111;
692 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
693 /// register and one whose operand is a register rotated by 8/16/24.
694 multiclass AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode> {
695 def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
696 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm",
697 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
698 Requires<[IsARM, HasV6]> {
699 let Inst{11-10} = 0b00;
701 def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
703 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
704 [(set GPR:$Rd, (opnode GPR:$Rn,
705 (rotr GPR:$Rm, rot_imm:$rot)))]>,
706 Requires<[IsARM, HasV6]> {
709 let Inst{19-16} = Rn;
710 let Inst{11-10} = rot;
714 // For disassembly only.
715 multiclass AI_exta_rrot_np<bits<8> opcod, string opc> {
716 def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
717 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm",
718 [/* For disassembly only; pattern left blank */]>,
719 Requires<[IsARM, HasV6]> {
720 let Inst{11-10} = 0b00;
722 def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
724 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
725 [/* For disassembly only; pattern left blank */]>,
726 Requires<[IsARM, HasV6]> {
729 let Inst{19-16} = Rn;
730 let Inst{11-10} = rot;
734 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
735 let Uses = [CPSR] in {
736 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
737 bit Commutable = 0> {
738 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
739 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
740 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
746 let Inst{15-12} = Rd;
747 let Inst{19-16} = Rn;
748 let Inst{11-0} = imm;
750 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
751 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
752 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
757 let Inst{11-4} = 0b00000000;
759 let isCommutable = Commutable;
761 let Inst{15-12} = Rd;
762 let Inst{19-16} = Rn;
764 def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
765 DPSoRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
766 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>,
772 let Inst{11-0} = shift;
773 let Inst{15-12} = Rd;
774 let Inst{19-16} = Rn;
777 // Carry setting variants
778 let Defs = [CPSR] in {
779 multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
780 bit Commutable = 0> {
781 def Sri : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
782 DPFrm, IIC_iALUi, !strconcat(opc, "\t$Rd, $Rn, $imm"),
783 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
788 let Inst{15-12} = Rd;
789 let Inst{19-16} = Rn;
790 let Inst{11-0} = imm;
794 def Srr : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
795 DPFrm, IIC_iALUr, !strconcat(opc, "\t$Rd, $Rn, $Rm"),
796 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
801 let Inst{11-4} = 0b00000000;
802 let isCommutable = Commutable;
804 let Inst{15-12} = Rd;
805 let Inst{19-16} = Rn;
809 def Srs : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
810 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$Rd, $Rn, $shift"),
811 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>,
816 let Inst{11-0} = shift;
817 let Inst{15-12} = Rd;
818 let Inst{19-16} = Rn;
826 let canFoldAsLoad = 1, isReMaterializable = 1 in {
827 multiclass AI_ldr1<bit opc22, string opc, InstrItinClass iii,
828 InstrItinClass iir, PatFrag opnode> {
829 // Note: We use the complex addrmode_imm12 rather than just an input
830 // GPR and a constrained immediate so that we can use this to match
831 // frame index references and avoid matching constant pool references.
832 def i12 : AIldst1<0b010, opc22, 1, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
833 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
834 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
837 let Inst{23} = addr{12}; // U (add = ('U' == 1))
838 let Inst{19-16} = addr{16-13}; // Rn
839 let Inst{15-12} = Rt;
840 let Inst{11-0} = addr{11-0}; // imm12
842 def rs : AIldst1<0b011, opc22, 1, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
843 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
844 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
847 let Inst{23} = shift{12}; // U (add = ('U' == 1))
848 let Inst{19-16} = shift{16-13}; // Rn
849 let Inst{11-0} = shift{11-0};
854 multiclass AI_str1<bit opc22, string opc, InstrItinClass iii,
855 InstrItinClass iir, PatFrag opnode> {
856 // Note: We use the complex addrmode_imm12 rather than just an input
857 // GPR and a constrained immediate so that we can use this to match
858 // frame index references and avoid matching constant pool references.
859 def i12 : AIldst1<0b010, opc22, 0, (outs),
860 (ins GPR:$Rt, addrmode_imm12:$addr),
861 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
862 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
865 let Inst{23} = addr{12}; // U (add = ('U' == 1))
866 let Inst{19-16} = addr{16-13}; // Rn
867 let Inst{15-12} = Rt;
868 let Inst{11-0} = addr{11-0}; // imm12
870 def rs : AIldst1<0b011, opc22, 0, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
871 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
872 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
875 let Inst{23} = shift{12}; // U (add = ('U' == 1))
876 let Inst{19-16} = shift{16-13}; // Rn
877 let Inst{11-0} = shift{11-0};
880 //===----------------------------------------------------------------------===//
882 //===----------------------------------------------------------------------===//
884 //===----------------------------------------------------------------------===//
885 // Miscellaneous Instructions.
888 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
889 /// the function. The first operand is the ID# for this instruction, the second
890 /// is the index into the MachineConstantPool that this is, the third is the
891 /// size in bytes of this constant pool entry.
892 let neverHasSideEffects = 1, isNotDuplicable = 1 in
893 def CONSTPOOL_ENTRY :
894 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
895 i32imm:$size), NoItinerary, "", []>;
897 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
898 // from removing one half of the matched pairs. That breaks PEI, which assumes
899 // these will always be in pairs, and asserts if it finds otherwise. Better way?
900 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
902 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary, "",
903 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
905 def ADJCALLSTACKDOWN :
906 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary, "",
907 [(ARMcallseq_start timm:$amt)]>;
910 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "",
911 [/* For disassembly only; pattern left blank */]>,
912 Requires<[IsARM, HasV6T2]> {
913 let Inst{27-16} = 0b001100100000;
914 let Inst{15-8} = 0b11110000;
915 let Inst{7-0} = 0b00000000;
918 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "",
919 [/* For disassembly only; pattern left blank */]>,
920 Requires<[IsARM, HasV6T2]> {
921 let Inst{27-16} = 0b001100100000;
922 let Inst{15-8} = 0b11110000;
923 let Inst{7-0} = 0b00000001;
926 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "",
927 [/* For disassembly only; pattern left blank */]>,
928 Requires<[IsARM, HasV6T2]> {
929 let Inst{27-16} = 0b001100100000;
930 let Inst{15-8} = 0b11110000;
931 let Inst{7-0} = 0b00000010;
934 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "",
935 [/* For disassembly only; pattern left blank */]>,
936 Requires<[IsARM, HasV6T2]> {
937 let Inst{27-16} = 0b001100100000;
938 let Inst{15-8} = 0b11110000;
939 let Inst{7-0} = 0b00000011;
942 def SEL : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, NoItinerary, "sel",
944 [/* For disassembly only; pattern left blank */]>,
945 Requires<[IsARM, HasV6]> {
950 let Inst{15-12} = Rd;
951 let Inst{19-16} = Rn;
952 let Inst{27-20} = 0b01101000;
953 let Inst{7-4} = 0b1011;
954 let Inst{11-8} = 0b1111;
957 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
958 [/* For disassembly only; pattern left blank */]>,
959 Requires<[IsARM, HasV6T2]> {
960 let Inst{27-16} = 0b001100100000;
961 let Inst{15-8} = 0b11110000;
962 let Inst{7-0} = 0b00000100;
965 // The i32imm operand $val can be used by a debugger to store more information
966 // about the breakpoint.
967 def BKPT : AI<(outs), (ins i32imm:$val), MiscFrm, NoItinerary, "bkpt", "\t$val",
968 [/* For disassembly only; pattern left blank */]>,
971 let Inst{3-0} = val{3-0};
972 let Inst{19-8} = val{15-4};
973 let Inst{27-20} = 0b00010010;
974 let Inst{7-4} = 0b0111;
977 // Change Processor State is a system instruction -- for disassembly only.
978 // The singleton $opt operand contains the following information:
979 // opt{4-0} = mode from Inst{4-0}
980 // opt{5} = changemode from Inst{17}
981 // opt{8-6} = AIF from Inst{8-6}
982 // opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
983 // FIXME: Integrated assembler will need these split out.
984 def CPS : AXI<(outs), (ins cps_opt:$opt), MiscFrm, NoItinerary, "cps$opt",
985 [/* For disassembly only; pattern left blank */]>,
987 let Inst{31-28} = 0b1111;
988 let Inst{27-20} = 0b00010000;
993 // Preload signals the memory system of possible future data/instruction access.
994 // These are for disassembly only.
996 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
997 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
998 multiclass APreLoad<bit data, bit read, string opc> {
1000 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, NoItinerary,
1001 !strconcat(opc, "\t$addr"), []> {
1004 let Inst{31-26} = 0b111101;
1005 let Inst{25} = 0; // 0 for immediate form
1006 let Inst{24} = data;
1007 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1008 let Inst{22} = read;
1009 let Inst{21-20} = 0b01;
1010 let Inst{19-16} = addr{16-13}; // Rn
1011 let Inst{15-12} = Rt;
1012 let Inst{11-0} = addr{11-0}; // imm12
1015 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, NoItinerary,
1016 !strconcat(opc, "\t$shift"), []> {
1019 let Inst{31-26} = 0b111101;
1020 let Inst{25} = 1; // 1 for register form
1021 let Inst{24} = data;
1022 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1023 let Inst{22} = read;
1024 let Inst{21-20} = 0b01;
1025 let Inst{19-16} = shift{16-13}; // Rn
1026 let Inst{11-0} = shift{11-0};
1030 defm PLD : APreLoad<1, 1, "pld">;
1031 defm PLDW : APreLoad<1, 0, "pldw">;
1032 defm PLI : APreLoad<0, 1, "pli">;
1034 def SETEND : AXI<(outs),(ins setend_op:$end), MiscFrm, NoItinerary,
1036 [/* For disassembly only; pattern left blank */]>,
1039 let Inst{31-10} = 0b1111000100000001000000;
1044 def DBG : AI<(outs), (ins i32imm:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1045 [/* For disassembly only; pattern left blank */]>,
1046 Requires<[IsARM, HasV7]> {
1048 let Inst{27-4} = 0b001100100000111100001111;
1049 let Inst{3-0} = opt;
1052 // A5.4 Permanently UNDEFINED instructions.
1053 let isBarrier = 1, isTerminator = 1 in
1054 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1057 let Inst{27-25} = 0b011;
1058 let Inst{24-20} = 0b11111;
1059 let Inst{7-5} = 0b111;
1063 // Address computation and loads and stores in PIC mode.
1064 // FIXME: These PIC insn patterns are pseudos, but derive from the normal insn
1065 // classes (AXI1, et.al.) and so have encoding information and such,
1066 // which is suboptimal. Once the rest of the code emitter (including
1067 // JIT) is MC-ized we should look at refactoring these into true
1069 let isNotDuplicable = 1 in {
1070 def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1071 Pseudo, IIC_iALUr, "",
1072 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1074 let AddedComplexity = 10 in {
1075 def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1076 Pseudo, IIC_iLoad_r, "",
1077 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1079 def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1080 Pseudo, IIC_iLoad_bh_r, "",
1081 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
1083 def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1084 Pseudo, IIC_iLoad_bh_r, "",
1085 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
1087 def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1088 Pseudo, IIC_iLoad_bh_r, "",
1089 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
1091 def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1092 Pseudo, IIC_iLoad_bh_r, "",
1093 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
1095 let AddedComplexity = 10 in {
1096 def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1097 Pseudo, IIC_iStore_r, "",
1098 [(store GPR:$src, addrmodepc:$addr)]>;
1100 def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1101 Pseudo, IIC_iStore_bh_r, "",
1102 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
1104 def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1105 Pseudo, IIC_iStore_bh_r, "",
1106 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1108 } // isNotDuplicable = 1
1111 // LEApcrel - Load a pc-relative address into a register without offending the
1113 // FIXME: These are marked as pseudos, but they're really not(?). They're just
1114 // the ADR instruction. Is this the right way to handle that? They need
1115 // encoding information regardless.
1116 let neverHasSideEffects = 1 in {
1117 let isReMaterializable = 1 in
1118 def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
1120 "adr$p\t$dst, #$label", []>;
1122 } // neverHasSideEffects
1123 def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
1124 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1126 "adr$p\t$dst, #${label}_${id}", []> {
1130 //===----------------------------------------------------------------------===//
1131 // Control Flow Instructions.
1134 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1136 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1137 "bx", "\tlr", [(ARMretflag)]>,
1138 Requires<[IsARM, HasV4T]> {
1139 let Inst{27-0} = 0b0001001011111111111100011110;
1143 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1144 "mov", "\tpc, lr", [(ARMretflag)]>,
1145 Requires<[IsARM, NoV4T]> {
1146 let Inst{27-0} = 0b0001101000001111000000001110;
1150 // Indirect branches
1151 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1153 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1154 [(brind GPR:$dst)]>,
1155 Requires<[IsARM, HasV4T]> {
1157 let Inst{31-4} = 0b1110000100101111111111110001;
1158 let Inst{3-0} = dst;
1162 def MOVPCRX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "mov\tpc, $dst",
1163 [(brind GPR:$dst)]>,
1164 Requires<[IsARM, NoV4T]> {
1166 let Inst{31-4} = 0b1110000110100000111100000000;
1167 let Inst{3-0} = dst;
1171 // FIXME: remove when we have a way to marking a MI with these properties.
1172 // FIXME: Should pc be an implicit operand like PICADD, etc?
1173 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
1174 hasExtraDefRegAllocReq = 1 in
1175 def LDM_RET : AXI4ld<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1176 reglist:$dsts, variable_ops),
1177 IndexModeUpd, LdStMulFrm, IIC_iLoad_mBr,
1178 "ldm${addr:submode}${p}\t$addr!, $dsts",
1179 "$addr.addr = $wb", []>;
1181 // On non-Darwin platforms R9 is callee-saved.
1183 Defs = [R0, R1, R2, R3, R12, LR,
1184 D0, D1, D2, D3, D4, D5, D6, D7,
1185 D16, D17, D18, D19, D20, D21, D22, D23,
1186 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
1187 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1188 IIC_Br, "bl\t$func",
1189 [(ARMcall tglobaladdr:$func)]>,
1190 Requires<[IsARM, IsNotDarwin]> {
1191 let Inst{31-28} = 0b1110;
1192 // FIXME: Encoding info for $func. Needs fixups bits.
1195 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1196 IIC_Br, "bl", "\t$func",
1197 [(ARMcall_pred tglobaladdr:$func)]>,
1198 Requires<[IsARM, IsNotDarwin]>;
1201 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1202 IIC_Br, "blx\t$func",
1203 [(ARMcall GPR:$func)]>,
1204 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1206 let Inst{27-4} = 0b000100101111111111110011;
1207 let Inst{3-0} = func;
1211 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1212 def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1213 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
1214 [(ARMcall_nolink tGPR:$func)]>,
1215 Requires<[IsARM, HasV4T, IsNotDarwin]> {
1217 let Inst{27-4} = 0b000100101111111111110001;
1218 let Inst{3-0} = func;
1222 def BMOVPCRX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1223 IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func",
1224 [(ARMcall_nolink tGPR:$func)]>,
1225 Requires<[IsARM, NoV4T, IsNotDarwin]> {
1227 let Inst{27-4} = 0b000110100000111100000000;
1228 let Inst{3-0} = func;
1232 // On Darwin R9 is call-clobbered.
1234 Defs = [R0, R1, R2, R3, R9, R12, LR,
1235 D0, D1, D2, D3, D4, D5, D6, D7,
1236 D16, D17, D18, D19, D20, D21, D22, D23,
1237 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
1238 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1239 IIC_Br, "bl\t$func",
1240 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
1241 let Inst{31-28} = 0b1110;
1242 // FIXME: Encoding info for $func. Needs fixups bits.
1245 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1246 IIC_Br, "bl", "\t$func",
1247 [(ARMcall_pred tglobaladdr:$func)]>,
1248 Requires<[IsARM, IsDarwin]>;
1251 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1252 IIC_Br, "blx\t$func",
1253 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
1255 let Inst{27-4} = 0b000100101111111111110011;
1256 let Inst{3-0} = func;
1260 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1261 def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1262 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
1263 [(ARMcall_nolink tGPR:$func)]>,
1264 Requires<[IsARM, HasV4T, IsDarwin]> {
1266 let Inst{27-4} = 0b000100101111111111110001;
1267 let Inst{3-0} = func;
1271 def BMOVPCRXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1272 IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func",
1273 [(ARMcall_nolink tGPR:$func)]>,
1274 Requires<[IsARM, NoV4T, IsDarwin]> {
1276 let Inst{27-4} = 0b000110100000111100000000;
1277 let Inst{3-0} = func;
1283 // FIXME: These should probably be xformed into the non-TC versions of the
1284 // instructions as part of MC lowering.
1285 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
1287 let Defs = [R0, R1, R2, R3, R9, R12,
1288 D0, D1, D2, D3, D4, D5, D6, D7,
1289 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26,
1290 D27, D28, D29, D30, D31, PC],
1292 def TCRETURNdi : AInoP<(outs), (ins i32imm:$dst, variable_ops),
1294 "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>;
1296 def TCRETURNri : AInoP<(outs), (ins tcGPR:$dst, variable_ops),
1298 "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>;
1300 def TAILJMPd : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1301 IIC_Br, "b\t$dst @ TAILCALL",
1302 []>, Requires<[IsDarwin]>;
1304 def TAILJMPdt: ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1305 IIC_Br, "b.w\t$dst @ TAILCALL",
1306 []>, Requires<[IsDarwin]>;
1308 def TAILJMPr : AXI<(outs), (ins tcGPR:$dst, variable_ops),
1309 BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL",
1310 []>, Requires<[IsDarwin]> {
1312 let Inst{31-4} = 0b1110000100101111111111110001;
1313 let Inst{3-0} = dst;
1317 // Non-Darwin versions (the difference is R9).
1318 let Defs = [R0, R1, R2, R3, R12,
1319 D0, D1, D2, D3, D4, D5, D6, D7,
1320 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26,
1321 D27, D28, D29, D30, D31, PC],
1323 def TCRETURNdiND : AInoP<(outs), (ins i32imm:$dst, variable_ops),
1325 "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>;
1327 def TCRETURNriND : AInoP<(outs), (ins tcGPR:$dst, variable_ops),
1329 "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>;
1331 def TAILJMPdND : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1332 IIC_Br, "b\t$dst @ TAILCALL",
1333 []>, Requires<[IsARM, IsNotDarwin]>;
1335 def TAILJMPdNDt : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1336 IIC_Br, "b.w\t$dst @ TAILCALL",
1337 []>, Requires<[IsThumb, IsNotDarwin]>;
1339 def TAILJMPrND : AXI<(outs), (ins tcGPR:$dst, variable_ops),
1340 BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL",
1341 []>, Requires<[IsNotDarwin]> {
1343 let Inst{31-4} = 0b1110000100101111111111110001;
1344 let Inst{3-0} = dst;
1349 let isBranch = 1, isTerminator = 1 in {
1350 // B is "predicable" since it can be xformed into a Bcc.
1351 let isBarrier = 1 in {
1352 let isPredicable = 1 in
1353 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
1354 "b\t$target", [(br bb:$target)]>;
1356 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1357 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
1358 IIC_Br, "mov\tpc, $target$jt",
1359 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
1360 let Inst{11-4} = 0b00000000;
1361 let Inst{15-12} = 0b1111;
1362 let Inst{20} = 0; // S Bit
1363 let Inst{24-21} = 0b1101;
1364 let Inst{27-25} = 0b000;
1366 def BR_JTm : JTI<(outs),
1367 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
1368 IIC_Br, "ldr\tpc, $target$jt",
1369 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1371 let Inst{15-12} = 0b1111;
1372 let Inst{20} = 1; // L bit
1373 let Inst{21} = 0; // W bit
1374 let Inst{22} = 0; // B bit
1375 let Inst{24} = 1; // P bit
1376 let Inst{27-25} = 0b011;
1378 def BR_JTadd : JTI<(outs),
1379 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
1380 IIC_Br, "add\tpc, $target, $idx$jt",
1381 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1383 let Inst{15-12} = 0b1111;
1384 let Inst{20} = 0; // S bit
1385 let Inst{24-21} = 0b0100;
1386 let Inst{27-25} = 0b000;
1388 } // isNotDuplicable = 1, isIndirectBranch = 1
1391 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1392 // a two-value operand where a dag node expects two operands. :(
1393 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
1394 IIC_Br, "b", "\t$target",
1395 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
1398 // Branch and Exchange Jazelle -- for disassembly only
1399 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1400 [/* For disassembly only; pattern left blank */]> {
1401 let Inst{23-20} = 0b0010;
1402 //let Inst{19-8} = 0xfff;
1403 let Inst{7-4} = 0b0010;
1406 // Secure Monitor Call is a system instruction -- for disassembly only
1407 def SMC : ABI<0b0001, (outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
1408 [/* For disassembly only; pattern left blank */]> {
1410 let Inst{23-4} = 0b01100000000000000111;
1411 let Inst{3-0} = opt;
1414 // Supervisor Call (Software Interrupt) -- for disassembly only
1416 def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
1417 [/* For disassembly only; pattern left blank */]> {
1419 let Inst{23-0} = svc;
1423 // Store Return State is a system instruction -- for disassembly only
1424 def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
1425 NoItinerary, "srs${addr:submode}\tsp!, $mode",
1426 [/* For disassembly only; pattern left blank */]> {
1427 let Inst{31-28} = 0b1111;
1428 let Inst{22-20} = 0b110; // W = 1
1431 def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
1432 NoItinerary, "srs${addr:submode}\tsp, $mode",
1433 [/* For disassembly only; pattern left blank */]> {
1434 let Inst{31-28} = 0b1111;
1435 let Inst{22-20} = 0b100; // W = 0
1438 // Return From Exception is a system instruction -- for disassembly only
1439 def RFEW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base),
1440 NoItinerary, "rfe${addr:submode}\t$base!",
1441 [/* For disassembly only; pattern left blank */]> {
1442 let Inst{31-28} = 0b1111;
1443 let Inst{22-20} = 0b011; // W = 1
1446 def RFE : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base),
1447 NoItinerary, "rfe${addr:submode}\t$base",
1448 [/* For disassembly only; pattern left blank */]> {
1449 let Inst{31-28} = 0b1111;
1450 let Inst{22-20} = 0b001; // W = 0
1453 //===----------------------------------------------------------------------===//
1454 // Load / store Instructions.
1460 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
1461 UnOpFrag<(load node:$Src)>>;
1462 defm LDRB : AI_ldr1<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
1463 UnOpFrag<(zextloadi8 node:$Src)>>;
1464 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
1465 BinOpFrag<(store node:$LHS, node:$RHS)>>;
1466 defm STRB : AI_str1<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
1467 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1469 // Special LDR for loads from non-pc-relative constpools.
1470 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
1471 isReMaterializable = 1 in
1472 def LDRcp : AIldst1<0b010, 0, 1, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1473 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr", []> {
1476 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1477 let Inst{19-16} = 0b1111;
1478 let Inst{15-12} = Rt;
1479 let Inst{11-0} = addr{11-0}; // imm12
1482 // Loads with zero extension
1483 def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1484 IIC_iLoad_bh_r, "ldrh", "\t$dst, $addr",
1485 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
1487 // Loads with sign extension
1488 def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1489 IIC_iLoad_bh_r, "ldrsh", "\t$dst, $addr",
1490 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
1492 def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1493 IIC_iLoad_bh_r, "ldrsb", "\t$dst, $addr",
1494 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
1496 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1498 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
1499 IIC_iLoad_d_r, "ldrd", "\t$dst1, $addr",
1500 []>, Requires<[IsARM, HasV5TE]>;
1503 def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
1504 (ins addrmode2:$addr), LdFrm, IIC_iLoad_ru,
1505 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1507 def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1508 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoad_ru,
1509 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1511 def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
1512 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1513 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1515 def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
1516 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1517 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1519 def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
1520 (ins addrmode2:$addr), LdFrm, IIC_iLoad_bh_ru,
1521 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1523 def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1524 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoad_bh_ru,
1525 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1527 def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
1528 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1529 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1531 def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
1532 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1533 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1535 def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
1536 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1537 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1539 def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
1540 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_ru,
1541 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1543 // For disassembly only
1544 def LDRD_PRE : AI3lddpr<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb),
1545 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_d_ru,
1546 "ldrd", "\t$dst1, $dst2, $addr!", "$addr.base = $base_wb", []>,
1547 Requires<[IsARM, HasV5TE]>;
1549 // For disassembly only
1550 def LDRD_POST : AI3lddpo<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb),
1551 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_d_ru,
1552 "ldrd", "\t$dst1, $dst2, [$base], $offset", "$base = $base_wb", []>,
1553 Requires<[IsARM, HasV5TE]>;
1555 } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
1557 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only.
1559 def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1560 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoad_ru,
1561 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1562 let Inst{21} = 1; // overwrite
1565 def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1566 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoad_bh_ru,
1567 "ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1568 let Inst{21} = 1; // overwrite
1571 def LDRSBT : AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
1572 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1573 "ldrsbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1574 let Inst{21} = 1; // overwrite
1577 def LDRHT : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
1578 (ins GPR:$base, am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1579 "ldrht", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1580 let Inst{21} = 1; // overwrite
1583 def LDRSHT : AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
1584 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1585 "ldrsht", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1586 let Inst{21} = 1; // overwrite
1591 // Stores with truncate
1592 def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
1593 IIC_iStore_bh_r, "strh", "\t$src, $addr",
1594 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
1597 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
1598 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
1599 StMiscFrm, IIC_iStore_d_r,
1600 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
1603 def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
1604 (ins GPR:$src, GPR:$base, am2offset:$offset),
1605 StFrm, IIC_iStore_ru,
1606 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
1608 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1610 def STR_POST : AI2stwpo<(outs GPR:$base_wb),
1611 (ins GPR:$src, GPR:$base,am2offset:$offset),
1612 StFrm, IIC_iStore_ru,
1613 "str", "\t$src, [$base], $offset", "$base = $base_wb",
1615 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1617 def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
1618 (ins GPR:$src, GPR:$base,am3offset:$offset),
1619 StMiscFrm, IIC_iStore_ru,
1620 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
1622 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1624 def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
1625 (ins GPR:$src, GPR:$base,am3offset:$offset),
1626 StMiscFrm, IIC_iStore_bh_ru,
1627 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
1628 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1629 GPR:$base, am3offset:$offset))]>;
1631 def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
1632 (ins GPR:$src, GPR:$base,am2offset:$offset),
1633 StFrm, IIC_iStore_bh_ru,
1634 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
1635 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
1636 GPR:$base, am2offset:$offset))]>;
1638 def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
1639 (ins GPR:$src, GPR:$base,am2offset:$offset),
1640 StFrm, IIC_iStore_bh_ru,
1641 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
1642 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
1643 GPR:$base, am2offset:$offset))]>;
1645 // For disassembly only
1646 def STRD_PRE : AI3stdpr<(outs GPR:$base_wb),
1647 (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset),
1648 StMiscFrm, IIC_iStore_d_ru,
1649 "strd", "\t$src1, $src2, [$base, $offset]!",
1650 "$base = $base_wb", []>;
1652 // For disassembly only
1653 def STRD_POST: AI3stdpo<(outs GPR:$base_wb),
1654 (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset),
1655 StMiscFrm, IIC_iStore_d_ru,
1656 "strd", "\t$src1, $src2, [$base], $offset",
1657 "$base = $base_wb", []>;
1659 // STRT, STRBT, and STRHT are for disassembly only.
1661 def STRT : AI2stwpo<(outs GPR:$base_wb),
1662 (ins GPR:$src, GPR:$base,am2offset:$offset),
1663 StFrm, IIC_iStore_ru,
1664 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1665 [/* For disassembly only; pattern left blank */]> {
1666 let Inst{21} = 1; // overwrite
1669 def STRBT : AI2stbpo<(outs GPR:$base_wb),
1670 (ins GPR:$src, GPR:$base,am2offset:$offset),
1671 StFrm, IIC_iStore_bh_ru,
1672 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1673 [/* For disassembly only; pattern left blank */]> {
1674 let Inst{21} = 1; // overwrite
1677 def STRHT: AI3sthpo<(outs GPR:$base_wb),
1678 (ins GPR:$src, GPR:$base,am3offset:$offset),
1679 StMiscFrm, IIC_iStore_bh_ru,
1680 "strht", "\t$src, [$base], $offset", "$base = $base_wb",
1681 [/* For disassembly only; pattern left blank */]> {
1682 let Inst{21} = 1; // overwrite
1685 //===----------------------------------------------------------------------===//
1686 // Load / store multiple Instructions.
1689 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1690 def LDM : AXI4ld<(outs), (ins addrmode4:$addr, pred:$p,
1691 reglist:$dsts, variable_ops),
1692 IndexModeNone, LdStMulFrm, IIC_iLoad_m,
1693 "ldm${addr:submode}${p}\t$addr, $dsts", "", []>;
1695 def LDM_UPD : AXI4ld<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1696 reglist:$dsts, variable_ops),
1697 IndexModeUpd, LdStMulFrm, IIC_iLoad_mu,
1698 "ldm${addr:submode}${p}\t$addr!, $dsts",
1699 "$addr.addr = $wb", []>;
1700 } // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
1702 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
1703 def STM : AXI4st<(outs), (ins addrmode4:$addr, pred:$p,
1704 reglist:$srcs, variable_ops),
1705 IndexModeNone, LdStMulFrm, IIC_iStore_m,
1706 "stm${addr:submode}${p}\t$addr, $srcs", "", []>;
1708 def STM_UPD : AXI4st<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1709 reglist:$srcs, variable_ops),
1710 IndexModeUpd, LdStMulFrm, IIC_iStore_mu,
1711 "stm${addr:submode}${p}\t$addr!, $srcs",
1712 "$addr.addr = $wb", []>;
1713 } // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
1715 //===----------------------------------------------------------------------===//
1716 // Move Instructions.
1719 let neverHasSideEffects = 1 in
1720 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
1721 "mov", "\t$Rd, $Rm", []>, UnaryDP {
1725 let Inst{11-4} = 0b00000000;
1728 let Inst{15-12} = Rd;
1731 // A version for the smaller set of tail call registers.
1732 let neverHasSideEffects = 1 in
1733 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
1734 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
1738 let Inst{11-4} = 0b00000000;
1741 let Inst{15-12} = Rd;
1744 def MOVs : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg:$src),
1745 DPSoRegFrm, IIC_iMOVsr,
1746 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg:$src)]>,
1750 let Inst{15-12} = Rd;
1751 let Inst{11-0} = src;
1755 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1756 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
1757 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
1761 let Inst{15-12} = Rd;
1762 let Inst{19-16} = 0b0000;
1763 let Inst{11-0} = imm;
1766 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1767 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins i32imm:$imm),
1769 "movw", "\t$Rd, $imm",
1770 [(set GPR:$Rd, imm0_65535:$imm)]>,
1771 Requires<[IsARM, HasV6T2]>, UnaryDP {
1774 let Inst{15-12} = Rd;
1775 let Inst{11-0} = imm{11-0};
1776 let Inst{19-16} = imm{15-12};
1781 let Constraints = "$src = $Rd" in
1782 def MOVTi16 : AI1<0b1010, (outs GPR:$Rd), (ins GPR:$src, i32imm:$imm),
1784 "movt", "\t$Rd, $imm",
1786 (or (and GPR:$src, 0xffff),
1787 lo16AllZero:$imm))]>, UnaryDP,
1788 Requires<[IsARM, HasV6T2]> {
1791 let Inst{15-12} = Rd;
1792 let Inst{11-0} = imm{11-0};
1793 let Inst{19-16} = imm{15-12};
1798 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1799 Requires<[IsARM, HasV6T2]>;
1801 let Uses = [CPSR] in
1802 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi, "",
1803 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
1806 // These aren't really mov instructions, but we have to define them this way
1807 // due to flag operands.
1809 let Defs = [CPSR] in {
1810 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "",
1811 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
1813 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "",
1814 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
1818 //===----------------------------------------------------------------------===//
1819 // Extend Instructions.
1824 defm SXTB : AI_ext_rrot<0b01101010,
1825 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1826 defm SXTH : AI_ext_rrot<0b01101011,
1827 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
1829 defm SXTAB : AI_exta_rrot<0b01101010,
1830 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1831 defm SXTAH : AI_exta_rrot<0b01101011,
1832 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1834 // For disassembly only
1835 defm SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
1837 // For disassembly only
1838 defm SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
1842 let AddedComplexity = 16 in {
1843 defm UXTB : AI_ext_rrot<0b01101110,
1844 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1845 defm UXTH : AI_ext_rrot<0b01101111,
1846 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1847 defm UXTB16 : AI_ext_rrot<0b01101100,
1848 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1850 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1851 // The transformation should probably be done as a combiner action
1852 // instead so we can include a check for masking back in the upper
1853 // eight bits of the source into the lower eight bits of the result.
1854 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
1855 // (UXTB16r_rot GPR:$Src, 24)>;
1856 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
1857 (UXTB16r_rot GPR:$Src, 8)>;
1859 defm UXTAB : AI_exta_rrot<0b01101110, "uxtab",
1860 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1861 defm UXTAH : AI_exta_rrot<0b01101111, "uxtah",
1862 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1865 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1866 // For disassembly only
1867 defm UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
1870 def SBFX : I<(outs GPR:$Rd),
1871 (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width),
1872 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1873 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
1874 Requires<[IsARM, HasV6T2]> {
1879 let Inst{27-21} = 0b0111101;
1880 let Inst{6-4} = 0b101;
1881 let Inst{20-16} = width;
1882 let Inst{15-12} = Rd;
1883 let Inst{11-7} = lsb;
1887 def UBFX : I<(outs GPR:$Rd),
1888 (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width),
1889 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1890 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
1891 Requires<[IsARM, HasV6T2]> {
1896 let Inst{27-21} = 0b0111111;
1897 let Inst{6-4} = 0b101;
1898 let Inst{20-16} = width;
1899 let Inst{15-12} = Rd;
1900 let Inst{11-7} = lsb;
1904 //===----------------------------------------------------------------------===//
1905 // Arithmetic Instructions.
1908 defm ADD : AsI1_bin_irs<0b0100, "add",
1909 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1910 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1911 defm SUB : AsI1_bin_irs<0b0010, "sub",
1912 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1913 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1915 // ADD and SUB with 's' bit set.
1916 defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1917 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1918 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1919 defm SUBS : AI1_bin_s_irs<0b0010, "subs",
1920 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1921 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
1923 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
1924 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
1925 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
1926 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
1927 defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
1928 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
1929 defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
1930 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
1932 def RSBri : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1933 IIC_iALUi, "rsb", "\t$Rd, $Rn, $imm",
1934 [(set GPR:$Rd, (sub so_imm:$imm, GPR:$Rn))]> {
1939 let Inst{15-12} = Rd;
1940 let Inst{19-16} = Rn;
1941 let Inst{11-0} = imm;
1944 // The reg/reg form is only defined for the disassembler; for codegen it is
1945 // equivalent to SUBrr.
1946 def RSBrr : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1947 IIC_iALUr, "rsb", "\t$Rd, $Rn, $Rm",
1948 [/* For disassembly only; pattern left blank */]> {
1952 let Inst{11-4} = 0b00000000;
1955 let Inst{15-12} = Rd;
1956 let Inst{19-16} = Rn;
1959 def RSBrs : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
1960 DPSoRegFrm, IIC_iALUsr, "rsb", "\t$Rd, $Rn, $shift",
1961 [(set GPR:$Rd, (sub so_reg:$shift, GPR:$Rn))]> {
1966 let Inst{11-0} = shift;
1967 let Inst{15-12} = Rd;
1968 let Inst{19-16} = Rn;
1971 // RSB with 's' bit set.
1972 let Defs = [CPSR] in {
1973 def RSBSri : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1974 IIC_iALUi, "rsbs", "\t$Rd, $Rn, $imm",
1975 [(set GPR:$Rd, (subc so_imm:$imm, GPR:$Rn))]> {
1981 let Inst{15-12} = Rd;
1982 let Inst{19-16} = Rn;
1983 let Inst{11-0} = imm;
1985 def RSBSrs : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
1986 DPSoRegFrm, IIC_iALUsr, "rsbs", "\t$Rd, $Rn, $shift",
1987 [(set GPR:$Rd, (subc so_reg:$shift, GPR:$Rn))]> {
1993 let Inst{11-0} = shift;
1994 let Inst{15-12} = Rd;
1995 let Inst{19-16} = Rn;
1999 let Uses = [CPSR] in {
2000 def RSCri : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
2001 DPFrm, IIC_iALUi, "rsc", "\t$Rd, $Rn, $imm",
2002 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
2008 let Inst{15-12} = Rd;
2009 let Inst{19-16} = Rn;
2010 let Inst{11-0} = imm;
2012 // The reg/reg form is only defined for the disassembler; for codegen it is
2013 // equivalent to SUBrr.
2014 def RSCrr : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2015 DPFrm, IIC_iALUr, "rsc", "\t$Rd, $Rn, $Rm",
2016 [/* For disassembly only; pattern left blank */]> {
2020 let Inst{11-4} = 0b00000000;
2023 let Inst{15-12} = Rd;
2024 let Inst{19-16} = Rn;
2026 def RSCrs : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
2027 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$Rd, $Rn, $shift",
2028 [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>,
2034 let Inst{11-0} = shift;
2035 let Inst{15-12} = Rd;
2036 let Inst{19-16} = Rn;
2040 // FIXME: Allow these to be predicated.
2041 let Defs = [CPSR], Uses = [CPSR] in {
2042 def RSCSri : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
2043 DPFrm, IIC_iALUi, "rscs\t$Rd, $Rn, $imm",
2044 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
2051 let Inst{15-12} = Rd;
2052 let Inst{19-16} = Rn;
2053 let Inst{11-0} = imm;
2055 def RSCSrs : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
2056 DPSoRegFrm, IIC_iALUsr, "rscs\t$Rd, $Rn, $shift",
2057 [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>,
2064 let Inst{11-0} = shift;
2065 let Inst{15-12} = Rd;
2066 let Inst{19-16} = Rn;
2070 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
2071 // The assume-no-carry-in form uses the negation of the input since add/sub
2072 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
2073 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
2075 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
2076 (SUBri GPR:$src, so_imm_neg:$imm)>;
2077 def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
2078 (SUBSri GPR:$src, so_imm_neg:$imm)>;
2079 // The with-carry-in form matches bitwise not instead of the negation.
2080 // Effectively, the inverse interpretation of the carry flag already accounts
2081 // for part of the negation.
2082 def : ARMPat<(adde GPR:$src, so_imm_not:$imm),
2083 (SBCri GPR:$src, so_imm_not:$imm)>;
2085 // Note: These are implemented in C++ code, because they have to generate
2086 // ADD/SUBrs instructions, which use a complex pattern that a xform function
2088 // (mul X, 2^n+1) -> (add (X << n), X)
2089 // (mul X, 2^n-1) -> (rsb X, (X << n))
2091 // ARM Arithmetic Instruction -- for disassembly only
2092 // GPR:$dst = GPR:$a op GPR:$b
2093 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
2094 list<dag> pattern = [/* For disassembly only; pattern left blank */]>
2095 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iALUr,
2096 opc, "\t$Rd, $Rn, $Rm", pattern> {
2100 let Inst{27-20} = op27_20;
2101 let Inst{11-4} = op11_4;
2102 let Inst{19-16} = Rn;
2103 let Inst{15-12} = Rd;
2107 // Saturating add/subtract -- for disassembly only
2109 def QADD : AAI<0b00010000, 0b00000101, "qadd",
2110 [(set GPR:$Rd, (int_arm_qadd GPR:$Rn, GPR:$Rm))]>;
2111 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
2112 [(set GPR:$Rd, (int_arm_qsub GPR:$Rn, GPR:$Rm))]>;
2113 def QDADD : AAI<0b00010100, 0b00000101, "qdadd">;
2114 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub">;
2116 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
2117 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
2118 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
2119 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
2120 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
2121 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
2122 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
2123 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
2124 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
2125 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
2126 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
2127 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
2129 // Signed/Unsigned add/subtract -- for disassembly only
2131 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
2132 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
2133 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
2134 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
2135 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
2136 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
2137 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
2138 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
2139 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
2140 def USAX : AAI<0b01100101, 0b11110101, "usax">;
2141 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
2142 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
2144 // Signed/Unsigned halving add/subtract -- for disassembly only
2146 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
2147 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
2148 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
2149 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
2150 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
2151 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
2152 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
2153 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
2154 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
2155 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
2156 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
2157 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
2159 // Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
2161 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2162 MulFrm /* for convenience */, NoItinerary, "usad8",
2163 "\t$Rd, $Rn, $Rm", []>,
2164 Requires<[IsARM, HasV6]> {
2168 let Inst{27-20} = 0b01111000;
2169 let Inst{15-12} = 0b1111;
2170 let Inst{7-4} = 0b0001;
2171 let Inst{19-16} = Rd;
2172 let Inst{11-8} = Rm;
2175 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2176 MulFrm /* for convenience */, NoItinerary, "usada8",
2177 "\t$Rd, $Rn, $Rm, $Ra", []>,
2178 Requires<[IsARM, HasV6]> {
2183 let Inst{27-20} = 0b01111000;
2184 let Inst{7-4} = 0b0001;
2185 let Inst{19-16} = Rd;
2186 let Inst{15-12} = Ra;
2187 let Inst{11-8} = Rm;
2191 // Signed/Unsigned saturate -- for disassembly only
2193 def SSAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
2194 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $a$sh",
2195 [/* For disassembly only; pattern left blank */]> {
2200 let Inst{27-21} = 0b0110101;
2201 let Inst{5-4} = 0b01;
2202 let Inst{20-16} = sat_imm;
2203 let Inst{15-12} = Rd;
2204 let Inst{11-7} = sh{7-3};
2205 let Inst{6} = sh{0};
2209 def SSAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$Rn), SatFrm,
2210 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn",
2211 [/* For disassembly only; pattern left blank */]> {
2215 let Inst{27-20} = 0b01101010;
2216 let Inst{11-4} = 0b11110011;
2217 let Inst{15-12} = Rd;
2218 let Inst{19-16} = sat_imm;
2222 def USAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
2223 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $a$sh",
2224 [/* For disassembly only; pattern left blank */]> {
2229 let Inst{27-21} = 0b0110111;
2230 let Inst{5-4} = 0b01;
2231 let Inst{15-12} = Rd;
2232 let Inst{11-7} = sh{7-3};
2233 let Inst{6} = sh{0};
2234 let Inst{20-16} = sat_imm;
2238 def USAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a), SatFrm,
2239 NoItinerary, "usat16", "\t$Rd, $sat_imm, $a",
2240 [/* For disassembly only; pattern left blank */]> {
2244 let Inst{27-20} = 0b01101110;
2245 let Inst{11-4} = 0b11110011;
2246 let Inst{15-12} = Rd;
2247 let Inst{19-16} = sat_imm;
2251 def : ARMV6Pat<(int_arm_ssat GPR:$a, imm:$pos), (SSAT imm:$pos, GPR:$a, 0)>;
2252 def : ARMV6Pat<(int_arm_usat GPR:$a, imm:$pos), (USAT imm:$pos, GPR:$a, 0)>;
2254 //===----------------------------------------------------------------------===//
2255 // Bitwise Instructions.
2258 defm AND : AsI1_bin_irs<0b0000, "and",
2259 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2260 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
2261 defm ORR : AsI1_bin_irs<0b1100, "orr",
2262 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2263 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
2264 defm EOR : AsI1_bin_irs<0b0001, "eor",
2265 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2266 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
2267 defm BIC : AsI1_bin_irs<0b1110, "bic",
2268 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2269 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
2271 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
2272 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2273 "bfc", "\t$Rd, $imm", "$src = $Rd",
2274 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
2275 Requires<[IsARM, HasV6T2]> {
2278 let Inst{27-21} = 0b0111110;
2279 let Inst{6-0} = 0b0011111;
2280 let Inst{15-12} = Rd;
2281 let Inst{11-7} = imm{4-0}; // lsb
2282 let Inst{20-16} = imm{9-5}; // width
2285 // A8.6.18 BFI - Bitfield insert (Encoding A1)
2286 def BFI : I<(outs GPR:$Rd), (ins GPR:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
2287 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2288 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
2289 [(set GPR:$Rd, (ARMbfi GPR:$src, GPR:$Rn,
2290 bf_inv_mask_imm:$imm))]>,
2291 Requires<[IsARM, HasV6T2]> {
2295 let Inst{27-21} = 0b0111110;
2296 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
2297 let Inst{15-12} = Rd;
2298 let Inst{11-7} = imm{4-0}; // lsb
2299 let Inst{20-16} = imm{9-5}; // width
2303 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
2304 "mvn", "\t$Rd, $Rm",
2305 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
2309 let Inst{19-16} = 0b0000;
2310 let Inst{11-4} = 0b00000000;
2311 let Inst{15-12} = Rd;
2314 def MVNs : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg:$shift), DPSoRegFrm,
2315 IIC_iMVNsr, "mvn", "\t$Rd, $shift",
2316 [(set GPR:$Rd, (not so_reg:$shift))]>, UnaryDP {
2321 let Inst{19-16} = 0b0000;
2322 let Inst{15-12} = Rd;
2323 let Inst{11-0} = shift;
2325 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
2326 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
2327 IIC_iMVNi, "mvn", "\t$Rd, $imm",
2328 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
2333 let Inst{19-16} = 0b0000;
2334 let Inst{15-12} = Rd;
2335 let Inst{11-0} = imm;
2338 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
2339 (BICri GPR:$src, so_imm_not:$imm)>;
2341 //===----------------------------------------------------------------------===//
2342 // Multiply Instructions.
2344 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
2345 string opc, string asm, list<dag> pattern>
2346 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
2350 let Inst{19-16} = Rd;
2351 let Inst{11-8} = Rm;
2354 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
2355 string opc, string asm, list<dag> pattern>
2356 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
2361 let Inst{19-16} = RdHi;
2362 let Inst{15-12} = RdLo;
2363 let Inst{11-8} = Rm;
2367 let isCommutable = 1 in
2368 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2369 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
2370 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>;
2372 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2373 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
2374 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]> {
2376 let Inst{15-12} = Ra;
2379 def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
2380 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
2381 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
2382 Requires<[IsARM, HasV6T2]> {
2386 let Inst{19-16} = Rd;
2387 let Inst{11-8} = Rm;
2391 // Extra precision multiplies with low / high results
2393 let neverHasSideEffects = 1 in {
2394 let isCommutable = 1 in {
2395 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
2396 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
2397 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2399 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
2400 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
2401 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2404 // Multiply + accumulate
2405 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
2406 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2407 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2409 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
2410 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2411 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2413 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
2414 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2415 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2416 Requires<[IsARM, HasV6]> {
2421 let Inst{19-16} = RdLo;
2422 let Inst{15-12} = RdHi;
2423 let Inst{11-8} = Rm;
2426 } // neverHasSideEffects
2428 // Most significant word multiply
2429 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2430 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
2431 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
2432 Requires<[IsARM, HasV6]> {
2433 let Inst{15-12} = 0b1111;
2436 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2437 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
2438 [/* For disassembly only; pattern left blank */]>,
2439 Requires<[IsARM, HasV6]> {
2440 let Inst{15-12} = 0b1111;
2443 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
2444 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2445 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
2446 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
2447 Requires<[IsARM, HasV6]>;
2449 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
2450 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2451 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
2452 [/* For disassembly only; pattern left blank */]>,
2453 Requires<[IsARM, HasV6]>;
2455 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
2456 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2457 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
2458 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
2459 Requires<[IsARM, HasV6]>;
2461 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
2462 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2463 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
2464 [/* For disassembly only; pattern left blank */]>,
2465 Requires<[IsARM, HasV6]>;
2467 multiclass AI_smul<string opc, PatFrag opnode> {
2468 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2469 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
2470 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
2471 (sext_inreg GPR:$Rm, i16)))]>,
2472 Requires<[IsARM, HasV5TE]>;
2474 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2475 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
2476 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
2477 (sra GPR:$Rm, (i32 16))))]>,
2478 Requires<[IsARM, HasV5TE]>;
2480 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2481 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
2482 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
2483 (sext_inreg GPR:$Rm, i16)))]>,
2484 Requires<[IsARM, HasV5TE]>;
2486 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2487 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
2488 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
2489 (sra GPR:$Rm, (i32 16))))]>,
2490 Requires<[IsARM, HasV5TE]>;
2492 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2493 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
2494 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
2495 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
2496 Requires<[IsARM, HasV5TE]>;
2498 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2499 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
2500 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
2501 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
2502 Requires<[IsARM, HasV5TE]>;
2506 multiclass AI_smla<string opc, PatFrag opnode> {
2507 def BB : AMulxyI<0b0001000, 0b00, (outs GPR:$Rd),
2508 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2509 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
2510 [(set GPR:$Rd, (add GPR:$Ra,
2511 (opnode (sext_inreg GPR:$Rn, i16),
2512 (sext_inreg GPR:$Rm, i16))))]>,
2513 Requires<[IsARM, HasV5TE]>;
2515 def BT : AMulxyI<0b0001000, 0b10, (outs GPR:$Rd),
2516 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2517 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
2518 [(set GPR:$Rd, (add GPR:$Ra, (opnode (sext_inreg GPR:$Rn, i16),
2519 (sra GPR:$Rm, (i32 16)))))]>,
2520 Requires<[IsARM, HasV5TE]>;
2522 def TB : AMulxyI<0b0001000, 0b01, (outs GPR:$Rd),
2523 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2524 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
2525 [(set GPR:$Rd, (add GPR:$Ra, (opnode (sra GPR:$Rn, (i32 16)),
2526 (sext_inreg GPR:$Rm, i16))))]>,
2527 Requires<[IsARM, HasV5TE]>;
2529 def TT : AMulxyI<0b0001000, 0b11, (outs GPR:$Rd),
2530 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2531 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
2532 [(set GPR:$Rd, (add GPR:$Ra, (opnode (sra GPR:$Rn, (i32 16)),
2533 (sra GPR:$Rm, (i32 16)))))]>,
2534 Requires<[IsARM, HasV5TE]>;
2536 def WB : AMulxyI<0b0001001, 0b00, (outs GPR:$Rd),
2537 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2538 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
2539 [(set GPR:$Rd, (add GPR:$Ra, (sra (opnode GPR:$Rn,
2540 (sext_inreg GPR:$Rm, i16)), (i32 16))))]>,
2541 Requires<[IsARM, HasV5TE]>;
2543 def WT : AMulxyI<0b0001001, 0b10, (outs GPR:$Rd),
2544 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2545 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
2546 [(set GPR:$Rd, (add GPR:$Ra, (sra (opnode GPR:$Rn,
2547 (sra GPR:$Rm, (i32 16))), (i32 16))))]>,
2548 Requires<[IsARM, HasV5TE]>;
2551 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2552 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2554 // Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only
2555 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPR:$RdLo, GPR:$RdHi),
2556 (ins GPR:$Rn, GPR:$Rm),
2557 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm",
2558 [/* For disassembly only; pattern left blank */]>,
2559 Requires<[IsARM, HasV5TE]>;
2561 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPR:$RdLo, GPR:$RdHi),
2562 (ins GPR:$Rn, GPR:$Rm),
2563 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm",
2564 [/* For disassembly only; pattern left blank */]>,
2565 Requires<[IsARM, HasV5TE]>;
2567 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPR:$RdLo, GPR:$RdHi),
2568 (ins GPR:$Rn, GPR:$Rm),
2569 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm",
2570 [/* For disassembly only; pattern left blank */]>,
2571 Requires<[IsARM, HasV5TE]>;
2573 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPR:$RdLo, GPR:$RdHi),
2574 (ins GPR:$Rn, GPR:$Rm),
2575 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm",
2576 [/* For disassembly only; pattern left blank */]>,
2577 Requires<[IsARM, HasV5TE]>;
2579 // Helper class for AI_smld -- for disassembly only
2580 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
2581 InstrItinClass itin, string opc, string asm>
2582 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
2589 let Inst{21-20} = 0b00;
2590 let Inst{22} = long;
2591 let Inst{27-23} = 0b01110;
2592 let Inst{11-8} = Rm;
2595 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
2596 InstrItinClass itin, string opc, string asm>
2597 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
2599 let Inst{15-12} = 0b1111;
2600 let Inst{19-16} = Rd;
2602 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
2603 InstrItinClass itin, string opc, string asm>
2604 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
2606 let Inst{15-12} = Ra;
2608 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
2609 InstrItinClass itin, string opc, string asm>
2610 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
2613 let Inst{19-16} = RdHi;
2614 let Inst{15-12} = RdLo;
2617 multiclass AI_smld<bit sub, string opc> {
2619 def D : AMulDualIa<0, sub, 0, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2620 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
2622 def DX: AMulDualIa<0, sub, 1, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2623 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
2625 def LD: AMulDualI64<1, sub, 0, (outs GPR:$RdLo,GPR:$RdHi),
2626 (ins GPR:$Rn, GPR:$Rm), NoItinerary,
2627 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
2629 def LDX : AMulDualI64<1, sub, 1, (outs GPR:$RdLo,GPR:$RdHi),
2630 (ins GPR:$Rn, GPR:$Rm), NoItinerary,
2631 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
2635 defm SMLA : AI_smld<0, "smla">;
2636 defm SMLS : AI_smld<1, "smls">;
2638 multiclass AI_sdml<bit sub, string opc> {
2640 def D : AMulDualI<0, sub, 0, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2641 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
2642 def DX : AMulDualI<0, sub, 1, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2643 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
2646 defm SMUA : AI_sdml<0, "smua">;
2647 defm SMUS : AI_sdml<1, "smus">;
2649 //===----------------------------------------------------------------------===//
2650 // Misc. Arithmetic Instructions.
2653 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
2654 IIC_iUNAr, "clz", "\t$Rd, $Rm",
2655 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
2657 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
2658 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
2659 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
2660 Requires<[IsARM, HasV6T2]>;
2662 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
2663 IIC_iUNAr, "rev", "\t$Rd, $Rm",
2664 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
2666 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
2667 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
2669 (or (and (srl GPR:$Rm, (i32 8)), 0xFF),
2670 (or (and (shl GPR:$Rm, (i32 8)), 0xFF00),
2671 (or (and (srl GPR:$Rm, (i32 8)), 0xFF0000),
2672 (and (shl GPR:$Rm, (i32 8)), 0xFF000000)))))]>,
2673 Requires<[IsARM, HasV6]>;
2675 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
2676 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
2679 (or (srl (and GPR:$Rm, 0xFF00), (i32 8)),
2680 (shl GPR:$Rm, (i32 8))), i16))]>,
2681 Requires<[IsARM, HasV6]>;
2683 def lsl_shift_imm : SDNodeXForm<imm, [{
2684 unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::lsl, N->getZExtValue());
2685 return CurDAG->getTargetConstant(Sh, MVT::i32);
2688 def lsl_amt : PatLeaf<(i32 imm), [{
2689 return (N->getZExtValue() < 32);
2692 def PKHBT : APKHI<0b01101000, 0, (outs GPR:$Rd),
2693 (ins GPR:$Rn, GPR:$Rm, shift_imm:$sh),
2694 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
2695 [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF),
2696 (and (shl GPR:$Rm, lsl_amt:$sh),
2698 Requires<[IsARM, HasV6]>;
2700 // Alternate cases for PKHBT where identities eliminate some nodes.
2701 def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (and GPR:$Rm, 0xFFFF0000)),
2702 (PKHBT GPR:$Rn, GPR:$Rm, 0)>;
2703 def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (shl GPR:$Rm, imm16_31:$sh)),
2704 (PKHBT GPR:$Rn, GPR:$Rm, (lsl_shift_imm imm16_31:$sh))>;
2706 def asr_shift_imm : SDNodeXForm<imm, [{
2707 unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::asr, N->getZExtValue());
2708 return CurDAG->getTargetConstant(Sh, MVT::i32);
2711 def asr_amt : PatLeaf<(i32 imm), [{
2712 return (N->getZExtValue() <= 32);
2715 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2716 // will match the pattern below.
2717 def PKHTB : APKHI<0b01101000, 1, (outs GPR:$Rd),
2718 (ins GPR:$Rn, GPR:$Rm, shift_imm:$sh),
2719 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
2720 [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF0000),
2721 (and (sra GPR:$Rm, asr_amt:$sh),
2723 Requires<[IsARM, HasV6]>;
2725 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
2726 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
2727 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, imm16_31:$sh)),
2728 (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm16_31:$sh))>;
2729 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
2730 (and (srl GPR:$src2, imm1_15:$sh), 0xFFFF)),
2731 (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm1_15:$sh))>;
2733 //===----------------------------------------------------------------------===//
2734 // Comparison Instructions...
2737 defm CMP : AI1_cmp_irs<0b1010, "cmp",
2738 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2739 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2741 // FIXME: We have to be careful when using the CMN instruction and comparison
2742 // with 0. One would expect these two pieces of code should give identical
2758 // However, the CMN gives the *opposite* result when r1 is 0. This is because
2759 // the carry flag is set in the CMP case but not in the CMN case. In short, the
2760 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
2761 // value of r0 and the carry bit (because the "carry bit" parameter to
2762 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
2763 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
2764 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
2765 // parameter to AddWithCarry is defined as 0).
2767 // When x is 0 and unsigned:
2771 // ~x + 1 = 0x1 0000 0000
2772 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
2774 // Therefore, we should disable CMN when comparing against zero, until we can
2775 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
2776 // when it's a comparison which doesn't look at the 'carry' flag).
2778 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
2780 // This is related to <rdar://problem/7569620>.
2782 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
2783 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
2785 // Note that TST/TEQ don't set all the same flags that CMP does!
2786 defm TST : AI1_cmp_irs<0b1000, "tst",
2787 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
2788 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
2789 defm TEQ : AI1_cmp_irs<0b1001, "teq",
2790 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
2791 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
2793 defm CMPz : AI1_cmp_irs<0b1010, "cmp",
2794 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2795 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
2796 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
2797 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2798 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2800 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
2801 // (CMNri GPR:$src, so_imm_neg:$imm)>;
2803 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
2804 (CMNzri GPR:$src, so_imm_neg:$imm)>;
2806 // Pseudo i64 compares for some floating point compares.
2807 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
2809 def BCCi64 : PseudoInst<(outs),
2810 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
2812 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
2814 def BCCZi64 : PseudoInst<(outs),
2815 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br, "",
2816 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
2817 } // usesCustomInserter
2820 // Conditional moves
2821 // FIXME: should be able to write a pattern for ARMcmov, but can't use
2822 // a two-value operand where a dag node expects two operands. :(
2823 // FIXME: These should all be pseudo-instructions that get expanded to
2824 // the normal MOV instructions. That would fix the dependency on
2825 // special casing them in tblgen.
2826 let neverHasSideEffects = 1 in {
2827 def MOVCCr : AI1<0b1101, (outs GPR:$Rd), (ins GPR:$false, GPR:$Rm), DPFrm,
2828 IIC_iCMOVr, "mov", "\t$Rd, $Rm",
2829 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
2830 RegConstraint<"$false = $Rd">, UnaryDP {
2835 let Inst{15-12} = Rd;
2836 let Inst{11-4} = 0b00000000;
2840 def MOVCCs : AI1<0b1101, (outs GPR:$Rd),
2841 (ins GPR:$false, so_reg:$shift), DPSoRegFrm, IIC_iCMOVsr,
2842 "mov", "\t$Rd, $shift",
2843 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg:$shift, imm:$cc, CCR:$ccr))*/]>,
2844 RegConstraint<"$false = $Rd">, UnaryDP {
2850 let Inst{19-16} = Rn;
2851 let Inst{15-12} = Rd;
2852 let Inst{11-0} = shift;
2855 def MOVCCi16 : AI1<0b1000, (outs GPR:$Rd), (ins GPR:$false, i32imm:$imm),
2857 "movw", "\t$Rd, $imm",
2859 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
2865 let Inst{19-16} = imm{15-12};
2866 let Inst{15-12} = Rd;
2867 let Inst{11-0} = imm{11-0};
2870 def MOVCCi : AI1<0b1101, (outs GPR:$Rd),
2871 (ins GPR:$false, so_imm:$imm), DPFrm, IIC_iCMOVi,
2872 "mov", "\t$Rd, $imm",
2873 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
2874 RegConstraint<"$false = $Rd">, UnaryDP {
2879 let Inst{19-16} = 0b0000;
2880 let Inst{15-12} = Rd;
2881 let Inst{11-0} = imm;
2883 } // neverHasSideEffects
2885 //===----------------------------------------------------------------------===//
2886 // Atomic operations intrinsics
2889 // memory barriers protect the atomic sequences
2890 let hasSideEffects = 1 in {
2891 def DMBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "dmb", "",
2892 [(ARMMemBarrier)]>, Requires<[IsARM, HasDB]> {
2893 let Inst{31-4} = 0xf57ff05;
2894 // FIXME: add support for options other than a full system DMB
2895 // See DMB disassembly-only variants below.
2896 let Inst{3-0} = 0b1111;
2899 def DSBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "dsb", "",
2900 [(ARMSyncBarrier)]>, Requires<[IsARM, HasDB]> {
2901 let Inst{31-4} = 0xf57ff04;
2902 // FIXME: add support for options other than a full system DSB
2903 // See DSB disassembly-only variants below.
2904 let Inst{3-0} = 0b1111;
2907 def DMB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary,
2908 "mcr", "\tp15, 0, $zero, c7, c10, 5",
2909 [(ARMMemBarrierMCR GPR:$zero)]>,
2910 Requires<[IsARM, HasV6]> {
2911 // FIXME: add support for options other than a full system DMB
2912 // FIXME: add encoding
2915 def DSB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary,
2916 "mcr", "\tp15, 0, $zero, c7, c10, 4",
2917 [(ARMSyncBarrierMCR GPR:$zero)]>,
2918 Requires<[IsARM, HasV6]> {
2919 // FIXME: add support for options other than a full system DSB
2920 // FIXME: add encoding
2924 // Memory Barrier Operations Variants -- for disassembly only
2926 def memb_opt : Operand<i32> {
2927 let PrintMethod = "printMemBOption";
2930 class AMBI<bits<4> op7_4, string opc>
2931 : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, opc, "\t$opt",
2932 [/* For disassembly only; pattern left blank */]>,
2933 Requires<[IsARM, HasDB]> {
2934 let Inst{31-8} = 0xf57ff0;
2935 let Inst{7-4} = op7_4;
2938 // These DMB variants are for disassembly only.
2939 def DMBvar : AMBI<0b0101, "dmb">;
2941 // These DSB variants are for disassembly only.
2942 def DSBvar : AMBI<0b0100, "dsb">;
2944 // ISB has only full system option -- for disassembly only
2945 def ISBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "isb", "", []>,
2946 Requires<[IsARM, HasDB]> {
2947 let Inst{31-4} = 0xf57ff06;
2948 let Inst{3-0} = 0b1111;
2951 let usesCustomInserter = 1 in {
2952 let Uses = [CPSR] in {
2953 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
2954 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2955 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
2956 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
2957 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2958 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
2959 def ATOMIC_LOAD_AND_I8 : PseudoInst<
2960 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2961 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
2962 def ATOMIC_LOAD_OR_I8 : PseudoInst<
2963 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2964 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
2965 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
2966 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2967 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
2968 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
2969 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2970 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
2971 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
2972 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2973 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
2974 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
2975 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2976 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
2977 def ATOMIC_LOAD_AND_I16 : PseudoInst<
2978 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2979 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
2980 def ATOMIC_LOAD_OR_I16 : PseudoInst<
2981 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2982 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
2983 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
2984 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2985 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
2986 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
2987 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2988 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
2989 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
2990 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2991 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
2992 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
2993 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2994 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
2995 def ATOMIC_LOAD_AND_I32 : PseudoInst<
2996 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2997 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
2998 def ATOMIC_LOAD_OR_I32 : PseudoInst<
2999 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3000 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
3001 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
3002 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3003 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
3004 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
3005 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3006 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
3008 def ATOMIC_SWAP_I8 : PseudoInst<
3009 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
3010 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
3011 def ATOMIC_SWAP_I16 : PseudoInst<
3012 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
3013 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
3014 def ATOMIC_SWAP_I32 : PseudoInst<
3015 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
3016 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
3018 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
3019 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
3020 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
3021 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
3022 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
3023 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
3024 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
3025 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
3026 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
3030 let mayLoad = 1 in {
3031 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary,
3032 "ldrexb", "\t$Rt, [$Rn]",
3034 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary,
3035 "ldrexh", "\t$Rt, [$Rn]",
3037 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary,
3038 "ldrex", "\t$Rt, [$Rn]",
3040 def LDREXD : AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2), (ins GPR:$Rn),
3042 "ldrexd", "\t$Rt, $Rt2, [$Rn]",
3046 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
3047 def STREXB : AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$src, GPR:$Rn),
3049 "strexb", "\t$Rd, $src, [$Rn]",
3051 def STREXH : AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn),
3053 "strexh", "\t$Rd, $Rt, [$Rn]",
3055 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn),
3057 "strex", "\t$Rd, $Rt, [$Rn]",
3059 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
3060 (ins GPR:$Rt, GPR:$Rt2, GPR:$Rn),
3062 "strexd", "\t$Rd, $Rt, $Rt2, [$Rn]",
3066 // Clear-Exclusive is for disassembly only.
3067 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
3068 [/* For disassembly only; pattern left blank */]>,
3069 Requires<[IsARM, HasV7]> {
3070 let Inst{31-20} = 0xf57;
3071 let Inst{7-4} = 0b0001;
3074 // SWP/SWPB are deprecated in V6/V7 and for disassembly only.
3075 let mayLoad = 1 in {
3076 def SWP : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
3077 "swp", "\t$dst, $src, [$ptr]",
3078 [/* For disassembly only; pattern left blank */]> {
3079 let Inst{27-23} = 0b00010;
3080 let Inst{22} = 0; // B = 0
3081 let Inst{21-20} = 0b00;
3082 let Inst{7-4} = 0b1001;
3085 def SWPB : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
3086 "swpb", "\t$dst, $src, [$ptr]",
3087 [/* For disassembly only; pattern left blank */]> {
3088 let Inst{27-23} = 0b00010;
3089 let Inst{22} = 1; // B = 1
3090 let Inst{21-20} = 0b00;
3091 let Inst{7-4} = 0b1001;
3095 //===----------------------------------------------------------------------===//
3099 // __aeabi_read_tp preserves the registers r1-r3.
3101 Defs = [R0, R12, LR, CPSR] in {
3102 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
3103 "bl\t__aeabi_read_tp",
3104 [(set R0, ARMthread_pointer)]>;
3107 //===----------------------------------------------------------------------===//
3108 // SJLJ Exception handling intrinsics
3109 // eh_sjlj_setjmp() is an instruction sequence to store the return
3110 // address and save #0 in R0 for the non-longjmp case.
3111 // Since by its nature we may be coming from some other function to get
3112 // here, and we're using the stack frame for the containing function to
3113 // save/restore registers, we can't keep anything live in regs across
3114 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
3115 // when we get here from a longjmp(). We force everthing out of registers
3116 // except for our own input by listing the relevant registers in Defs. By
3117 // doing so, we also cause the prologue/epilogue code to actively preserve
3118 // all of the callee-saved resgisters, which is exactly what we want.
3119 // A constant value is passed in $val, and we use the location as a scratch.
3121 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
3122 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
3123 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
3124 D31 ], hasSideEffects = 1, isBarrier = 1 in {
3125 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
3126 AddrModeNone, SizeSpecial, IndexModeNone,
3127 Pseudo, NoItinerary, "", "",
3128 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
3129 Requires<[IsARM, HasVFP2]>;
3133 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
3134 hasSideEffects = 1, isBarrier = 1 in {
3135 def Int_eh_sjlj_setjmp_nofp : XI<(outs), (ins GPR:$src, GPR:$val),
3136 AddrModeNone, SizeSpecial, IndexModeNone,
3137 Pseudo, NoItinerary, "", "",
3138 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
3139 Requires<[IsARM, NoVFP]>;
3142 // FIXME: Non-Darwin version(s)
3143 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
3144 Defs = [ R7, LR, SP ] in {
3145 def Int_eh_sjlj_longjmp : XI<(outs), (ins GPR:$src, GPR:$scratch),
3146 AddrModeNone, SizeSpecial, IndexModeNone,
3147 Pseudo, NoItinerary, "", "",
3148 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
3149 Requires<[IsARM, IsDarwin]>;
3152 // eh.sjlj.dispatchsetup pseudo-instruction.
3153 // This pseudo is usef for ARM, Thumb1 and Thumb2. Any differences are
3154 // handled when the pseudo is expanded (which happens before any passes
3155 // that need the instruction size).
3156 let isBarrier = 1, hasSideEffects = 1 in
3157 def Int_eh_sjlj_dispatchsetup :
3158 PseudoInst<(outs), (ins GPR:$src), NoItinerary, "",
3159 [(ARMeh_sjlj_dispatchsetup GPR:$src)]>,
3160 Requires<[IsDarwin]>;
3162 //===----------------------------------------------------------------------===//
3163 // Non-Instruction Patterns
3166 // Large immediate handling.
3168 // Two piece so_imms.
3169 // FIXME: Expand this in ARMExpandPseudoInsts.
3170 // FIXME: Remove this when we can do generalized remat.
3171 let isReMaterializable = 1 in
3172 def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
3173 Pseudo, IIC_iMOVix2,
3174 "mov", "\t$dst, $src",
3175 [(set GPR:$dst, so_imm2part:$src)]>,
3176 Requires<[IsARM, NoV6T2]>;
3178 def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
3179 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3180 (so_imm2part_2 imm:$RHS))>;
3181 def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
3182 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3183 (so_imm2part_2 imm:$RHS))>;
3184 def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
3185 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3186 (so_imm2part_2 imm:$RHS))>;
3187 def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
3188 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
3189 (so_neg_imm2part_2 imm:$RHS))>;
3191 // 32-bit immediate using movw + movt.
3192 // This is a single pseudo instruction, the benefit is that it can be remat'd
3193 // as a single unit instead of having to handle reg inputs.
3194 // FIXME: Remove this when we can do generalized remat.
3195 let isReMaterializable = 1 in
3196 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2, "",
3197 [(set GPR:$dst, (i32 imm:$src))]>,
3198 Requires<[IsARM, HasV6T2]>;
3200 // ConstantPool, GlobalAddress, and JumpTable
3201 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
3202 Requires<[IsARM, DontUseMovt]>;
3203 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
3204 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
3205 Requires<[IsARM, UseMovt]>;
3206 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3207 (LEApcrelJT tjumptable:$dst, imm:$id)>;
3209 // TODO: add,sub,and, 3-instr forms?
3212 def : ARMPat<(ARMtcret tcGPR:$dst),
3213 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
3215 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
3216 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
3218 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
3219 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
3221 def : ARMPat<(ARMtcret tcGPR:$dst),
3222 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
3224 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
3225 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
3227 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
3228 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
3231 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
3232 Requires<[IsARM, IsNotDarwin]>;
3233 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
3234 Requires<[IsARM, IsDarwin]>;
3236 // zextload i1 -> zextload i8
3237 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
3238 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
3240 // extload -> zextload
3241 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
3242 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
3243 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
3244 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
3246 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
3248 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
3249 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
3252 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3253 (sra (shl GPR:$b, (i32 16)), (i32 16))),
3254 (SMULBB GPR:$a, GPR:$b)>;
3255 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
3256 (SMULBB GPR:$a, GPR:$b)>;
3257 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3258 (sra GPR:$b, (i32 16))),
3259 (SMULBT GPR:$a, GPR:$b)>;
3260 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
3261 (SMULBT GPR:$a, GPR:$b)>;
3262 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
3263 (sra (shl GPR:$b, (i32 16)), (i32 16))),
3264 (SMULTB GPR:$a, GPR:$b)>;
3265 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
3266 (SMULTB GPR:$a, GPR:$b)>;
3267 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
3269 (SMULWB GPR:$a, GPR:$b)>;
3270 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
3271 (SMULWB GPR:$a, GPR:$b)>;
3273 def : ARMV5TEPat<(add GPR:$acc,
3274 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3275 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
3276 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3277 def : ARMV5TEPat<(add GPR:$acc,
3278 (mul sext_16_node:$a, sext_16_node:$b)),
3279 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3280 def : ARMV5TEPat<(add GPR:$acc,
3281 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3282 (sra GPR:$b, (i32 16)))),
3283 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3284 def : ARMV5TEPat<(add GPR:$acc,
3285 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
3286 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3287 def : ARMV5TEPat<(add GPR:$acc,
3288 (mul (sra GPR:$a, (i32 16)),
3289 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
3290 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3291 def : ARMV5TEPat<(add GPR:$acc,
3292 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
3293 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3294 def : ARMV5TEPat<(add GPR:$acc,
3295 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
3297 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3298 def : ARMV5TEPat<(add GPR:$acc,
3299 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
3300 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3302 //===----------------------------------------------------------------------===//
3306 include "ARMInstrThumb.td"
3308 //===----------------------------------------------------------------------===//
3312 include "ARMInstrThumb2.td"
3314 //===----------------------------------------------------------------------===//
3315 // Floating Point Support
3318 include "ARMInstrVFP.td"
3320 //===----------------------------------------------------------------------===//
3321 // Advanced SIMD (NEON) Support
3324 include "ARMInstrNEON.td"
3326 //===----------------------------------------------------------------------===//
3327 // Coprocessor Instructions. For disassembly only.
3330 def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3331 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3332 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
3333 [/* For disassembly only; pattern left blank */]> {
3337 def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3338 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3339 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
3340 [/* For disassembly only; pattern left blank */]> {
3341 let Inst{31-28} = 0b1111;
3345 class ACI<dag oops, dag iops, string opc, string asm>
3346 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
3347 opc, asm, "", [/* For disassembly only; pattern left blank */]> {
3348 let Inst{27-25} = 0b110;
3351 multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
3353 def _OFFSET : ACI<(outs),
3354 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3355 opc, "\tp$cop, cr$CRd, $addr"> {
3356 let Inst{31-28} = op31_28;
3357 let Inst{24} = 1; // P = 1
3358 let Inst{21} = 0; // W = 0
3359 let Inst{22} = 0; // D = 0
3360 let Inst{20} = load;
3363 def _PRE : ACI<(outs),
3364 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3365 opc, "\tp$cop, cr$CRd, $addr!"> {
3366 let Inst{31-28} = op31_28;
3367 let Inst{24} = 1; // P = 1
3368 let Inst{21} = 1; // W = 1
3369 let Inst{22} = 0; // D = 0
3370 let Inst{20} = load;
3373 def _POST : ACI<(outs),
3374 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
3375 opc, "\tp$cop, cr$CRd, [$base], $offset"> {
3376 let Inst{31-28} = op31_28;
3377 let Inst{24} = 0; // P = 0
3378 let Inst{21} = 1; // W = 1
3379 let Inst{22} = 0; // D = 0
3380 let Inst{20} = load;
3383 def _OPTION : ACI<(outs),
3384 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option),
3385 opc, "\tp$cop, cr$CRd, [$base], $option"> {
3386 let Inst{31-28} = op31_28;
3387 let Inst{24} = 0; // P = 0
3388 let Inst{23} = 1; // U = 1
3389 let Inst{21} = 0; // W = 0
3390 let Inst{22} = 0; // D = 0
3391 let Inst{20} = load;
3394 def L_OFFSET : ACI<(outs),
3395 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3396 !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr"> {
3397 let Inst{31-28} = op31_28;
3398 let Inst{24} = 1; // P = 1
3399 let Inst{21} = 0; // W = 0
3400 let Inst{22} = 1; // D = 1
3401 let Inst{20} = load;
3404 def L_PRE : ACI<(outs),
3405 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3406 !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr!"> {
3407 let Inst{31-28} = op31_28;
3408 let Inst{24} = 1; // P = 1
3409 let Inst{21} = 1; // W = 1
3410 let Inst{22} = 1; // D = 1
3411 let Inst{20} = load;
3414 def L_POST : ACI<(outs),
3415 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
3416 !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $offset"> {
3417 let Inst{31-28} = op31_28;
3418 let Inst{24} = 0; // P = 0
3419 let Inst{21} = 1; // W = 1
3420 let Inst{22} = 1; // D = 1
3421 let Inst{20} = load;
3424 def L_OPTION : ACI<(outs),
3425 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option),
3426 !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $option"> {
3427 let Inst{31-28} = op31_28;
3428 let Inst{24} = 0; // P = 0
3429 let Inst{23} = 1; // U = 1
3430 let Inst{21} = 0; // W = 0
3431 let Inst{22} = 1; // D = 1
3432 let Inst{20} = load;
3436 defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">;
3437 defm LDC2 : LdStCop<0b1111, 1, "ldc2">;
3438 defm STC : LdStCop<{?,?,?,?}, 0, "stc">;
3439 defm STC2 : LdStCop<0b1111, 0, "stc2">;
3441 def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3442 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3443 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3444 [/* For disassembly only; pattern left blank */]> {
3449 def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3450 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3451 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3452 [/* For disassembly only; pattern left blank */]> {
3453 let Inst{31-28} = 0b1111;
3458 def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3459 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3460 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3461 [/* For disassembly only; pattern left blank */]> {
3466 def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3467 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3468 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3469 [/* For disassembly only; pattern left blank */]> {
3470 let Inst{31-28} = 0b1111;
3475 def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3476 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3477 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3478 [/* For disassembly only; pattern left blank */]> {
3479 let Inst{23-20} = 0b0100;
3482 def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3483 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3484 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3485 [/* For disassembly only; pattern left blank */]> {
3486 let Inst{31-28} = 0b1111;
3487 let Inst{23-20} = 0b0100;
3490 def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3491 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3492 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3493 [/* For disassembly only; pattern left blank */]> {
3494 let Inst{23-20} = 0b0101;
3497 def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3498 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3499 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3500 [/* For disassembly only; pattern left blank */]> {
3501 let Inst{31-28} = 0b1111;
3502 let Inst{23-20} = 0b0101;
3505 //===----------------------------------------------------------------------===//
3506 // Move between special register and ARM core register -- for disassembly only
3509 def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr",
3510 [/* For disassembly only; pattern left blank */]> {
3511 let Inst{23-20} = 0b0000;
3512 let Inst{7-4} = 0b0000;
3515 def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr",
3516 [/* For disassembly only; pattern left blank */]> {
3517 let Inst{23-20} = 0b0100;
3518 let Inst{7-4} = 0b0000;
3521 def MSR : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary,
3522 "msr", "\tcpsr$mask, $src",
3523 [/* For disassembly only; pattern left blank */]> {
3524 let Inst{23-20} = 0b0010;
3525 let Inst{7-4} = 0b0000;
3528 def MSRi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary,
3529 "msr", "\tcpsr$mask, $a",
3530 [/* For disassembly only; pattern left blank */]> {
3531 let Inst{23-20} = 0b0010;
3532 let Inst{7-4} = 0b0000;
3535 def MSRsys : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary,
3536 "msr", "\tspsr$mask, $src",
3537 [/* For disassembly only; pattern left blank */]> {
3538 let Inst{23-20} = 0b0110;
3539 let Inst{7-4} = 0b0000;
3542 def MSRsysi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary,
3543 "msr", "\tspsr$mask, $a",
3544 [/* For disassembly only; pattern left blank */]> {
3545 let Inst{23-20} = 0b0110;
3546 let Inst{7-4} = 0b0000;