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 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
303 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
304 int32_t v = (int32_t)N->getZExtValue();
305 return v == 8 || v == 16 || v == 24; }]> {
306 string EncoderMethod = "getRotImmOpValue";
309 // shift_imm: An integer that encodes a shift amount and the type of shift
310 // (currently either asr or lsl) using the same encoding used for the
311 // immediates in so_reg operands.
312 def shift_imm : Operand<i32> {
313 let PrintMethod = "printShiftImmOperand";
316 // shifter_operand operands: so_reg and so_imm.
317 def so_reg : Operand<i32>, // reg reg imm
318 ComplexPattern<i32, 3, "SelectShifterOperandReg",
319 [shl,srl,sra,rotr]> {
320 string EncoderMethod = "getSORegOpValue";
321 let PrintMethod = "printSORegOperand";
322 let MIOperandInfo = (ops GPR, GPR, i32imm);
325 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
326 // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
327 // represented in the imm field in the same 12-bit form that they are encoded
328 // into so_imm instructions: the 8-bit immediate is the least significant bits
329 // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
330 def so_imm : Operand<i32>, PatLeaf<(imm), [{ return Pred_so_imm(N); }]> {
331 string EncoderMethod = "getSOImmOpValue";
332 let PrintMethod = "printSOImmOperand";
335 // Break so_imm's up into two pieces. This handles immediates with up to 16
336 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
337 // get the first/second pieces.
338 def so_imm2part : Operand<i32>,
340 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
342 let PrintMethod = "printSOImm2PartOperand";
345 def so_imm2part_1 : SDNodeXForm<imm, [{
346 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
347 return CurDAG->getTargetConstant(V, MVT::i32);
350 def so_imm2part_2 : SDNodeXForm<imm, [{
351 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
352 return CurDAG->getTargetConstant(V, MVT::i32);
355 def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
356 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
358 let PrintMethod = "printSOImm2PartOperand";
361 def so_neg_imm2part_1 : SDNodeXForm<imm, [{
362 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
363 return CurDAG->getTargetConstant(V, MVT::i32);
366 def so_neg_imm2part_2 : SDNodeXForm<imm, [{
367 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
368 return CurDAG->getTargetConstant(V, MVT::i32);
371 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
372 def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
373 return (int32_t)N->getZExtValue() < 32;
376 /// imm0_31_m1 - Matches and prints like imm0_31, but encodes as 'value - 1'.
377 def imm0_31_m1 : Operand<i32>, PatLeaf<(imm), [{
378 return (int32_t)N->getZExtValue() < 32;
380 string EncoderMethod = "getImmMinusOneOpValue";
383 // Define ARM specific addressing modes.
385 // addrmode2base := reg +/- imm12
387 def addrmode2base : Operand<i32>,
388 ComplexPattern<i32, 3, "SelectAddrMode2Base", []> {
389 let PrintMethod = "printAddrMode2Operand";
390 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
392 // addrmode2shop := reg +/- reg shop imm
394 def addrmode2shop : Operand<i32>,
395 ComplexPattern<i32, 3, "SelectAddrMode2ShOp", []> {
396 let PrintMethod = "printAddrMode2Operand";
397 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
400 // addrmode2 := (addrmode2base || addrmode2shop)
402 def addrmode2 : Operand<i32>,
403 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
404 let PrintMethod = "printAddrMode2Operand";
405 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
408 def am2offset : Operand<i32>,
409 ComplexPattern<i32, 2, "SelectAddrMode2Offset",
410 [], [SDNPWantRoot]> {
411 let PrintMethod = "printAddrMode2OffsetOperand";
412 let MIOperandInfo = (ops GPR, i32imm);
415 // addrmode3 := reg +/- reg
416 // addrmode3 := reg +/- imm8
418 def addrmode3 : Operand<i32>,
419 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
420 let PrintMethod = "printAddrMode3Operand";
421 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
424 def am3offset : Operand<i32>,
425 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
426 [], [SDNPWantRoot]> {
427 let PrintMethod = "printAddrMode3OffsetOperand";
428 let MIOperandInfo = (ops GPR, i32imm);
431 // addrmode4 := reg, <mode|W>
433 def addrmode4 : Operand<i32>,
434 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
435 let PrintMethod = "printAddrMode4Operand";
436 let MIOperandInfo = (ops GPR:$addr, i32imm);
439 // addrmode5 := reg +/- imm8*4
441 def addrmode5 : Operand<i32>,
442 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
443 let PrintMethod = "printAddrMode5Operand";
444 let MIOperandInfo = (ops GPR:$base, i32imm);
447 // addrmode6 := reg with optional writeback
449 def addrmode6 : Operand<i32>,
450 ComplexPattern<i32, 2, "SelectAddrMode6", []> {
451 let PrintMethod = "printAddrMode6Operand";
452 let MIOperandInfo = (ops GPR:$addr, i32imm);
455 def am6offset : Operand<i32> {
456 let PrintMethod = "printAddrMode6OffsetOperand";
457 let MIOperandInfo = (ops GPR);
460 // addrmodepc := pc + reg
462 def addrmodepc : Operand<i32>,
463 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
464 let PrintMethod = "printAddrModePCOperand";
465 let MIOperandInfo = (ops GPR, i32imm);
468 def nohash_imm : Operand<i32> {
469 let PrintMethod = "printNoHashImmediate";
472 //===----------------------------------------------------------------------===//
474 include "ARMInstrFormats.td"
476 //===----------------------------------------------------------------------===//
477 // Multiclass helpers...
480 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
481 /// binop that produces a value.
482 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
483 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
484 PatFrag opnode, bit Commutable = 0> {
485 // The register-immediate version is re-materializable. This is useful
486 // in particular for taking the address of a local.
487 let isReMaterializable = 1 in {
488 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
489 iii, opc, "\t$Rd, $Rn, $imm",
490 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
495 let Inst{15-12} = Rd;
496 let Inst{19-16} = Rn;
497 let Inst{11-0} = imm;
500 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
501 iir, opc, "\t$Rd, $Rn, $Rm",
502 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
506 let Inst{11-4} = 0b00000000;
508 let isCommutable = Commutable;
510 let Inst{15-12} = Rd;
511 let Inst{19-16} = Rn;
513 def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm,
514 iis, opc, "\t$Rd, $Rn, $shift",
515 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> {
520 let Inst{11-0} = shift;
521 let Inst{15-12} = Rd;
522 let Inst{19-16} = Rn;
526 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
527 /// instruction modifies the CPSR register.
528 let Defs = [CPSR] in {
529 multiclass AI1_bin_s_irs<bits<4> opcod, string opc,
530 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
531 PatFrag opnode, bit Commutable = 0> {
532 def ri : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
533 iii, opc, "\t$Rd, $Rn, $imm",
534 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
539 let Inst{15-12} = Rd;
540 let Inst{19-16} = Rn;
541 let Inst{11-0} = imm;
544 def rr : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
545 iir, opc, "\t$Rd, $Rn, $Rm",
546 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
550 let Inst{11-4} = 0b00000000;
552 let isCommutable = Commutable;
554 let Inst{15-12} = Rd;
555 let Inst{19-16} = Rn;
558 def rs : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm,
559 iis, opc, "\t$Rd, $Rn, $shift",
560 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> {
565 let Inst{11-0} = shift;
566 let Inst{15-12} = Rd;
567 let Inst{19-16} = Rn;
573 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
574 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
575 /// a explicit result, only implicitly set CPSR.
576 let isCompare = 1, Defs = [CPSR] in {
577 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
578 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
579 PatFrag opnode, bit Commutable = 0> {
580 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
582 [(opnode GPR:$Rn, so_imm:$imm)]> {
586 let Inst{15-12} = 0b0000;
587 let Inst{19-16} = Rn;
588 let Inst{11-0} = imm;
592 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
594 [(opnode GPR:$Rn, GPR:$Rm)]> {
597 let Inst{11-4} = 0b00000000;
599 let isCommutable = Commutable;
601 let Inst{15-12} = 0b0000;
602 let Inst{19-16} = Rn;
605 def rs : AI1<opcod, (outs), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, iis,
606 opc, "\t$Rn, $shift",
607 [(opnode GPR:$Rn, so_reg:$shift)]> {
611 let Inst{11-0} = shift;
612 let Inst{15-12} = 0b0000;
613 let Inst{19-16} = Rn;
619 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
620 /// register and one whose operand is a register rotated by 8/16/24.
621 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
622 multiclass AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode> {
623 def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm),
624 IIC_iEXTr, opc, "\t$Rd, $Rm",
625 [(set GPR:$Rd, (opnode GPR:$Rm))]>,
626 Requires<[IsARM, HasV6]> {
629 let Inst{15-12} = Rd;
631 let Inst{11-10} = 0b00;
632 let Inst{19-16} = 0b1111;
634 def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot),
635 IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot",
636 [(set GPR:$Rd, (opnode (rotr GPR:$Rm, rot_imm:$rot)))]>,
637 Requires<[IsARM, HasV6]> {
641 let Inst{15-12} = Rd;
642 let Inst{11-10} = rot;
644 let Inst{19-16} = 0b1111;
648 multiclass AI_ext_rrot_np<bits<8> opcod, string opc> {
649 def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm),
650 IIC_iEXTr, opc, "\t$Rd, $Rm",
651 [/* For disassembly only; pattern left blank */]>,
652 Requires<[IsARM, HasV6]> {
653 let Inst{11-10} = 0b00;
654 let Inst{19-16} = 0b1111;
656 def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot),
657 IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot",
658 [/* For disassembly only; pattern left blank */]>,
659 Requires<[IsARM, HasV6]> {
661 let Inst{11-10} = rot;
662 let Inst{19-16} = 0b1111;
666 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
667 /// register and one whose operand is a register rotated by 8/16/24.
668 multiclass AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode> {
669 def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
670 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm",
671 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
672 Requires<[IsARM, HasV6]> {
673 let Inst{11-10} = 0b00;
675 def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
677 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
678 [(set GPR:$Rd, (opnode GPR:$Rn,
679 (rotr GPR:$Rm, rot_imm:$rot)))]>,
680 Requires<[IsARM, HasV6]> {
683 let Inst{19-16} = Rn;
684 let Inst{11-10} = rot;
688 // For disassembly only.
689 multiclass AI_exta_rrot_np<bits<8> opcod, string opc> {
690 def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
691 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm",
692 [/* For disassembly only; pattern left blank */]>,
693 Requires<[IsARM, HasV6]> {
694 let Inst{11-10} = 0b00;
696 def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
698 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
699 [/* For disassembly only; pattern left blank */]>,
700 Requires<[IsARM, HasV6]> {
703 let Inst{19-16} = Rn;
704 let Inst{11-10} = rot;
708 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
709 let Uses = [CPSR] in {
710 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
711 bit Commutable = 0> {
712 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
713 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
714 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
720 let Inst{15-12} = Rd;
721 let Inst{19-16} = Rn;
722 let Inst{11-0} = imm;
724 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
725 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
726 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
731 let Inst{11-4} = 0b00000000;
733 let isCommutable = Commutable;
735 let Inst{15-12} = Rd;
736 let Inst{19-16} = Rn;
738 def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
739 DPSoRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
740 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>,
746 let Inst{11-0} = shift;
747 let Inst{15-12} = Rd;
748 let Inst{19-16} = Rn;
751 // Carry setting variants
752 let Defs = [CPSR] in {
753 multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
754 bit Commutable = 0> {
755 def Sri : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
756 DPFrm, IIC_iALUi, !strconcat(opc, "\t$Rd, $Rn, $imm"),
757 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
762 let Inst{15-12} = Rd;
763 let Inst{19-16} = Rn;
764 let Inst{11-0} = imm;
768 def Srr : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
769 DPFrm, IIC_iALUr, !strconcat(opc, "\t$Rd, $Rn, $Rm"),
770 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
775 let Inst{11-4} = 0b00000000;
776 let isCommutable = Commutable;
778 let Inst{15-12} = Rd;
779 let Inst{19-16} = Rn;
783 def Srs : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
784 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$Rd, $Rn, $shift"),
785 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>,
790 let Inst{11-0} = shift;
791 let Inst{15-12} = Rd;
792 let Inst{19-16} = Rn;
800 //===----------------------------------------------------------------------===//
802 //===----------------------------------------------------------------------===//
804 //===----------------------------------------------------------------------===//
805 // Miscellaneous Instructions.
808 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
809 /// the function. The first operand is the ID# for this instruction, the second
810 /// is the index into the MachineConstantPool that this is, the third is the
811 /// size in bytes of this constant pool entry.
812 let neverHasSideEffects = 1, isNotDuplicable = 1 in
813 def CONSTPOOL_ENTRY :
814 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
815 i32imm:$size), NoItinerary, "", []>;
817 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
818 // from removing one half of the matched pairs. That breaks PEI, which assumes
819 // these will always be in pairs, and asserts if it finds otherwise. Better way?
820 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
822 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary, "",
823 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
825 def ADJCALLSTACKDOWN :
826 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary, "",
827 [(ARMcallseq_start timm:$amt)]>;
830 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "",
831 [/* For disassembly only; pattern left blank */]>,
832 Requires<[IsARM, HasV6T2]> {
833 let Inst{27-16} = 0b001100100000;
834 let Inst{15-8} = 0b11110000;
835 let Inst{7-0} = 0b00000000;
838 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "",
839 [/* For disassembly only; pattern left blank */]>,
840 Requires<[IsARM, HasV6T2]> {
841 let Inst{27-16} = 0b001100100000;
842 let Inst{15-8} = 0b11110000;
843 let Inst{7-0} = 0b00000001;
846 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "",
847 [/* For disassembly only; pattern left blank */]>,
848 Requires<[IsARM, HasV6T2]> {
849 let Inst{27-16} = 0b001100100000;
850 let Inst{15-8} = 0b11110000;
851 let Inst{7-0} = 0b00000010;
854 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "",
855 [/* For disassembly only; pattern left blank */]>,
856 Requires<[IsARM, HasV6T2]> {
857 let Inst{27-16} = 0b001100100000;
858 let Inst{15-8} = 0b11110000;
859 let Inst{7-0} = 0b00000011;
862 def SEL : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, NoItinerary, "sel",
864 [/* For disassembly only; pattern left blank */]>,
865 Requires<[IsARM, HasV6]> {
870 let Inst{15-12} = Rd;
871 let Inst{19-16} = Rn;
872 let Inst{27-20} = 0b01101000;
873 let Inst{7-4} = 0b1011;
874 let Inst{11-8} = 0b1111;
877 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
878 [/* For disassembly only; pattern left blank */]>,
879 Requires<[IsARM, HasV6T2]> {
880 let Inst{27-16} = 0b001100100000;
881 let Inst{15-8} = 0b11110000;
882 let Inst{7-0} = 0b00000100;
885 // The i32imm operand $val can be used by a debugger to store more information
886 // about the breakpoint.
887 def BKPT : AI<(outs), (ins i32imm:$val), MiscFrm, NoItinerary, "bkpt", "\t$val",
888 [/* For disassembly only; pattern left blank */]>,
891 let Inst{3-0} = val{3-0};
892 let Inst{19-8} = val{15-4};
893 let Inst{27-20} = 0b00010010;
894 let Inst{7-4} = 0b0111;
897 // Change Processor State is a system instruction -- for disassembly only.
898 // The singleton $opt operand contains the following information:
899 // opt{4-0} = mode from Inst{4-0}
900 // opt{5} = changemode from Inst{17}
901 // opt{8-6} = AIF from Inst{8-6}
902 // opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
903 // FIXME: Integrated assembler will need these split out.
904 def CPS : AXI<(outs), (ins cps_opt:$opt), MiscFrm, NoItinerary, "cps$opt",
905 [/* For disassembly only; pattern left blank */]>,
907 let Inst{31-28} = 0b1111;
908 let Inst{27-20} = 0b00010000;
913 // Preload signals the memory system of possible future data/instruction access.
914 // These are for disassembly only.
916 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
917 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
918 multiclass APreLoad<bit data, bit read, string opc> {
920 def i : AXI<(outs), (ins GPR:$base, neg_zero:$imm), MiscFrm, NoItinerary,
921 !strconcat(opc, "\t[$base, $imm]"), []> {
922 let Inst{31-26} = 0b111101;
923 let Inst{25} = 0; // 0 for immediate form
926 let Inst{21-20} = 0b01;
929 def r : AXI<(outs), (ins addrmode2:$addr), MiscFrm, NoItinerary,
930 !strconcat(opc, "\t$addr"), []> {
931 let Inst{31-26} = 0b111101;
932 let Inst{25} = 1; // 1 for register form
935 let Inst{21-20} = 0b01;
940 defm PLD : APreLoad<1, 1, "pld">;
941 defm PLDW : APreLoad<1, 0, "pldw">;
942 defm PLI : APreLoad<0, 1, "pli">;
944 def SETEND : AXI<(outs),(ins setend_op:$end), MiscFrm, NoItinerary,
946 [/* For disassembly only; pattern left blank */]>,
949 let Inst{31-10} = 0b1111000100000001000000;
954 def DBG : AI<(outs), (ins i32imm:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
955 [/* For disassembly only; pattern left blank */]>,
956 Requires<[IsARM, HasV7]> {
958 let Inst{27-4} = 0b001100100000111100001111;
962 // A5.4 Permanently UNDEFINED instructions.
963 let isBarrier = 1, isTerminator = 1 in
964 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
967 let Inst{27-25} = 0b011;
968 let Inst{24-20} = 0b11111;
969 let Inst{7-5} = 0b111;
973 // Address computation and loads and stores in PIC mode.
974 // FIXME: These PIC insn patterns are pseudos, but derive from the normal insn
975 // classes (AXI1, et.al.) and so have encoding information and such,
976 // which is suboptimal. Once the rest of the code emitter (including
977 // JIT) is MC-ized we should look at refactoring these into true
979 let isNotDuplicable = 1 in {
980 def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
981 Pseudo, IIC_iALUr, "",
982 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
984 let AddedComplexity = 10 in {
985 def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
986 Pseudo, IIC_iLoad_r, "",
987 [(set GPR:$dst, (load addrmodepc:$addr))]>;
989 def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
990 Pseudo, IIC_iLoad_bh_r, "",
991 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
993 def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
994 Pseudo, IIC_iLoad_bh_r, "",
995 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
997 def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
998 Pseudo, IIC_iLoad_bh_r, "",
999 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
1001 def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1002 Pseudo, IIC_iLoad_bh_r, "",
1003 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
1005 let AddedComplexity = 10 in {
1006 def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1007 Pseudo, IIC_iStore_r, "",
1008 [(store GPR:$src, addrmodepc:$addr)]>;
1010 def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1011 Pseudo, IIC_iStore_bh_r, "",
1012 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
1014 def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1015 Pseudo, IIC_iStore_bh_r, "",
1016 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1018 } // isNotDuplicable = 1
1021 // LEApcrel - Load a pc-relative address into a register without offending the
1023 // FIXME: These are marked as pseudos, but they're really not(?). They're just
1024 // the ADR instruction. Is this the right way to handle that? They need
1025 // encoding information regardless.
1026 let neverHasSideEffects = 1 in {
1027 let isReMaterializable = 1 in
1028 def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
1030 "adr$p\t$dst, #$label", []>;
1032 } // neverHasSideEffects
1033 def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
1034 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1036 "adr$p\t$dst, #${label}_${id}", []> {
1040 //===----------------------------------------------------------------------===//
1041 // Control Flow Instructions.
1044 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1046 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1047 "bx", "\tlr", [(ARMretflag)]>,
1048 Requires<[IsARM, HasV4T]> {
1049 let Inst{27-0} = 0b0001001011111111111100011110;
1053 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1054 "mov", "\tpc, lr", [(ARMretflag)]>,
1055 Requires<[IsARM, NoV4T]> {
1056 let Inst{27-0} = 0b0001101000001111000000001110;
1060 // Indirect branches
1061 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1063 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1064 [(brind GPR:$dst)]>,
1065 Requires<[IsARM, HasV4T]> {
1067 let Inst{31-4} = 0b1110000100101111111111110001;
1068 let Inst{3-0} = dst;
1072 def MOVPCRX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "mov\tpc, $dst",
1073 [(brind GPR:$dst)]>,
1074 Requires<[IsARM, NoV4T]> {
1076 let Inst{31-4} = 0b1110000110100000111100000000;
1077 let Inst{3-0} = dst;
1081 // FIXME: remove when we have a way to marking a MI with these properties.
1082 // FIXME: Should pc be an implicit operand like PICADD, etc?
1083 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
1084 hasExtraDefRegAllocReq = 1 in
1085 def LDM_RET : AXI4ld<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1086 reglist:$dsts, variable_ops),
1087 IndexModeUpd, LdStMulFrm, IIC_iLoad_mBr,
1088 "ldm${addr:submode}${p}\t$addr!, $dsts",
1089 "$addr.addr = $wb", []>;
1091 // On non-Darwin platforms R9 is callee-saved.
1093 Defs = [R0, R1, R2, R3, R12, LR,
1094 D0, D1, D2, D3, D4, D5, D6, D7,
1095 D16, D17, D18, D19, D20, D21, D22, D23,
1096 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
1097 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1098 IIC_Br, "bl\t$func",
1099 [(ARMcall tglobaladdr:$func)]>,
1100 Requires<[IsARM, IsNotDarwin]> {
1101 let Inst{31-28} = 0b1110;
1102 // FIXME: Encoding info for $func. Needs fixups bits.
1105 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1106 IIC_Br, "bl", "\t$func",
1107 [(ARMcall_pred tglobaladdr:$func)]>,
1108 Requires<[IsARM, IsNotDarwin]>;
1111 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1112 IIC_Br, "blx\t$func",
1113 [(ARMcall GPR:$func)]>,
1114 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1116 let Inst{27-4} = 0b000100101111111111110011;
1117 let Inst{3-0} = func;
1121 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1122 def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1123 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
1124 [(ARMcall_nolink tGPR:$func)]>,
1125 Requires<[IsARM, HasV4T, IsNotDarwin]> {
1127 let Inst{27-4} = 0b000100101111111111110001;
1128 let Inst{3-0} = func;
1132 def BMOVPCRX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1133 IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func",
1134 [(ARMcall_nolink tGPR:$func)]>,
1135 Requires<[IsARM, NoV4T, IsNotDarwin]> {
1137 let Inst{27-4} = 0b000110100000111100000000;
1138 let Inst{3-0} = func;
1142 // On Darwin R9 is call-clobbered.
1144 Defs = [R0, R1, R2, R3, R9, R12, LR,
1145 D0, D1, D2, D3, D4, D5, D6, D7,
1146 D16, D17, D18, D19, D20, D21, D22, D23,
1147 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
1148 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1149 IIC_Br, "bl\t$func",
1150 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
1151 let Inst{31-28} = 0b1110;
1152 // FIXME: Encoding info for $func. Needs fixups bits.
1155 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
1156 IIC_Br, "bl", "\t$func",
1157 [(ARMcall_pred tglobaladdr:$func)]>,
1158 Requires<[IsARM, IsDarwin]>;
1161 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1162 IIC_Br, "blx\t$func",
1163 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
1165 let Inst{27-4} = 0b000100101111111111110011;
1166 let Inst{3-0} = func;
1170 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1171 def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1172 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
1173 [(ARMcall_nolink tGPR:$func)]>,
1174 Requires<[IsARM, HasV4T, IsDarwin]> {
1176 let Inst{27-4} = 0b000100101111111111110001;
1177 let Inst{3-0} = func;
1181 def BMOVPCRXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1182 IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func",
1183 [(ARMcall_nolink tGPR:$func)]>,
1184 Requires<[IsARM, NoV4T, IsDarwin]> {
1186 let Inst{27-4} = 0b000110100000111100000000;
1187 let Inst{3-0} = func;
1193 // FIXME: These should probably be xformed into the non-TC versions of the
1194 // instructions as part of MC lowering.
1195 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
1197 let Defs = [R0, R1, R2, R3, R9, R12,
1198 D0, D1, D2, D3, D4, D5, D6, D7,
1199 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26,
1200 D27, D28, D29, D30, D31, PC],
1202 def TCRETURNdi : AInoP<(outs), (ins i32imm:$dst, variable_ops),
1204 "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>;
1206 def TCRETURNri : AInoP<(outs), (ins tcGPR:$dst, variable_ops),
1208 "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>;
1210 def TAILJMPd : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1211 IIC_Br, "b\t$dst @ TAILCALL",
1212 []>, Requires<[IsDarwin]>;
1214 def TAILJMPdt: ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1215 IIC_Br, "b.w\t$dst @ TAILCALL",
1216 []>, Requires<[IsDarwin]>;
1218 def TAILJMPr : AXI<(outs), (ins tcGPR:$dst, variable_ops),
1219 BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL",
1220 []>, Requires<[IsDarwin]> {
1222 let Inst{31-4} = 0b1110000100101111111111110001;
1223 let Inst{3-0} = dst;
1227 // Non-Darwin versions (the difference is R9).
1228 let Defs = [R0, R1, R2, R3, R12,
1229 D0, D1, D2, D3, D4, D5, D6, D7,
1230 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26,
1231 D27, D28, D29, D30, D31, PC],
1233 def TCRETURNdiND : AInoP<(outs), (ins i32imm:$dst, variable_ops),
1235 "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>;
1237 def TCRETURNriND : AInoP<(outs), (ins tcGPR:$dst, variable_ops),
1239 "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>;
1241 def TAILJMPdND : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1242 IIC_Br, "b\t$dst @ TAILCALL",
1243 []>, Requires<[IsARM, IsNotDarwin]>;
1245 def TAILJMPdNDt : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1246 IIC_Br, "b.w\t$dst @ TAILCALL",
1247 []>, Requires<[IsThumb, IsNotDarwin]>;
1249 def TAILJMPrND : AXI<(outs), (ins tcGPR:$dst, variable_ops),
1250 BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL",
1251 []>, Requires<[IsNotDarwin]> {
1253 let Inst{31-4} = 0b1110000100101111111111110001;
1254 let Inst{3-0} = dst;
1259 let isBranch = 1, isTerminator = 1 in {
1260 // B is "predicable" since it can be xformed into a Bcc.
1261 let isBarrier = 1 in {
1262 let isPredicable = 1 in
1263 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
1264 "b\t$target", [(br bb:$target)]>;
1266 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1267 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
1268 IIC_Br, "mov\tpc, $target$jt",
1269 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
1270 let Inst{11-4} = 0b00000000;
1271 let Inst{15-12} = 0b1111;
1272 let Inst{20} = 0; // S Bit
1273 let Inst{24-21} = 0b1101;
1274 let Inst{27-25} = 0b000;
1276 def BR_JTm : JTI<(outs),
1277 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
1278 IIC_Br, "ldr\tpc, $target$jt",
1279 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1281 let Inst{15-12} = 0b1111;
1282 let Inst{20} = 1; // L bit
1283 let Inst{21} = 0; // W bit
1284 let Inst{22} = 0; // B bit
1285 let Inst{24} = 1; // P bit
1286 let Inst{27-25} = 0b011;
1288 def BR_JTadd : JTI<(outs),
1289 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
1290 IIC_Br, "add\tpc, $target, $idx$jt",
1291 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1293 let Inst{15-12} = 0b1111;
1294 let Inst{20} = 0; // S bit
1295 let Inst{24-21} = 0b0100;
1296 let Inst{27-25} = 0b000;
1298 } // isNotDuplicable = 1, isIndirectBranch = 1
1301 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1302 // a two-value operand where a dag node expects two operands. :(
1303 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
1304 IIC_Br, "b", "\t$target",
1305 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
1308 // Branch and Exchange Jazelle -- for disassembly only
1309 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1310 [/* For disassembly only; pattern left blank */]> {
1311 let Inst{23-20} = 0b0010;
1312 //let Inst{19-8} = 0xfff;
1313 let Inst{7-4} = 0b0010;
1316 // Secure Monitor Call is a system instruction -- for disassembly only
1317 def SMC : ABI<0b0001, (outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
1318 [/* For disassembly only; pattern left blank */]> {
1320 let Inst{23-4} = 0b01100000000000000111;
1321 let Inst{3-0} = opt;
1324 // Supervisor Call (Software Interrupt) -- for disassembly only
1326 def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
1327 [/* For disassembly only; pattern left blank */]> {
1329 let Inst{23-0} = svc;
1333 // Store Return State is a system instruction -- for disassembly only
1334 def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
1335 NoItinerary, "srs${addr:submode}\tsp!, $mode",
1336 [/* For disassembly only; pattern left blank */]> {
1337 let Inst{31-28} = 0b1111;
1338 let Inst{22-20} = 0b110; // W = 1
1341 def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
1342 NoItinerary, "srs${addr:submode}\tsp, $mode",
1343 [/* For disassembly only; pattern left blank */]> {
1344 let Inst{31-28} = 0b1111;
1345 let Inst{22-20} = 0b100; // W = 0
1348 // Return From Exception is a system instruction -- for disassembly only
1349 def RFEW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base),
1350 NoItinerary, "rfe${addr:submode}\t$base!",
1351 [/* For disassembly only; pattern left blank */]> {
1352 let Inst{31-28} = 0b1111;
1353 let Inst{22-20} = 0b011; // W = 1
1356 def RFE : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base),
1357 NoItinerary, "rfe${addr:submode}\t$base",
1358 [/* For disassembly only; pattern left blank */]> {
1359 let Inst{31-28} = 0b1111;
1360 let Inst{22-20} = 0b001; // W = 0
1363 //===----------------------------------------------------------------------===//
1364 // Load / store Instructions.
1368 let canFoldAsLoad = 1, isReMaterializable = 1 in
1369 def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoad_r,
1370 "ldr", "\t$dst, $addr",
1371 [(set GPR:$dst, (load addrmode2:$addr))]>;
1373 // Special LDR for loads from non-pc-relative constpools.
1374 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
1375 isReMaterializable = 1 in
1376 def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoad_r,
1377 "ldr", "\t$dst, $addr", []>;
1379 // Loads with zero extension
1380 def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1381 IIC_iLoad_bh_r, "ldrh", "\t$dst, $addr",
1382 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
1384 def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
1385 IIC_iLoad_bh_r, "ldrb", "\t$dst, $addr",
1386 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
1388 // Loads with sign extension
1389 def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1390 IIC_iLoad_bh_r, "ldrsh", "\t$dst, $addr",
1391 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
1393 def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1394 IIC_iLoad_bh_r, "ldrsb", "\t$dst, $addr",
1395 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
1397 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1399 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
1400 IIC_iLoad_d_r, "ldrd", "\t$dst1, $addr",
1401 []>, Requires<[IsARM, HasV5TE]>;
1404 def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
1405 (ins addrmode2:$addr), LdFrm, IIC_iLoad_ru,
1406 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1408 def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1409 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoad_ru,
1410 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1412 def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
1413 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1414 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1416 def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
1417 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1418 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1420 def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
1421 (ins addrmode2:$addr), LdFrm, IIC_iLoad_bh_ru,
1422 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1424 def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1425 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoad_bh_ru,
1426 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1428 def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
1429 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1430 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1432 def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
1433 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1434 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1436 def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
1437 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1438 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1440 def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
1441 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_ru,
1442 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1444 // For disassembly only
1445 def LDRD_PRE : AI3lddpr<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb),
1446 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_d_ru,
1447 "ldrd", "\t$dst1, $dst2, $addr!", "$addr.base = $base_wb", []>,
1448 Requires<[IsARM, HasV5TE]>;
1450 // For disassembly only
1451 def LDRD_POST : AI3lddpo<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb),
1452 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_d_ru,
1453 "ldrd", "\t$dst1, $dst2, [$base], $offset", "$base = $base_wb", []>,
1454 Requires<[IsARM, HasV5TE]>;
1456 } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
1458 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only.
1460 def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1461 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoad_ru,
1462 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1463 let Inst{21} = 1; // overwrite
1466 def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1467 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoad_bh_ru,
1468 "ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1469 let Inst{21} = 1; // overwrite
1472 def LDRSBT : AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
1473 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1474 "ldrsbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1475 let Inst{21} = 1; // overwrite
1478 def LDRHT : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
1479 (ins GPR:$base, am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1480 "ldrht", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1481 let Inst{21} = 1; // overwrite
1484 def LDRSHT : AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
1485 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1486 "ldrsht", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1487 let Inst{21} = 1; // overwrite
1491 def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStore_r,
1492 "str", "\t$src, $addr",
1493 [(store GPR:$src, addrmode2:$addr)]>;
1495 // Stores with truncate
1496 def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
1497 IIC_iStore_bh_r, "strh", "\t$src, $addr",
1498 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
1500 def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm,
1501 IIC_iStore_bh_r, "strb", "\t$src, $addr",
1502 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
1505 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
1506 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
1507 StMiscFrm, IIC_iStore_d_r,
1508 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
1511 def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
1512 (ins GPR:$src, GPR:$base, am2offset:$offset),
1513 StFrm, IIC_iStore_ru,
1514 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
1516 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1518 def STR_POST : AI2stwpo<(outs GPR:$base_wb),
1519 (ins GPR:$src, GPR:$base,am2offset:$offset),
1520 StFrm, IIC_iStore_ru,
1521 "str", "\t$src, [$base], $offset", "$base = $base_wb",
1523 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1525 def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
1526 (ins GPR:$src, GPR:$base,am3offset:$offset),
1527 StMiscFrm, IIC_iStore_ru,
1528 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
1530 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1532 def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
1533 (ins GPR:$src, GPR:$base,am3offset:$offset),
1534 StMiscFrm, IIC_iStore_bh_ru,
1535 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
1536 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1537 GPR:$base, am3offset:$offset))]>;
1539 def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
1540 (ins GPR:$src, GPR:$base,am2offset:$offset),
1541 StFrm, IIC_iStore_bh_ru,
1542 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
1543 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
1544 GPR:$base, am2offset:$offset))]>;
1546 def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
1547 (ins GPR:$src, GPR:$base,am2offset:$offset),
1548 StFrm, IIC_iStore_bh_ru,
1549 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
1550 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
1551 GPR:$base, am2offset:$offset))]>;
1553 // For disassembly only
1554 def STRD_PRE : AI3stdpr<(outs GPR:$base_wb),
1555 (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset),
1556 StMiscFrm, IIC_iStore_d_ru,
1557 "strd", "\t$src1, $src2, [$base, $offset]!",
1558 "$base = $base_wb", []>;
1560 // For disassembly only
1561 def STRD_POST: AI3stdpo<(outs GPR:$base_wb),
1562 (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset),
1563 StMiscFrm, IIC_iStore_d_ru,
1564 "strd", "\t$src1, $src2, [$base], $offset",
1565 "$base = $base_wb", []>;
1567 // STRT, STRBT, and STRHT are for disassembly only.
1569 def STRT : AI2stwpo<(outs GPR:$base_wb),
1570 (ins GPR:$src, GPR:$base,am2offset:$offset),
1571 StFrm, IIC_iStore_ru,
1572 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1573 [/* For disassembly only; pattern left blank */]> {
1574 let Inst{21} = 1; // overwrite
1577 def STRBT : AI2stbpo<(outs GPR:$base_wb),
1578 (ins GPR:$src, GPR:$base,am2offset:$offset),
1579 StFrm, IIC_iStore_bh_ru,
1580 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1581 [/* For disassembly only; pattern left blank */]> {
1582 let Inst{21} = 1; // overwrite
1585 def STRHT: AI3sthpo<(outs GPR:$base_wb),
1586 (ins GPR:$src, GPR:$base,am3offset:$offset),
1587 StMiscFrm, IIC_iStore_bh_ru,
1588 "strht", "\t$src, [$base], $offset", "$base = $base_wb",
1589 [/* For disassembly only; pattern left blank */]> {
1590 let Inst{21} = 1; // overwrite
1593 //===----------------------------------------------------------------------===//
1594 // Load / store multiple Instructions.
1597 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1598 def LDM : AXI4ld<(outs), (ins addrmode4:$addr, pred:$p,
1599 reglist:$dsts, variable_ops),
1600 IndexModeNone, LdStMulFrm, IIC_iLoad_m,
1601 "ldm${addr:submode}${p}\t$addr, $dsts", "", []>;
1603 def LDM_UPD : AXI4ld<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1604 reglist:$dsts, variable_ops),
1605 IndexModeUpd, LdStMulFrm, IIC_iLoad_mu,
1606 "ldm${addr:submode}${p}\t$addr!, $dsts",
1607 "$addr.addr = $wb", []>;
1608 } // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
1610 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
1611 def STM : AXI4st<(outs), (ins addrmode4:$addr, pred:$p,
1612 reglist:$srcs, variable_ops),
1613 IndexModeNone, LdStMulFrm, IIC_iStore_m,
1614 "stm${addr:submode}${p}\t$addr, $srcs", "", []>;
1616 def STM_UPD : AXI4st<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
1617 reglist:$srcs, variable_ops),
1618 IndexModeUpd, LdStMulFrm, IIC_iStore_mu,
1619 "stm${addr:submode}${p}\t$addr!, $srcs",
1620 "$addr.addr = $wb", []>;
1621 } // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
1623 //===----------------------------------------------------------------------===//
1624 // Move Instructions.
1627 let neverHasSideEffects = 1 in
1628 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
1629 "mov", "\t$Rd, $Rm", []>, UnaryDP {
1633 let Inst{11-4} = 0b00000000;
1636 let Inst{15-12} = Rd;
1639 // A version for the smaller set of tail call registers.
1640 let neverHasSideEffects = 1 in
1641 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
1642 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
1646 let Inst{11-4} = 0b00000000;
1649 let Inst{15-12} = Rd;
1652 def MOVs : AsI1<0b1101, (outs GPR:$Rd), (ins so_reg:$src),
1653 DPSoRegFrm, IIC_iMOVsr,
1654 "mov", "\t$Rd, $src", [(set GPR:$Rd, so_reg:$src)]>, UnaryDP {
1657 let Inst{15-12} = Rd;
1658 let Inst{11-0} = src;
1662 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1663 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
1664 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
1668 let Inst{15-12} = Rd;
1669 let Inst{19-16} = 0b0000;
1670 let Inst{11-0} = imm;
1673 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1674 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins i32imm:$imm),
1676 "movw", "\t$Rd, $imm",
1677 [(set GPR:$Rd, imm0_65535:$imm)]>,
1678 Requires<[IsARM, HasV6T2]>, UnaryDP {
1681 let Inst{15-12} = Rd;
1682 let Inst{11-0} = imm{11-0};
1683 let Inst{19-16} = imm{15-12};
1688 let Constraints = "$src = $Rd" in
1689 def MOVTi16 : AI1<0b1010, (outs GPR:$Rd), (ins GPR:$src, i32imm:$imm),
1691 "movt", "\t$Rd, $imm",
1693 (or (and GPR:$src, 0xffff),
1694 lo16AllZero:$imm))]>, UnaryDP,
1695 Requires<[IsARM, HasV6T2]> {
1698 let Inst{15-12} = Rd;
1699 let Inst{11-0} = imm{11-0};
1700 let Inst{19-16} = imm{15-12};
1705 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1706 Requires<[IsARM, HasV6T2]>;
1708 let Uses = [CPSR] in
1709 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi, "",
1710 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
1713 // These aren't really mov instructions, but we have to define them this way
1714 // due to flag operands.
1716 let Defs = [CPSR] in {
1717 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "",
1718 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
1720 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "",
1721 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
1725 //===----------------------------------------------------------------------===//
1726 // Extend Instructions.
1731 defm SXTB : AI_ext_rrot<0b01101010,
1732 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1733 defm SXTH : AI_ext_rrot<0b01101011,
1734 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
1736 defm SXTAB : AI_exta_rrot<0b01101010,
1737 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1738 defm SXTAH : AI_exta_rrot<0b01101011,
1739 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1741 // For disassembly only
1742 defm SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
1744 // For disassembly only
1745 defm SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
1749 let AddedComplexity = 16 in {
1750 defm UXTB : AI_ext_rrot<0b01101110,
1751 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1752 defm UXTH : AI_ext_rrot<0b01101111,
1753 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1754 defm UXTB16 : AI_ext_rrot<0b01101100,
1755 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1757 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
1758 // The transformation should probably be done as a combiner action
1759 // instead so we can include a check for masking back in the upper
1760 // eight bits of the source into the lower eight bits of the result.
1761 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
1762 // (UXTB16r_rot GPR:$Src, 24)>;
1763 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
1764 (UXTB16r_rot GPR:$Src, 8)>;
1766 defm UXTAB : AI_exta_rrot<0b01101110, "uxtab",
1767 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1768 defm UXTAH : AI_exta_rrot<0b01101111, "uxtah",
1769 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1772 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1773 // For disassembly only
1774 defm UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
1777 def SBFX : I<(outs GPR:$Rd),
1778 (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width),
1779 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1780 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
1781 Requires<[IsARM, HasV6T2]> {
1786 let Inst{27-21} = 0b0111101;
1787 let Inst{6-4} = 0b101;
1788 let Inst{20-16} = width;
1789 let Inst{15-12} = Rd;
1790 let Inst{11-7} = lsb;
1794 def UBFX : I<(outs GPR:$Rd),
1795 (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width),
1796 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1797 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
1798 Requires<[IsARM, HasV6T2]> {
1803 let Inst{27-21} = 0b0111111;
1804 let Inst{6-4} = 0b101;
1805 let Inst{20-16} = width;
1806 let Inst{15-12} = Rd;
1807 let Inst{11-7} = lsb;
1811 //===----------------------------------------------------------------------===//
1812 // Arithmetic Instructions.
1815 defm ADD : AsI1_bin_irs<0b0100, "add",
1816 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1817 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1818 defm SUB : AsI1_bin_irs<0b0010, "sub",
1819 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1820 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1822 // ADD and SUB with 's' bit set.
1823 defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1824 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1825 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1826 defm SUBS : AI1_bin_s_irs<0b0010, "subs",
1827 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
1828 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
1830 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
1831 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
1832 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
1833 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
1834 defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
1835 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
1836 defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
1837 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
1839 def RSBri : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1840 IIC_iALUi, "rsb", "\t$Rd, $Rn, $imm",
1841 [(set GPR:$Rd, (sub so_imm:$imm, GPR:$Rn))]> {
1846 let Inst{15-12} = Rd;
1847 let Inst{19-16} = Rn;
1848 let Inst{11-0} = imm;
1851 // The reg/reg form is only defined for the disassembler; for codegen it is
1852 // equivalent to SUBrr.
1853 def RSBrr : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1854 IIC_iALUr, "rsb", "\t$Rd, $Rn, $Rm",
1855 [/* For disassembly only; pattern left blank */]> {
1859 let Inst{11-4} = 0b00000000;
1862 let Inst{15-12} = Rd;
1863 let Inst{19-16} = Rn;
1866 def RSBrs : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
1867 DPSoRegFrm, IIC_iALUsr, "rsb", "\t$Rd, $Rn, $shift",
1868 [(set GPR:$Rd, (sub so_reg:$shift, GPR:$Rn))]> {
1873 let Inst{11-0} = shift;
1874 let Inst{15-12} = Rd;
1875 let Inst{19-16} = Rn;
1878 // RSB with 's' bit set.
1879 let Defs = [CPSR] in {
1880 def RSBSri : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1881 IIC_iALUi, "rsbs", "\t$Rd, $Rn, $imm",
1882 [(set GPR:$Rd, (subc so_imm:$imm, GPR:$Rn))]> {
1888 let Inst{15-12} = Rd;
1889 let Inst{19-16} = Rn;
1890 let Inst{11-0} = imm;
1892 def RSBSrs : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
1893 DPSoRegFrm, IIC_iALUsr, "rsbs", "\t$Rd, $Rn, $shift",
1894 [(set GPR:$Rd, (subc so_reg:$shift, GPR:$Rn))]> {
1900 let Inst{11-0} = shift;
1901 let Inst{15-12} = Rd;
1902 let Inst{19-16} = Rn;
1906 let Uses = [CPSR] in {
1907 def RSCri : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1908 DPFrm, IIC_iALUi, "rsc", "\t$Rd, $Rn, $imm",
1909 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
1915 let Inst{15-12} = Rd;
1916 let Inst{19-16} = Rn;
1917 let Inst{11-0} = imm;
1919 // The reg/reg form is only defined for the disassembler; for codegen it is
1920 // equivalent to SUBrr.
1921 def RSCrr : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1922 DPFrm, IIC_iALUr, "rsc", "\t$Rd, $Rn, $Rm",
1923 [/* For disassembly only; pattern left blank */]> {
1927 let Inst{11-4} = 0b00000000;
1930 let Inst{15-12} = Rd;
1931 let Inst{19-16} = Rn;
1933 def RSCrs : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
1934 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$Rd, $Rn, $shift",
1935 [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>,
1941 let Inst{11-0} = shift;
1942 let Inst{15-12} = Rd;
1943 let Inst{19-16} = Rn;
1947 // FIXME: Allow these to be predicated.
1948 let Defs = [CPSR], Uses = [CPSR] in {
1949 def RSCSri : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1950 DPFrm, IIC_iALUi, "rscs\t$Rd, $Rn, $imm",
1951 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
1958 let Inst{15-12} = Rd;
1959 let Inst{19-16} = Rn;
1960 let Inst{11-0} = imm;
1962 def RSCSrs : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
1963 DPSoRegFrm, IIC_iALUsr, "rscs\t$Rd, $Rn, $shift",
1964 [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>,
1971 let Inst{11-0} = shift;
1972 let Inst{15-12} = Rd;
1973 let Inst{19-16} = Rn;
1977 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1978 // The assume-no-carry-in form uses the negation of the input since add/sub
1979 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
1980 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
1982 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1983 (SUBri GPR:$src, so_imm_neg:$imm)>;
1984 def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1985 (SUBSri GPR:$src, so_imm_neg:$imm)>;
1986 // The with-carry-in form matches bitwise not instead of the negation.
1987 // Effectively, the inverse interpretation of the carry flag already accounts
1988 // for part of the negation.
1989 def : ARMPat<(adde GPR:$src, so_imm_not:$imm),
1990 (SBCri GPR:$src, so_imm_not:$imm)>;
1992 // Note: These are implemented in C++ code, because they have to generate
1993 // ADD/SUBrs instructions, which use a complex pattern that a xform function
1995 // (mul X, 2^n+1) -> (add (X << n), X)
1996 // (mul X, 2^n-1) -> (rsb X, (X << n))
1998 // ARM Arithmetic Instruction -- for disassembly only
1999 // GPR:$dst = GPR:$a op GPR:$b
2000 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
2001 list<dag> pattern = [/* For disassembly only; pattern left blank */]>
2002 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iALUr,
2003 opc, "\t$Rd, $Rn, $Rm", pattern> {
2007 let Inst{27-20} = op27_20;
2008 let Inst{11-4} = op11_4;
2009 let Inst{19-16} = Rn;
2010 let Inst{15-12} = Rd;
2014 // Saturating add/subtract -- for disassembly only
2016 def QADD : AAI<0b00010000, 0b00000101, "qadd",
2017 [(set GPR:$Rd, (int_arm_qadd GPR:$Rn, GPR:$Rm))]>;
2018 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
2019 [(set GPR:$Rd, (int_arm_qsub GPR:$Rn, GPR:$Rm))]>;
2020 def QDADD : AAI<0b00010100, 0b00000101, "qdadd">;
2021 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub">;
2023 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
2024 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
2025 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
2026 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
2027 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
2028 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
2029 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
2030 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
2031 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
2032 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
2033 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
2034 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
2036 // Signed/Unsigned add/subtract -- for disassembly only
2038 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
2039 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
2040 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
2041 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
2042 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
2043 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
2044 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
2045 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
2046 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
2047 def USAX : AAI<0b01100101, 0b11110101, "usax">;
2048 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
2049 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
2051 // Signed/Unsigned halving add/subtract -- for disassembly only
2053 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
2054 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
2055 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
2056 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
2057 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
2058 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
2059 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
2060 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
2061 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
2062 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
2063 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
2064 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
2066 // Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
2068 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2069 MulFrm /* for convenience */, NoItinerary, "usad8",
2070 "\t$Rd, $Rn, $Rm", []>,
2071 Requires<[IsARM, HasV6]> {
2075 let Inst{27-20} = 0b01111000;
2076 let Inst{15-12} = 0b1111;
2077 let Inst{7-4} = 0b0001;
2078 let Inst{19-16} = Rd;
2079 let Inst{11-8} = Rm;
2082 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2083 MulFrm /* for convenience */, NoItinerary, "usada8",
2084 "\t$Rd, $Rn, $Rm, $Ra", []>,
2085 Requires<[IsARM, HasV6]> {
2090 let Inst{27-20} = 0b01111000;
2091 let Inst{7-4} = 0b0001;
2092 let Inst{19-16} = Rd;
2093 let Inst{15-12} = Ra;
2094 let Inst{11-8} = Rm;
2098 // Signed/Unsigned saturate -- for disassembly only
2100 def SSAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
2101 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $a$sh",
2102 [/* For disassembly only; pattern left blank */]> {
2107 let Inst{27-21} = 0b0110101;
2108 let Inst{5-4} = 0b01;
2109 let Inst{20-16} = sat_imm;
2110 let Inst{15-12} = Rd;
2111 let Inst{11-7} = sh{7-3};
2112 let Inst{6} = sh{0};
2116 def SSAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$Rn), SatFrm,
2117 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn",
2118 [/* For disassembly only; pattern left blank */]> {
2122 let Inst{27-20} = 0b01101010;
2123 let Inst{11-4} = 0b11110011;
2124 let Inst{15-12} = Rd;
2125 let Inst{19-16} = sat_imm;
2129 def USAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
2130 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $a$sh",
2131 [/* For disassembly only; pattern left blank */]> {
2136 let Inst{27-21} = 0b0110111;
2137 let Inst{5-4} = 0b01;
2138 let Inst{15-12} = Rd;
2139 let Inst{11-7} = sh{7-3};
2140 let Inst{6} = sh{0};
2141 let Inst{20-16} = sat_imm;
2145 def USAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a), SatFrm,
2146 NoItinerary, "usat16", "\t$Rd, $sat_imm, $a",
2147 [/* For disassembly only; pattern left blank */]> {
2151 let Inst{27-20} = 0b01101110;
2152 let Inst{11-4} = 0b11110011;
2153 let Inst{15-12} = Rd;
2154 let Inst{19-16} = sat_imm;
2158 def : ARMV6Pat<(int_arm_ssat GPR:$a, imm:$pos), (SSAT imm:$pos, GPR:$a, 0)>;
2159 def : ARMV6Pat<(int_arm_usat GPR:$a, imm:$pos), (USAT imm:$pos, GPR:$a, 0)>;
2161 //===----------------------------------------------------------------------===//
2162 // Bitwise Instructions.
2165 defm AND : AsI1_bin_irs<0b0000, "and",
2166 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2167 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
2168 defm ORR : AsI1_bin_irs<0b1100, "orr",
2169 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2170 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
2171 defm EOR : AsI1_bin_irs<0b0001, "eor",
2172 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2173 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
2174 defm BIC : AsI1_bin_irs<0b1110, "bic",
2175 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2176 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
2178 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
2179 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2180 "bfc", "\t$Rd, $imm", "$src = $Rd",
2181 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
2182 Requires<[IsARM, HasV6T2]> {
2185 let Inst{27-21} = 0b0111110;
2186 let Inst{6-0} = 0b0011111;
2187 let Inst{15-12} = Rd;
2188 let Inst{11-7} = imm{4-0}; // lsb
2189 let Inst{20-16} = imm{9-5}; // width
2192 // A8.6.18 BFI - Bitfield insert (Encoding A1)
2193 def BFI : I<(outs GPR:$Rd), (ins GPR:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
2194 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2195 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
2196 [(set GPR:$Rd, (ARMbfi GPR:$src, GPR:$Rn,
2197 bf_inv_mask_imm:$imm))]>,
2198 Requires<[IsARM, HasV6T2]> {
2202 let Inst{27-21} = 0b0111110;
2203 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
2204 let Inst{15-12} = Rd;
2205 let Inst{11-7} = imm{4-0}; // lsb
2206 let Inst{20-16} = imm{9-5}; // width
2210 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
2211 "mvn", "\t$Rd, $Rm",
2212 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
2216 let Inst{19-16} = 0b0000;
2217 let Inst{11-4} = 0b00000000;
2218 let Inst{15-12} = Rd;
2221 def MVNs : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg:$shift), DPSoRegFrm,
2222 IIC_iMVNsr, "mvn", "\t$Rd, $shift",
2223 [(set GPR:$Rd, (not so_reg:$shift))]>, UnaryDP {
2228 let Inst{19-16} = 0b0000;
2229 let Inst{15-12} = Rd;
2230 let Inst{11-0} = shift;
2232 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
2233 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
2234 IIC_iMVNi, "mvn", "\t$Rd, $imm",
2235 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
2240 let Inst{19-16} = 0b0000;
2241 let Inst{15-12} = Rd;
2242 let Inst{11-0} = imm;
2245 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
2246 (BICri GPR:$src, so_imm_not:$imm)>;
2248 //===----------------------------------------------------------------------===//
2249 // Multiply Instructions.
2251 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
2252 string opc, string asm, list<dag> pattern>
2253 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
2257 let Inst{19-16} = Rd;
2258 let Inst{11-8} = Rm;
2261 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
2262 string opc, string asm, list<dag> pattern>
2263 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
2268 let Inst{19-16} = RdHi;
2269 let Inst{15-12} = RdLo;
2270 let Inst{11-8} = Rm;
2274 let isCommutable = 1 in
2275 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2276 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
2277 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>;
2279 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2280 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
2281 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]> {
2283 let Inst{15-12} = Ra;
2286 def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
2287 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
2288 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
2289 Requires<[IsARM, HasV6T2]> {
2293 let Inst{19-16} = Rd;
2294 let Inst{11-8} = Rm;
2298 // Extra precision multiplies with low / high results
2300 let neverHasSideEffects = 1 in {
2301 let isCommutable = 1 in {
2302 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
2303 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
2304 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2306 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
2307 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
2308 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2311 // Multiply + accumulate
2312 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
2313 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2314 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2316 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
2317 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2318 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2320 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
2321 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2322 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2323 Requires<[IsARM, HasV6]> {
2328 let Inst{19-16} = RdLo;
2329 let Inst{15-12} = RdHi;
2330 let Inst{11-8} = Rm;
2333 } // neverHasSideEffects
2335 // Most significant word multiply
2336 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2337 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
2338 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
2339 Requires<[IsARM, HasV6]> {
2340 let Inst{15-12} = 0b1111;
2343 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2344 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
2345 [/* For disassembly only; pattern left blank */]>,
2346 Requires<[IsARM, HasV6]> {
2347 let Inst{15-12} = 0b1111;
2350 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
2351 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2352 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
2353 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
2354 Requires<[IsARM, HasV6]>;
2356 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
2357 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2358 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
2359 [/* For disassembly only; pattern left blank */]>,
2360 Requires<[IsARM, HasV6]>;
2362 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
2363 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2364 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
2365 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
2366 Requires<[IsARM, HasV6]>;
2368 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
2369 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2370 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
2371 [/* For disassembly only; pattern left blank */]>,
2372 Requires<[IsARM, HasV6]>;
2374 multiclass AI_smul<string opc, PatFrag opnode> {
2375 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2376 IIC_iMUL16, !strconcat(opc, "bb"), "\t$dst, $a, $b",
2377 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
2378 (sext_inreg GPR:$b, i16)))]>,
2379 Requires<[IsARM, HasV5TE]> {
2382 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2383 IIC_iMUL16, !strconcat(opc, "bt"), "\t$dst, $a, $b",
2384 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
2385 (sra GPR:$b, (i32 16))))]>,
2386 Requires<[IsARM, HasV5TE]> {
2389 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2390 IIC_iMUL16, !strconcat(opc, "tb"), "\t$dst, $a, $b",
2391 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
2392 (sext_inreg GPR:$b, i16)))]>,
2393 Requires<[IsARM, HasV5TE]> {
2396 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2397 IIC_iMUL16, !strconcat(opc, "tt"), "\t$dst, $a, $b",
2398 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
2399 (sra GPR:$b, (i32 16))))]>,
2400 Requires<[IsARM, HasV5TE]> {
2403 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2404 IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b",
2405 [(set GPR:$dst, (sra (opnode GPR:$a,
2406 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
2407 Requires<[IsARM, HasV5TE]> {
2410 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2411 IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b",
2412 [(set GPR:$dst, (sra (opnode GPR:$a,
2413 (sra GPR:$b, (i32 16))), (i32 16)))]>,
2414 Requires<[IsARM, HasV5TE]> {
2419 multiclass AI_smla<string opc, PatFrag opnode> {
2420 def BB : AMulxyI<0b0001000, 0b00, (outs GPR:$dst),
2421 (ins GPR:$a, GPR:$b, GPR:$acc),
2422 IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
2423 [(set GPR:$dst, (add GPR:$acc,
2424 (opnode (sext_inreg GPR:$a, i16),
2425 (sext_inreg GPR:$b, i16))))]>,
2426 Requires<[IsARM, HasV5TE]> {
2429 def BT : AMulxyI<0b0001000, 0b10, (outs GPR:$dst),
2430 (ins GPR:$a, GPR:$b, GPR:$acc),
2431 IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
2432 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
2433 (sra GPR:$b, (i32 16)))))]>,
2434 Requires<[IsARM, HasV5TE]> {
2437 def TB : AMulxyI<0b0001000, 0b01, (outs GPR:$dst),
2438 (ins GPR:$a, GPR:$b, GPR:$acc),
2439 IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
2440 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
2441 (sext_inreg GPR:$b, i16))))]>,
2442 Requires<[IsARM, HasV5TE]> {
2445 def TT : AMulxyI<0b0001000, 0b11, (outs GPR:$dst),
2446 (ins GPR:$a, GPR:$b, GPR:$acc),
2447 IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
2448 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
2449 (sra GPR:$b, (i32 16)))))]>,
2450 Requires<[IsARM, HasV5TE]> {
2453 def WB : AMulxyI<0b0001001, 0b00, (outs GPR:$dst),
2454 (ins GPR:$a, GPR:$b, GPR:$acc),
2455 IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
2456 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
2457 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
2458 Requires<[IsARM, HasV5TE]> {
2461 def WT : AMulxyI<0b0001001, 0b10, (outs GPR:$dst),
2462 (ins GPR:$a, GPR:$b, GPR:$acc),
2463 IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
2464 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
2465 (sra GPR:$b, (i32 16))), (i32 16))))]>,
2466 Requires<[IsARM, HasV5TE]> {
2470 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2471 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2473 // Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only
2474 def SMLALBB : AMulxyI<0b0001010, 0b00, (outs GPR:$ldst, GPR:$hdst),
2475 (ins GPR:$a, GPR:$b),
2476 IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
2477 [/* For disassembly only; pattern left blank */]>,
2478 Requires<[IsARM, HasV5TE]> {
2481 def SMLALBT : AMulxyI<0b0001010, 0b10, (outs GPR:$ldst, GPR:$hdst),
2482 (ins GPR:$a, GPR:$b),
2483 IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
2484 [/* For disassembly only; pattern left blank */]>,
2485 Requires<[IsARM, HasV5TE]> {
2488 def SMLALTB : AMulxyI<0b0001010, 0b01, (outs GPR:$ldst, GPR:$hdst),
2489 (ins GPR:$a, GPR:$b),
2490 IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
2491 [/* For disassembly only; pattern left blank */]>,
2492 Requires<[IsARM, HasV5TE]> {
2495 def SMLALTT : AMulxyI<0b0001010, 0b11, (outs GPR:$ldst, GPR:$hdst),
2496 (ins GPR:$a, GPR:$b),
2497 IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
2498 [/* For disassembly only; pattern left blank */]>,
2499 Requires<[IsARM, HasV5TE]> {
2502 // Helper class for AI_smld -- for disassembly only
2503 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
2504 InstrItinClass itin, string opc, string asm>
2505 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
2510 let Inst{21-20} = 0b00;
2511 let Inst{22} = long;
2512 let Inst{27-23} = 0b01110;
2515 multiclass AI_smld<bit sub, string opc> {
2517 def D : AMulDualI<0, sub, 0, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
2518 NoItinerary, !strconcat(opc, "d"), "\t$dst, $a, $b, $acc">;
2520 def DX : AMulDualI<0, sub, 1, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
2521 NoItinerary, !strconcat(opc, "dx"), "\t$dst, $a, $b, $acc">;
2523 def LD : AMulDualI<1, sub, 0, (outs GPR:$ldst,GPR:$hdst), (ins GPR:$a,GPR:$b),
2524 NoItinerary, !strconcat(opc, "ld"), "\t$ldst, $hdst, $a, $b">;
2526 def LDX : AMulDualI<1, sub, 1, (outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
2527 NoItinerary, !strconcat(opc, "ldx"),"\t$ldst, $hdst, $a, $b">;
2531 defm SMLA : AI_smld<0, "smla">;
2532 defm SMLS : AI_smld<1, "smls">;
2534 multiclass AI_sdml<bit sub, string opc> {
2536 def D : AMulDualI<0, sub, 0, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2537 NoItinerary, !strconcat(opc, "d"), "\t$dst, $a, $b"> {
2538 let Inst{15-12} = 0b1111;
2541 def DX : AMulDualI<0, sub, 1, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
2542 NoItinerary, !strconcat(opc, "dx"), "\t$dst, $a, $b"> {
2543 let Inst{15-12} = 0b1111;
2548 defm SMUA : AI_sdml<0, "smua">;
2549 defm SMUS : AI_sdml<1, "smus">;
2551 //===----------------------------------------------------------------------===//
2552 // Misc. Arithmetic Instructions.
2555 def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
2556 "clz", "\t$dst, $src",
2557 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
2558 let Inst{7-4} = 0b0001;
2559 let Inst{11-8} = 0b1111;
2560 let Inst{19-16} = 0b1111;
2563 def RBIT : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
2564 "rbit", "\t$dst, $src",
2565 [(set GPR:$dst, (ARMrbit GPR:$src))]>,
2566 Requires<[IsARM, HasV6T2]> {
2567 let Inst{7-4} = 0b0011;
2568 let Inst{11-8} = 0b1111;
2569 let Inst{19-16} = 0b1111;
2572 def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
2573 "rev", "\t$dst, $src",
2574 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
2575 let Inst{7-4} = 0b0011;
2576 let Inst{11-8} = 0b1111;
2577 let Inst{19-16} = 0b1111;
2580 def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
2581 "rev16", "\t$dst, $src",
2583 (or (and (srl GPR:$src, (i32 8)), 0xFF),
2584 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
2585 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
2586 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
2587 Requires<[IsARM, HasV6]> {
2588 let Inst{7-4} = 0b1011;
2589 let Inst{11-8} = 0b1111;
2590 let Inst{19-16} = 0b1111;
2593 def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
2594 "revsh", "\t$dst, $src",
2597 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
2598 (shl GPR:$src, (i32 8))), i16))]>,
2599 Requires<[IsARM, HasV6]> {
2600 let Inst{7-4} = 0b1011;
2601 let Inst{11-8} = 0b1111;
2602 let Inst{19-16} = 0b1111;
2605 def lsl_shift_imm : SDNodeXForm<imm, [{
2606 unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::lsl, N->getZExtValue());
2607 return CurDAG->getTargetConstant(Sh, MVT::i32);
2610 def lsl_amt : PatLeaf<(i32 imm), [{
2611 return (N->getZExtValue() < 32);
2614 def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
2615 (ins GPR:$src1, GPR:$src2, shift_imm:$sh),
2616 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2$sh",
2617 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
2618 (and (shl GPR:$src2, lsl_amt:$sh),
2620 Requires<[IsARM, HasV6]> {
2621 let Inst{6-4} = 0b001;
2624 // Alternate cases for PKHBT where identities eliminate some nodes.
2625 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
2626 (PKHBT GPR:$src1, GPR:$src2, 0)>;
2627 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$sh)),
2628 (PKHBT GPR:$src1, GPR:$src2, (lsl_shift_imm imm16_31:$sh))>;
2630 def asr_shift_imm : SDNodeXForm<imm, [{
2631 unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::asr, N->getZExtValue());
2632 return CurDAG->getTargetConstant(Sh, MVT::i32);
2635 def asr_amt : PatLeaf<(i32 imm), [{
2636 return (N->getZExtValue() <= 32);
2639 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2640 // will match the pattern below.
2641 def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
2642 (ins GPR:$src1, GPR:$src2, shift_imm:$sh),
2643 IIC_iBITsi, "pkhtb", "\t$dst, $src1, $src2$sh",
2644 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
2645 (and (sra GPR:$src2, asr_amt:$sh),
2647 Requires<[IsARM, HasV6]> {
2648 let Inst{6-4} = 0b101;
2651 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
2652 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
2653 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, imm16_31:$sh)),
2654 (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm16_31:$sh))>;
2655 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
2656 (and (srl GPR:$src2, imm1_15:$sh), 0xFFFF)),
2657 (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm1_15:$sh))>;
2659 //===----------------------------------------------------------------------===//
2660 // Comparison Instructions...
2663 defm CMP : AI1_cmp_irs<0b1010, "cmp",
2664 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2665 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2667 // FIXME: We have to be careful when using the CMN instruction and comparison
2668 // with 0. One would expect these two pieces of code should give identical
2684 // However, the CMN gives the *opposite* result when r1 is 0. This is because
2685 // the carry flag is set in the CMP case but not in the CMN case. In short, the
2686 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
2687 // value of r0 and the carry bit (because the "carry bit" parameter to
2688 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
2689 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
2690 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
2691 // parameter to AddWithCarry is defined as 0).
2693 // When x is 0 and unsigned:
2697 // ~x + 1 = 0x1 0000 0000
2698 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
2700 // Therefore, we should disable CMN when comparing against zero, until we can
2701 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
2702 // when it's a comparison which doesn't look at the 'carry' flag).
2704 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
2706 // This is related to <rdar://problem/7569620>.
2708 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
2709 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
2711 // Note that TST/TEQ don't set all the same flags that CMP does!
2712 defm TST : AI1_cmp_irs<0b1000, "tst",
2713 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
2714 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
2715 defm TEQ : AI1_cmp_irs<0b1001, "teq",
2716 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
2717 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
2719 defm CMPz : AI1_cmp_irs<0b1010, "cmp",
2720 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2721 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
2722 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
2723 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2724 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2726 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
2727 // (CMNri GPR:$src, so_imm_neg:$imm)>;
2729 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
2730 (CMNzri GPR:$src, so_imm_neg:$imm)>;
2732 // Pseudo i64 compares for some floating point compares.
2733 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
2735 def BCCi64 : PseudoInst<(outs),
2736 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
2738 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
2740 def BCCZi64 : PseudoInst<(outs),
2741 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br, "",
2742 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
2743 } // usesCustomInserter
2746 // Conditional moves
2747 // FIXME: should be able to write a pattern for ARMcmov, but can't use
2748 // a two-value operand where a dag node expects two operands. :(
2749 // FIXME: These should all be pseudo-instructions that get expanded to
2750 // the normal MOV instructions. That would fix the dependency on
2751 // special casing them in tblgen.
2752 let neverHasSideEffects = 1 in {
2753 def MOVCCr : AI1<0b1101, (outs GPR:$Rd), (ins GPR:$false, GPR:$Rm), DPFrm,
2754 IIC_iCMOVr, "mov", "\t$Rd, $Rm",
2755 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
2756 RegConstraint<"$false = $Rd">, UnaryDP {
2760 let Inst{11-4} = 0b00000000;
2763 let Inst{15-12} = Rd;
2764 let Inst{11-4} = 0b00000000;
2768 def MOVCCs : AI1<0b1101, (outs GPR:$dst),
2769 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
2770 "mov", "\t$dst, $true",
2771 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
2772 RegConstraint<"$false = $dst">, UnaryDP {
2776 def MOVCCi16 : AI1<0b1000, (outs GPR:$dst), (ins GPR:$false, i32imm:$src),
2778 "movw", "\t$dst, $src",
2780 RegConstraint<"$false = $dst">, Requires<[IsARM, HasV6T2]>,
2786 def MOVCCi : AI1<0b1101, (outs GPR:$dst),
2787 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
2788 "mov", "\t$dst, $true",
2789 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
2790 RegConstraint<"$false = $dst">, UnaryDP {
2793 } // neverHasSideEffects
2795 //===----------------------------------------------------------------------===//
2796 // Atomic operations intrinsics
2799 // memory barriers protect the atomic sequences
2800 let hasSideEffects = 1 in {
2801 def DMBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "dmb", "",
2802 [(ARMMemBarrier)]>, Requires<[IsARM, HasDB]> {
2803 let Inst{31-4} = 0xf57ff05;
2804 // FIXME: add support for options other than a full system DMB
2805 // See DMB disassembly-only variants below.
2806 let Inst{3-0} = 0b1111;
2809 def DSBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "dsb", "",
2810 [(ARMSyncBarrier)]>, Requires<[IsARM, HasDB]> {
2811 let Inst{31-4} = 0xf57ff04;
2812 // FIXME: add support for options other than a full system DSB
2813 // See DSB disassembly-only variants below.
2814 let Inst{3-0} = 0b1111;
2817 def DMB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary,
2818 "mcr", "\tp15, 0, $zero, c7, c10, 5",
2819 [(ARMMemBarrierMCR GPR:$zero)]>,
2820 Requires<[IsARM, HasV6]> {
2821 // FIXME: add support for options other than a full system DMB
2822 // FIXME: add encoding
2825 def DSB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary,
2826 "mcr", "\tp15, 0, $zero, c7, c10, 4",
2827 [(ARMSyncBarrierMCR GPR:$zero)]>,
2828 Requires<[IsARM, HasV6]> {
2829 // FIXME: add support for options other than a full system DSB
2830 // FIXME: add encoding
2834 // Memory Barrier Operations Variants -- for disassembly only
2836 def memb_opt : Operand<i32> {
2837 let PrintMethod = "printMemBOption";
2840 class AMBI<bits<4> op7_4, string opc>
2841 : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, opc, "\t$opt",
2842 [/* For disassembly only; pattern left blank */]>,
2843 Requires<[IsARM, HasDB]> {
2844 let Inst{31-8} = 0xf57ff0;
2845 let Inst{7-4} = op7_4;
2848 // These DMB variants are for disassembly only.
2849 def DMBvar : AMBI<0b0101, "dmb">;
2851 // These DSB variants are for disassembly only.
2852 def DSBvar : AMBI<0b0100, "dsb">;
2854 // ISB has only full system option -- for disassembly only
2855 def ISBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "isb", "", []>,
2856 Requires<[IsARM, HasDB]> {
2857 let Inst{31-4} = 0xf57ff06;
2858 let Inst{3-0} = 0b1111;
2861 let usesCustomInserter = 1 in {
2862 let Uses = [CPSR] in {
2863 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
2864 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2865 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
2866 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
2867 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2868 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
2869 def ATOMIC_LOAD_AND_I8 : PseudoInst<
2870 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2871 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
2872 def ATOMIC_LOAD_OR_I8 : PseudoInst<
2873 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2874 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
2875 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
2876 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2877 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
2878 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
2879 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2880 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
2881 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
2882 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2883 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
2884 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
2885 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2886 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
2887 def ATOMIC_LOAD_AND_I16 : PseudoInst<
2888 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2889 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
2890 def ATOMIC_LOAD_OR_I16 : PseudoInst<
2891 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2892 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
2893 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
2894 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2895 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
2896 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
2897 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2898 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
2899 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
2900 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2901 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
2902 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
2903 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2904 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
2905 def ATOMIC_LOAD_AND_I32 : PseudoInst<
2906 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2907 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
2908 def ATOMIC_LOAD_OR_I32 : PseudoInst<
2909 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2910 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
2911 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
2912 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2913 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
2914 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
2915 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
2916 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
2918 def ATOMIC_SWAP_I8 : PseudoInst<
2919 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
2920 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
2921 def ATOMIC_SWAP_I16 : PseudoInst<
2922 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
2923 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
2924 def ATOMIC_SWAP_I32 : PseudoInst<
2925 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
2926 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
2928 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
2929 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
2930 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
2931 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
2932 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
2933 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
2934 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
2935 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
2936 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
2940 let mayLoad = 1 in {
2941 def LDREXB : AIldrex<0b10, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
2942 "ldrexb", "\t$dest, [$ptr]",
2944 def LDREXH : AIldrex<0b11, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
2945 "ldrexh", "\t$dest, [$ptr]",
2947 def LDREX : AIldrex<0b00, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
2948 "ldrex", "\t$dest, [$ptr]",
2950 def LDREXD : AIldrex<0b01, (outs GPR:$dest, GPR:$dest2), (ins GPR:$ptr),
2952 "ldrexd", "\t$dest, $dest2, [$ptr]",
2956 let mayStore = 1, Constraints = "@earlyclobber $success" in {
2957 def STREXB : AIstrex<0b10, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
2959 "strexb", "\t$success, $src, [$ptr]",
2961 def STREXH : AIstrex<0b11, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
2963 "strexh", "\t$success, $src, [$ptr]",
2965 def STREX : AIstrex<0b00, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
2967 "strex", "\t$success, $src, [$ptr]",
2969 def STREXD : AIstrex<0b01, (outs GPR:$success),
2970 (ins GPR:$src, GPR:$src2, GPR:$ptr),
2972 "strexd", "\t$success, $src, $src2, [$ptr]",
2976 // Clear-Exclusive is for disassembly only.
2977 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
2978 [/* For disassembly only; pattern left blank */]>,
2979 Requires<[IsARM, HasV7]> {
2980 let Inst{31-20} = 0xf57;
2981 let Inst{7-4} = 0b0001;
2984 // SWP/SWPB are deprecated in V6/V7 and for disassembly only.
2985 let mayLoad = 1 in {
2986 def SWP : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2987 "swp", "\t$dst, $src, [$ptr]",
2988 [/* For disassembly only; pattern left blank */]> {
2989 let Inst{27-23} = 0b00010;
2990 let Inst{22} = 0; // B = 0
2991 let Inst{21-20} = 0b00;
2992 let Inst{7-4} = 0b1001;
2995 def SWPB : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2996 "swpb", "\t$dst, $src, [$ptr]",
2997 [/* For disassembly only; pattern left blank */]> {
2998 let Inst{27-23} = 0b00010;
2999 let Inst{22} = 1; // B = 1
3000 let Inst{21-20} = 0b00;
3001 let Inst{7-4} = 0b1001;
3005 //===----------------------------------------------------------------------===//
3009 // __aeabi_read_tp preserves the registers r1-r3.
3011 Defs = [R0, R12, LR, CPSR] in {
3012 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
3013 "bl\t__aeabi_read_tp",
3014 [(set R0, ARMthread_pointer)]>;
3017 //===----------------------------------------------------------------------===//
3018 // SJLJ Exception handling intrinsics
3019 // eh_sjlj_setjmp() is an instruction sequence to store the return
3020 // address and save #0 in R0 for the non-longjmp case.
3021 // Since by its nature we may be coming from some other function to get
3022 // here, and we're using the stack frame for the containing function to
3023 // save/restore registers, we can't keep anything live in regs across
3024 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
3025 // when we get here from a longjmp(). We force everthing out of registers
3026 // except for our own input by listing the relevant registers in Defs. By
3027 // doing so, we also cause the prologue/epilogue code to actively preserve
3028 // all of the callee-saved resgisters, which is exactly what we want.
3029 // A constant value is passed in $val, and we use the location as a scratch.
3031 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
3032 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
3033 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
3034 D31 ], hasSideEffects = 1, isBarrier = 1 in {
3035 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
3036 AddrModeNone, SizeSpecial, IndexModeNone,
3037 Pseudo, NoItinerary, "", "",
3038 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
3039 Requires<[IsARM, HasVFP2]>;
3043 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
3044 hasSideEffects = 1, isBarrier = 1 in {
3045 def Int_eh_sjlj_setjmp_nofp : XI<(outs), (ins GPR:$src, GPR:$val),
3046 AddrModeNone, SizeSpecial, IndexModeNone,
3047 Pseudo, NoItinerary, "", "",
3048 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
3049 Requires<[IsARM, NoVFP]>;
3052 // FIXME: Non-Darwin version(s)
3053 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
3054 Defs = [ R7, LR, SP ] in {
3055 def Int_eh_sjlj_longjmp : XI<(outs), (ins GPR:$src, GPR:$scratch),
3056 AddrModeNone, SizeSpecial, IndexModeNone,
3057 Pseudo, NoItinerary, "", "",
3058 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
3059 Requires<[IsARM, IsDarwin]>;
3062 // eh.sjlj.dispatchsetup pseudo-instruction.
3063 // This pseudo is usef for ARM, Thumb1 and Thumb2. Any differences are
3064 // handled when the pseudo is expanded (which happens before any passes
3065 // that need the instruction size).
3066 let isBarrier = 1, hasSideEffects = 1 in
3067 def Int_eh_sjlj_dispatchsetup :
3068 PseudoInst<(outs), (ins GPR:$src), NoItinerary, "",
3069 [(ARMeh_sjlj_dispatchsetup GPR:$src)]>,
3070 Requires<[IsDarwin]>;
3072 //===----------------------------------------------------------------------===//
3073 // Non-Instruction Patterns
3076 // Large immediate handling.
3078 // Two piece so_imms.
3079 // FIXME: Expand this in ARMExpandPseudoInsts.
3080 // FIXME: Remove this when we can do generalized remat.
3081 let isReMaterializable = 1 in
3082 def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
3083 Pseudo, IIC_iMOVix2,
3084 "mov", "\t$dst, $src",
3085 [(set GPR:$dst, so_imm2part:$src)]>,
3086 Requires<[IsARM, NoV6T2]>;
3088 def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
3089 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3090 (so_imm2part_2 imm:$RHS))>;
3091 def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
3092 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3093 (so_imm2part_2 imm:$RHS))>;
3094 def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
3095 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3096 (so_imm2part_2 imm:$RHS))>;
3097 def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
3098 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
3099 (so_neg_imm2part_2 imm:$RHS))>;
3101 // 32-bit immediate using movw + movt.
3102 // This is a single pseudo instruction, the benefit is that it can be remat'd
3103 // as a single unit instead of having to handle reg inputs.
3104 // FIXME: Remove this when we can do generalized remat.
3105 let isReMaterializable = 1 in
3106 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2, "",
3107 [(set GPR:$dst, (i32 imm:$src))]>,
3108 Requires<[IsARM, HasV6T2]>;
3110 // ConstantPool, GlobalAddress, and JumpTable
3111 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
3112 Requires<[IsARM, DontUseMovt]>;
3113 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
3114 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
3115 Requires<[IsARM, UseMovt]>;
3116 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3117 (LEApcrelJT tjumptable:$dst, imm:$id)>;
3119 // TODO: add,sub,and, 3-instr forms?
3122 def : ARMPat<(ARMtcret tcGPR:$dst),
3123 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
3125 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
3126 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
3128 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
3129 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
3131 def : ARMPat<(ARMtcret tcGPR:$dst),
3132 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
3134 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
3135 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
3137 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
3138 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
3141 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
3142 Requires<[IsARM, IsNotDarwin]>;
3143 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
3144 Requires<[IsARM, IsDarwin]>;
3146 // zextload i1 -> zextload i8
3147 def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
3149 // extload -> zextload
3150 def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
3151 def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
3152 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
3154 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
3155 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
3158 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3159 (sra (shl GPR:$b, (i32 16)), (i32 16))),
3160 (SMULBB GPR:$a, GPR:$b)>;
3161 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
3162 (SMULBB GPR:$a, GPR:$b)>;
3163 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3164 (sra GPR:$b, (i32 16))),
3165 (SMULBT GPR:$a, GPR:$b)>;
3166 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
3167 (SMULBT GPR:$a, GPR:$b)>;
3168 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
3169 (sra (shl GPR:$b, (i32 16)), (i32 16))),
3170 (SMULTB GPR:$a, GPR:$b)>;
3171 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
3172 (SMULTB GPR:$a, GPR:$b)>;
3173 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
3175 (SMULWB GPR:$a, GPR:$b)>;
3176 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
3177 (SMULWB GPR:$a, GPR:$b)>;
3179 def : ARMV5TEPat<(add GPR:$acc,
3180 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3181 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
3182 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3183 def : ARMV5TEPat<(add GPR:$acc,
3184 (mul sext_16_node:$a, sext_16_node:$b)),
3185 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3186 def : ARMV5TEPat<(add GPR:$acc,
3187 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3188 (sra GPR:$b, (i32 16)))),
3189 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3190 def : ARMV5TEPat<(add GPR:$acc,
3191 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
3192 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3193 def : ARMV5TEPat<(add GPR:$acc,
3194 (mul (sra GPR:$a, (i32 16)),
3195 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
3196 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3197 def : ARMV5TEPat<(add GPR:$acc,
3198 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
3199 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3200 def : ARMV5TEPat<(add GPR:$acc,
3201 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
3203 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3204 def : ARMV5TEPat<(add GPR:$acc,
3205 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
3206 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3208 //===----------------------------------------------------------------------===//
3212 include "ARMInstrThumb.td"
3214 //===----------------------------------------------------------------------===//
3218 include "ARMInstrThumb2.td"
3220 //===----------------------------------------------------------------------===//
3221 // Floating Point Support
3224 include "ARMInstrVFP.td"
3226 //===----------------------------------------------------------------------===//
3227 // Advanced SIMD (NEON) Support
3230 include "ARMInstrNEON.td"
3232 //===----------------------------------------------------------------------===//
3233 // Coprocessor Instructions. For disassembly only.
3236 def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3237 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3238 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
3239 [/* For disassembly only; pattern left blank */]> {
3243 def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3244 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3245 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
3246 [/* For disassembly only; pattern left blank */]> {
3247 let Inst{31-28} = 0b1111;
3251 class ACI<dag oops, dag iops, string opc, string asm>
3252 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
3253 opc, asm, "", [/* For disassembly only; pattern left blank */]> {
3254 let Inst{27-25} = 0b110;
3257 multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
3259 def _OFFSET : ACI<(outs),
3260 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3261 opc, "\tp$cop, cr$CRd, $addr"> {
3262 let Inst{31-28} = op31_28;
3263 let Inst{24} = 1; // P = 1
3264 let Inst{21} = 0; // W = 0
3265 let Inst{22} = 0; // D = 0
3266 let Inst{20} = load;
3269 def _PRE : ACI<(outs),
3270 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3271 opc, "\tp$cop, cr$CRd, $addr!"> {
3272 let Inst{31-28} = op31_28;
3273 let Inst{24} = 1; // P = 1
3274 let Inst{21} = 1; // W = 1
3275 let Inst{22} = 0; // D = 0
3276 let Inst{20} = load;
3279 def _POST : ACI<(outs),
3280 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
3281 opc, "\tp$cop, cr$CRd, [$base], $offset"> {
3282 let Inst{31-28} = op31_28;
3283 let Inst{24} = 0; // P = 0
3284 let Inst{21} = 1; // W = 1
3285 let Inst{22} = 0; // D = 0
3286 let Inst{20} = load;
3289 def _OPTION : ACI<(outs),
3290 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option),
3291 opc, "\tp$cop, cr$CRd, [$base], $option"> {
3292 let Inst{31-28} = op31_28;
3293 let Inst{24} = 0; // P = 0
3294 let Inst{23} = 1; // U = 1
3295 let Inst{21} = 0; // W = 0
3296 let Inst{22} = 0; // D = 0
3297 let Inst{20} = load;
3300 def L_OFFSET : ACI<(outs),
3301 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3302 !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr"> {
3303 let Inst{31-28} = op31_28;
3304 let Inst{24} = 1; // P = 1
3305 let Inst{21} = 0; // W = 0
3306 let Inst{22} = 1; // D = 1
3307 let Inst{20} = load;
3310 def L_PRE : ACI<(outs),
3311 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3312 !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr!"> {
3313 let Inst{31-28} = op31_28;
3314 let Inst{24} = 1; // P = 1
3315 let Inst{21} = 1; // W = 1
3316 let Inst{22} = 1; // D = 1
3317 let Inst{20} = load;
3320 def L_POST : ACI<(outs),
3321 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
3322 !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $offset"> {
3323 let Inst{31-28} = op31_28;
3324 let Inst{24} = 0; // P = 0
3325 let Inst{21} = 1; // W = 1
3326 let Inst{22} = 1; // D = 1
3327 let Inst{20} = load;
3330 def L_OPTION : ACI<(outs),
3331 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option),
3332 !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $option"> {
3333 let Inst{31-28} = op31_28;
3334 let Inst{24} = 0; // P = 0
3335 let Inst{23} = 1; // U = 1
3336 let Inst{21} = 0; // W = 0
3337 let Inst{22} = 1; // D = 1
3338 let Inst{20} = load;
3342 defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">;
3343 defm LDC2 : LdStCop<0b1111, 1, "ldc2">;
3344 defm STC : LdStCop<{?,?,?,?}, 0, "stc">;
3345 defm STC2 : LdStCop<0b1111, 0, "stc2">;
3347 def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3348 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3349 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3350 [/* For disassembly only; pattern left blank */]> {
3355 def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3356 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3357 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3358 [/* For disassembly only; pattern left blank */]> {
3359 let Inst{31-28} = 0b1111;
3364 def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3365 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3366 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3367 [/* For disassembly only; pattern left blank */]> {
3372 def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3373 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3374 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3375 [/* For disassembly only; pattern left blank */]> {
3376 let Inst{31-28} = 0b1111;
3381 def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3382 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3383 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3384 [/* For disassembly only; pattern left blank */]> {
3385 let Inst{23-20} = 0b0100;
3388 def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3389 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3390 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3391 [/* For disassembly only; pattern left blank */]> {
3392 let Inst{31-28} = 0b1111;
3393 let Inst{23-20} = 0b0100;
3396 def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3397 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3398 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3399 [/* For disassembly only; pattern left blank */]> {
3400 let Inst{23-20} = 0b0101;
3403 def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3404 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3405 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3406 [/* For disassembly only; pattern left blank */]> {
3407 let Inst{31-28} = 0b1111;
3408 let Inst{23-20} = 0b0101;
3411 //===----------------------------------------------------------------------===//
3412 // Move between special register and ARM core register -- for disassembly only
3415 def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr",
3416 [/* For disassembly only; pattern left blank */]> {
3417 let Inst{23-20} = 0b0000;
3418 let Inst{7-4} = 0b0000;
3421 def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr",
3422 [/* For disassembly only; pattern left blank */]> {
3423 let Inst{23-20} = 0b0100;
3424 let Inst{7-4} = 0b0000;
3427 def MSR : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary,
3428 "msr", "\tcpsr$mask, $src",
3429 [/* For disassembly only; pattern left blank */]> {
3430 let Inst{23-20} = 0b0010;
3431 let Inst{7-4} = 0b0000;
3434 def MSRi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary,
3435 "msr", "\tcpsr$mask, $a",
3436 [/* For disassembly only; pattern left blank */]> {
3437 let Inst{23-20} = 0b0010;
3438 let Inst{7-4} = 0b0000;
3441 def MSRsys : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary,
3442 "msr", "\tspsr$mask, $src",
3443 [/* For disassembly only; pattern left blank */]> {
3444 let Inst{23-20} = 0b0110;
3445 let Inst{7-4} = 0b0000;
3448 def MSRsysi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary,
3449 "msr", "\tspsr$mask, $a",
3450 [/* For disassembly only; pattern left blank */]> {
3451 let Inst{23-20} = 0b0110;
3452 let Inst{7-4} = 0b0000;