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, 1, [SDTCisInt<0>]>;
65 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
67 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
68 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
71 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
72 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
74 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
75 [SDNPHasChain, SDNPOutFlag]>;
76 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
77 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
79 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
80 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag,
82 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
83 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag,
85 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
86 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag,
89 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
90 [SDNPHasChain, SDNPOptInFlag]>;
92 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
94 def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
97 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
98 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
100 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
102 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
105 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
108 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
111 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
112 [SDNPOutFlag, SDNPCommutative]>;
114 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
116 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
117 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
118 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
120 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
121 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
122 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
123 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
124 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
125 def ARMeh_sjlj_dispatchsetup: SDNode<"ARMISD::EH_SJLJ_DISPATCHSETUP",
126 SDT_ARMEH_SJLJ_DispatchSetup, [SDNPHasChain]>;
129 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
131 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
133 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDTPrefetch,
134 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
136 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
138 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
139 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
142 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
144 //===----------------------------------------------------------------------===//
145 // ARM Instruction Predicate Definitions.
147 def HasV4T : Predicate<"Subtarget->hasV4TOps()">, AssemblerPredicate;
148 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
149 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
150 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">, AssemblerPredicate;
151 def HasV6 : Predicate<"Subtarget->hasV6Ops()">, AssemblerPredicate;
152 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">, AssemblerPredicate;
153 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
154 def HasV7 : Predicate<"Subtarget->hasV7Ops()">, AssemblerPredicate;
155 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
156 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">, AssemblerPredicate;
157 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">, AssemblerPredicate;
158 def HasNEON : Predicate<"Subtarget->hasNEON()">, AssemblerPredicate;
159 def HasDivide : Predicate<"Subtarget->hasDivide()">, AssemblerPredicate;
160 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
162 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
164 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
166 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
167 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
168 def IsThumb : Predicate<"Subtarget->isThumb()">, AssemblerPredicate;
169 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
170 def IsThumb2 : Predicate<"Subtarget->isThumb2()">, AssemblerPredicate;
171 def IsARM : Predicate<"!Subtarget->isThumb()">, AssemblerPredicate;
172 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
173 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
175 // FIXME: Eventually this will be just "hasV6T2Ops".
176 def UseMovt : Predicate<"Subtarget->useMovt()">;
177 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
178 def UseVMLx : Predicate<"Subtarget->useVMLx()">;
180 //===----------------------------------------------------------------------===//
181 // ARM Flag Definitions.
183 class RegConstraint<string C> {
184 string Constraints = C;
187 //===----------------------------------------------------------------------===//
188 // ARM specific transformation functions and pattern fragments.
191 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
192 // so_imm_neg def below.
193 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
194 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
197 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
198 // so_imm_not def below.
199 def so_imm_not_XFORM : SDNodeXForm<imm, [{
200 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
203 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
204 def imm1_15 : PatLeaf<(i32 imm), [{
205 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
208 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
209 def imm16_31 : PatLeaf<(i32 imm), [{
210 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
215 return ARM_AM::getSOImmVal(-(uint32_t)N->getZExtValue()) != -1;
216 }], so_imm_neg_XFORM>;
220 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
221 }], so_imm_not_XFORM>;
223 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
224 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
225 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
228 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
230 def bf_inv_mask_imm : Operand<i32>,
232 return ARM::isBitFieldInvertedMask(N->getZExtValue());
234 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
235 let PrintMethod = "printBitfieldInvMaskImmOperand";
238 /// Split a 32-bit immediate into two 16 bit parts.
239 def hi16 : SDNodeXForm<imm, [{
240 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
243 def lo16AllZero : PatLeaf<(i32 imm), [{
244 // Returns true if all low 16-bits are 0.
245 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
248 /// imm0_65535 predicate - True if the 32-bit immediate is in the range
250 def imm0_65535 : PatLeaf<(i32 imm), [{
251 return (uint32_t)N->getZExtValue() < 65536;
254 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
255 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
257 /// adde and sube predicates - True based on whether the carry flag output
258 /// will be needed or not.
259 def adde_dead_carry :
260 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
261 [{return !N->hasAnyUseOfValue(1);}]>;
262 def sube_dead_carry :
263 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
264 [{return !N->hasAnyUseOfValue(1);}]>;
265 def adde_live_carry :
266 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
267 [{return N->hasAnyUseOfValue(1);}]>;
268 def sube_live_carry :
269 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
270 [{return N->hasAnyUseOfValue(1);}]>;
272 //===----------------------------------------------------------------------===//
273 // Operand Definitions.
277 def brtarget : Operand<OtherVT> {
278 let EncoderMethod = "getBranchTargetOpValue";
282 def bltarget : Operand<i32> {
283 // Encoded the same as branch targets.
284 let EncoderMethod = "getBranchTargetOpValue";
287 // A list of registers separated by comma. Used by load/store multiple.
288 def RegListAsmOperand : AsmOperandClass {
289 let Name = "RegList";
290 let SuperClasses = [];
293 def reglist : Operand<i32> {
294 let EncoderMethod = "getRegisterListOpValue";
295 let ParserMatchClass = RegListAsmOperand;
296 let PrintMethod = "printRegisterList";
299 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
300 def cpinst_operand : Operand<i32> {
301 let PrintMethod = "printCPInstOperand";
304 def jtblock_operand : Operand<i32> {
305 let PrintMethod = "printJTBlockOperand";
307 def jt2block_operand : Operand<i32> {
308 let PrintMethod = "printJT2BlockOperand";
312 def pclabel : Operand<i32> {
313 let PrintMethod = "printPCLabel";
316 def neon_vcvt_imm32 : Operand<i32> {
317 let EncoderMethod = "getNEONVcvtImm32OpValue";
320 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
321 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
322 int32_t v = (int32_t)N->getZExtValue();
323 return v == 8 || v == 16 || v == 24; }]> {
324 let EncoderMethod = "getRotImmOpValue";
327 // shift_imm: An integer that encodes a shift amount and the type of shift
328 // (currently either asr or lsl) using the same encoding used for the
329 // immediates in so_reg operands.
330 def shift_imm : Operand<i32> {
331 let PrintMethod = "printShiftImmOperand";
334 // shifter_operand operands: so_reg and so_imm.
335 def so_reg : Operand<i32>, // reg reg imm
336 ComplexPattern<i32, 3, "SelectShifterOperandReg",
337 [shl,srl,sra,rotr]> {
338 let EncoderMethod = "getSORegOpValue";
339 let PrintMethod = "printSORegOperand";
340 let MIOperandInfo = (ops GPR, GPR, i32imm);
342 def shift_so_reg : Operand<i32>, // reg reg imm
343 ComplexPattern<i32, 3, "SelectShiftShifterOperandReg",
344 [shl,srl,sra,rotr]> {
345 let EncoderMethod = "getSORegOpValue";
346 let PrintMethod = "printSORegOperand";
347 let MIOperandInfo = (ops GPR, GPR, i32imm);
350 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
351 // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
352 // represented in the imm field in the same 12-bit form that they are encoded
353 // into so_imm instructions: the 8-bit immediate is the least significant bits
354 // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
355 def so_imm : Operand<i32>, PatLeaf<(imm), [{ return Pred_so_imm(N); }]> {
356 let EncoderMethod = "getSOImmOpValue";
357 let PrintMethod = "printSOImmOperand";
360 // Break so_imm's up into two pieces. This handles immediates with up to 16
361 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
362 // get the first/second pieces.
363 def so_imm2part : PatLeaf<(imm), [{
364 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
367 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
369 def arm_i32imm : PatLeaf<(imm), [{
370 if (Subtarget->hasV6T2Ops())
372 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
375 def so_imm2part_1 : SDNodeXForm<imm, [{
376 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
377 return CurDAG->getTargetConstant(V, MVT::i32);
380 def so_imm2part_2 : SDNodeXForm<imm, [{
381 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
382 return CurDAG->getTargetConstant(V, MVT::i32);
385 def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
386 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
388 let PrintMethod = "printSOImm2PartOperand";
391 def so_neg_imm2part_1 : SDNodeXForm<imm, [{
392 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
393 return CurDAG->getTargetConstant(V, MVT::i32);
396 def so_neg_imm2part_2 : SDNodeXForm<imm, [{
397 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
398 return CurDAG->getTargetConstant(V, MVT::i32);
401 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
402 def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
403 return (int32_t)N->getZExtValue() < 32;
406 /// imm0_31_m1 - Matches and prints like imm0_31, but encodes as 'value - 1'.
407 def imm0_31_m1 : Operand<i32>, PatLeaf<(imm), [{
408 return (int32_t)N->getZExtValue() < 32;
410 let EncoderMethod = "getImmMinusOneOpValue";
413 // Define ARM specific addressing modes.
416 // addrmode_imm12 := reg +/- imm12
418 def addrmode_imm12 : Operand<i32>,
419 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
420 // 12-bit immediate operand. Note that instructions using this encode
421 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
422 // immediate values are as normal.
424 let EncoderMethod = "getAddrModeImm12OpValue";
425 let PrintMethod = "printAddrModeImm12Operand";
426 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
428 // ldst_so_reg := reg +/- reg shop imm
430 def ldst_so_reg : Operand<i32>,
431 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
432 let EncoderMethod = "getLdStSORegOpValue";
433 // FIXME: Simplify the printer
434 let PrintMethod = "printAddrMode2Operand";
435 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
438 // addrmode2 := reg +/- imm12
439 // := reg +/- reg shop imm
441 def addrmode2 : Operand<i32>,
442 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
443 string EncoderMethod = "getAddrMode2OpValue";
444 let PrintMethod = "printAddrMode2Operand";
445 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
448 def am2offset : Operand<i32>,
449 ComplexPattern<i32, 2, "SelectAddrMode2Offset",
450 [], [SDNPWantRoot]> {
451 string EncoderMethod = "getAddrMode2OffsetOpValue";
452 let PrintMethod = "printAddrMode2OffsetOperand";
453 let MIOperandInfo = (ops GPR, i32imm);
456 // addrmode3 := reg +/- reg
457 // addrmode3 := reg +/- imm8
459 def addrmode3 : Operand<i32>,
460 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
461 let EncoderMethod = "getAddrMode3OpValue";
462 let PrintMethod = "printAddrMode3Operand";
463 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
466 def am3offset : Operand<i32>,
467 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
468 [], [SDNPWantRoot]> {
469 let EncoderMethod = "getAddrMode3OffsetOpValue";
470 let PrintMethod = "printAddrMode3OffsetOperand";
471 let MIOperandInfo = (ops GPR, i32imm);
474 // ldstm_mode := {ia, ib, da, db}
476 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
477 let EncoderMethod = "getLdStmModeOpValue";
478 let PrintMethod = "printLdStmModeOperand";
481 def MemMode5AsmOperand : AsmOperandClass {
482 let Name = "MemMode5";
483 let SuperClasses = [];
486 // addrmode5 := reg +/- imm8*4
488 def addrmode5 : Operand<i32>,
489 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
490 let PrintMethod = "printAddrMode5Operand";
491 let MIOperandInfo = (ops GPR:$base, i32imm);
492 let ParserMatchClass = MemMode5AsmOperand;
493 let EncoderMethod = "getAddrMode5OpValue";
496 // addrmode6 := reg with optional writeback
498 def addrmode6 : Operand<i32>,
499 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
500 let PrintMethod = "printAddrMode6Operand";
501 let MIOperandInfo = (ops GPR:$addr, i32imm);
502 let EncoderMethod = "getAddrMode6AddressOpValue";
505 def am6offset : Operand<i32> {
506 let PrintMethod = "printAddrMode6OffsetOperand";
507 let MIOperandInfo = (ops GPR);
508 let EncoderMethod = "getAddrMode6OffsetOpValue";
511 // addrmodepc := pc + reg
513 def addrmodepc : Operand<i32>,
514 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
515 let PrintMethod = "printAddrModePCOperand";
516 let MIOperandInfo = (ops GPR, i32imm);
519 def nohash_imm : Operand<i32> {
520 let PrintMethod = "printNoHashImmediate";
523 //===----------------------------------------------------------------------===//
525 include "ARMInstrFormats.td"
527 //===----------------------------------------------------------------------===//
528 // Multiclass helpers...
531 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
532 /// binop that produces a value.
533 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
534 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
535 PatFrag opnode, bit Commutable = 0> {
536 // The register-immediate version is re-materializable. This is useful
537 // in particular for taking the address of a local.
538 let isReMaterializable = 1 in {
539 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
540 iii, opc, "\t$Rd, $Rn, $imm",
541 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
546 let Inst{19-16} = Rn;
547 let Inst{15-12} = Rd;
548 let Inst{11-0} = imm;
551 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
552 iir, opc, "\t$Rd, $Rn, $Rm",
553 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
558 let isCommutable = Commutable;
559 let Inst{19-16} = Rn;
560 let Inst{15-12} = Rd;
561 let Inst{11-4} = 0b00000000;
564 def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm,
565 iis, opc, "\t$Rd, $Rn, $shift",
566 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> {
571 let Inst{19-16} = Rn;
572 let Inst{15-12} = Rd;
573 let Inst{11-0} = shift;
577 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
578 /// instruction modifies the CPSR register.
579 let Defs = [CPSR] in {
580 multiclass AI1_bin_s_irs<bits<4> opcod, string opc,
581 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
582 PatFrag opnode, bit Commutable = 0> {
583 def ri : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
584 iii, opc, "\t$Rd, $Rn, $imm",
585 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
591 let Inst{19-16} = Rn;
592 let Inst{15-12} = Rd;
593 let Inst{11-0} = imm;
595 def rr : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
596 iir, opc, "\t$Rd, $Rn, $Rm",
597 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
601 let isCommutable = Commutable;
604 let Inst{19-16} = Rn;
605 let Inst{15-12} = Rd;
606 let Inst{11-4} = 0b00000000;
609 def rs : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm,
610 iis, opc, "\t$Rd, $Rn, $shift",
611 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> {
617 let Inst{19-16} = Rn;
618 let Inst{15-12} = Rd;
619 let Inst{11-0} = shift;
624 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
625 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
626 /// a explicit result, only implicitly set CPSR.
627 let isCompare = 1, Defs = [CPSR] in {
628 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
629 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
630 PatFrag opnode, bit Commutable = 0> {
631 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
633 [(opnode GPR:$Rn, so_imm:$imm)]> {
638 let Inst{19-16} = Rn;
639 let Inst{15-12} = 0b0000;
640 let Inst{11-0} = imm;
642 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
644 [(opnode GPR:$Rn, GPR:$Rm)]> {
647 let isCommutable = Commutable;
650 let Inst{19-16} = Rn;
651 let Inst{15-12} = 0b0000;
652 let Inst{11-4} = 0b00000000;
655 def rs : AI1<opcod, (outs), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, iis,
656 opc, "\t$Rn, $shift",
657 [(opnode GPR:$Rn, so_reg:$shift)]> {
662 let Inst{19-16} = Rn;
663 let Inst{15-12} = 0b0000;
664 let Inst{11-0} = shift;
669 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
670 /// register and one whose operand is a register rotated by 8/16/24.
671 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
672 multiclass AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode> {
673 def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm),
674 IIC_iEXTr, opc, "\t$Rd, $Rm",
675 [(set GPR:$Rd, (opnode GPR:$Rm))]>,
676 Requires<[IsARM, HasV6]> {
679 let Inst{19-16} = 0b1111;
680 let Inst{15-12} = Rd;
681 let Inst{11-10} = 0b00;
684 def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot),
685 IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot",
686 [(set GPR:$Rd, (opnode (rotr GPR:$Rm, rot_imm:$rot)))]>,
687 Requires<[IsARM, HasV6]> {
691 let Inst{19-16} = 0b1111;
692 let Inst{15-12} = Rd;
693 let Inst{11-10} = rot;
698 multiclass AI_ext_rrot_np<bits<8> opcod, string opc> {
699 def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm),
700 IIC_iEXTr, opc, "\t$Rd, $Rm",
701 [/* For disassembly only; pattern left blank */]>,
702 Requires<[IsARM, HasV6]> {
703 let Inst{19-16} = 0b1111;
704 let Inst{11-10} = 0b00;
706 def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot),
707 IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot",
708 [/* For disassembly only; pattern left blank */]>,
709 Requires<[IsARM, HasV6]> {
711 let Inst{19-16} = 0b1111;
712 let Inst{11-10} = rot;
716 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
717 /// register and one whose operand is a register rotated by 8/16/24.
718 multiclass AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode> {
719 def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
720 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm",
721 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
722 Requires<[IsARM, HasV6]> {
723 let Inst{11-10} = 0b00;
725 def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
727 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
728 [(set GPR:$Rd, (opnode GPR:$Rn,
729 (rotr GPR:$Rm, rot_imm:$rot)))]>,
730 Requires<[IsARM, HasV6]> {
733 let Inst{19-16} = Rn;
734 let Inst{11-10} = rot;
738 // For disassembly only.
739 multiclass AI_exta_rrot_np<bits<8> opcod, string opc> {
740 def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
741 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm",
742 [/* For disassembly only; pattern left blank */]>,
743 Requires<[IsARM, HasV6]> {
744 let Inst{11-10} = 0b00;
746 def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
748 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot",
749 [/* For disassembly only; pattern left blank */]>,
750 Requires<[IsARM, HasV6]> {
753 let Inst{19-16} = Rn;
754 let Inst{11-10} = rot;
758 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
759 let Uses = [CPSR] in {
760 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
761 bit Commutable = 0> {
762 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
763 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
764 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
770 let Inst{15-12} = Rd;
771 let Inst{19-16} = Rn;
772 let Inst{11-0} = imm;
774 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
775 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
776 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
781 let Inst{11-4} = 0b00000000;
783 let isCommutable = Commutable;
785 let Inst{15-12} = Rd;
786 let Inst{19-16} = Rn;
788 def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
789 DPSoRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
790 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>,
796 let Inst{11-0} = shift;
797 let Inst{15-12} = Rd;
798 let Inst{19-16} = Rn;
801 // Carry setting variants
802 let Defs = [CPSR] in {
803 multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
804 bit Commutable = 0> {
805 def Sri : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
806 DPFrm, IIC_iALUi, !strconcat(opc, "\t$Rd, $Rn, $imm"),
807 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
812 let Inst{15-12} = Rd;
813 let Inst{19-16} = Rn;
814 let Inst{11-0} = imm;
818 def Srr : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
819 DPFrm, IIC_iALUr, !strconcat(opc, "\t$Rd, $Rn, $Rm"),
820 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
825 let Inst{11-4} = 0b00000000;
826 let isCommutable = Commutable;
828 let Inst{15-12} = Rd;
829 let Inst{19-16} = Rn;
833 def Srs : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
834 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$Rd, $Rn, $shift"),
835 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>,
840 let Inst{11-0} = shift;
841 let Inst{15-12} = Rd;
842 let Inst{19-16} = Rn;
850 let canFoldAsLoad = 1, isReMaterializable = 1 in {
851 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
852 InstrItinClass iir, PatFrag opnode> {
853 // Note: We use the complex addrmode_imm12 rather than just an input
854 // GPR and a constrained immediate so that we can use this to match
855 // frame index references and avoid matching constant pool references.
856 def i12: AIldst1<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
857 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
858 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
861 let Inst{23} = addr{12}; // U (add = ('U' == 1))
862 let Inst{19-16} = addr{16-13}; // Rn
863 let Inst{15-12} = Rt;
864 let Inst{11-0} = addr{11-0}; // imm12
866 def rs : AIldst1<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
867 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
868 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
871 let Inst{23} = shift{12}; // U (add = ('U' == 1))
872 let Inst{19-16} = shift{16-13}; // Rn
873 let Inst{15-12} = Rt;
874 let Inst{11-0} = shift{11-0};
879 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
880 InstrItinClass iir, PatFrag opnode> {
881 // Note: We use the complex addrmode_imm12 rather than just an input
882 // GPR and a constrained immediate so that we can use this to match
883 // frame index references and avoid matching constant pool references.
884 def i12 : AIldst1<0b010, 0, isByte, (outs),
885 (ins GPR:$Rt, addrmode_imm12:$addr),
886 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
887 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
890 let Inst{23} = addr{12}; // U (add = ('U' == 1))
891 let Inst{19-16} = addr{16-13}; // Rn
892 let Inst{15-12} = Rt;
893 let Inst{11-0} = addr{11-0}; // imm12
895 def rs : AIldst1<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
896 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
897 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
900 let Inst{23} = shift{12}; // U (add = ('U' == 1))
901 let Inst{19-16} = shift{16-13}; // Rn
902 let Inst{15-12} = Rt;
903 let Inst{11-0} = shift{11-0};
906 //===----------------------------------------------------------------------===//
908 //===----------------------------------------------------------------------===//
910 //===----------------------------------------------------------------------===//
911 // Miscellaneous Instructions.
914 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
915 /// the function. The first operand is the ID# for this instruction, the second
916 /// is the index into the MachineConstantPool that this is, the third is the
917 /// size in bytes of this constant pool entry.
918 let neverHasSideEffects = 1, isNotDuplicable = 1 in
919 def CONSTPOOL_ENTRY :
920 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
921 i32imm:$size), NoItinerary, "", []>;
923 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
924 // from removing one half of the matched pairs. That breaks PEI, which assumes
925 // these will always be in pairs, and asserts if it finds otherwise. Better way?
926 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
928 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary, "",
929 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
931 def ADJCALLSTACKDOWN :
932 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary, "",
933 [(ARMcallseq_start timm:$amt)]>;
936 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "",
937 [/* For disassembly only; pattern left blank */]>,
938 Requires<[IsARM, HasV6T2]> {
939 let Inst{27-16} = 0b001100100000;
940 let Inst{15-8} = 0b11110000;
941 let Inst{7-0} = 0b00000000;
944 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "",
945 [/* For disassembly only; pattern left blank */]>,
946 Requires<[IsARM, HasV6T2]> {
947 let Inst{27-16} = 0b001100100000;
948 let Inst{15-8} = 0b11110000;
949 let Inst{7-0} = 0b00000001;
952 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "",
953 [/* For disassembly only; pattern left blank */]>,
954 Requires<[IsARM, HasV6T2]> {
955 let Inst{27-16} = 0b001100100000;
956 let Inst{15-8} = 0b11110000;
957 let Inst{7-0} = 0b00000010;
960 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "",
961 [/* For disassembly only; pattern left blank */]>,
962 Requires<[IsARM, HasV6T2]> {
963 let Inst{27-16} = 0b001100100000;
964 let Inst{15-8} = 0b11110000;
965 let Inst{7-0} = 0b00000011;
968 def SEL : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, NoItinerary, "sel",
970 [/* For disassembly only; pattern left blank */]>,
971 Requires<[IsARM, HasV6]> {
976 let Inst{15-12} = Rd;
977 let Inst{19-16} = Rn;
978 let Inst{27-20} = 0b01101000;
979 let Inst{7-4} = 0b1011;
980 let Inst{11-8} = 0b1111;
983 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
984 [/* For disassembly only; pattern left blank */]>,
985 Requires<[IsARM, HasV6T2]> {
986 let Inst{27-16} = 0b001100100000;
987 let Inst{15-8} = 0b11110000;
988 let Inst{7-0} = 0b00000100;
991 // The i32imm operand $val can be used by a debugger to store more information
992 // about the breakpoint.
993 def BKPT : AI<(outs), (ins i32imm:$val), MiscFrm, NoItinerary, "bkpt", "\t$val",
994 [/* For disassembly only; pattern left blank */]>,
997 let Inst{3-0} = val{3-0};
998 let Inst{19-8} = val{15-4};
999 let Inst{27-20} = 0b00010010;
1000 let Inst{7-4} = 0b0111;
1003 // Change Processor State is a system instruction -- for disassembly only.
1004 // The singleton $opt operand contains the following information:
1005 // opt{4-0} = mode from Inst{4-0}
1006 // opt{5} = changemode from Inst{17}
1007 // opt{8-6} = AIF from Inst{8-6}
1008 // opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
1009 // FIXME: Integrated assembler will need these split out.
1010 def CPS : AXI<(outs), (ins cps_opt:$opt), MiscFrm, NoItinerary, "cps$opt",
1011 [/* For disassembly only; pattern left blank */]>,
1013 let Inst{31-28} = 0b1111;
1014 let Inst{27-20} = 0b00010000;
1019 // Preload signals the memory system of possible future data/instruction access.
1020 // These are for disassembly only.
1021 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1023 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1024 !strconcat(opc, "\t$addr"),
1025 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1028 let Inst{31-26} = 0b111101;
1029 let Inst{25} = 0; // 0 for immediate form
1030 let Inst{24} = data;
1031 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1032 let Inst{22} = read;
1033 let Inst{21-20} = 0b01;
1034 let Inst{19-16} = addr{16-13}; // Rn
1035 let Inst{15-12} = Rt;
1036 let Inst{11-0} = addr{11-0}; // imm12
1039 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1040 !strconcat(opc, "\t$shift"),
1041 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1044 let Inst{31-26} = 0b111101;
1045 let Inst{25} = 1; // 1 for register form
1046 let Inst{24} = data;
1047 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1048 let Inst{22} = read;
1049 let Inst{21-20} = 0b01;
1050 let Inst{19-16} = shift{16-13}; // Rn
1051 let Inst{11-0} = shift{11-0};
1055 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1056 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1057 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1059 def SETEND : AXI<(outs),(ins setend_op:$end), MiscFrm, NoItinerary,
1061 [/* For disassembly only; pattern left blank */]>,
1064 let Inst{31-10} = 0b1111000100000001000000;
1069 def DBG : AI<(outs), (ins i32imm:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1070 [/* For disassembly only; pattern left blank */]>,
1071 Requires<[IsARM, HasV7]> {
1073 let Inst{27-4} = 0b001100100000111100001111;
1074 let Inst{3-0} = opt;
1077 // A5.4 Permanently UNDEFINED instructions.
1078 let isBarrier = 1, isTerminator = 1 in
1079 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1082 let Inst{27-25} = 0b011;
1083 let Inst{24-20} = 0b11111;
1084 let Inst{7-5} = 0b111;
1088 // Address computation and loads and stores in PIC mode.
1089 // FIXME: These PIC insn patterns are pseudos, but derive from the normal insn
1090 // classes (AXI1, et.al.) and so have encoding information and such,
1091 // which is suboptimal. Once the rest of the code emitter (including
1092 // JIT) is MC-ized we should look at refactoring these into true
1093 // pseudos. As is, the encoding information ends up being ignored,
1094 // as these instructions are lowered to individual MC-insts.
1095 let isNotDuplicable = 1 in {
1096 def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1097 Pseudo, IIC_iALUr, "",
1098 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1100 let AddedComplexity = 10 in {
1101 def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1102 Pseudo, IIC_iLoad_r, "",
1103 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1105 def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1106 Pseudo, IIC_iLoad_bh_r, "",
1107 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
1109 def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1110 Pseudo, IIC_iLoad_bh_r, "",
1111 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
1113 def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1114 Pseudo, IIC_iLoad_bh_r, "",
1115 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
1117 def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1118 Pseudo, IIC_iLoad_bh_r, "",
1119 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
1121 let AddedComplexity = 10 in {
1122 def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1123 Pseudo, IIC_iStore_r, "",
1124 [(store GPR:$src, addrmodepc:$addr)]>;
1126 def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1127 Pseudo, IIC_iStore_bh_r, "",
1128 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
1130 def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1131 Pseudo, IIC_iStore_bh_r, "",
1132 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1134 } // isNotDuplicable = 1
1137 // LEApcrel - Load a pc-relative address into a register without offending the
1139 // FIXME: These are marked as pseudos, but they're really not(?). They're just
1140 // the ADR instruction. Is this the right way to handle that? They need
1141 // encoding information regardless.
1142 let neverHasSideEffects = 1 in {
1143 let isReMaterializable = 1 in
1144 def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
1146 "adr$p\t$dst, #$label", []>;
1148 } // neverHasSideEffects
1149 def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
1150 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1152 "adr$p\t$dst, #${label}_${id}", []> {
1156 //===----------------------------------------------------------------------===//
1157 // Control Flow Instructions.
1160 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1162 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1163 "bx", "\tlr", [(ARMretflag)]>,
1164 Requires<[IsARM, HasV4T]> {
1165 let Inst{27-0} = 0b0001001011111111111100011110;
1169 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1170 "mov", "\tpc, lr", [(ARMretflag)]>,
1171 Requires<[IsARM, NoV4T]> {
1172 let Inst{27-0} = 0b0001101000001111000000001110;
1176 // Indirect branches
1177 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1179 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1180 [(brind GPR:$dst)]>,
1181 Requires<[IsARM, HasV4T]> {
1183 let Inst{31-4} = 0b1110000100101111111111110001;
1184 let Inst{3-0} = dst;
1188 def MOVPCRX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "mov\tpc, $dst",
1189 [(brind GPR:$dst)]>,
1190 Requires<[IsARM, NoV4T]> {
1192 let Inst{31-4} = 0b1110000110100000111100000000;
1193 let Inst{3-0} = dst;
1197 // On non-Darwin platforms R9 is callee-saved.
1199 Defs = [R0, R1, R2, R3, R12, LR,
1200 D0, D1, D2, D3, D4, D5, D6, D7,
1201 D16, D17, D18, D19, D20, D21, D22, D23,
1202 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
1203 def BL : ABXI<0b1011, (outs), (ins bltarget:$func, variable_ops),
1204 IIC_Br, "bl\t$func",
1205 [(ARMcall tglobaladdr:$func)]>,
1206 Requires<[IsARM, IsNotDarwin]> {
1207 let Inst{31-28} = 0b1110;
1209 let Inst{23-0} = func;
1212 def BL_pred : ABI<0b1011, (outs), (ins bltarget:$func, variable_ops),
1213 IIC_Br, "bl", "\t$func",
1214 [(ARMcall_pred tglobaladdr:$func)]>,
1215 Requires<[IsARM, IsNotDarwin]> {
1217 let Inst{23-0} = func;
1221 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1222 IIC_Br, "blx\t$func",
1223 [(ARMcall GPR:$func)]>,
1224 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1226 let Inst{27-4} = 0b000100101111111111110011;
1227 let Inst{3-0} = func;
1231 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1232 def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1233 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
1234 [(ARMcall_nolink tGPR:$func)]>,
1235 Requires<[IsARM, HasV4T, IsNotDarwin]> {
1237 let Inst{27-4} = 0b000100101111111111110001;
1238 let Inst{3-0} = func;
1242 def BMOVPCRX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1243 IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func",
1244 [(ARMcall_nolink tGPR:$func)]>,
1245 Requires<[IsARM, NoV4T, IsNotDarwin]> {
1247 let Inst{27-4} = 0b000110100000111100000000;
1248 let Inst{3-0} = func;
1252 // On Darwin R9 is call-clobbered.
1254 Defs = [R0, R1, R2, R3, R9, R12, LR,
1255 D0, D1, D2, D3, D4, D5, D6, D7,
1256 D16, D17, D18, D19, D20, D21, D22, D23,
1257 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
1258 def BLr9 : ABXI<0b1011, (outs), (ins bltarget:$func, variable_ops),
1259 IIC_Br, "bl\t$func",
1260 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
1261 let Inst{31-28} = 0b1110;
1263 let Inst{23-0} = func;
1266 def BLr9_pred : ABI<0b1011, (outs), (ins bltarget:$func, variable_ops),
1267 IIC_Br, "bl", "\t$func",
1268 [(ARMcall_pred tglobaladdr:$func)]>,
1269 Requires<[IsARM, IsDarwin]> {
1271 let Inst{23-0} = func;
1275 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1276 IIC_Br, "blx\t$func",
1277 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
1279 let Inst{27-4} = 0b000100101111111111110011;
1280 let Inst{3-0} = func;
1284 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1285 def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1286 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
1287 [(ARMcall_nolink tGPR:$func)]>,
1288 Requires<[IsARM, HasV4T, IsDarwin]> {
1290 let Inst{27-4} = 0b000100101111111111110001;
1291 let Inst{3-0} = func;
1295 def BMOVPCRXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
1296 IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func",
1297 [(ARMcall_nolink tGPR:$func)]>,
1298 Requires<[IsARM, NoV4T, IsDarwin]> {
1300 let Inst{27-4} = 0b000110100000111100000000;
1301 let Inst{3-0} = func;
1307 // FIXME: These should probably be xformed into the non-TC versions of the
1308 // instructions as part of MC lowering.
1309 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
1311 let Defs = [R0, R1, R2, R3, R9, R12,
1312 D0, D1, D2, D3, D4, D5, D6, D7,
1313 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26,
1314 D27, D28, D29, D30, D31, PC],
1316 def TCRETURNdi : AInoP<(outs), (ins i32imm:$dst, variable_ops),
1318 "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>;
1320 def TCRETURNri : AInoP<(outs), (ins tcGPR:$dst, variable_ops),
1322 "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>;
1324 def TAILJMPd : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1325 IIC_Br, "b\t$dst @ TAILCALL",
1326 []>, Requires<[IsDarwin]>;
1328 def TAILJMPdt: ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1329 IIC_Br, "b.w\t$dst @ TAILCALL",
1330 []>, Requires<[IsDarwin]>;
1332 def TAILJMPr : AXI<(outs), (ins tcGPR:$dst, variable_ops),
1333 BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL",
1334 []>, Requires<[IsDarwin]> {
1336 let Inst{31-4} = 0b1110000100101111111111110001;
1337 let Inst{3-0} = dst;
1341 // Non-Darwin versions (the difference is R9).
1342 let Defs = [R0, R1, R2, R3, R12,
1343 D0, D1, D2, D3, D4, D5, D6, D7,
1344 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26,
1345 D27, D28, D29, D30, D31, PC],
1347 def TCRETURNdiND : AInoP<(outs), (ins i32imm:$dst, variable_ops),
1349 "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>;
1351 def TCRETURNriND : AInoP<(outs), (ins tcGPR:$dst, variable_ops),
1353 "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>;
1355 def TAILJMPdND : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1356 IIC_Br, "b\t$dst @ TAILCALL",
1357 []>, Requires<[IsARM, IsNotDarwin]>;
1359 def TAILJMPdNDt : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops),
1360 IIC_Br, "b.w\t$dst @ TAILCALL",
1361 []>, Requires<[IsThumb, IsNotDarwin]>;
1363 def TAILJMPrND : AXI<(outs), (ins tcGPR:$dst, variable_ops),
1364 BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL",
1365 []>, Requires<[IsNotDarwin]> {
1367 let Inst{31-4} = 0b1110000100101111111111110001;
1368 let Inst{3-0} = dst;
1373 let isBranch = 1, isTerminator = 1 in {
1374 // B is "predicable" since it can be xformed into a Bcc.
1375 let isBarrier = 1 in {
1376 let isPredicable = 1 in
1377 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
1378 "b\t$target", [(br bb:$target)]> {
1380 let Inst{31-28} = 0b1110;
1381 let Inst{23-0} = target;
1384 let isNotDuplicable = 1, isIndirectBranch = 1,
1385 // FIXME: $imm field is not specified by asm string. Mark as cgonly.
1386 isCodeGenOnly = 1 in {
1387 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
1388 IIC_Br, "mov\tpc, $target$jt",
1389 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
1390 let Inst{11-4} = 0b00000000;
1391 let Inst{15-12} = 0b1111;
1392 let Inst{20} = 0; // S Bit
1393 let Inst{24-21} = 0b1101;
1394 let Inst{27-25} = 0b000;
1396 def BR_JTm : JTI<(outs),
1397 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
1398 IIC_Br, "ldr\tpc, $target$jt",
1399 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1401 let Inst{15-12} = 0b1111;
1402 let Inst{20} = 1; // L bit
1403 let Inst{21} = 0; // W bit
1404 let Inst{22} = 0; // B bit
1405 let Inst{24} = 1; // P bit
1406 let Inst{27-25} = 0b011;
1408 def BR_JTadd : JTI<(outs),
1409 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
1410 IIC_Br, "add\tpc, $target, $idx$jt",
1411 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1413 let Inst{15-12} = 0b1111;
1414 let Inst{20} = 0; // S bit
1415 let Inst{24-21} = 0b0100;
1416 let Inst{27-25} = 0b000;
1418 } // isNotDuplicable = 1, isIndirectBranch = 1
1421 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1422 // a two-value operand where a dag node expects two operands. :(
1423 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
1424 IIC_Br, "b", "\t$target",
1425 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1427 let Inst{23-0} = target;
1431 // Branch and Exchange Jazelle -- for disassembly only
1432 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1433 [/* For disassembly only; pattern left blank */]> {
1434 let Inst{23-20} = 0b0010;
1435 //let Inst{19-8} = 0xfff;
1436 let Inst{7-4} = 0b0010;
1439 // Secure Monitor Call is a system instruction -- for disassembly only
1440 def SMC : ABI<0b0001, (outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
1441 [/* For disassembly only; pattern left blank */]> {
1443 let Inst{23-4} = 0b01100000000000000111;
1444 let Inst{3-0} = opt;
1447 // Supervisor Call (Software Interrupt) -- for disassembly only
1449 def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
1450 [/* For disassembly only; pattern left blank */]> {
1452 let Inst{23-0} = svc;
1456 // Store Return State is a system instruction -- for disassembly only
1457 let isCodeGenOnly = 1 in { // FIXME: This should not use submode!
1458 def SRSW : ABXI<{1,0,0,?}, (outs), (ins ldstm_mode:$amode, i32imm:$mode),
1459 NoItinerary, "srs${amode}\tsp!, $mode",
1460 [/* For disassembly only; pattern left blank */]> {
1461 let Inst{31-28} = 0b1111;
1462 let Inst{22-20} = 0b110; // W = 1
1465 def SRS : ABXI<{1,0,0,?}, (outs), (ins ldstm_mode:$amode, i32imm:$mode),
1466 NoItinerary, "srs${amode}\tsp, $mode",
1467 [/* For disassembly only; pattern left blank */]> {
1468 let Inst{31-28} = 0b1111;
1469 let Inst{22-20} = 0b100; // W = 0
1472 // Return From Exception is a system instruction -- for disassembly only
1473 def RFEW : ABXI<{1,0,0,?}, (outs), (ins ldstm_mode:$amode, GPR:$base),
1474 NoItinerary, "rfe${amode}\t$base!",
1475 [/* For disassembly only; pattern left blank */]> {
1476 let Inst{31-28} = 0b1111;
1477 let Inst{22-20} = 0b011; // W = 1
1480 def RFE : ABXI<{1,0,0,?}, (outs), (ins ldstm_mode:$amode, GPR:$base),
1481 NoItinerary, "rfe${amode}\t$base",
1482 [/* For disassembly only; pattern left blank */]> {
1483 let Inst{31-28} = 0b1111;
1484 let Inst{22-20} = 0b001; // W = 0
1486 } // isCodeGenOnly = 1
1488 //===----------------------------------------------------------------------===//
1489 // Load / store Instructions.
1495 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
1496 UnOpFrag<(load node:$Src)>>;
1497 defm LDRB : AI_ldr1<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
1498 UnOpFrag<(zextloadi8 node:$Src)>>;
1499 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
1500 BinOpFrag<(store node:$LHS, node:$RHS)>>;
1501 defm STRB : AI_str1<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
1502 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1504 // Special LDR for loads from non-pc-relative constpools.
1505 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
1506 isReMaterializable = 1 in
1507 def LDRcp : AIldst1<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1508 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
1512 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1513 let Inst{19-16} = 0b1111;
1514 let Inst{15-12} = Rt;
1515 let Inst{11-0} = addr{11-0}; // imm12
1518 // Loads with zero extension
1519 def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1520 IIC_iLoad_bh_r, "ldrh", "\t$dst, $addr",
1521 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
1523 // Loads with sign extension
1524 def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1525 IIC_iLoad_bh_r, "ldrsh", "\t$dst, $addr",
1526 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
1528 def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
1529 IIC_iLoad_bh_r, "ldrsb", "\t$dst, $addr",
1530 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
1532 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
1533 isCodeGenOnly = 1 in { // $dst2 doesn't exist in asmstring?
1535 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
1536 IIC_iLoad_d_r, "ldrd", "\t$dst1, $addr",
1537 []>, Requires<[IsARM, HasV5TE]>;
1540 multiclass AI2_ldridx<bit isByte, string opc, InstrItinClass itin> {
1541 def _PRE : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1542 (ins addrmode2:$addr), IndexModePre, LdFrm, itin,
1543 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
1545 // {13} 1 == Rm, 0 == imm12
1549 let Inst{25} = addr{13};
1550 let Inst{23} = addr{12};
1551 let Inst{19-16} = addr{17-14};
1552 let Inst{11-0} = addr{11-0};
1554 def _POST : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
1555 (ins GPR:$Rn, am2offset:$offset),
1556 IndexModePost, LdFrm, itin,
1557 opc, "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", []> {
1558 // {13} 1 == Rm, 0 == imm12
1563 let Inst{25} = offset{13};
1564 let Inst{23} = offset{12};
1565 let Inst{19-16} = Rn;
1566 let Inst{11-0} = offset{11-0};
1570 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_ru>;
1571 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_ru>;
1573 def LDRH_PRE : AI3ldhpr<(outs GPR:$Rt, GPR:$Rn_wb),
1574 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1575 "ldrh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>;
1577 def LDRH_POST : AI3ldhpo<(outs GPR:$Rt, GPR:$Rn_wb),
1578 (ins GPR:$Rn,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1579 "ldrh", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", []>;
1581 def LDRSH_PRE : AI3ldshpr<(outs GPR:$Rt, GPR:$Rn_wb),
1582 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1583 "ldrsh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>;
1585 def LDRSH_POST: AI3ldshpo<(outs GPR:$Rt, GPR:$Rn_wb),
1586 (ins GPR:$Rn,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1587 "ldrsh", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", []>;
1589 def LDRSB_PRE : AI3ldsbpr<(outs GPR:$Rt, GPR:$Rn_wb),
1590 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru,
1591 "ldrsb", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []>;
1593 def LDRSB_POST: AI3ldsbpo<(outs GPR:$Rt, GPR:$Rn_wb),
1594 (ins GPR:$Rn,am3offset:$offset), LdMiscFrm, IIC_iLoad_ru,
1595 "ldrsb", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", []>;
1597 // For disassembly only
1598 def LDRD_PRE : AI3lddpr<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb),
1599 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_d_ru,
1600 "ldrd", "\t$dst1, $dst2, $addr!", "$addr.base = $base_wb", []>,
1601 Requires<[IsARM, HasV5TE]>;
1603 // For disassembly only
1604 def LDRD_POST : AI3lddpo<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb),
1605 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_d_ru,
1606 "ldrd", "\t$dst1, $dst2, [$base], $offset", "$base = $base_wb", []>,
1607 Requires<[IsARM, HasV5TE]>;
1609 } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1
1611 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only.
1613 def LDRT : AI2ldstidx<1, 0, 0, (outs GPR:$dst, GPR:$base_wb),
1614 (ins GPR:$base, am2offset:$offset), IndexModeNone,
1615 LdFrm, IIC_iLoad_ru,
1616 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1617 let Inst{21} = 1; // overwrite
1620 def LDRBT : AI2ldstidx<1, 1, 0, (outs GPR:$dst, GPR:$base_wb),
1621 (ins GPR:$base,am2offset:$offset), IndexModeNone,
1622 LdFrm, IIC_iLoad_bh_ru,
1623 "ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1624 let Inst{21} = 1; // overwrite
1627 def LDRSBT : AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
1628 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1629 "ldrsbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1630 let Inst{21} = 1; // overwrite
1633 def LDRHT : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
1634 (ins GPR:$base, am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1635 "ldrht", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1636 let Inst{21} = 1; // overwrite
1639 def LDRSHT : AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
1640 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru,
1641 "ldrsht", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1642 let Inst{21} = 1; // overwrite
1647 // Stores with truncate
1648 def STRH : AI3sth<(outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
1649 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
1650 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
1653 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
1654 isCodeGenOnly = 1 in // $src2 doesn't exist in asm string
1655 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
1656 StMiscFrm, IIC_iStore_d_r,
1657 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
1660 def STR_PRE : AI2ldstidx<0, 0, 1, (outs GPR:$Rn_wb),
1661 (ins GPR:$Rt, GPR:$Rn, am2offset:$offset),
1662 IndexModePre, StFrm, IIC_iStore_ru,
1663 "str", "\t$Rt, [$Rn, $offset]!", "$Rn = $Rn_wb",
1665 (pre_store GPR:$Rt, GPR:$Rn, am2offset:$offset))]> {
1666 // {13} 1 == Rm, 0 == imm12
1671 let Inst{25} = offset{13};
1672 let Inst{23} = offset{12};
1673 let Inst{19-16} = Rn;
1674 let Inst{11-0} = offset{11-0};
1677 def STR_POST : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
1678 (ins GPR:$Rt, GPR:$Rn, am2offset:$offset),
1679 IndexModePost, StFrm, IIC_iStore_ru,
1680 "str", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb",
1682 (post_store GPR:$Rt, GPR:$Rn, am2offset:$offset))]> {
1683 // {13} 1 == Rm, 0 == imm12
1688 let Inst{25} = offset{13};
1689 let Inst{23} = offset{12};
1690 let Inst{19-16} = Rn;
1691 let Inst{11-0} = offset{11-0};
1694 def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
1695 (ins GPR:$src, GPR:$base,am3offset:$offset),
1696 StMiscFrm, IIC_iStore_ru,
1697 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
1699 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1701 def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
1702 (ins GPR:$src, GPR:$base,am3offset:$offset),
1703 StMiscFrm, IIC_iStore_bh_ru,
1704 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
1705 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1706 GPR:$base, am3offset:$offset))]>;
1708 def STRB_PRE : AI2ldstidx<0, 1, 1, (outs GPR:$Rn_wb),
1709 (ins GPR:$Rt, GPR:$Rn,am2offset:$offset),
1710 IndexModePre, StFrm, IIC_iStore_bh_ru,
1711 "strb", "\t$Rt, [$Rn, $offset]!", "$Rn = $Rn_wb",
1712 [(set GPR:$Rn_wb, (pre_truncsti8 GPR:$Rt,
1713 GPR:$Rn, am2offset:$offset))]> {
1714 // {13} 1 == Rm, 0 == imm12
1719 let Inst{25} = offset{13};
1720 let Inst{23} = offset{12};
1721 let Inst{19-16} = Rn;
1722 let Inst{11-0} = offset{11-0};
1725 def STRB_POST: AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
1726 (ins GPR:$Rt, GPR:$Rn,am2offset:$offset),
1727 IndexModePost, StFrm, IIC_iStore_bh_ru,
1728 "strb", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb",
1729 [(set GPR:$Rn_wb, (post_truncsti8 GPR:$Rt,
1730 GPR:$Rn, am2offset:$offset))]> {
1731 // {13} 1 == Rm, 0 == imm12
1736 let Inst{25} = offset{13};
1737 let Inst{23} = offset{12};
1738 let Inst{19-16} = Rn;
1739 let Inst{11-0} = offset{11-0};
1742 // For disassembly only
1743 def STRD_PRE : AI3stdpr<(outs GPR:$base_wb),
1744 (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset),
1745 StMiscFrm, IIC_iStore_d_ru,
1746 "strd", "\t$src1, $src2, [$base, $offset]!",
1747 "$base = $base_wb", []>;
1749 // For disassembly only
1750 def STRD_POST: AI3stdpo<(outs GPR:$base_wb),
1751 (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset),
1752 StMiscFrm, IIC_iStore_d_ru,
1753 "strd", "\t$src1, $src2, [$base], $offset",
1754 "$base = $base_wb", []>;
1756 // STRT, STRBT, and STRHT are for disassembly only.
1758 def STRT : AI2ldstidx<0, 0, 0, (outs GPR:$base_wb),
1759 (ins GPR:$src, GPR:$base,am2offset:$offset),
1760 IndexModeNone, StFrm, IIC_iStore_ru,
1761 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1762 [/* For disassembly only; pattern left blank */]> {
1763 let Inst{21} = 1; // overwrite
1766 def STRBT : AI2ldstidx<0, 1, 0, (outs GPR:$base_wb),
1767 (ins GPR:$src, GPR:$base,am2offset:$offset),
1768 IndexModeNone, StFrm, IIC_iStore_bh_ru,
1769 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1770 [/* For disassembly only; pattern left blank */]> {
1771 let Inst{21} = 1; // overwrite
1774 def STRHT: AI3sthpo<(outs GPR:$base_wb),
1775 (ins GPR:$src, GPR:$base,am3offset:$offset),
1776 StMiscFrm, IIC_iStore_bh_ru,
1777 "strht", "\t$src, [$base], $offset", "$base = $base_wb",
1778 [/* For disassembly only; pattern left blank */]> {
1779 let Inst{21} = 1; // overwrite
1782 //===----------------------------------------------------------------------===//
1783 // Load / store multiple Instructions.
1786 multiclass arm_ldst_mult<string asm, bit L_bit, Format f,
1787 InstrItinClass itin, InstrItinClass itin_upd> {
1789 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1790 IndexModeNone, f, itin,
1791 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
1792 let Inst{24-23} = 0b01; // Increment After
1793 let Inst{21} = 0; // No writeback
1794 let Inst{20} = L_bit;
1797 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1798 IndexModeUpd, f, itin_upd,
1799 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1800 let Inst{24-23} = 0b01; // Increment After
1801 let Inst{21} = 1; // Writeback
1802 let Inst{20} = L_bit;
1805 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1806 IndexModeNone, f, itin,
1807 !strconcat(asm, "da${p}\t$Rn, $regs"), "", []> {
1808 let Inst{24-23} = 0b00; // Decrement After
1809 let Inst{21} = 0; // No writeback
1810 let Inst{20} = L_bit;
1813 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1814 IndexModeUpd, f, itin_upd,
1815 !strconcat(asm, "da${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1816 let Inst{24-23} = 0b00; // Decrement After
1817 let Inst{21} = 1; // Writeback
1818 let Inst{20} = L_bit;
1821 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1822 IndexModeNone, f, itin,
1823 !strconcat(asm, "db${p}\t$Rn, $regs"), "", []> {
1824 let Inst{24-23} = 0b10; // Decrement Before
1825 let Inst{21} = 0; // No writeback
1826 let Inst{20} = L_bit;
1829 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1830 IndexModeUpd, f, itin_upd,
1831 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1832 let Inst{24-23} = 0b10; // Decrement Before
1833 let Inst{21} = 1; // Writeback
1834 let Inst{20} = L_bit;
1837 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1838 IndexModeNone, f, itin,
1839 !strconcat(asm, "ib${p}\t$Rn, $regs"), "", []> {
1840 let Inst{24-23} = 0b11; // Increment Before
1841 let Inst{21} = 0; // No writeback
1842 let Inst{20} = L_bit;
1845 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
1846 IndexModeUpd, f, itin_upd,
1847 !strconcat(asm, "ib${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
1848 let Inst{24-23} = 0b11; // Increment Before
1849 let Inst{21} = 1; // Writeback
1850 let Inst{20} = L_bit;
1854 let neverHasSideEffects = 1 in {
1856 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1857 defm LDM : arm_ldst_mult<"ldm", 1, LdStMulFrm, IIC_iLoad_m, IIC_iLoad_mu>;
1859 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1860 defm STM : arm_ldst_mult<"stm", 0, LdStMulFrm, IIC_iStore_m, IIC_iStore_mu>;
1862 } // neverHasSideEffects
1864 // Load / Store Multiple Mnemnoic Aliases
1865 def : MnemonicAlias<"ldm", "ldmia">;
1866 def : MnemonicAlias<"stm", "stmia">;
1868 // FIXME: remove when we have a way to marking a MI with these properties.
1869 // FIXME: Should pc be an implicit operand like PICADD, etc?
1870 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
1871 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
1872 def LDMIA_RET : AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
1873 reglist:$dsts, variable_ops),
1874 IndexModeUpd, LdStMulFrm, IIC_iLoad_mBr,
1875 "ldmia${p}\t$Rn!, $dsts",
1877 let Inst{24-23} = 0b01; // Increment After
1878 let Inst{21} = 1; // Writeback
1879 let Inst{20} = 1; // Load
1882 //===----------------------------------------------------------------------===//
1883 // Move Instructions.
1886 let neverHasSideEffects = 1 in
1887 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
1888 "mov", "\t$Rd, $Rm", []>, UnaryDP {
1892 let Inst{11-4} = 0b00000000;
1895 let Inst{15-12} = Rd;
1898 // A version for the smaller set of tail call registers.
1899 let neverHasSideEffects = 1 in
1900 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
1901 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
1905 let Inst{11-4} = 0b00000000;
1908 let Inst{15-12} = Rd;
1911 def MOVs : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg:$src),
1912 DPSoRegFrm, IIC_iMOVsr,
1913 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg:$src)]>,
1917 let Inst{15-12} = Rd;
1918 let Inst{11-0} = src;
1922 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1923 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
1924 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
1928 let Inst{15-12} = Rd;
1929 let Inst{19-16} = 0b0000;
1930 let Inst{11-0} = imm;
1933 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1934 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins i32imm:$imm),
1936 "movw", "\t$Rd, $imm",
1937 [(set GPR:$Rd, imm0_65535:$imm)]>,
1938 Requires<[IsARM, HasV6T2]>, UnaryDP {
1941 let Inst{15-12} = Rd;
1942 let Inst{11-0} = imm{11-0};
1943 let Inst{19-16} = imm{15-12};
1948 let Constraints = "$src = $Rd" in
1949 def MOVTi16 : AI1<0b1010, (outs GPR:$Rd), (ins GPR:$src, i32imm:$imm),
1951 "movt", "\t$Rd, $imm",
1953 (or (and GPR:$src, 0xffff),
1954 lo16AllZero:$imm))]>, UnaryDP,
1955 Requires<[IsARM, HasV6T2]> {
1958 let Inst{15-12} = Rd;
1959 let Inst{11-0} = imm{11-0};
1960 let Inst{19-16} = imm{15-12};
1965 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1966 Requires<[IsARM, HasV6T2]>;
1968 let Uses = [CPSR] in
1969 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi, "",
1970 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
1973 // These aren't really mov instructions, but we have to define them this way
1974 // due to flag operands.
1976 let Defs = [CPSR] in {
1977 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "",
1978 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
1980 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "",
1981 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
1985 //===----------------------------------------------------------------------===//
1986 // Extend Instructions.
1991 defm SXTB : AI_ext_rrot<0b01101010,
1992 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1993 defm SXTH : AI_ext_rrot<0b01101011,
1994 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
1996 defm SXTAB : AI_exta_rrot<0b01101010,
1997 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1998 defm SXTAH : AI_exta_rrot<0b01101011,
1999 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
2001 // For disassembly only
2002 defm SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
2004 // For disassembly only
2005 defm SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
2009 let AddedComplexity = 16 in {
2010 defm UXTB : AI_ext_rrot<0b01101110,
2011 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
2012 defm UXTH : AI_ext_rrot<0b01101111,
2013 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
2014 defm UXTB16 : AI_ext_rrot<0b01101100,
2015 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
2017 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
2018 // The transformation should probably be done as a combiner action
2019 // instead so we can include a check for masking back in the upper
2020 // eight bits of the source into the lower eight bits of the result.
2021 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
2022 // (UXTB16r_rot GPR:$Src, 24)>;
2023 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
2024 (UXTB16r_rot GPR:$Src, 8)>;
2026 defm UXTAB : AI_exta_rrot<0b01101110, "uxtab",
2027 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
2028 defm UXTAH : AI_exta_rrot<0b01101111, "uxtah",
2029 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
2032 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
2033 // For disassembly only
2034 defm UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
2037 def SBFX : I<(outs GPR:$Rd),
2038 (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width),
2039 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2040 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
2041 Requires<[IsARM, HasV6T2]> {
2046 let Inst{27-21} = 0b0111101;
2047 let Inst{6-4} = 0b101;
2048 let Inst{20-16} = width;
2049 let Inst{15-12} = Rd;
2050 let Inst{11-7} = lsb;
2054 def UBFX : I<(outs GPR:$Rd),
2055 (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width),
2056 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2057 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
2058 Requires<[IsARM, HasV6T2]> {
2063 let Inst{27-21} = 0b0111111;
2064 let Inst{6-4} = 0b101;
2065 let Inst{20-16} = width;
2066 let Inst{15-12} = Rd;
2067 let Inst{11-7} = lsb;
2071 //===----------------------------------------------------------------------===//
2072 // Arithmetic Instructions.
2075 defm ADD : AsI1_bin_irs<0b0100, "add",
2076 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2077 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
2078 defm SUB : AsI1_bin_irs<0b0010, "sub",
2079 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2080 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
2082 // ADD and SUB with 's' bit set.
2083 defm ADDS : AI1_bin_s_irs<0b0100, "adds",
2084 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2085 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
2086 defm SUBS : AI1_bin_s_irs<0b0010, "subs",
2087 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2088 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
2090 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
2091 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
2092 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
2093 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
2094 defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
2095 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
2096 defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
2097 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
2099 def RSBri : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
2100 IIC_iALUi, "rsb", "\t$Rd, $Rn, $imm",
2101 [(set GPR:$Rd, (sub so_imm:$imm, GPR:$Rn))]> {
2106 let Inst{15-12} = Rd;
2107 let Inst{19-16} = Rn;
2108 let Inst{11-0} = imm;
2111 // The reg/reg form is only defined for the disassembler; for codegen it is
2112 // equivalent to SUBrr.
2113 def RSBrr : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
2114 IIC_iALUr, "rsb", "\t$Rd, $Rn, $Rm",
2115 [/* For disassembly only; pattern left blank */]> {
2119 let Inst{11-4} = 0b00000000;
2122 let Inst{15-12} = Rd;
2123 let Inst{19-16} = Rn;
2126 def RSBrs : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
2127 DPSoRegFrm, IIC_iALUsr, "rsb", "\t$Rd, $Rn, $shift",
2128 [(set GPR:$Rd, (sub so_reg:$shift, GPR:$Rn))]> {
2133 let Inst{11-0} = shift;
2134 let Inst{15-12} = Rd;
2135 let Inst{19-16} = Rn;
2138 // RSB with 's' bit set.
2139 let Defs = [CPSR] in {
2140 def RSBSri : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
2141 IIC_iALUi, "rsbs", "\t$Rd, $Rn, $imm",
2142 [(set GPR:$Rd, (subc so_imm:$imm, GPR:$Rn))]> {
2148 let Inst{15-12} = Rd;
2149 let Inst{19-16} = Rn;
2150 let Inst{11-0} = imm;
2152 def RSBSrs : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
2153 DPSoRegFrm, IIC_iALUsr, "rsbs", "\t$Rd, $Rn, $shift",
2154 [(set GPR:$Rd, (subc so_reg:$shift, GPR:$Rn))]> {
2160 let Inst{11-0} = shift;
2161 let Inst{15-12} = Rd;
2162 let Inst{19-16} = Rn;
2166 let Uses = [CPSR] in {
2167 def RSCri : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
2168 DPFrm, IIC_iALUi, "rsc", "\t$Rd, $Rn, $imm",
2169 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
2175 let Inst{15-12} = Rd;
2176 let Inst{19-16} = Rn;
2177 let Inst{11-0} = imm;
2179 // The reg/reg form is only defined for the disassembler; for codegen it is
2180 // equivalent to SUBrr.
2181 def RSCrr : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2182 DPFrm, IIC_iALUr, "rsc", "\t$Rd, $Rn, $Rm",
2183 [/* For disassembly only; pattern left blank */]> {
2187 let Inst{11-4} = 0b00000000;
2190 let Inst{15-12} = Rd;
2191 let Inst{19-16} = Rn;
2193 def RSCrs : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
2194 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$Rd, $Rn, $shift",
2195 [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>,
2201 let Inst{11-0} = shift;
2202 let Inst{15-12} = Rd;
2203 let Inst{19-16} = Rn;
2207 // FIXME: Allow these to be predicated.
2208 let Defs = [CPSR], Uses = [CPSR] in {
2209 def RSCSri : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
2210 DPFrm, IIC_iALUi, "rscs\t$Rd, $Rn, $imm",
2211 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
2218 let Inst{15-12} = Rd;
2219 let Inst{19-16} = Rn;
2220 let Inst{11-0} = imm;
2222 def RSCSrs : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift),
2223 DPSoRegFrm, IIC_iALUsr, "rscs\t$Rd, $Rn, $shift",
2224 [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>,
2231 let Inst{11-0} = shift;
2232 let Inst{15-12} = Rd;
2233 let Inst{19-16} = Rn;
2237 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
2238 // The assume-no-carry-in form uses the negation of the input since add/sub
2239 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
2240 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
2242 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
2243 (SUBri GPR:$src, so_imm_neg:$imm)>;
2244 def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
2245 (SUBSri GPR:$src, so_imm_neg:$imm)>;
2246 // The with-carry-in form matches bitwise not instead of the negation.
2247 // Effectively, the inverse interpretation of the carry flag already accounts
2248 // for part of the negation.
2249 def : ARMPat<(adde GPR:$src, so_imm_not:$imm),
2250 (SBCri GPR:$src, so_imm_not:$imm)>;
2252 // Note: These are implemented in C++ code, because they have to generate
2253 // ADD/SUBrs instructions, which use a complex pattern that a xform function
2255 // (mul X, 2^n+1) -> (add (X << n), X)
2256 // (mul X, 2^n-1) -> (rsb X, (X << n))
2258 // ARM Arithmetic Instruction -- for disassembly only
2259 // GPR:$dst = GPR:$a op GPR:$b
2260 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
2261 list<dag> pattern = [/* For disassembly only; pattern left blank */]>
2262 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iALUr,
2263 opc, "\t$Rd, $Rn, $Rm", pattern> {
2267 let Inst{27-20} = op27_20;
2268 let Inst{11-4} = op11_4;
2269 let Inst{19-16} = Rn;
2270 let Inst{15-12} = Rd;
2274 // Saturating add/subtract -- for disassembly only
2276 def QADD : AAI<0b00010000, 0b00000101, "qadd",
2277 [(set GPR:$Rd, (int_arm_qadd GPR:$Rn, GPR:$Rm))]>;
2278 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
2279 [(set GPR:$Rd, (int_arm_qsub GPR:$Rn, GPR:$Rm))]>;
2280 def QDADD : AAI<0b00010100, 0b00000101, "qdadd">;
2281 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub">;
2283 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
2284 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
2285 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
2286 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
2287 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
2288 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
2289 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
2290 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
2291 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
2292 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
2293 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
2294 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
2296 // Signed/Unsigned add/subtract -- for disassembly only
2298 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
2299 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
2300 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
2301 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
2302 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
2303 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
2304 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
2305 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
2306 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
2307 def USAX : AAI<0b01100101, 0b11110101, "usax">;
2308 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
2309 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
2311 // Signed/Unsigned halving add/subtract -- for disassembly only
2313 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
2314 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
2315 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
2316 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
2317 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
2318 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
2319 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
2320 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
2321 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
2322 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
2323 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
2324 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
2326 // Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only
2328 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2329 MulFrm /* for convenience */, NoItinerary, "usad8",
2330 "\t$Rd, $Rn, $Rm", []>,
2331 Requires<[IsARM, HasV6]> {
2335 let Inst{27-20} = 0b01111000;
2336 let Inst{15-12} = 0b1111;
2337 let Inst{7-4} = 0b0001;
2338 let Inst{19-16} = Rd;
2339 let Inst{11-8} = Rm;
2342 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2343 MulFrm /* for convenience */, NoItinerary, "usada8",
2344 "\t$Rd, $Rn, $Rm, $Ra", []>,
2345 Requires<[IsARM, HasV6]> {
2350 let Inst{27-20} = 0b01111000;
2351 let Inst{7-4} = 0b0001;
2352 let Inst{19-16} = Rd;
2353 let Inst{15-12} = Ra;
2354 let Inst{11-8} = Rm;
2358 // Signed/Unsigned saturate -- for disassembly only
2360 def SSAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
2361 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $a$sh",
2362 [/* For disassembly only; pattern left blank */]> {
2367 let Inst{27-21} = 0b0110101;
2368 let Inst{5-4} = 0b01;
2369 let Inst{20-16} = sat_imm;
2370 let Inst{15-12} = Rd;
2371 let Inst{11-7} = sh{7-3};
2372 let Inst{6} = sh{0};
2376 def SSAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$Rn), SatFrm,
2377 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn",
2378 [/* For disassembly only; pattern left blank */]> {
2382 let Inst{27-20} = 0b01101010;
2383 let Inst{11-4} = 0b11110011;
2384 let Inst{15-12} = Rd;
2385 let Inst{19-16} = sat_imm;
2389 def USAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
2390 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $a$sh",
2391 [/* For disassembly only; pattern left blank */]> {
2396 let Inst{27-21} = 0b0110111;
2397 let Inst{5-4} = 0b01;
2398 let Inst{15-12} = Rd;
2399 let Inst{11-7} = sh{7-3};
2400 let Inst{6} = sh{0};
2401 let Inst{20-16} = sat_imm;
2405 def USAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a), SatFrm,
2406 NoItinerary, "usat16", "\t$Rd, $sat_imm, $a",
2407 [/* For disassembly only; pattern left blank */]> {
2411 let Inst{27-20} = 0b01101110;
2412 let Inst{11-4} = 0b11110011;
2413 let Inst{15-12} = Rd;
2414 let Inst{19-16} = sat_imm;
2418 def : ARMV6Pat<(int_arm_ssat GPR:$a, imm:$pos), (SSAT imm:$pos, GPR:$a, 0)>;
2419 def : ARMV6Pat<(int_arm_usat GPR:$a, imm:$pos), (USAT imm:$pos, GPR:$a, 0)>;
2421 //===----------------------------------------------------------------------===//
2422 // Bitwise Instructions.
2425 defm AND : AsI1_bin_irs<0b0000, "and",
2426 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2427 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
2428 defm ORR : AsI1_bin_irs<0b1100, "orr",
2429 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2430 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
2431 defm EOR : AsI1_bin_irs<0b0001, "eor",
2432 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2433 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
2434 defm BIC : AsI1_bin_irs<0b1110, "bic",
2435 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
2436 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
2438 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
2439 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2440 "bfc", "\t$Rd, $imm", "$src = $Rd",
2441 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
2442 Requires<[IsARM, HasV6T2]> {
2445 let Inst{27-21} = 0b0111110;
2446 let Inst{6-0} = 0b0011111;
2447 let Inst{15-12} = Rd;
2448 let Inst{11-7} = imm{4-0}; // lsb
2449 let Inst{20-16} = imm{9-5}; // width
2452 // A8.6.18 BFI - Bitfield insert (Encoding A1)
2453 def BFI : I<(outs GPR:$Rd), (ins GPR:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
2454 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
2455 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
2456 [(set GPR:$Rd, (ARMbfi GPR:$src, GPR:$Rn,
2457 bf_inv_mask_imm:$imm))]>,
2458 Requires<[IsARM, HasV6T2]> {
2462 let Inst{27-21} = 0b0111110;
2463 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
2464 let Inst{15-12} = Rd;
2465 let Inst{11-7} = imm{4-0}; // lsb
2466 let Inst{20-16} = imm{9-5}; // width
2470 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
2471 "mvn", "\t$Rd, $Rm",
2472 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
2476 let Inst{19-16} = 0b0000;
2477 let Inst{11-4} = 0b00000000;
2478 let Inst{15-12} = Rd;
2481 def MVNs : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg:$shift), DPSoRegFrm,
2482 IIC_iMVNsr, "mvn", "\t$Rd, $shift",
2483 [(set GPR:$Rd, (not so_reg:$shift))]>, UnaryDP {
2487 let Inst{19-16} = 0b0000;
2488 let Inst{15-12} = Rd;
2489 let Inst{11-0} = shift;
2491 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
2492 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
2493 IIC_iMVNi, "mvn", "\t$Rd, $imm",
2494 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
2498 let Inst{19-16} = 0b0000;
2499 let Inst{15-12} = Rd;
2500 let Inst{11-0} = imm;
2503 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
2504 (BICri GPR:$src, so_imm_not:$imm)>;
2506 //===----------------------------------------------------------------------===//
2507 // Multiply Instructions.
2509 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
2510 string opc, string asm, list<dag> pattern>
2511 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
2515 let Inst{19-16} = Rd;
2516 let Inst{11-8} = Rm;
2519 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
2520 string opc, string asm, list<dag> pattern>
2521 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
2526 let Inst{19-16} = RdHi;
2527 let Inst{15-12} = RdLo;
2528 let Inst{11-8} = Rm;
2532 let isCommutable = 1 in
2533 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2534 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
2535 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>;
2537 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2538 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
2539 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]> {
2541 let Inst{15-12} = Ra;
2544 def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
2545 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
2546 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
2547 Requires<[IsARM, HasV6T2]> {
2551 let Inst{19-16} = Rd;
2552 let Inst{11-8} = Rm;
2556 // Extra precision multiplies with low / high results
2558 let neverHasSideEffects = 1 in {
2559 let isCommutable = 1 in {
2560 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
2561 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
2562 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2564 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
2565 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
2566 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2569 // Multiply + accumulate
2570 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
2571 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2572 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2574 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
2575 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2576 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>;
2578 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
2579 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
2580 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
2581 Requires<[IsARM, HasV6]> {
2586 let Inst{19-16} = RdLo;
2587 let Inst{15-12} = RdHi;
2588 let Inst{11-8} = Rm;
2591 } // neverHasSideEffects
2593 // Most significant word multiply
2594 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2595 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
2596 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
2597 Requires<[IsARM, HasV6]> {
2598 let Inst{15-12} = 0b1111;
2601 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2602 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
2603 [/* For disassembly only; pattern left blank */]>,
2604 Requires<[IsARM, HasV6]> {
2605 let Inst{15-12} = 0b1111;
2608 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
2609 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2610 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
2611 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
2612 Requires<[IsARM, HasV6]>;
2614 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
2615 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2616 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
2617 [/* For disassembly only; pattern left blank */]>,
2618 Requires<[IsARM, HasV6]>;
2620 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
2621 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2622 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
2623 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
2624 Requires<[IsARM, HasV6]>;
2626 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
2627 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2628 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
2629 [/* For disassembly only; pattern left blank */]>,
2630 Requires<[IsARM, HasV6]>;
2632 multiclass AI_smul<string opc, PatFrag opnode> {
2633 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2634 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
2635 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
2636 (sext_inreg GPR:$Rm, i16)))]>,
2637 Requires<[IsARM, HasV5TE]>;
2639 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2640 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
2641 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
2642 (sra GPR:$Rm, (i32 16))))]>,
2643 Requires<[IsARM, HasV5TE]>;
2645 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2646 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
2647 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
2648 (sext_inreg GPR:$Rm, i16)))]>,
2649 Requires<[IsARM, HasV5TE]>;
2651 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2652 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
2653 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
2654 (sra GPR:$Rm, (i32 16))))]>,
2655 Requires<[IsARM, HasV5TE]>;
2657 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2658 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
2659 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
2660 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
2661 Requires<[IsARM, HasV5TE]>;
2663 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2664 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
2665 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
2666 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
2667 Requires<[IsARM, HasV5TE]>;
2671 multiclass AI_smla<string opc, PatFrag opnode> {
2672 def BB : AMulxyIa<0b0001000, 0b00, (outs GPR:$Rd),
2673 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2674 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
2675 [(set GPR:$Rd, (add GPR:$Ra,
2676 (opnode (sext_inreg GPR:$Rn, i16),
2677 (sext_inreg GPR:$Rm, i16))))]>,
2678 Requires<[IsARM, HasV5TE]>;
2680 def BT : AMulxyIa<0b0001000, 0b10, (outs GPR:$Rd),
2681 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2682 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
2683 [(set GPR:$Rd, (add GPR:$Ra, (opnode (sext_inreg GPR:$Rn, i16),
2684 (sra GPR:$Rm, (i32 16)))))]>,
2685 Requires<[IsARM, HasV5TE]>;
2687 def TB : AMulxyIa<0b0001000, 0b01, (outs GPR:$Rd),
2688 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2689 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
2690 [(set GPR:$Rd, (add GPR:$Ra, (opnode (sra GPR:$Rn, (i32 16)),
2691 (sext_inreg GPR:$Rm, i16))))]>,
2692 Requires<[IsARM, HasV5TE]>;
2694 def TT : AMulxyIa<0b0001000, 0b11, (outs GPR:$Rd),
2695 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2696 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
2697 [(set GPR:$Rd, (add GPR:$Ra, (opnode (sra GPR:$Rn, (i32 16)),
2698 (sra GPR:$Rm, (i32 16)))))]>,
2699 Requires<[IsARM, HasV5TE]>;
2701 def WB : AMulxyIa<0b0001001, 0b00, (outs GPR:$Rd),
2702 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2703 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
2704 [(set GPR:$Rd, (add GPR:$Ra, (sra (opnode GPR:$Rn,
2705 (sext_inreg GPR:$Rm, i16)), (i32 16))))]>,
2706 Requires<[IsARM, HasV5TE]>;
2708 def WT : AMulxyIa<0b0001001, 0b10, (outs GPR:$Rd),
2709 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2710 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
2711 [(set GPR:$Rd, (add GPR:$Ra, (sra (opnode GPR:$Rn,
2712 (sra GPR:$Rm, (i32 16))), (i32 16))))]>,
2713 Requires<[IsARM, HasV5TE]>;
2716 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2717 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
2719 // Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only
2720 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPR:$RdLo, GPR:$RdHi),
2721 (ins GPR:$Rn, GPR:$Rm),
2722 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm",
2723 [/* For disassembly only; pattern left blank */]>,
2724 Requires<[IsARM, HasV5TE]>;
2726 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPR:$RdLo, GPR:$RdHi),
2727 (ins GPR:$Rn, GPR:$Rm),
2728 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm",
2729 [/* For disassembly only; pattern left blank */]>,
2730 Requires<[IsARM, HasV5TE]>;
2732 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPR:$RdLo, GPR:$RdHi),
2733 (ins GPR:$Rn, GPR:$Rm),
2734 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm",
2735 [/* For disassembly only; pattern left blank */]>,
2736 Requires<[IsARM, HasV5TE]>;
2738 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPR:$RdLo, GPR:$RdHi),
2739 (ins GPR:$Rn, GPR:$Rm),
2740 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm",
2741 [/* For disassembly only; pattern left blank */]>,
2742 Requires<[IsARM, HasV5TE]>;
2744 // Helper class for AI_smld -- for disassembly only
2745 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
2746 InstrItinClass itin, string opc, string asm>
2747 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
2754 let Inst{21-20} = 0b00;
2755 let Inst{22} = long;
2756 let Inst{27-23} = 0b01110;
2757 let Inst{11-8} = Rm;
2760 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
2761 InstrItinClass itin, string opc, string asm>
2762 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
2764 let Inst{15-12} = 0b1111;
2765 let Inst{19-16} = Rd;
2767 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
2768 InstrItinClass itin, string opc, string asm>
2769 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
2771 let Inst{15-12} = Ra;
2773 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
2774 InstrItinClass itin, string opc, string asm>
2775 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
2778 let Inst{19-16} = RdHi;
2779 let Inst{15-12} = RdLo;
2782 multiclass AI_smld<bit sub, string opc> {
2784 def D : AMulDualIa<0, sub, 0, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2785 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
2787 def DX: AMulDualIa<0, sub, 1, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
2788 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
2790 def LD: AMulDualI64<1, sub, 0, (outs GPR:$RdLo,GPR:$RdHi),
2791 (ins GPR:$Rn, GPR:$Rm), NoItinerary,
2792 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
2794 def LDX : AMulDualI64<1, sub, 1, (outs GPR:$RdLo,GPR:$RdHi),
2795 (ins GPR:$Rn, GPR:$Rm), NoItinerary,
2796 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
2800 defm SMLA : AI_smld<0, "smla">;
2801 defm SMLS : AI_smld<1, "smls">;
2803 multiclass AI_sdml<bit sub, string opc> {
2805 def D : AMulDualI<0, sub, 0, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2806 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
2807 def DX : AMulDualI<0, sub, 1, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2808 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
2811 defm SMUA : AI_sdml<0, "smua">;
2812 defm SMUS : AI_sdml<1, "smus">;
2814 //===----------------------------------------------------------------------===//
2815 // Misc. Arithmetic Instructions.
2818 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
2819 IIC_iUNAr, "clz", "\t$Rd, $Rm",
2820 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
2822 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
2823 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
2824 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
2825 Requires<[IsARM, HasV6T2]>;
2827 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
2828 IIC_iUNAr, "rev", "\t$Rd, $Rm",
2829 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
2831 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
2832 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
2834 (or (and (srl GPR:$Rm, (i32 8)), 0xFF),
2835 (or (and (shl GPR:$Rm, (i32 8)), 0xFF00),
2836 (or (and (srl GPR:$Rm, (i32 8)), 0xFF0000),
2837 (and (shl GPR:$Rm, (i32 8)), 0xFF000000)))))]>,
2838 Requires<[IsARM, HasV6]>;
2840 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
2841 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
2844 (or (srl (and GPR:$Rm, 0xFF00), (i32 8)),
2845 (shl GPR:$Rm, (i32 8))), i16))]>,
2846 Requires<[IsARM, HasV6]>;
2848 def lsl_shift_imm : SDNodeXForm<imm, [{
2849 unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::lsl, N->getZExtValue());
2850 return CurDAG->getTargetConstant(Sh, MVT::i32);
2853 def lsl_amt : PatLeaf<(i32 imm), [{
2854 return (N->getZExtValue() < 32);
2857 def PKHBT : APKHI<0b01101000, 0, (outs GPR:$Rd),
2858 (ins GPR:$Rn, GPR:$Rm, shift_imm:$sh),
2859 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
2860 [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF),
2861 (and (shl GPR:$Rm, lsl_amt:$sh),
2863 Requires<[IsARM, HasV6]>;
2865 // Alternate cases for PKHBT where identities eliminate some nodes.
2866 def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (and GPR:$Rm, 0xFFFF0000)),
2867 (PKHBT GPR:$Rn, GPR:$Rm, 0)>;
2868 def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (shl GPR:$Rm, imm16_31:$sh)),
2869 (PKHBT GPR:$Rn, GPR:$Rm, (lsl_shift_imm imm16_31:$sh))>;
2871 def asr_shift_imm : SDNodeXForm<imm, [{
2872 unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::asr, N->getZExtValue());
2873 return CurDAG->getTargetConstant(Sh, MVT::i32);
2876 def asr_amt : PatLeaf<(i32 imm), [{
2877 return (N->getZExtValue() <= 32);
2880 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
2881 // will match the pattern below.
2882 def PKHTB : APKHI<0b01101000, 1, (outs GPR:$Rd),
2883 (ins GPR:$Rn, GPR:$Rm, shift_imm:$sh),
2884 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
2885 [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF0000),
2886 (and (sra GPR:$Rm, asr_amt:$sh),
2888 Requires<[IsARM, HasV6]>;
2890 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
2891 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
2892 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, imm16_31:$sh)),
2893 (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm16_31:$sh))>;
2894 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
2895 (and (srl GPR:$src2, imm1_15:$sh), 0xFFFF)),
2896 (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm1_15:$sh))>;
2898 //===----------------------------------------------------------------------===//
2899 // Comparison Instructions...
2902 defm CMP : AI1_cmp_irs<0b1010, "cmp",
2903 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2904 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
2906 // FIXME: We have to be careful when using the CMN instruction and comparison
2907 // with 0. One would expect these two pieces of code should give identical
2923 // However, the CMN gives the *opposite* result when r1 is 0. This is because
2924 // the carry flag is set in the CMP case but not in the CMN case. In short, the
2925 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
2926 // value of r0 and the carry bit (because the "carry bit" parameter to
2927 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
2928 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
2929 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
2930 // parameter to AddWithCarry is defined as 0).
2932 // When x is 0 and unsigned:
2936 // ~x + 1 = 0x1 0000 0000
2937 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
2939 // Therefore, we should disable CMN when comparing against zero, until we can
2940 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
2941 // when it's a comparison which doesn't look at the 'carry' flag).
2943 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
2945 // This is related to <rdar://problem/7569620>.
2947 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
2948 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
2950 // Note that TST/TEQ don't set all the same flags that CMP does!
2951 defm TST : AI1_cmp_irs<0b1000, "tst",
2952 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
2953 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
2954 defm TEQ : AI1_cmp_irs<0b1001, "teq",
2955 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
2956 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
2958 defm CMPz : AI1_cmp_irs<0b1010, "cmp",
2959 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2960 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
2961 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
2962 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
2963 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
2965 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
2966 // (CMNri GPR:$src, so_imm_neg:$imm)>;
2968 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
2969 (CMNzri GPR:$src, so_imm_neg:$imm)>;
2971 // Pseudo i64 compares for some floating point compares.
2972 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
2974 def BCCi64 : PseudoInst<(outs),
2975 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
2977 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
2979 def BCCZi64 : PseudoInst<(outs),
2980 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br, "",
2981 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
2982 } // usesCustomInserter
2985 // Conditional moves
2986 // FIXME: should be able to write a pattern for ARMcmov, but can't use
2987 // a two-value operand where a dag node expects two operands. :(
2988 // FIXME: These should all be pseudo-instructions that get expanded to
2989 // the normal MOV instructions. That would fix the dependency on
2990 // special casing them in tblgen.
2991 let neverHasSideEffects = 1 in {
2992 def MOVCCr : AI1<0b1101, (outs GPR:$Rd), (ins GPR:$false, GPR:$Rm), DPFrm,
2993 IIC_iCMOVr, "mov", "\t$Rd, $Rm",
2994 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
2995 RegConstraint<"$false = $Rd">, UnaryDP {
3000 let Inst{15-12} = Rd;
3001 let Inst{11-4} = 0b00000000;
3005 def MOVCCs : AI1<0b1101, (outs GPR:$Rd),
3006 (ins GPR:$false, so_reg:$shift), DPSoRegFrm, IIC_iCMOVsr,
3007 "mov", "\t$Rd, $shift",
3008 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg:$shift, imm:$cc, CCR:$ccr))*/]>,
3009 RegConstraint<"$false = $Rd">, UnaryDP {
3015 let Inst{19-16} = Rn;
3016 let Inst{15-12} = Rd;
3017 let Inst{11-0} = shift;
3020 def MOVCCi16 : AI1<0b1000, (outs GPR:$Rd), (ins GPR:$false, i32imm:$imm),
3022 "movw", "\t$Rd, $imm",
3024 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
3030 let Inst{19-16} = imm{15-12};
3031 let Inst{15-12} = Rd;
3032 let Inst{11-0} = imm{11-0};
3035 def MOVCCi : AI1<0b1101, (outs GPR:$Rd),
3036 (ins GPR:$false, so_imm:$imm), DPFrm, IIC_iCMOVi,
3037 "mov", "\t$Rd, $imm",
3038 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3039 RegConstraint<"$false = $Rd">, UnaryDP {
3044 let Inst{19-16} = 0b0000;
3045 let Inst{15-12} = Rd;
3046 let Inst{11-0} = imm;
3049 // Two instruction predicate mov immediate.
3050 def MOVCCi32imm : PseudoInst<(outs GPR:$Rd),
3051 (ins GPR:$false, i32imm:$src, pred:$p),
3052 IIC_iCMOVix2, "", []>, RegConstraint<"$false = $Rd">;
3054 def MVNCCi : AI1<0b1111, (outs GPR:$Rd),
3055 (ins GPR:$false, so_imm:$imm), DPFrm, IIC_iCMOVi,
3056 "mvn", "\t$Rd, $imm",
3057 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
3058 RegConstraint<"$false = $Rd">, UnaryDP {
3063 let Inst{19-16} = 0b0000;
3064 let Inst{15-12} = Rd;
3065 let Inst{11-0} = imm;
3067 } // neverHasSideEffects
3069 //===----------------------------------------------------------------------===//
3070 // Atomic operations intrinsics
3073 def memb_opt : Operand<i32> {
3074 let PrintMethod = "printMemBOption";
3077 // memory barriers protect the atomic sequences
3078 let hasSideEffects = 1 in {
3079 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
3080 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
3081 Requires<[IsARM, HasDB]> {
3083 let Inst{31-4} = 0xf57ff05;
3084 let Inst{3-0} = opt;
3087 def DMB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary,
3088 "mcr", "\tp15, 0, $zero, c7, c10, 5",
3089 [(ARMMemBarrierMCR GPR:$zero)]>,
3090 Requires<[IsARM, HasV6]> {
3091 // FIXME: add encoding
3095 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
3097 [/* For disassembly only; pattern left blank */]>,
3098 Requires<[IsARM, HasDB]> {
3100 let Inst{31-4} = 0xf57ff04;
3101 let Inst{3-0} = opt;
3104 // ISB has only full system option -- for disassembly only
3105 def ISB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "isb", "", []>,
3106 Requires<[IsARM, HasDB]> {
3107 let Inst{31-4} = 0xf57ff06;
3108 let Inst{3-0} = 0b1111;
3111 let usesCustomInserter = 1 in {
3112 let Uses = [CPSR] in {
3113 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
3114 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3115 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
3116 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
3117 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3118 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
3119 def ATOMIC_LOAD_AND_I8 : PseudoInst<
3120 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3121 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
3122 def ATOMIC_LOAD_OR_I8 : PseudoInst<
3123 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3124 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
3125 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
3126 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3127 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
3128 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
3129 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3130 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
3131 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
3132 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3133 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
3134 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
3135 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3136 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
3137 def ATOMIC_LOAD_AND_I16 : PseudoInst<
3138 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3139 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
3140 def ATOMIC_LOAD_OR_I16 : PseudoInst<
3141 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3142 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
3143 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
3144 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3145 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
3146 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
3147 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3148 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
3149 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
3150 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3151 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
3152 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
3153 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3154 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
3155 def ATOMIC_LOAD_AND_I32 : PseudoInst<
3156 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3157 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
3158 def ATOMIC_LOAD_OR_I32 : PseudoInst<
3159 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3160 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
3161 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
3162 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3163 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
3164 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
3165 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "",
3166 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
3168 def ATOMIC_SWAP_I8 : PseudoInst<
3169 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
3170 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
3171 def ATOMIC_SWAP_I16 : PseudoInst<
3172 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
3173 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
3174 def ATOMIC_SWAP_I32 : PseudoInst<
3175 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "",
3176 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
3178 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
3179 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
3180 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
3181 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
3182 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
3183 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
3184 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
3185 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "",
3186 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
3190 let mayLoad = 1 in {
3191 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary,
3192 "ldrexb", "\t$Rt, [$Rn]",
3194 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary,
3195 "ldrexh", "\t$Rt, [$Rn]",
3197 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary,
3198 "ldrex", "\t$Rt, [$Rn]",
3200 def LDREXD : AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2), (ins GPR:$Rn),
3202 "ldrexd", "\t$Rt, $Rt2, [$Rn]",
3206 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
3207 def STREXB : AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$src, GPR:$Rn),
3209 "strexb", "\t$Rd, $src, [$Rn]",
3211 def STREXH : AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn),
3213 "strexh", "\t$Rd, $Rt, [$Rn]",
3215 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn),
3217 "strex", "\t$Rd, $Rt, [$Rn]",
3219 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
3220 (ins GPR:$Rt, GPR:$Rt2, GPR:$Rn),
3222 "strexd", "\t$Rd, $Rt, $Rt2, [$Rn]",
3226 // Clear-Exclusive is for disassembly only.
3227 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
3228 [/* For disassembly only; pattern left blank */]>,
3229 Requires<[IsARM, HasV7]> {
3230 let Inst{31-0} = 0b11110101011111111111000000011111;
3233 // SWP/SWPB are deprecated in V6/V7 and for disassembly only.
3234 let mayLoad = 1 in {
3235 def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, GPR:$Rn), "swp",
3236 [/* For disassembly only; pattern left blank */]>;
3237 def SWPB : AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, GPR:$Rn), "swpb",
3238 [/* For disassembly only; pattern left blank */]>;
3241 //===----------------------------------------------------------------------===//
3245 // __aeabi_read_tp preserves the registers r1-r3.
3246 // FIXME: This needs to be a pseudo of some sort so that we can get the
3247 // encoding right, complete with fixup for the aeabi_read_tp function.
3249 Defs = [R0, R12, LR, CPSR] in {
3250 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
3251 "bl\t__aeabi_read_tp",
3252 [(set R0, ARMthread_pointer)]>;
3255 //===----------------------------------------------------------------------===//
3256 // SJLJ Exception handling intrinsics
3257 // eh_sjlj_setjmp() is an instruction sequence to store the return
3258 // address and save #0 in R0 for the non-longjmp case.
3259 // Since by its nature we may be coming from some other function to get
3260 // here, and we're using the stack frame for the containing function to
3261 // save/restore registers, we can't keep anything live in regs across
3262 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
3263 // when we get here from a longjmp(). We force everthing out of registers
3264 // except for our own input by listing the relevant registers in Defs. By
3265 // doing so, we also cause the prologue/epilogue code to actively preserve
3266 // all of the callee-saved resgisters, which is exactly what we want.
3267 // A constant value is passed in $val, and we use the location as a scratch.
3269 // These are pseudo-instructions and are lowered to individual MC-insts, so
3270 // no encoding information is necessary.
3272 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
3273 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
3274 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
3275 D31 ], hasSideEffects = 1, isBarrier = 1 in {
3276 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
3277 AddrModeNone, SizeSpecial, IndexModeNone,
3278 Pseudo, NoItinerary, "", "",
3279 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
3280 Requires<[IsARM, HasVFP2]>;
3284 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ],
3285 hasSideEffects = 1, isBarrier = 1 in {
3286 def Int_eh_sjlj_setjmp_nofp : XI<(outs), (ins GPR:$src, GPR:$val),
3287 AddrModeNone, SizeSpecial, IndexModeNone,
3288 Pseudo, NoItinerary, "", "",
3289 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
3290 Requires<[IsARM, NoVFP]>;
3293 // FIXME: Non-Darwin version(s)
3294 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
3295 Defs = [ R7, LR, SP ] in {
3296 def Int_eh_sjlj_longjmp : XI<(outs), (ins GPR:$src, GPR:$scratch),
3297 AddrModeNone, SizeSpecial, IndexModeNone,
3298 Pseudo, NoItinerary, "", "",
3299 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
3300 Requires<[IsARM, IsDarwin]>;
3303 // eh.sjlj.dispatchsetup pseudo-instruction.
3304 // This pseudo is used for ARM, Thumb1 and Thumb2. Any differences are
3305 // handled when the pseudo is expanded (which happens before any passes
3306 // that need the instruction size).
3307 let isBarrier = 1, hasSideEffects = 1 in
3308 def Int_eh_sjlj_dispatchsetup :
3309 PseudoInst<(outs), (ins GPR:$src), NoItinerary, "",
3310 [(ARMeh_sjlj_dispatchsetup GPR:$src)]>,
3311 Requires<[IsDarwin]>;
3313 //===----------------------------------------------------------------------===//
3314 // Non-Instruction Patterns
3317 // Large immediate handling.
3319 // FIXME: Folding immediates into these logical operations aren't necessary
3320 // good ideas. If it's in a loop machine licm could have hoisted the immediate
3321 // computation out of the loop.
3322 def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
3323 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3324 (so_imm2part_2 imm:$RHS))>;
3325 def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
3326 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3327 (so_imm2part_2 imm:$RHS))>;
3328 def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
3329 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
3330 (so_imm2part_2 imm:$RHS))>;
3331 def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
3332 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
3333 (so_neg_imm2part_2 imm:$RHS))>;
3335 // 32-bit immediate using two piece so_imms or movw + movt.
3336 // This is a single pseudo instruction, the benefit is that it can be remat'd
3337 // as a single unit instead of having to handle reg inputs.
3338 // FIXME: Remove this when we can do generalized remat.
3339 let isReMaterializable = 1 in
3340 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2, "",
3341 [(set GPR:$dst, (arm_i32imm:$src))]>,
3344 // ConstantPool, GlobalAddress, and JumpTable
3345 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
3346 Requires<[IsARM, DontUseMovt]>;
3347 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
3348 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
3349 Requires<[IsARM, UseMovt]>;
3350 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
3351 (LEApcrelJT tjumptable:$dst, imm:$id)>;
3353 // TODO: add,sub,and, 3-instr forms?
3356 def : ARMPat<(ARMtcret tcGPR:$dst),
3357 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
3359 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
3360 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
3362 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
3363 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
3365 def : ARMPat<(ARMtcret tcGPR:$dst),
3366 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
3368 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
3369 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
3371 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
3372 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
3375 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
3376 Requires<[IsARM, IsNotDarwin]>;
3377 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
3378 Requires<[IsARM, IsDarwin]>;
3380 // zextload i1 -> zextload i8
3381 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
3382 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
3384 // extload -> zextload
3385 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
3386 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
3387 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
3388 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
3390 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
3392 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
3393 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
3396 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3397 (sra (shl GPR:$b, (i32 16)), (i32 16))),
3398 (SMULBB GPR:$a, GPR:$b)>;
3399 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
3400 (SMULBB GPR:$a, GPR:$b)>;
3401 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3402 (sra GPR:$b, (i32 16))),
3403 (SMULBT GPR:$a, GPR:$b)>;
3404 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
3405 (SMULBT GPR:$a, GPR:$b)>;
3406 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
3407 (sra (shl GPR:$b, (i32 16)), (i32 16))),
3408 (SMULTB GPR:$a, GPR:$b)>;
3409 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
3410 (SMULTB GPR:$a, GPR:$b)>;
3411 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
3413 (SMULWB GPR:$a, GPR:$b)>;
3414 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
3415 (SMULWB GPR:$a, GPR:$b)>;
3417 def : ARMV5TEPat<(add GPR:$acc,
3418 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3419 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
3420 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3421 def : ARMV5TEPat<(add GPR:$acc,
3422 (mul sext_16_node:$a, sext_16_node:$b)),
3423 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
3424 def : ARMV5TEPat<(add GPR:$acc,
3425 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
3426 (sra GPR:$b, (i32 16)))),
3427 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3428 def : ARMV5TEPat<(add GPR:$acc,
3429 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
3430 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
3431 def : ARMV5TEPat<(add GPR:$acc,
3432 (mul (sra GPR:$a, (i32 16)),
3433 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
3434 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3435 def : ARMV5TEPat<(add GPR:$acc,
3436 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
3437 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
3438 def : ARMV5TEPat<(add GPR:$acc,
3439 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
3441 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3442 def : ARMV5TEPat<(add GPR:$acc,
3443 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
3444 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
3446 //===----------------------------------------------------------------------===//
3450 include "ARMInstrThumb.td"
3452 //===----------------------------------------------------------------------===//
3456 include "ARMInstrThumb2.td"
3458 //===----------------------------------------------------------------------===//
3459 // Floating Point Support
3462 include "ARMInstrVFP.td"
3464 //===----------------------------------------------------------------------===//
3465 // Advanced SIMD (NEON) Support
3468 include "ARMInstrNEON.td"
3470 //===----------------------------------------------------------------------===//
3471 // Coprocessor Instructions. For disassembly only.
3474 def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3475 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3476 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
3477 [/* For disassembly only; pattern left blank */]> {
3481 def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3482 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3483 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
3484 [/* For disassembly only; pattern left blank */]> {
3485 let Inst{31-28} = 0b1111;
3489 class ACI<dag oops, dag iops, string opc, string asm>
3490 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
3491 opc, asm, "", [/* For disassembly only; pattern left blank */]> {
3492 let Inst{27-25} = 0b110;
3495 multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
3497 def _OFFSET : ACI<(outs),
3498 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3499 opc, "\tp$cop, cr$CRd, $addr"> {
3500 let Inst{31-28} = op31_28;
3501 let Inst{24} = 1; // P = 1
3502 let Inst{21} = 0; // W = 0
3503 let Inst{22} = 0; // D = 0
3504 let Inst{20} = load;
3507 def _PRE : ACI<(outs),
3508 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3509 opc, "\tp$cop, cr$CRd, $addr!"> {
3510 let Inst{31-28} = op31_28;
3511 let Inst{24} = 1; // P = 1
3512 let Inst{21} = 1; // W = 1
3513 let Inst{22} = 0; // D = 0
3514 let Inst{20} = load;
3517 def _POST : ACI<(outs),
3518 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
3519 opc, "\tp$cop, cr$CRd, [$base], $offset"> {
3520 let Inst{31-28} = op31_28;
3521 let Inst{24} = 0; // P = 0
3522 let Inst{21} = 1; // W = 1
3523 let Inst{22} = 0; // D = 0
3524 let Inst{20} = load;
3527 def _OPTION : ACI<(outs),
3528 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option),
3529 opc, "\tp$cop, cr$CRd, [$base], $option"> {
3530 let Inst{31-28} = op31_28;
3531 let Inst{24} = 0; // P = 0
3532 let Inst{23} = 1; // U = 1
3533 let Inst{21} = 0; // W = 0
3534 let Inst{22} = 0; // D = 0
3535 let Inst{20} = load;
3538 def L_OFFSET : ACI<(outs),
3539 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3540 !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr"> {
3541 let Inst{31-28} = op31_28;
3542 let Inst{24} = 1; // P = 1
3543 let Inst{21} = 0; // W = 0
3544 let Inst{22} = 1; // D = 1
3545 let Inst{20} = load;
3548 def L_PRE : ACI<(outs),
3549 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
3550 !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr!"> {
3551 let Inst{31-28} = op31_28;
3552 let Inst{24} = 1; // P = 1
3553 let Inst{21} = 1; // W = 1
3554 let Inst{22} = 1; // D = 1
3555 let Inst{20} = load;
3558 def L_POST : ACI<(outs),
3559 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
3560 !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $offset"> {
3561 let Inst{31-28} = op31_28;
3562 let Inst{24} = 0; // P = 0
3563 let Inst{21} = 1; // W = 1
3564 let Inst{22} = 1; // D = 1
3565 let Inst{20} = load;
3568 def L_OPTION : ACI<(outs),
3569 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option),
3570 !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $option"> {
3571 let Inst{31-28} = op31_28;
3572 let Inst{24} = 0; // P = 0
3573 let Inst{23} = 1; // U = 1
3574 let Inst{21} = 0; // W = 0
3575 let Inst{22} = 1; // D = 1
3576 let Inst{20} = load;
3580 defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">;
3581 defm LDC2 : LdStCop<0b1111, 1, "ldc2">;
3582 defm STC : LdStCop<{?,?,?,?}, 0, "stc">;
3583 defm STC2 : LdStCop<0b1111, 0, "stc2">;
3585 def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3586 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3587 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3588 [/* For disassembly only; pattern left blank */]> {
3593 def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3594 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3595 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3596 [/* For disassembly only; pattern left blank */]> {
3597 let Inst{31-28} = 0b1111;
3602 def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3603 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3604 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3605 [/* For disassembly only; pattern left blank */]> {
3610 def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
3611 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
3612 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
3613 [/* For disassembly only; pattern left blank */]> {
3614 let Inst{31-28} = 0b1111;
3619 def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3620 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3621 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3622 [/* For disassembly only; pattern left blank */]> {
3623 let Inst{23-20} = 0b0100;
3626 def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3627 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3628 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3629 [/* For disassembly only; pattern left blank */]> {
3630 let Inst{31-28} = 0b1111;
3631 let Inst{23-20} = 0b0100;
3634 def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3635 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3636 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3637 [/* For disassembly only; pattern left blank */]> {
3638 let Inst{23-20} = 0b0101;
3641 def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
3642 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
3643 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
3644 [/* For disassembly only; pattern left blank */]> {
3645 let Inst{31-28} = 0b1111;
3646 let Inst{23-20} = 0b0101;
3649 //===----------------------------------------------------------------------===//
3650 // Move between special register and ARM core register -- for disassembly only
3653 def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr",
3654 [/* For disassembly only; pattern left blank */]> {
3655 let Inst{23-20} = 0b0000;
3656 let Inst{7-4} = 0b0000;
3659 def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr",
3660 [/* For disassembly only; pattern left blank */]> {
3661 let Inst{23-20} = 0b0100;
3662 let Inst{7-4} = 0b0000;
3665 def MSR : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary,
3666 "msr", "\tcpsr$mask, $src",
3667 [/* For disassembly only; pattern left blank */]> {
3668 let Inst{23-20} = 0b0010;
3669 let Inst{7-4} = 0b0000;
3672 def MSRi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary,
3673 "msr", "\tcpsr$mask, $a",
3674 [/* For disassembly only; pattern left blank */]> {
3675 let Inst{23-20} = 0b0010;
3676 let Inst{7-4} = 0b0000;
3679 def MSRsys : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary,
3680 "msr", "\tspsr$mask, $src",
3681 [/* For disassembly only; pattern left blank */]> {
3682 let Inst{23-20} = 0b0110;
3683 let Inst{7-4} = 0b0000;
3686 def MSRsysi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary,
3687 "msr", "\tspsr$mask, $a",
3688 [/* For disassembly only; pattern left blank */]> {
3689 let Inst{23-20} = 0b0110;
3690 let Inst{7-4} = 0b0000;