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, [SDTCisInt<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_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
43 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
44 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
46 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
47 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
50 def SDT_ARMMEMBARRIERV7 : SDTypeProfile<0, 0, []>;
51 def SDT_ARMSYNCBARRIERV7 : SDTypeProfile<0, 0, []>;
52 def SDT_ARMMEMBARRIERV6 : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
53 def SDT_ARMSYNCBARRIERV6 : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
56 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
57 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
59 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
60 [SDNPHasChain, SDNPOutFlag]>;
61 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
62 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
64 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
65 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
66 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
67 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
68 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
69 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
71 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
72 [SDNPHasChain, SDNPOptInFlag]>;
74 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
76 def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
79 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
80 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
82 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
84 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
87 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
90 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
91 [SDNPOutFlag,SDNPCommutative]>;
93 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
95 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
96 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
97 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
99 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
100 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", SDT_ARMEH_SJLJ_Setjmp>;
102 def ARMMemBarrierV7 : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERV7,
104 def ARMSyncBarrierV7 : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERV7,
106 def ARMMemBarrierV6 : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERV6,
108 def ARMSyncBarrierV6 : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERV6,
111 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
113 //===----------------------------------------------------------------------===//
114 // ARM Instruction Predicate Definitions.
116 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
117 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
118 def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
119 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">;
120 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
121 def HasV7 : Predicate<"Subtarget->hasV7Ops()">;
122 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">;
123 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">;
124 def HasNEON : Predicate<"Subtarget->hasNEON()">;
125 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
126 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
127 def IsThumb : Predicate<"Subtarget->isThumb()">;
128 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
129 def IsThumb2 : Predicate<"Subtarget->isThumb2()">;
130 def IsARM : Predicate<"!Subtarget->isThumb()">;
131 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
132 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
134 // FIXME: Eventually this will be just "hasV6T2Ops".
135 def UseMovt : Predicate<"Subtarget->useMovt()">;
136 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
138 //===----------------------------------------------------------------------===//
139 // ARM Flag Definitions.
141 class RegConstraint<string C> {
142 string Constraints = C;
145 //===----------------------------------------------------------------------===//
146 // ARM specific transformation functions and pattern fragments.
149 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
150 // so_imm_neg def below.
151 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
152 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
155 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
156 // so_imm_not def below.
157 def so_imm_not_XFORM : SDNodeXForm<imm, [{
158 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
161 // rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
162 def rot_imm : PatLeaf<(i32 imm), [{
163 int32_t v = (int32_t)N->getZExtValue();
164 return v == 8 || v == 16 || v == 24;
167 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
168 def imm1_15 : PatLeaf<(i32 imm), [{
169 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
172 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
173 def imm16_31 : PatLeaf<(i32 imm), [{
174 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
179 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
180 }], so_imm_neg_XFORM>;
184 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
185 }], so_imm_not_XFORM>;
187 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
188 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
189 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
192 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
194 def bf_inv_mask_imm : Operand<i32>,
196 uint32_t v = (uint32_t)N->getZExtValue();
199 // there can be 1's on either or both "outsides", all the "inside"
201 unsigned int lsb = 0, msb = 31;
202 while (v & (1 << msb)) --msb;
203 while (v & (1 << lsb)) ++lsb;
204 for (unsigned int i = lsb; i <= msb; ++i) {
210 let PrintMethod = "printBitfieldInvMaskImmOperand";
213 /// Split a 32-bit immediate into two 16 bit parts.
214 def lo16 : SDNodeXForm<imm, [{
215 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() & 0xffff,
219 def hi16 : SDNodeXForm<imm, [{
220 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
223 def lo16AllZero : PatLeaf<(i32 imm), [{
224 // Returns true if all low 16-bits are 0.
225 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
228 /// imm0_65535 predicate - True if the 32-bit immediate is in the range
230 def imm0_65535 : PatLeaf<(i32 imm), [{
231 return (uint32_t)N->getZExtValue() < 65536;
234 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
235 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
237 /// adde and sube predicates - True based on whether the carry flag output
238 /// will be needed or not.
239 def adde_dead_carry :
240 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
241 [{return !N->hasAnyUseOfValue(1);}]>;
242 def sube_dead_carry :
243 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
244 [{return !N->hasAnyUseOfValue(1);}]>;
245 def adde_live_carry :
246 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
247 [{return N->hasAnyUseOfValue(1);}]>;
248 def sube_live_carry :
249 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
250 [{return N->hasAnyUseOfValue(1);}]>;
252 //===----------------------------------------------------------------------===//
253 // Operand Definitions.
257 def brtarget : Operand<OtherVT>;
259 // A list of registers separated by comma. Used by load/store multiple.
260 def reglist : Operand<i32> {
261 let PrintMethod = "printRegisterList";
264 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
265 def cpinst_operand : Operand<i32> {
266 let PrintMethod = "printCPInstOperand";
269 def jtblock_operand : Operand<i32> {
270 let PrintMethod = "printJTBlockOperand";
272 def jt2block_operand : Operand<i32> {
273 let PrintMethod = "printJT2BlockOperand";
277 def pclabel : Operand<i32> {
278 let PrintMethod = "printPCLabel";
281 // shifter_operand operands: so_reg and so_imm.
282 def so_reg : Operand<i32>, // reg reg imm
283 ComplexPattern<i32, 3, "SelectShifterOperandReg",
284 [shl,srl,sra,rotr]> {
285 let PrintMethod = "printSORegOperand";
286 let MIOperandInfo = (ops GPR, GPR, i32imm);
289 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
290 // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
291 // represented in the imm field in the same 12-bit form that they are encoded
292 // into so_imm instructions: the 8-bit immediate is the least significant bits
293 // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
294 def so_imm : Operand<i32>,
296 return ARM_AM::getSOImmVal(N->getZExtValue()) != -1;
298 let PrintMethod = "printSOImmOperand";
301 // Break so_imm's up into two pieces. This handles immediates with up to 16
302 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
303 // get the first/second pieces.
304 def so_imm2part : Operand<i32>,
306 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
308 let PrintMethod = "printSOImm2PartOperand";
311 def so_imm2part_1 : SDNodeXForm<imm, [{
312 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
313 return CurDAG->getTargetConstant(V, MVT::i32);
316 def so_imm2part_2 : SDNodeXForm<imm, [{
317 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
318 return CurDAG->getTargetConstant(V, MVT::i32);
321 def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
322 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
324 let PrintMethod = "printSOImm2PartOperand";
327 def so_neg_imm2part_1 : SDNodeXForm<imm, [{
328 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
329 return CurDAG->getTargetConstant(V, MVT::i32);
332 def so_neg_imm2part_2 : SDNodeXForm<imm, [{
333 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
334 return CurDAG->getTargetConstant(V, MVT::i32);
337 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
338 def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
339 return (int32_t)N->getZExtValue() < 32;
342 // Define ARM specific addressing modes.
344 // addrmode2 := reg +/- reg shop imm
345 // addrmode2 := reg +/- imm12
347 def addrmode2 : Operand<i32>,
348 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
349 let PrintMethod = "printAddrMode2Operand";
350 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
353 def am2offset : Operand<i32>,
354 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
355 let PrintMethod = "printAddrMode2OffsetOperand";
356 let MIOperandInfo = (ops GPR, i32imm);
359 // addrmode3 := reg +/- reg
360 // addrmode3 := reg +/- imm8
362 def addrmode3 : Operand<i32>,
363 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
364 let PrintMethod = "printAddrMode3Operand";
365 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
368 def am3offset : Operand<i32>,
369 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
370 let PrintMethod = "printAddrMode3OffsetOperand";
371 let MIOperandInfo = (ops GPR, i32imm);
374 // addrmode4 := reg, <mode|W>
376 def addrmode4 : Operand<i32>,
377 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
378 let PrintMethod = "printAddrMode4Operand";
379 let MIOperandInfo = (ops GPR, i32imm);
382 // addrmode5 := reg +/- imm8*4
384 def addrmode5 : Operand<i32>,
385 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
386 let PrintMethod = "printAddrMode5Operand";
387 let MIOperandInfo = (ops GPR, i32imm);
390 // addrmode6 := reg with optional writeback
392 def addrmode6 : Operand<i32>,
393 ComplexPattern<i32, 4, "SelectAddrMode6", []> {
394 let PrintMethod = "printAddrMode6Operand";
395 let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm);
398 // addrmodepc := pc + reg
400 def addrmodepc : Operand<i32>,
401 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
402 let PrintMethod = "printAddrModePCOperand";
403 let MIOperandInfo = (ops GPR, i32imm);
406 def nohash_imm : Operand<i32> {
407 let PrintMethod = "printNoHashImmediate";
410 //===----------------------------------------------------------------------===//
412 include "ARMInstrFormats.td"
414 //===----------------------------------------------------------------------===//
415 // Multiclass helpers...
418 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
419 /// binop that produces a value.
420 multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
421 bit Commutable = 0> {
422 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
423 IIC_iALUi, opc, "\t$dst, $a, $b",
424 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
427 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
428 IIC_iALUr, opc, "\t$dst, $a, $b",
429 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
430 let Inst{11-4} = 0b00000000;
432 let isCommutable = Commutable;
434 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
435 IIC_iALUsr, opc, "\t$dst, $a, $b",
436 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
441 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
442 /// instruction modifies the CPSR register.
443 let Defs = [CPSR] in {
444 multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
445 bit Commutable = 0> {
446 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
447 IIC_iALUi, opc, "\t$dst, $a, $b",
448 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
452 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
453 IIC_iALUr, opc, "\t$dst, $a, $b",
454 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
455 let isCommutable = Commutable;
456 let Inst{11-4} = 0b00000000;
460 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
461 IIC_iALUsr, opc, "\t$dst, $a, $b",
462 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
469 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
470 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
471 /// a explicit result, only implicitly set CPSR.
472 let Defs = [CPSR] in {
473 multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode,
474 bit Commutable = 0> {
475 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iCMPi,
477 [(opnode GPR:$a, so_imm:$b)]> {
481 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm, IIC_iCMPr,
483 [(opnode GPR:$a, GPR:$b)]> {
484 let Inst{11-4} = 0b00000000;
487 let isCommutable = Commutable;
489 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iCMPsr,
491 [(opnode GPR:$a, so_reg:$b)]> {
498 /// AI_unary_rrot - A unary operation with two forms: one whose operand is a
499 /// register and one whose operand is a register rotated by 8/16/24.
500 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
501 multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> {
502 def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src),
503 IIC_iUNAr, opc, "\t$dst, $src",
504 [(set GPR:$dst, (opnode GPR:$src))]>,
505 Requires<[IsARM, HasV6]> {
506 let Inst{11-10} = 0b00;
507 let Inst{19-16} = 0b1111;
509 def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src, i32imm:$rot),
510 IIC_iUNAsi, opc, "\t$dst, $src, ror $rot",
511 [(set GPR:$dst, (opnode (rotr GPR:$src, rot_imm:$rot)))]>,
512 Requires<[IsARM, HasV6]> {
513 let Inst{19-16} = 0b1111;
517 /// AI_bin_rrot - A binary operation with two forms: one whose operand is a
518 /// register and one whose operand is a register rotated by 8/16/24.
519 multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> {
520 def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
521 IIC_iALUr, opc, "\t$dst, $LHS, $RHS",
522 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
523 Requires<[IsARM, HasV6]> {
524 let Inst{11-10} = 0b00;
526 def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS,
528 IIC_iALUsi, opc, "\t$dst, $LHS, $RHS, ror $rot",
529 [(set GPR:$dst, (opnode GPR:$LHS,
530 (rotr GPR:$RHS, rot_imm:$rot)))]>,
531 Requires<[IsARM, HasV6]>;
534 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
535 let Uses = [CPSR] in {
536 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
537 bit Commutable = 0> {
538 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
539 DPFrm, IIC_iALUi, opc, "\t$dst, $a, $b",
540 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
544 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
545 DPFrm, IIC_iALUr, opc, "\t$dst, $a, $b",
546 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
548 let isCommutable = Commutable;
549 let Inst{11-4} = 0b00000000;
552 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
553 DPSoRegFrm, IIC_iALUsr, opc, "\t$dst, $a, $b",
554 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
559 // Carry setting variants
560 let Defs = [CPSR] in {
561 multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
562 bit Commutable = 0> {
563 def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
564 DPFrm, IIC_iALUi, !strconcat(opc, "\t$dst, $a, $b"),
565 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
570 def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
571 DPFrm, IIC_iALUr, !strconcat(opc, "\t$dst, $a, $b"),
572 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
574 let Inst{11-4} = 0b00000000;
578 def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
579 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$dst, $a, $b"),
580 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
589 //===----------------------------------------------------------------------===//
591 //===----------------------------------------------------------------------===//
593 //===----------------------------------------------------------------------===//
594 // Miscellaneous Instructions.
597 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
598 /// the function. The first operand is the ID# for this instruction, the second
599 /// is the index into the MachineConstantPool that this is, the third is the
600 /// size in bytes of this constant pool entry.
601 let neverHasSideEffects = 1, isNotDuplicable = 1 in
602 def CONSTPOOL_ENTRY :
603 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
604 i32imm:$size), NoItinerary,
605 "${instid:label} ${cpidx:cpentry}", []>;
607 let Defs = [SP], Uses = [SP] in {
609 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
610 "@ ADJCALLSTACKUP $amt1",
611 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
613 def ADJCALLSTACKDOWN :
614 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
615 "@ ADJCALLSTACKDOWN $amt",
616 [(ARMcallseq_start timm:$amt)]>;
619 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "",
620 [/* For disassembly only; pattern left blank */]>,
621 Requires<[IsARM, HasV6T2]> {
622 let Inst{27-16} = 0b001100100000;
623 let Inst{7-0} = 0b00000000;
626 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "",
627 [/* For disassembly only; pattern left blank */]>,
628 Requires<[IsARM, HasV6T2]> {
629 let Inst{27-16} = 0b001100100000;
630 let Inst{7-0} = 0b00000001;
633 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "",
634 [/* For disassembly only; pattern left blank */]>,
635 Requires<[IsARM, HasV6T2]> {
636 let Inst{27-16} = 0b001100100000;
637 let Inst{7-0} = 0b00000010;
640 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "",
641 [/* For disassembly only; pattern left blank */]>,
642 Requires<[IsARM, HasV6T2]> {
643 let Inst{27-16} = 0b001100100000;
644 let Inst{7-0} = 0b00000011;
647 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
648 [/* For disassembly only; pattern left blank */]>,
649 Requires<[IsARM, HasV6T2]> {
650 let Inst{27-16} = 0b001100100000;
651 let Inst{7-0} = 0b00000100;
654 // The i32imm operand $val can be used by a debugger to store more information
655 // about the breakpoint.
656 def BKPT : AI<(outs), (ins i32imm:$val), MiscFrm, NoItinerary, "bkpt", "\t$val",
657 [/* For disassembly only; pattern left blank */]>,
659 let Inst{27-20} = 0b00010010;
660 let Inst{7-4} = 0b0111;
663 // Change Processor State is a system instruction -- for disassembly only.
664 // The singleton $opt operand contains the following information:
665 // opt{4-0} = mode from Inst{4-0}
666 // opt{5} = changemode from Inst{17}
667 // opt{8-6} = AIF from Inst{8-6}
668 // opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
669 def CPS : AXI<(outs),(ins i32imm:$opt), MiscFrm, NoItinerary, "cps${opt:cps}",
670 [/* For disassembly only; pattern left blank */]>,
672 let Inst{31-28} = 0b1111;
673 let Inst{27-20} = 0b00010000;
678 def SETENDBE : AXI<(outs),(ins), MiscFrm, NoItinerary, "setend\tbe",
679 [/* For disassembly only; pattern left blank */]>,
681 let Inst{31-28} = 0b1111;
682 let Inst{27-20} = 0b00010000;
685 let Inst{7-4} = 0b0000;
688 def SETENDLE : AXI<(outs),(ins), MiscFrm, NoItinerary, "setend\tle",
689 [/* For disassembly only; pattern left blank */]>,
691 let Inst{31-28} = 0b1111;
692 let Inst{27-20} = 0b00010000;
695 let Inst{7-4} = 0b0000;
698 def DBG : AI<(outs), (ins i32imm:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
699 [/* For disassembly only; pattern left blank */]>,
700 Requires<[IsARM, HasV7]> {
701 let Inst{27-16} = 0b001100100000;
702 let Inst{7-4} = 0b1111;
705 // A5.4 Permanently UNDEFINED instructions.
706 def TRAP : AI<(outs), (ins), MiscFrm, NoItinerary, "trap", "",
707 [/* For disassembly only; pattern left blank */]>,
709 let Inst{27-25} = 0b011;
710 let Inst{24-20} = 0b11111;
711 let Inst{7-5} = 0b111;
715 // Address computation and loads and stores in PIC mode.
716 let isNotDuplicable = 1 in {
717 def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
718 Pseudo, IIC_iALUr, "\n$cp:\n\tadd$p\t$dst, pc, $a",
719 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
721 let AddedComplexity = 10 in {
722 def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
723 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr$p\t$dst, $addr",
724 [(set GPR:$dst, (load addrmodepc:$addr))]>;
726 def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
727 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrh${p}\t$dst, $addr",
728 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
730 def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
731 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrb${p}\t$dst, $addr",
732 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
734 def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
735 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsh${p}\t$dst, $addr",
736 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
738 def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
739 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsb${p}\t$dst, $addr",
740 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
742 let AddedComplexity = 10 in {
743 def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
744 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr$p\t$src, $addr",
745 [(store GPR:$src, addrmodepc:$addr)]>;
747 def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
748 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrh${p}\t$src, $addr",
749 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
751 def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
752 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrb${p}\t$src, $addr",
753 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
755 } // isNotDuplicable = 1
758 // LEApcrel - Load a pc-relative address into a register without offending the
760 def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
762 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(",
763 "${:private}PCRELL${:uid}+8))\n"),
764 !strconcat("${:private}PCRELL${:uid}:\n\t",
765 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
768 def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
769 (ins i32imm:$label, nohash_imm:$id, pred:$p),
771 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, "
773 "${:private}PCRELL${:uid}+8))\n"),
774 !strconcat("${:private}PCRELL${:uid}:\n\t",
775 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
780 //===----------------------------------------------------------------------===//
781 // Control Flow Instructions.
784 let isReturn = 1, isTerminator = 1, isBarrier = 1 in
785 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
786 "bx", "\tlr", [(ARMretflag)]> {
787 let Inst{3-0} = 0b1110;
788 let Inst{7-4} = 0b0001;
789 let Inst{19-8} = 0b111111111111;
790 let Inst{27-20} = 0b00010010;
794 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
795 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
796 [(brind GPR:$dst)]> {
797 let Inst{7-4} = 0b0001;
798 let Inst{19-8} = 0b111111111111;
799 let Inst{27-20} = 0b00010010;
800 let Inst{31-28} = 0b1110;
804 // FIXME: remove when we have a way to marking a MI with these properties.
805 // FIXME: Should pc be an implicit operand like PICADD, etc?
806 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
807 hasExtraDefRegAllocReq = 1 in
808 def LDM_RET : AXI4ld<(outs),
809 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
810 LdStMulFrm, IIC_Br, "ldm${addr:submode}${p}\t$addr, $wb",
813 // On non-Darwin platforms R9 is callee-saved.
815 Defs = [R0, R1, R2, R3, R12, LR,
816 D0, D1, D2, D3, D4, D5, D6, D7,
817 D16, D17, D18, D19, D20, D21, D22, D23,
818 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
819 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
820 IIC_Br, "bl\t${func:call}",
821 [(ARMcall tglobaladdr:$func)]>,
822 Requires<[IsARM, IsNotDarwin]> {
823 let Inst{31-28} = 0b1110;
826 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
827 IIC_Br, "bl", "\t${func:call}",
828 [(ARMcall_pred tglobaladdr:$func)]>,
829 Requires<[IsARM, IsNotDarwin]>;
832 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
833 IIC_Br, "blx\t$func",
834 [(ARMcall GPR:$func)]>,
835 Requires<[IsARM, HasV5T, IsNotDarwin]> {
836 let Inst{7-4} = 0b0011;
837 let Inst{19-8} = 0b111111111111;
838 let Inst{27-20} = 0b00010010;
842 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
843 def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
844 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
845 [(ARMcall_nolink tGPR:$func)]>,
846 Requires<[IsARM, IsNotDarwin]> {
847 let Inst{7-4} = 0b0001;
848 let Inst{19-8} = 0b111111111111;
849 let Inst{27-20} = 0b00010010;
853 // On Darwin R9 is call-clobbered.
855 Defs = [R0, R1, R2, R3, R9, R12, LR,
856 D0, D1, D2, D3, D4, D5, D6, D7,
857 D16, D17, D18, D19, D20, D21, D22, D23,
858 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
859 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
860 IIC_Br, "bl\t${func:call}",
861 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
862 let Inst{31-28} = 0b1110;
865 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
866 IIC_Br, "bl", "\t${func:call}",
867 [(ARMcall_pred tglobaladdr:$func)]>,
868 Requires<[IsARM, IsDarwin]>;
871 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
872 IIC_Br, "blx\t$func",
873 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
874 let Inst{7-4} = 0b0011;
875 let Inst{19-8} = 0b111111111111;
876 let Inst{27-20} = 0b00010010;
880 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
881 def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
882 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
883 [(ARMcall_nolink tGPR:$func)]>, Requires<[IsARM, IsDarwin]> {
884 let Inst{7-4} = 0b0001;
885 let Inst{19-8} = 0b111111111111;
886 let Inst{27-20} = 0b00010010;
890 let isBranch = 1, isTerminator = 1 in {
891 // B is "predicable" since it can be xformed into a Bcc.
892 let isBarrier = 1 in {
893 let isPredicable = 1 in
894 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
895 "b\t$target", [(br bb:$target)]>;
897 let isNotDuplicable = 1, isIndirectBranch = 1 in {
898 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
899 IIC_Br, "mov\tpc, $target \n$jt",
900 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
901 let Inst{11-4} = 0b00000000;
902 let Inst{15-12} = 0b1111;
903 let Inst{20} = 0; // S Bit
904 let Inst{24-21} = 0b1101;
905 let Inst{27-25} = 0b000;
907 def BR_JTm : JTI<(outs),
908 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
909 IIC_Br, "ldr\tpc, $target \n$jt",
910 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
912 let Inst{15-12} = 0b1111;
913 let Inst{20} = 1; // L bit
914 let Inst{21} = 0; // W bit
915 let Inst{22} = 0; // B bit
916 let Inst{24} = 1; // P bit
917 let Inst{27-25} = 0b011;
919 def BR_JTadd : JTI<(outs),
920 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
921 IIC_Br, "add\tpc, $target, $idx \n$jt",
922 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
924 let Inst{15-12} = 0b1111;
925 let Inst{20} = 0; // S bit
926 let Inst{24-21} = 0b0100;
927 let Inst{27-25} = 0b000;
929 } // isNotDuplicable = 1, isIndirectBranch = 1
932 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
933 // a two-value operand where a dag node expects two operands. :(
934 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
935 IIC_Br, "b", "\t$target",
936 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
939 // Branch and Exchange Jazelle -- for disassembly only
940 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
941 [/* For disassembly only; pattern left blank */]> {
942 let Inst{23-20} = 0b0010;
943 //let Inst{19-8} = 0xfff;
944 let Inst{7-4} = 0b0010;
947 // Supervisor Call (Software Interrupt) -- for disassembly only
949 def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
950 [/* For disassembly only; pattern left blank */]>;
953 // Store Return State -- for disassembly only
954 def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$opt),
955 NoItinerary, "srs${addr:submode}\tsp!, $opt",
956 [/* For disassembly only; pattern left blank */]> {
957 let Inst{31-28} = 0b1111;
958 let Inst{22-20} = 0b110; // W = 1
961 def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
962 NoItinerary, "srs${addr:submode}\tsp, $mode",
963 [/* For disassembly only; pattern left blank */]> {
964 let Inst{31-28} = 0b1111;
965 let Inst{22-20} = 0b100; // W = 0
968 //===----------------------------------------------------------------------===//
969 // Load / store Instructions.
973 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
974 def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
975 "ldr", "\t$dst, $addr",
976 [(set GPR:$dst, (load addrmode2:$addr))]>;
978 // Special LDR for loads from non-pc-relative constpools.
979 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1,
980 mayHaveSideEffects = 1 in
981 def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
982 "ldr", "\t$dst, $addr", []>;
984 // Loads with zero extension
985 def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
986 IIC_iLoadr, "ldrh", "\t$dst, $addr",
987 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
989 def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
990 IIC_iLoadr, "ldrb", "\t$dst, $addr",
991 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
993 // Loads with sign extension
994 def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
995 IIC_iLoadr, "ldrsh", "\t$dst, $addr",
996 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
998 def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
999 IIC_iLoadr, "ldrsb", "\t$dst, $addr",
1000 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
1002 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
1004 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
1005 IIC_iLoadr, "ldrd", "\t$dst1, $addr",
1006 []>, Requires<[IsARM, HasV5TE]>;
1009 def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
1010 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
1011 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1013 def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1014 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
1015 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1017 def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
1018 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
1019 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1021 def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
1022 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
1023 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1025 def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
1026 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
1027 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1029 def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1030 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
1031 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1033 def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
1034 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
1035 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1037 def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
1038 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
1039 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1041 def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
1042 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
1043 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
1045 def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
1046 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
1047 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
1050 // LDRT and LDRBT are for disassembly only.
1052 def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1053 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
1054 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1055 let Inst{21} = 1; // overwrite
1058 def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1059 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
1060 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1061 let Inst{21} = 1; // overwrite
1065 def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
1066 "str", "\t$src, $addr",
1067 [(store GPR:$src, addrmode2:$addr)]>;
1069 // Stores with truncate
1070 def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
1071 IIC_iStorer, "strh", "\t$src, $addr",
1072 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
1074 def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
1075 "strb", "\t$src, $addr",
1076 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
1079 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1080 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
1081 StMiscFrm, IIC_iStorer,
1082 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
1085 def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
1086 (ins GPR:$src, GPR:$base, am2offset:$offset),
1087 StFrm, IIC_iStoreru,
1088 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
1090 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1092 def STR_POST : AI2stwpo<(outs GPR:$base_wb),
1093 (ins GPR:$src, GPR:$base,am2offset:$offset),
1094 StFrm, IIC_iStoreru,
1095 "str", "\t$src, [$base], $offset", "$base = $base_wb",
1097 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1099 def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
1100 (ins GPR:$src, GPR:$base,am3offset:$offset),
1101 StMiscFrm, IIC_iStoreru,
1102 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
1104 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1106 def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
1107 (ins GPR:$src, GPR:$base,am3offset:$offset),
1108 StMiscFrm, IIC_iStoreru,
1109 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
1110 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1111 GPR:$base, am3offset:$offset))]>;
1113 def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
1114 (ins GPR:$src, GPR:$base,am2offset:$offset),
1115 StFrm, IIC_iStoreru,
1116 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
1117 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
1118 GPR:$base, am2offset:$offset))]>;
1120 def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
1121 (ins GPR:$src, GPR:$base,am2offset:$offset),
1122 StFrm, IIC_iStoreru,
1123 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
1124 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
1125 GPR:$base, am2offset:$offset))]>;
1127 // STRT and STRBT are for disassembly only.
1129 def STRT : AI2stwpo<(outs GPR:$base_wb),
1130 (ins GPR:$src, GPR:$base,am2offset:$offset),
1131 StFrm, IIC_iStoreru,
1132 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1133 [/* For disassembly only; pattern left blank */]> {
1134 let Inst{21} = 1; // overwrite
1137 def STRBT : AI2stbpo<(outs GPR:$base_wb),
1138 (ins GPR:$src, GPR:$base,am2offset:$offset),
1139 StFrm, IIC_iStoreru,
1140 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1141 [/* For disassembly only; pattern left blank */]> {
1142 let Inst{21} = 1; // overwrite
1145 //===----------------------------------------------------------------------===//
1146 // Load / store multiple Instructions.
1149 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1150 def LDM : AXI4ld<(outs),
1151 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
1152 LdStMulFrm, IIC_iLoadm, "ldm${addr:submode}${p}\t$addr, $wb",
1155 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1156 def STM : AXI4st<(outs),
1157 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
1158 LdStMulFrm, IIC_iStorem, "stm${addr:submode}${p}\t$addr, $wb",
1161 //===----------------------------------------------------------------------===//
1162 // Move Instructions.
1165 let neverHasSideEffects = 1 in
1166 def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
1167 "mov", "\t$dst, $src", []>, UnaryDP {
1168 let Inst{11-4} = 0b00000000;
1172 def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src),
1173 DPSoRegFrm, IIC_iMOVsr,
1174 "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP {
1178 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1179 def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi,
1180 "mov", "\t$dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP {
1184 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1185 def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src),
1187 "movw", "\t$dst, $src",
1188 [(set GPR:$dst, imm0_65535:$src)]>,
1189 Requires<[IsARM, HasV6T2]>, UnaryDP {
1194 let Constraints = "$src = $dst" in
1195 def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
1197 "movt", "\t$dst, $imm",
1199 (or (and GPR:$src, 0xffff),
1200 lo16AllZero:$imm))]>, UnaryDP,
1201 Requires<[IsARM, HasV6T2]> {
1206 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1207 Requires<[IsARM, HasV6T2]>;
1209 let Uses = [CPSR] in
1210 def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi,
1211 "mov", "\t$dst, $src, rrx",
1212 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
1214 // These aren't really mov instructions, but we have to define them this way
1215 // due to flag operands.
1217 let Defs = [CPSR] in {
1218 def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
1219 IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1",
1220 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
1221 def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
1222 IIC_iMOVsi, "movs", "\t$dst, $src, asr #1",
1223 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
1226 //===----------------------------------------------------------------------===//
1227 // Extend Instructions.
1232 defm SXTB : AI_unary_rrot<0b01101010,
1233 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1234 defm SXTH : AI_unary_rrot<0b01101011,
1235 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
1237 defm SXTAB : AI_bin_rrot<0b01101010,
1238 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1239 defm SXTAH : AI_bin_rrot<0b01101011,
1240 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1242 // TODO: SXT(A){B|H}16
1246 let AddedComplexity = 16 in {
1247 defm UXTB : AI_unary_rrot<0b01101110,
1248 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1249 defm UXTH : AI_unary_rrot<0b01101111,
1250 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1251 defm UXTB16 : AI_unary_rrot<0b01101100,
1252 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1254 def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
1255 (UXTB16r_rot GPR:$Src, 24)>;
1256 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
1257 (UXTB16r_rot GPR:$Src, 8)>;
1259 defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
1260 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1261 defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
1262 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1265 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1266 //defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1268 // TODO: UXT(A){B|H}16
1270 def SBFX : I<(outs GPR:$dst),
1271 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1272 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
1273 "sbfx", "\t$dst, $src, $lsb, $width", "", []>,
1274 Requires<[IsARM, HasV6T2]> {
1275 let Inst{27-21} = 0b0111101;
1276 let Inst{6-4} = 0b101;
1279 def UBFX : I<(outs GPR:$dst),
1280 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1281 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
1282 "ubfx", "\t$dst, $src, $lsb, $width", "", []>,
1283 Requires<[IsARM, HasV6T2]> {
1284 let Inst{27-21} = 0b0111111;
1285 let Inst{6-4} = 0b101;
1288 //===----------------------------------------------------------------------===//
1289 // Arithmetic Instructions.
1292 defm ADD : AsI1_bin_irs<0b0100, "add",
1293 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1294 defm SUB : AsI1_bin_irs<0b0010, "sub",
1295 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1297 // ADD and SUB with 's' bit set.
1298 defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1299 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1300 defm SUBS : AI1_bin_s_irs<0b0010, "subs",
1301 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
1303 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
1304 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
1305 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
1306 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
1307 defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
1308 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
1309 defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
1310 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
1312 // These don't define reg/reg forms, because they are handled above.
1313 def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
1314 IIC_iALUi, "rsb", "\t$dst, $a, $b",
1315 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> {
1319 def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
1320 IIC_iALUsr, "rsb", "\t$dst, $a, $b",
1321 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> {
1325 // RSB with 's' bit set.
1326 let Defs = [CPSR] in {
1327 def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
1328 IIC_iALUi, "rsbs", "\t$dst, $a, $b",
1329 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> {
1333 def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
1334 IIC_iALUsr, "rsbs", "\t$dst, $a, $b",
1335 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> {
1341 let Uses = [CPSR] in {
1342 def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
1343 DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b",
1344 [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>,
1348 def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
1349 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b",
1350 [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>,
1356 // FIXME: Allow these to be predicated.
1357 let Defs = [CPSR], Uses = [CPSR] in {
1358 def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
1359 DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b",
1360 [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>,
1365 def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
1366 DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b",
1367 [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>,
1374 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1375 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1376 (SUBri GPR:$src, so_imm_neg:$imm)>;
1378 //def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1379 // (SUBSri GPR:$src, so_imm_neg:$imm)>;
1380 //def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1381 // (SBCri GPR:$src, so_imm_neg:$imm)>;
1383 // Note: These are implemented in C++ code, because they have to generate
1384 // ADD/SUBrs instructions, which use a complex pattern that a xform function
1386 // (mul X, 2^n+1) -> (add (X << n), X)
1387 // (mul X, 2^n-1) -> (rsb X, (X << n))
1389 // Saturating adds/subtracts -- for disassembly only
1391 // GPR:$dst = GPR:$a op GPR:$b
1392 class AQI<bits<8> op27_20, bits<4> op7_4, string opc>
1393 : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, IIC_iALUr,
1394 opc, "\t$dst, $a, $b",
1395 [/* For disassembly only; pattern left blank */]> {
1396 let Inst{27-20} = op27_20;
1397 let Inst{7-4} = op7_4;
1400 def QADD : AQI<0b00010000, 0b0101, "qadd">;
1401 def QADD16 : AQI<0b01100010, 0b0001, "qadd16">;
1402 def QADD8 : AQI<0b01100010, 0b1001, "qadd8">;
1403 def QASX : AQI<0b01100010, 0b0011, "qasx">;
1404 def QDADD : AQI<0b00010100, 0b0101, "qdadd">;
1405 def QDSUB : AQI<0b00010110, 0b0101, "qdsub">;
1406 def QSAX : AQI<0b01100010, 0b0101, "qsax">;
1407 def QSUB : AQI<0b00010010, 0b0101, "qsub">;
1408 def QSUB16 : AQI<0b01100010, 0b0111, "qsub16">;
1409 def QSUB8 : AQI<0b01100010, 0b1111, "qsub8">;
1410 def UQADD16 : AQI<0b01100110, 0b0001, "uqadd16">;
1411 def UQADD8 : AQI<0b01100110, 0b1001, "uqadd8">;
1412 def UQASX : AQI<0b01100110, 0b0011, "uqasx">;
1413 def UQSAX : AQI<0b01100110, 0b0101, "uqsax">;
1414 def UQSUB16 : AQI<0b01100110, 0b0111, "uqsub16">;
1415 def UQSUB8 : AQI<0b01100110, 0b1111, "uqsub8">;
1417 //===----------------------------------------------------------------------===//
1418 // Bitwise Instructions.
1421 defm AND : AsI1_bin_irs<0b0000, "and",
1422 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1423 defm ORR : AsI1_bin_irs<0b1100, "orr",
1424 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1425 defm EOR : AsI1_bin_irs<0b0001, "eor",
1426 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
1427 defm BIC : AsI1_bin_irs<0b1110, "bic",
1428 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1430 def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
1431 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1432 "bfc", "\t$dst, $imm", "$src = $dst",
1433 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1434 Requires<[IsARM, HasV6T2]> {
1435 let Inst{27-21} = 0b0111110;
1436 let Inst{6-0} = 0b0011111;
1439 def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
1440 "mvn", "\t$dst, $src",
1441 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP {
1443 let Inst{11-4} = 0b00000000;
1445 def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
1446 IIC_iMOVsr, "mvn", "\t$dst, $src",
1447 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP {
1450 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1451 def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
1452 IIC_iMOVi, "mvn", "\t$dst, $imm",
1453 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP {
1457 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1458 (BICri GPR:$src, so_imm_not:$imm)>;
1460 //===----------------------------------------------------------------------===//
1461 // Multiply Instructions.
1464 let isCommutable = 1 in
1465 def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1466 IIC_iMUL32, "mul", "\t$dst, $a, $b",
1467 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
1469 def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1470 IIC_iMAC32, "mla", "\t$dst, $a, $b, $c",
1471 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
1473 def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1474 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
1475 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1476 Requires<[IsARM, HasV6T2]>;
1478 // Extra precision multiplies with low / high results
1479 let neverHasSideEffects = 1 in {
1480 let isCommutable = 1 in {
1481 def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
1482 (ins GPR:$a, GPR:$b), IIC_iMUL64,
1483 "smull", "\t$ldst, $hdst, $a, $b", []>;
1485 def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
1486 (ins GPR:$a, GPR:$b), IIC_iMUL64,
1487 "umull", "\t$ldst, $hdst, $a, $b", []>;
1490 // Multiply + accumulate
1491 def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
1492 (ins GPR:$a, GPR:$b), IIC_iMAC64,
1493 "smlal", "\t$ldst, $hdst, $a, $b", []>;
1495 def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
1496 (ins GPR:$a, GPR:$b), IIC_iMAC64,
1497 "umlal", "\t$ldst, $hdst, $a, $b", []>;
1499 def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
1500 (ins GPR:$a, GPR:$b), IIC_iMAC64,
1501 "umaal", "\t$ldst, $hdst, $a, $b", []>,
1502 Requires<[IsARM, HasV6]>;
1503 } // neverHasSideEffects
1505 // Most significant word multiply
1506 def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1507 IIC_iMUL32, "smmul", "\t$dst, $a, $b",
1508 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
1509 Requires<[IsARM, HasV6]> {
1510 let Inst{7-4} = 0b0001;
1511 let Inst{15-12} = 0b1111;
1514 def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1515 IIC_iMAC32, "smmla", "\t$dst, $a, $b, $c",
1516 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
1517 Requires<[IsARM, HasV6]> {
1518 let Inst{7-4} = 0b0001;
1522 def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1523 IIC_iMAC32, "smmls", "\t$dst, $a, $b, $c",
1524 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
1525 Requires<[IsARM, HasV6]> {
1526 let Inst{7-4} = 0b1101;
1529 multiclass AI_smul<string opc, PatFrag opnode> {
1530 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1531 IIC_iMUL32, !strconcat(opc, "bb"), "\t$dst, $a, $b",
1532 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1533 (sext_inreg GPR:$b, i16)))]>,
1534 Requires<[IsARM, HasV5TE]> {
1539 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1540 IIC_iMUL32, !strconcat(opc, "bt"), "\t$dst, $a, $b",
1541 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1542 (sra GPR:$b, (i32 16))))]>,
1543 Requires<[IsARM, HasV5TE]> {
1548 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1549 IIC_iMUL32, !strconcat(opc, "tb"), "\t$dst, $a, $b",
1550 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1551 (sext_inreg GPR:$b, i16)))]>,
1552 Requires<[IsARM, HasV5TE]> {
1557 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1558 IIC_iMUL32, !strconcat(opc, "tt"), "\t$dst, $a, $b",
1559 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1560 (sra GPR:$b, (i32 16))))]>,
1561 Requires<[IsARM, HasV5TE]> {
1566 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1567 IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b",
1568 [(set GPR:$dst, (sra (opnode GPR:$a,
1569 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
1570 Requires<[IsARM, HasV5TE]> {
1575 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1576 IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b",
1577 [(set GPR:$dst, (sra (opnode GPR:$a,
1578 (sra GPR:$b, (i32 16))), (i32 16)))]>,
1579 Requires<[IsARM, HasV5TE]> {
1586 multiclass AI_smla<string opc, PatFrag opnode> {
1587 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1588 IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
1589 [(set GPR:$dst, (add GPR:$acc,
1590 (opnode (sext_inreg GPR:$a, i16),
1591 (sext_inreg GPR:$b, i16))))]>,
1592 Requires<[IsARM, HasV5TE]> {
1597 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1598 IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
1599 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
1600 (sra GPR:$b, (i32 16)))))]>,
1601 Requires<[IsARM, HasV5TE]> {
1606 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1607 IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
1608 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1609 (sext_inreg GPR:$b, i16))))]>,
1610 Requires<[IsARM, HasV5TE]> {
1615 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1616 IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
1617 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1618 (sra GPR:$b, (i32 16)))))]>,
1619 Requires<[IsARM, HasV5TE]> {
1624 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1625 IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
1626 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1627 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
1628 Requires<[IsARM, HasV5TE]> {
1633 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1634 IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
1635 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1636 (sra GPR:$b, (i32 16))), (i32 16))))]>,
1637 Requires<[IsARM, HasV5TE]> {
1643 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1644 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1646 // Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only
1647 def SMLALBB : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1648 IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
1649 [/* For disassembly only; pattern left blank */]>,
1650 Requires<[IsARM, HasV5TE]> {
1655 def SMLALBT : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1656 IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
1657 [/* For disassembly only; pattern left blank */]>,
1658 Requires<[IsARM, HasV5TE]> {
1663 def SMLALTB : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1664 IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
1665 [/* For disassembly only; pattern left blank */]>,
1666 Requires<[IsARM, HasV5TE]> {
1671 def SMLALTT : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1672 IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
1673 [/* For disassembly only; pattern left blank */]>,
1674 Requires<[IsARM, HasV5TE]> {
1679 // TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1681 //===----------------------------------------------------------------------===//
1682 // Misc. Arithmetic Instructions.
1685 def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1686 "clz", "\t$dst, $src",
1687 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1688 let Inst{7-4} = 0b0001;
1689 let Inst{11-8} = 0b1111;
1690 let Inst{19-16} = 0b1111;
1693 def RBIT : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1694 "rbit", "\t$dst, $src",
1695 [(set GPR:$dst, (ARMrbit GPR:$src))]>,
1696 Requires<[IsARM, HasV6T2]> {
1697 let Inst{7-4} = 0b0011;
1698 let Inst{11-8} = 0b1111;
1699 let Inst{19-16} = 0b1111;
1702 def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1703 "rev", "\t$dst, $src",
1704 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1705 let Inst{7-4} = 0b0011;
1706 let Inst{11-8} = 0b1111;
1707 let Inst{19-16} = 0b1111;
1710 def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1711 "rev16", "\t$dst, $src",
1713 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1714 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1715 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1716 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
1717 Requires<[IsARM, HasV6]> {
1718 let Inst{7-4} = 0b1011;
1719 let Inst{11-8} = 0b1111;
1720 let Inst{19-16} = 0b1111;
1723 def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1724 "revsh", "\t$dst, $src",
1727 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1728 (shl GPR:$src, (i32 8))), i16))]>,
1729 Requires<[IsARM, HasV6]> {
1730 let Inst{7-4} = 0b1011;
1731 let Inst{11-8} = 0b1111;
1732 let Inst{19-16} = 0b1111;
1735 def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1736 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1737 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2, LSL $shamt",
1738 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1739 (and (shl GPR:$src2, (i32 imm:$shamt)),
1741 Requires<[IsARM, HasV6]> {
1742 let Inst{6-4} = 0b001;
1745 // Alternate cases for PKHBT where identities eliminate some nodes.
1746 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1747 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1748 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1749 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1752 def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1753 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1754 IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2, ASR $shamt",
1755 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1756 (and (sra GPR:$src2, imm16_31:$shamt),
1757 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1758 let Inst{6-4} = 0b101;
1761 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
1762 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
1763 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
1764 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1765 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1766 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1767 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1769 //===----------------------------------------------------------------------===//
1770 // Comparison Instructions...
1773 defm CMP : AI1_cmp_irs<0b1010, "cmp",
1774 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
1775 //FIXME: Disable CMN, as CCodes are backwards from compare expectations
1776 // Compare-to-zero still works out, just not the relationals
1777 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
1778 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
1780 // Note that TST/TEQ don't set all the same flags that CMP does!
1781 defm TST : AI1_cmp_irs<0b1000, "tst",
1782 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
1783 defm TEQ : AI1_cmp_irs<0b1001, "teq",
1784 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
1786 defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1787 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1788 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1789 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
1791 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1792 // (CMNri GPR:$src, so_imm_neg:$imm)>;
1794 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
1795 (CMNzri GPR:$src, so_imm_neg:$imm)>;
1798 // Conditional moves
1799 // FIXME: should be able to write a pattern for ARMcmov, but can't use
1800 // a two-value operand where a dag node expects two operands. :(
1801 def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
1802 IIC_iCMOVr, "mov", "\t$dst, $true",
1803 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
1804 RegConstraint<"$false = $dst">, UnaryDP {
1805 let Inst{11-4} = 0b00000000;
1809 def MOVCCs : AI1<0b1101, (outs GPR:$dst),
1810 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
1811 "mov", "\t$dst, $true",
1812 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
1813 RegConstraint<"$false = $dst">, UnaryDP {
1817 def MOVCCi : AI1<0b1101, (outs GPR:$dst),
1818 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
1819 "mov", "\t$dst, $true",
1820 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
1821 RegConstraint<"$false = $dst">, UnaryDP {
1825 //===----------------------------------------------------------------------===//
1826 // Atomic operations intrinsics
1829 // memory barriers protect the atomic sequences
1830 let hasSideEffects = 1 in {
1831 def Int_MemBarrierV7 : AInoP<(outs), (ins),
1832 Pseudo, NoItinerary,
1834 [(ARMMemBarrierV7)]>,
1835 Requires<[IsARM, HasV7]> {
1836 let Inst{31-4} = 0xf57ff05;
1837 // FIXME: add support for options other than a full system DMB
1838 let Inst{3-0} = 0b1111;
1841 def Int_SyncBarrierV7 : AInoP<(outs), (ins),
1842 Pseudo, NoItinerary,
1844 [(ARMSyncBarrierV7)]>,
1845 Requires<[IsARM, HasV7]> {
1846 let Inst{31-4} = 0xf57ff04;
1847 // FIXME: add support for options other than a full system DSB
1848 let Inst{3-0} = 0b1111;
1851 def Int_MemBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1852 Pseudo, NoItinerary,
1853 "mcr", "\tp15, 0, $zero, c7, c10, 5",
1854 [(ARMMemBarrierV6 GPR:$zero)]>,
1855 Requires<[IsARM, HasV6]> {
1856 // FIXME: add support for options other than a full system DMB
1857 // FIXME: add encoding
1860 def Int_SyncBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1861 Pseudo, NoItinerary,
1862 "mcr", "\tp15, 0, $zero, c7, c10, 4",
1863 [(ARMSyncBarrierV6 GPR:$zero)]>,
1864 Requires<[IsARM, HasV6]> {
1865 // FIXME: add support for options other than a full system DSB
1866 // FIXME: add encoding
1870 let usesCustomInserter = 1 in {
1871 let Uses = [CPSR] in {
1872 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
1873 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1874 "${:comment} ATOMIC_LOAD_ADD_I8 PSEUDO!",
1875 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
1876 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
1877 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1878 "${:comment} ATOMIC_LOAD_SUB_I8 PSEUDO!",
1879 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
1880 def ATOMIC_LOAD_AND_I8 : PseudoInst<
1881 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1882 "${:comment} ATOMIC_LOAD_AND_I8 PSEUDO!",
1883 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
1884 def ATOMIC_LOAD_OR_I8 : PseudoInst<
1885 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1886 "${:comment} ATOMIC_LOAD_OR_I8 PSEUDO!",
1887 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
1888 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
1889 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1890 "${:comment} ATOMIC_LOAD_XOR_I8 PSEUDO!",
1891 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
1892 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
1893 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1894 "${:comment} ATOMIC_LOAD_NAND_I8 PSEUDO!",
1895 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
1896 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
1897 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1898 "${:comment} ATOMIC_LOAD_ADD_I16 PSEUDO!",
1899 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
1900 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
1901 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1902 "${:comment} ATOMIC_LOAD_SUB_I16 PSEUDO!",
1903 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
1904 def ATOMIC_LOAD_AND_I16 : PseudoInst<
1905 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1906 "${:comment} ATOMIC_LOAD_AND_I16 PSEUDO!",
1907 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
1908 def ATOMIC_LOAD_OR_I16 : PseudoInst<
1909 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1910 "${:comment} ATOMIC_LOAD_OR_I16 PSEUDO!",
1911 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
1912 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
1913 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1914 "${:comment} ATOMIC_LOAD_XOR_I16 PSEUDO!",
1915 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
1916 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
1917 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1918 "${:comment} ATOMIC_LOAD_NAND_I16 PSEUDO!",
1919 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
1920 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
1921 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1922 "${:comment} ATOMIC_LOAD_ADD_I32 PSEUDO!",
1923 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
1924 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
1925 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1926 "${:comment} ATOMIC_LOAD_SUB_I32 PSEUDO!",
1927 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
1928 def ATOMIC_LOAD_AND_I32 : PseudoInst<
1929 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1930 "${:comment} ATOMIC_LOAD_AND_I32 PSEUDO!",
1931 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
1932 def ATOMIC_LOAD_OR_I32 : PseudoInst<
1933 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1934 "${:comment} ATOMIC_LOAD_OR_I32 PSEUDO!",
1935 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
1936 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
1937 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1938 "${:comment} ATOMIC_LOAD_XOR_I32 PSEUDO!",
1939 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
1940 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
1941 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1942 "${:comment} ATOMIC_LOAD_NAND_I32 PSEUDO!",
1943 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
1945 def ATOMIC_SWAP_I8 : PseudoInst<
1946 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1947 "${:comment} ATOMIC_SWAP_I8 PSEUDO!",
1948 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
1949 def ATOMIC_SWAP_I16 : PseudoInst<
1950 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1951 "${:comment} ATOMIC_SWAP_I16 PSEUDO!",
1952 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
1953 def ATOMIC_SWAP_I32 : PseudoInst<
1954 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1955 "${:comment} ATOMIC_SWAP_I32 PSEUDO!",
1956 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
1958 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
1959 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1960 "${:comment} ATOMIC_CMP_SWAP_I8 PSEUDO!",
1961 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
1962 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
1963 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1964 "${:comment} ATOMIC_CMP_SWAP_I16 PSEUDO!",
1965 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
1966 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
1967 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1968 "${:comment} ATOMIC_CMP_SWAP_I32 PSEUDO!",
1969 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
1973 let mayLoad = 1 in {
1974 def LDREXB : AIldrex<0b10, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1975 "ldrexb", "\t$dest, [$ptr]",
1977 def LDREXH : AIldrex<0b11, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1978 "ldrexh", "\t$dest, [$ptr]",
1980 def LDREX : AIldrex<0b00, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1981 "ldrex", "\t$dest, [$ptr]",
1983 def LDREXD : AIldrex<0b01, (outs GPR:$dest, GPR:$dest2), (ins GPR:$ptr),
1985 "ldrexd", "\t$dest, $dest2, [$ptr]",
1989 let mayStore = 1, Constraints = "@earlyclobber $success" in {
1990 def STREXB : AIstrex<0b10, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
1992 "strexb", "\t$success, $src, [$ptr]",
1994 def STREXH : AIstrex<0b11, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
1996 "strexh", "\t$success, $src, [$ptr]",
1998 def STREX : AIstrex<0b00, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
2000 "strex", "\t$success, $src, [$ptr]",
2002 def STREXD : AIstrex<0b01, (outs GPR:$success),
2003 (ins GPR:$src, GPR:$src2, GPR:$ptr),
2005 "strexd", "\t$success, $src, $src2, [$ptr]",
2009 // SWP/SWPB are deprecated in V6/V7 and for disassembly only.
2010 let mayLoad = 1 in {
2011 def SWP : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2012 "swp", "\t$dst, $src, [$ptr]",
2013 [/* For disassembly only; pattern left blank */]> {
2014 let Inst{27-23} = 0b00010;
2015 let Inst{22} = 0; // B = 0
2016 let Inst{21-20} = 0b00;
2017 let Inst{7-4} = 0b1001;
2020 def SWPB : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2021 "swpb", "\t$dst, $src, [$ptr]",
2022 [/* For disassembly only; pattern left blank */]> {
2023 let Inst{27-23} = 0b00010;
2024 let Inst{22} = 1; // B = 1
2025 let Inst{21-20} = 0b00;
2026 let Inst{7-4} = 0b1001;
2030 //===----------------------------------------------------------------------===//
2034 // __aeabi_read_tp preserves the registers r1-r3.
2036 Defs = [R0, R12, LR, CPSR] in {
2037 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
2038 "bl\t__aeabi_read_tp",
2039 [(set R0, ARMthread_pointer)]>;
2042 //===----------------------------------------------------------------------===//
2043 // SJLJ Exception handling intrinsics
2044 // eh_sjlj_setjmp() is an instruction sequence to store the return
2045 // address and save #0 in R0 for the non-longjmp case.
2046 // Since by its nature we may be coming from some other function to get
2047 // here, and we're using the stack frame for the containing function to
2048 // save/restore registers, we can't keep anything live in regs across
2049 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
2050 // when we get here from a longjmp(). We force everthing out of registers
2051 // except for our own input by listing the relevant registers in Defs. By
2052 // doing so, we also cause the prologue/epilogue code to actively preserve
2053 // all of the callee-saved resgisters, which is exactly what we want.
2054 // A constant value is passed in $val, and we use the location as a scratch.
2056 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2057 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
2058 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
2060 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
2061 AddrModeNone, SizeSpecial, IndexModeNone,
2062 Pseudo, NoItinerary,
2063 "str\tsp, [$src, #+8] @ eh_setjmp begin\n\t"
2064 "add\t$val, pc, #8\n\t"
2065 "str\t$val, [$src, #+4]\n\t"
2067 "add\tpc, pc, #0\n\t"
2068 "mov\tr0, #1 @ eh_setjmp end", "",
2069 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>;
2072 //===----------------------------------------------------------------------===//
2073 // Non-Instruction Patterns
2076 // Large immediate handling.
2078 // Two piece so_imms.
2079 let isReMaterializable = 1 in
2080 def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
2082 "mov", "\t$dst, $src",
2083 [(set GPR:$dst, so_imm2part:$src)]>,
2084 Requires<[IsARM, NoV6T2]>;
2086 def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
2087 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2088 (so_imm2part_2 imm:$RHS))>;
2089 def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
2090 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2091 (so_imm2part_2 imm:$RHS))>;
2092 def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
2093 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2094 (so_imm2part_2 imm:$RHS))>;
2095 def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
2096 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
2097 (so_neg_imm2part_2 imm:$RHS))>;
2099 // 32-bit immediate using movw + movt.
2100 // This is a single pseudo instruction, the benefit is that it can be remat'd
2101 // as a single unit instead of having to handle reg inputs.
2102 // FIXME: Remove this when we can do generalized remat.
2103 let isReMaterializable = 1 in
2104 def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi,
2105 "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}",
2106 [(set GPR:$dst, (i32 imm:$src))]>,
2107 Requires<[IsARM, HasV6T2]>;
2109 // ConstantPool, GlobalAddress, and JumpTable
2110 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
2111 Requires<[IsARM, DontUseMovt]>;
2112 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
2113 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
2114 Requires<[IsARM, UseMovt]>;
2115 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
2116 (LEApcrelJT tjumptable:$dst, imm:$id)>;
2118 // TODO: add,sub,and, 3-instr forms?
2122 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
2123 Requires<[IsARM, IsNotDarwin]>;
2124 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
2125 Requires<[IsARM, IsDarwin]>;
2127 // zextload i1 -> zextload i8
2128 def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2130 // extload -> zextload
2131 def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2132 def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2133 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
2135 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
2136 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
2139 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2140 (sra (shl GPR:$b, (i32 16)), (i32 16))),
2141 (SMULBB GPR:$a, GPR:$b)>;
2142 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
2143 (SMULBB GPR:$a, GPR:$b)>;
2144 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2145 (sra GPR:$b, (i32 16))),
2146 (SMULBT GPR:$a, GPR:$b)>;
2147 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
2148 (SMULBT GPR:$a, GPR:$b)>;
2149 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
2150 (sra (shl GPR:$b, (i32 16)), (i32 16))),
2151 (SMULTB GPR:$a, GPR:$b)>;
2152 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
2153 (SMULTB GPR:$a, GPR:$b)>;
2154 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2156 (SMULWB GPR:$a, GPR:$b)>;
2157 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
2158 (SMULWB GPR:$a, GPR:$b)>;
2160 def : ARMV5TEPat<(add GPR:$acc,
2161 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2162 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
2163 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
2164 def : ARMV5TEPat<(add GPR:$acc,
2165 (mul sext_16_node:$a, sext_16_node:$b)),
2166 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
2167 def : ARMV5TEPat<(add GPR:$acc,
2168 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2169 (sra GPR:$b, (i32 16)))),
2170 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
2171 def : ARMV5TEPat<(add GPR:$acc,
2172 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
2173 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
2174 def : ARMV5TEPat<(add GPR:$acc,
2175 (mul (sra GPR:$a, (i32 16)),
2176 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
2177 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2178 def : ARMV5TEPat<(add GPR:$acc,
2179 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
2180 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2181 def : ARMV5TEPat<(add GPR:$acc,
2182 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2184 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2185 def : ARMV5TEPat<(add GPR:$acc,
2186 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
2187 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2189 //===----------------------------------------------------------------------===//
2193 include "ARMInstrThumb.td"
2195 //===----------------------------------------------------------------------===//
2199 include "ARMInstrThumb2.td"
2201 //===----------------------------------------------------------------------===//
2202 // Floating Point Support
2205 include "ARMInstrVFP.td"
2207 //===----------------------------------------------------------------------===//
2208 // Advanced SIMD (NEON) Support
2211 include "ARMInstrNEON.td"
2213 //===----------------------------------------------------------------------===//
2214 // Coprocessor Instructions. For disassembly only.
2217 def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2218 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2219 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2220 [/* For disassembly only; pattern left blank */]> {
2224 def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2225 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2226 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2227 [/* For disassembly only; pattern left blank */]> {
2228 let Inst{31-28} = 0b1111;
2232 class ACI<dag oops, dag iops, string opc, string asm>
2233 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
2234 opc, asm, "", [/* For disassembly only; pattern left blank */]> {
2235 let Inst{27-25} = 0b110;
2238 multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
2240 def _OFFSET : ACI<(outs),
2241 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2242 opc, "\tp$cop, cr$CRd, $addr"> {
2243 let Inst{31-28} = op31_28;
2244 let Inst{24} = 1; // P = 1
2245 let Inst{21} = 0; // W = 0
2246 let Inst{22} = 0; // D = 0
2247 let Inst{20} = load;
2250 def _PRE : ACI<(outs),
2251 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2252 opc, "\tp$cop, cr$CRd, $addr!"> {
2253 let Inst{31-28} = op31_28;
2254 let Inst{24} = 1; // P = 1
2255 let Inst{21} = 1; // W = 1
2256 let Inst{22} = 0; // D = 0
2257 let Inst{20} = load;
2260 def _POST : ACI<(outs),
2261 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
2262 opc, "\tp$cop, cr$CRd, [$base], $offset"> {
2263 let Inst{31-28} = op31_28;
2264 let Inst{24} = 0; // P = 0
2265 let Inst{21} = 1; // W = 1
2266 let Inst{22} = 0; // D = 0
2267 let Inst{20} = load;
2270 def _OPTION : ACI<(outs),
2271 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option),
2272 opc, "\tp$cop, cr$CRd, [$base], $option"> {
2273 let Inst{31-28} = op31_28;
2274 let Inst{24} = 0; // P = 0
2275 let Inst{23} = 1; // U = 1
2276 let Inst{21} = 0; // W = 0
2277 let Inst{22} = 0; // D = 0
2278 let Inst{20} = load;
2281 def L_OFFSET : ACI<(outs),
2282 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2283 opc, "l\tp$cop, cr$CRd, $addr"> {
2284 let Inst{31-28} = op31_28;
2285 let Inst{24} = 1; // P = 1
2286 let Inst{21} = 0; // W = 0
2287 let Inst{22} = 1; // D = 1
2288 let Inst{20} = load;
2291 def L_PRE : ACI<(outs),
2292 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2293 opc, "l\tp$cop, cr$CRd, $addr!"> {
2294 let Inst{31-28} = op31_28;
2295 let Inst{24} = 1; // P = 1
2296 let Inst{21} = 1; // W = 1
2297 let Inst{22} = 1; // D = 1
2298 let Inst{20} = load;
2301 def L_POST : ACI<(outs),
2302 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
2303 opc, "l\tp$cop, cr$CRd, [$base], $offset"> {
2304 let Inst{31-28} = op31_28;
2305 let Inst{24} = 0; // P = 0
2306 let Inst{21} = 1; // W = 1
2307 let Inst{22} = 1; // D = 1
2308 let Inst{20} = load;
2311 def L_OPTION : ACI<(outs),
2312 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option),
2313 opc, "l\tp$cop, cr$CRd, [$base], $option"> {
2314 let Inst{31-28} = op31_28;
2315 let Inst{24} = 0; // P = 0
2316 let Inst{23} = 1; // U = 1
2317 let Inst{21} = 0; // W = 0
2318 let Inst{22} = 1; // D = 1
2319 let Inst{20} = load;
2323 defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">;
2324 defm LDC2 : LdStCop<0b1111, 1, "ldc2">;
2325 defm STC : LdStCop<{?,?,?,?}, 0, "stc">;
2326 defm STC2 : LdStCop<0b1111, 0, "stc2">;
2328 def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2329 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2330 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2331 [/* For disassembly only; pattern left blank */]> {
2336 def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2337 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2338 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2339 [/* For disassembly only; pattern left blank */]> {
2340 let Inst{31-28} = 0b1111;
2345 def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2346 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2347 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2348 [/* For disassembly only; pattern left blank */]> {
2353 def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2354 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2355 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2356 [/* For disassembly only; pattern left blank */]> {
2357 let Inst{31-28} = 0b1111;
2362 def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2363 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2364 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2365 [/* For disassembly only; pattern left blank */]> {
2366 let Inst{23-20} = 0b0100;
2369 def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2370 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2371 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2372 [/* For disassembly only; pattern left blank */]> {
2373 let Inst{31-28} = 0b1111;
2374 let Inst{23-20} = 0b0100;
2377 def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2378 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2379 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2380 [/* For disassembly only; pattern left blank */]> {
2381 let Inst{23-20} = 0b0101;
2384 def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2385 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2386 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2387 [/* For disassembly only; pattern left blank */]> {
2388 let Inst{31-28} = 0b1111;
2389 let Inst{23-20} = 0b0101;
2392 //===----------------------------------------------------------------------===//
2393 // Move between special register and ARM core register -- for disassembly only
2396 def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr",
2397 [/* For disassembly only; pattern left blank */]> {
2398 let Inst{23-20} = 0b0000;
2399 let Inst{7-4} = 0b0000;
2402 def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr",
2403 [/* For disassembly only; pattern left blank */]> {
2404 let Inst{23-20} = 0b0100;
2405 let Inst{7-4} = 0b0000;
2408 // FIXME: mask is ignored for the time being.
2409 def MSR : ABI<0b0001,(outs),(ins GPR:$src), NoItinerary, "msr", "\tcpsr, $src",
2410 [/* For disassembly only; pattern left blank */]> {
2411 let Inst{23-20} = 0b0010;
2412 let Inst{7-4} = 0b0000;
2415 // FIXME: mask is ignored for the time being.
2416 def MSRi : ABI<0b0011,(outs),(ins so_imm:$a), NoItinerary, "msr", "\tcpsr, $a",
2417 [/* For disassembly only; pattern left blank */]> {
2418 let Inst{23-20} = 0b0010;
2419 let Inst{7-4} = 0b0000;
2422 // FIXME: mask is ignored for the time being.
2423 def MSRsys : ABI<0b0001,(outs),(ins GPR:$src),NoItinerary,"msr","\tspsr, $src",
2424 [/* For disassembly only; pattern left blank */]> {
2425 let Inst{23-20} = 0b0110;
2426 let Inst{7-4} = 0b0000;
2429 // FIXME: mask is ignored for the time being.
2430 def MSRsysi : ABI<0b0011,(outs),(ins so_imm:$a),NoItinerary,"msr","\tspsr, $a",
2431 [/* For disassembly only; pattern left blank */]> {
2432 let Inst{23-20} = 0b0110;
2433 let Inst{7-4} = 0b0000;