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()">;
133 def CarryDefIsUnused : Predicate<"!N->hasAnyUseOfValue(1)">;
134 def CarryDefIsUsed : Predicate<"N->hasAnyUseOfValue(1)">;
136 // FIXME: Eventually this will be just "hasV6T2Ops".
137 def UseMovt : Predicate<"Subtarget->useMovt()">;
138 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
140 //===----------------------------------------------------------------------===//
141 // ARM Flag Definitions.
143 class RegConstraint<string C> {
144 string Constraints = C;
147 //===----------------------------------------------------------------------===//
148 // ARM specific transformation functions and pattern fragments.
151 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
152 // so_imm_neg def below.
153 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
154 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
157 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
158 // so_imm_not def below.
159 def so_imm_not_XFORM : SDNodeXForm<imm, [{
160 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
163 // rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
164 def rot_imm : PatLeaf<(i32 imm), [{
165 int32_t v = (int32_t)N->getZExtValue();
166 return v == 8 || v == 16 || v == 24;
169 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
170 def imm1_15 : PatLeaf<(i32 imm), [{
171 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
174 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
175 def imm16_31 : PatLeaf<(i32 imm), [{
176 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
181 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
182 }], so_imm_neg_XFORM>;
186 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
187 }], so_imm_not_XFORM>;
189 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
190 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
191 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
194 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
196 def bf_inv_mask_imm : Operand<i32>,
198 uint32_t v = (uint32_t)N->getZExtValue();
201 // there can be 1's on either or both "outsides", all the "inside"
203 unsigned int lsb = 0, msb = 31;
204 while (v & (1 << msb)) --msb;
205 while (v & (1 << lsb)) ++lsb;
206 for (unsigned int i = lsb; i <= msb; ++i) {
212 let PrintMethod = "printBitfieldInvMaskImmOperand";
215 /// Split a 32-bit immediate into two 16 bit parts.
216 def lo16 : SDNodeXForm<imm, [{
217 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() & 0xffff,
221 def hi16 : SDNodeXForm<imm, [{
222 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
225 def lo16AllZero : PatLeaf<(i32 imm), [{
226 // Returns true if all low 16-bits are 0.
227 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
230 /// imm0_65535 predicate - True if the 32-bit immediate is in the range
232 def imm0_65535 : PatLeaf<(i32 imm), [{
233 return (uint32_t)N->getZExtValue() < 65536;
236 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
237 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
239 //===----------------------------------------------------------------------===//
240 // Operand Definitions.
244 def brtarget : Operand<OtherVT>;
246 // A list of registers separated by comma. Used by load/store multiple.
247 def reglist : Operand<i32> {
248 let PrintMethod = "printRegisterList";
251 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
252 def cpinst_operand : Operand<i32> {
253 let PrintMethod = "printCPInstOperand";
256 def jtblock_operand : Operand<i32> {
257 let PrintMethod = "printJTBlockOperand";
259 def jt2block_operand : Operand<i32> {
260 let PrintMethod = "printJT2BlockOperand";
264 def pclabel : Operand<i32> {
265 let PrintMethod = "printPCLabel";
268 // shifter_operand operands: so_reg and so_imm.
269 def so_reg : Operand<i32>, // reg reg imm
270 ComplexPattern<i32, 3, "SelectShifterOperandReg",
271 [shl,srl,sra,rotr]> {
272 let PrintMethod = "printSORegOperand";
273 let MIOperandInfo = (ops GPR, GPR, i32imm);
276 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
277 // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
278 // represented in the imm field in the same 12-bit form that they are encoded
279 // into so_imm instructions: the 8-bit immediate is the least significant bits
280 // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
281 def so_imm : Operand<i32>,
283 return ARM_AM::getSOImmVal(N->getZExtValue()) != -1;
285 let PrintMethod = "printSOImmOperand";
288 // Break so_imm's up into two pieces. This handles immediates with up to 16
289 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
290 // get the first/second pieces.
291 def so_imm2part : Operand<i32>,
293 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
295 let PrintMethod = "printSOImm2PartOperand";
298 def so_imm2part_1 : SDNodeXForm<imm, [{
299 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
300 return CurDAG->getTargetConstant(V, MVT::i32);
303 def so_imm2part_2 : SDNodeXForm<imm, [{
304 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
305 return CurDAG->getTargetConstant(V, MVT::i32);
308 def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
309 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
311 let PrintMethod = "printSOImm2PartOperand";
314 def so_neg_imm2part_1 : SDNodeXForm<imm, [{
315 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
316 return CurDAG->getTargetConstant(V, MVT::i32);
319 def so_neg_imm2part_2 : SDNodeXForm<imm, [{
320 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
321 return CurDAG->getTargetConstant(V, MVT::i32);
324 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
325 def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
326 return (int32_t)N->getZExtValue() < 32;
329 // Define ARM specific addressing modes.
331 // addrmode2 := reg +/- reg shop imm
332 // addrmode2 := reg +/- imm12
334 def addrmode2 : Operand<i32>,
335 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
336 let PrintMethod = "printAddrMode2Operand";
337 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
340 def am2offset : Operand<i32>,
341 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
342 let PrintMethod = "printAddrMode2OffsetOperand";
343 let MIOperandInfo = (ops GPR, i32imm);
346 // addrmode3 := reg +/- reg
347 // addrmode3 := reg +/- imm8
349 def addrmode3 : Operand<i32>,
350 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
351 let PrintMethod = "printAddrMode3Operand";
352 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
355 def am3offset : Operand<i32>,
356 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
357 let PrintMethod = "printAddrMode3OffsetOperand";
358 let MIOperandInfo = (ops GPR, i32imm);
361 // addrmode4 := reg, <mode|W>
363 def addrmode4 : Operand<i32>,
364 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
365 let PrintMethod = "printAddrMode4Operand";
366 let MIOperandInfo = (ops GPR, i32imm);
369 // addrmode5 := reg +/- imm8*4
371 def addrmode5 : Operand<i32>,
372 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
373 let PrintMethod = "printAddrMode5Operand";
374 let MIOperandInfo = (ops GPR, i32imm);
377 // addrmode6 := reg with optional writeback
379 def addrmode6 : Operand<i32>,
380 ComplexPattern<i32, 4, "SelectAddrMode6", []> {
381 let PrintMethod = "printAddrMode6Operand";
382 let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm);
385 // addrmodepc := pc + reg
387 def addrmodepc : Operand<i32>,
388 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
389 let PrintMethod = "printAddrModePCOperand";
390 let MIOperandInfo = (ops GPR, i32imm);
393 def nohash_imm : Operand<i32> {
394 let PrintMethod = "printNoHashImmediate";
397 //===----------------------------------------------------------------------===//
399 include "ARMInstrFormats.td"
401 //===----------------------------------------------------------------------===//
402 // Multiclass helpers...
405 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
406 /// binop that produces a value.
407 multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
408 bit Commutable = 0> {
409 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
410 IIC_iALUi, opc, "\t$dst, $a, $b",
411 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
414 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
415 IIC_iALUr, opc, "\t$dst, $a, $b",
416 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
417 let Inst{11-4} = 0b00000000;
419 let isCommutable = Commutable;
421 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
422 IIC_iALUsr, opc, "\t$dst, $a, $b",
423 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
428 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
429 /// instruction modifies the CPSR register.
430 let Defs = [CPSR] in {
431 multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
432 bit Commutable = 0> {
433 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
434 IIC_iALUi, opc, "\t$dst, $a, $b",
435 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
439 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
440 IIC_iALUr, opc, "\t$dst, $a, $b",
441 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
442 let isCommutable = Commutable;
443 let Inst{11-4} = 0b00000000;
447 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
448 IIC_iALUsr, opc, "\t$dst, $a, $b",
449 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
456 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
457 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
458 /// a explicit result, only implicitly set CPSR.
459 let Defs = [CPSR] in {
460 multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode,
461 bit Commutable = 0> {
462 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iCMPi,
464 [(opnode GPR:$a, so_imm:$b)]> {
468 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm, IIC_iCMPr,
470 [(opnode GPR:$a, GPR:$b)]> {
471 let Inst{11-4} = 0b00000000;
474 let isCommutable = Commutable;
476 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iCMPsr,
478 [(opnode GPR:$a, so_reg:$b)]> {
485 /// AI_unary_rrot - A unary operation with two forms: one whose operand is a
486 /// register and one whose operand is a register rotated by 8/16/24.
487 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
488 multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> {
489 def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src),
490 IIC_iUNAr, opc, "\t$dst, $src",
491 [(set GPR:$dst, (opnode GPR:$src))]>,
492 Requires<[IsARM, HasV6]> {
493 let Inst{11-10} = 0b00;
494 let Inst{19-16} = 0b1111;
496 def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src, i32imm:$rot),
497 IIC_iUNAsi, opc, "\t$dst, $src, ror $rot",
498 [(set GPR:$dst, (opnode (rotr GPR:$src, rot_imm:$rot)))]>,
499 Requires<[IsARM, HasV6]> {
500 let Inst{19-16} = 0b1111;
504 /// AI_bin_rrot - A binary operation with two forms: one whose operand is a
505 /// register and one whose operand is a register rotated by 8/16/24.
506 multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> {
507 def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
508 IIC_iALUr, opc, "\t$dst, $LHS, $RHS",
509 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
510 Requires<[IsARM, HasV6]> {
511 let Inst{11-10} = 0b00;
513 def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot),
514 IIC_iALUsi, opc, "\t$dst, $LHS, $RHS, ror $rot",
515 [(set GPR:$dst, (opnode GPR:$LHS,
516 (rotr GPR:$RHS, rot_imm:$rot)))]>,
517 Requires<[IsARM, HasV6]>;
520 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
521 let Uses = [CPSR] in {
522 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
523 bit Commutable = 0> {
524 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
525 DPFrm, IIC_iALUi, opc, "\t$dst, $a, $b",
526 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
527 Requires<[IsARM, CarryDefIsUnused]> {
530 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
531 DPFrm, IIC_iALUr, opc, "\t$dst, $a, $b",
532 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
533 Requires<[IsARM, CarryDefIsUnused]> {
534 let isCommutable = Commutable;
535 let Inst{11-4} = 0b00000000;
538 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
539 DPSoRegFrm, IIC_iALUsr, opc, "\t$dst, $a, $b",
540 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
541 Requires<[IsARM, CarryDefIsUnused]> {
545 // Carry setting variants
546 let Defs = [CPSR] in {
547 multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
548 bit Commutable = 0> {
549 def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
550 DPFrm, IIC_iALUi, !strconcat(opc, "\t$dst, $a, $b"),
551 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
552 Requires<[IsARM, CarryDefIsUsed]> {
557 def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
558 DPFrm, IIC_iALUr, !strconcat(opc, "\t$dst, $a, $b"),
559 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
560 Requires<[IsARM, CarryDefIsUsed]> {
562 let Inst{11-4} = 0b00000000;
566 def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
567 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$dst, $a, $b"),
568 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
569 Requires<[IsARM, CarryDefIsUsed]> {
578 //===----------------------------------------------------------------------===//
580 //===----------------------------------------------------------------------===//
582 //===----------------------------------------------------------------------===//
583 // Miscellaneous Instructions.
586 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
587 /// the function. The first operand is the ID# for this instruction, the second
588 /// is the index into the MachineConstantPool that this is, the third is the
589 /// size in bytes of this constant pool entry.
590 let neverHasSideEffects = 1, isNotDuplicable = 1 in
591 def CONSTPOOL_ENTRY :
592 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
593 i32imm:$size), NoItinerary,
594 "${instid:label} ${cpidx:cpentry}", []>;
596 let Defs = [SP], Uses = [SP] in {
598 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
599 "@ ADJCALLSTACKUP $amt1",
600 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
602 def ADJCALLSTACKDOWN :
603 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
604 "@ ADJCALLSTACKDOWN $amt",
605 [(ARMcallseq_start timm:$amt)]>;
608 def NOP : AI<(outs), (ins), Pseudo, NoItinerary, "nop", "",
609 [/* For disassembly only; pattern left blank */]>,
610 Requires<[IsARM, HasV6T2]> {
611 let Inst{27-16} = 0b001100100000;
612 let Inst{7-0} = 0b00000000;
615 // The i32imm operand $val can be used by a debugger to store more information
616 // about the breakpoint.
617 def BKPT : AI<(outs), (ins i32imm:$val), Pseudo, NoItinerary, "bkpt", "\t$val",
618 [/* For disassembly only; pattern left blank */]>,
620 let Inst{27-20} = 0b00010010;
621 let Inst{7-4} = 0b0111;
624 def DBG : AI<(outs), (ins i32imm:$opt), Pseudo, NoItinerary, "dbg", "\t$opt",
625 [/* For disassembly only; pattern left blank */]>,
626 Requires<[IsARM, HasV7]> {
627 let Inst{27-16} = 0b001100100000;
628 let Inst{7-4} = 0b1111;
631 // A5.4 Permanently UNDEFINED instructions.
632 def TRAP : AI<(outs), (ins), Pseudo, NoItinerary, "trap", "",
633 [/* For disassembly only; pattern left blank */]>,
635 let Inst{27-25} = 0b011;
636 let Inst{24-20} = 0b11111;
637 let Inst{7-5} = 0b111;
641 // Address computation and loads and stores in PIC mode.
642 let isNotDuplicable = 1 in {
643 def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
644 Pseudo, IIC_iALUr, "\n$cp:\n\tadd$p\t$dst, pc, $a",
645 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
647 let AddedComplexity = 10 in {
648 def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
649 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr$p\t$dst, $addr",
650 [(set GPR:$dst, (load addrmodepc:$addr))]>;
652 def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
653 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrh${p}\t$dst, $addr",
654 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
656 def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
657 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrb${p}\t$dst, $addr",
658 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
660 def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
661 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsh${p}\t$dst, $addr",
662 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
664 def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
665 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsb${p}\t$dst, $addr",
666 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
668 let AddedComplexity = 10 in {
669 def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
670 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr$p\t$src, $addr",
671 [(store GPR:$src, addrmodepc:$addr)]>;
673 def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
674 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrh${p}\t$src, $addr",
675 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
677 def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
678 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrb${p}\t$src, $addr",
679 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
681 } // isNotDuplicable = 1
684 // LEApcrel - Load a pc-relative address into a register without offending the
686 def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
688 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(",
689 "${:private}PCRELL${:uid}+8))\n"),
690 !strconcat("${:private}PCRELL${:uid}:\n\t",
691 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
694 def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
695 (ins i32imm:$label, nohash_imm:$id, pred:$p),
697 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, "
699 "${:private}PCRELL${:uid}+8))\n"),
700 !strconcat("${:private}PCRELL${:uid}:\n\t",
701 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
706 //===----------------------------------------------------------------------===//
707 // Control Flow Instructions.
710 let isReturn = 1, isTerminator = 1, isBarrier = 1 in
711 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
712 "bx", "\tlr", [(ARMretflag)]> {
713 let Inst{3-0} = 0b1110;
714 let Inst{7-4} = 0b0001;
715 let Inst{19-8} = 0b111111111111;
716 let Inst{27-20} = 0b00010010;
720 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
721 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
722 [(brind GPR:$dst)]> {
723 let Inst{7-4} = 0b0001;
724 let Inst{19-8} = 0b111111111111;
725 let Inst{27-20} = 0b00010010;
726 let Inst{31-28} = 0b1110;
730 // FIXME: remove when we have a way to marking a MI with these properties.
731 // FIXME: Should pc be an implicit operand like PICADD, etc?
732 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
733 hasExtraDefRegAllocReq = 1 in
734 def LDM_RET : AXI4ld<(outs),
735 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
736 LdStMulFrm, IIC_Br, "ldm${addr:submode}${p}\t$addr, $wb",
739 // On non-Darwin platforms R9 is callee-saved.
741 Defs = [R0, R1, R2, R3, R12, LR,
742 D0, D1, D2, D3, D4, D5, D6, D7,
743 D16, D17, D18, D19, D20, D21, D22, D23,
744 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
745 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
746 IIC_Br, "bl\t${func:call}",
747 [(ARMcall tglobaladdr:$func)]>,
748 Requires<[IsARM, IsNotDarwin]> {
749 let Inst{31-28} = 0b1110;
752 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
753 IIC_Br, "bl", "\t${func:call}",
754 [(ARMcall_pred tglobaladdr:$func)]>,
755 Requires<[IsARM, IsNotDarwin]>;
758 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
759 IIC_Br, "blx\t$func",
760 [(ARMcall GPR:$func)]>,
761 Requires<[IsARM, HasV5T, IsNotDarwin]> {
762 let Inst{7-4} = 0b0011;
763 let Inst{19-8} = 0b111111111111;
764 let Inst{27-20} = 0b00010010;
768 def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops),
769 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
770 [(ARMcall_nolink GPR:$func)]>,
771 Requires<[IsARM, IsNotDarwin]> {
772 let Inst{7-4} = 0b0001;
773 let Inst{19-8} = 0b111111111111;
774 let Inst{27-20} = 0b00010010;
778 // On Darwin R9 is call-clobbered.
780 Defs = [R0, R1, R2, R3, R9, R12, LR,
781 D0, D1, D2, D3, D4, D5, D6, D7,
782 D16, D17, D18, D19, D20, D21, D22, D23,
783 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
784 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
785 IIC_Br, "bl\t${func:call}",
786 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
787 let Inst{31-28} = 0b1110;
790 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
791 IIC_Br, "bl", "\t${func:call}",
792 [(ARMcall_pred tglobaladdr:$func)]>,
793 Requires<[IsARM, IsDarwin]>;
796 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
797 IIC_Br, "blx\t$func",
798 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
799 let Inst{7-4} = 0b0011;
800 let Inst{19-8} = 0b111111111111;
801 let Inst{27-20} = 0b00010010;
805 def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops),
806 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
807 [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> {
808 let Inst{7-4} = 0b0001;
809 let Inst{19-8} = 0b111111111111;
810 let Inst{27-20} = 0b00010010;
814 let isBranch = 1, isTerminator = 1 in {
815 // B is "predicable" since it can be xformed into a Bcc.
816 let isBarrier = 1 in {
817 let isPredicable = 1 in
818 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
819 "b\t$target", [(br bb:$target)]>;
821 let isNotDuplicable = 1, isIndirectBranch = 1 in {
822 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
823 IIC_Br, "mov\tpc, $target \n$jt",
824 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
825 let Inst{11-4} = 0b00000000;
826 let Inst{15-12} = 0b1111;
827 let Inst{20} = 0; // S Bit
828 let Inst{24-21} = 0b1101;
829 let Inst{27-25} = 0b000;
831 def BR_JTm : JTI<(outs),
832 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
833 IIC_Br, "ldr\tpc, $target \n$jt",
834 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
836 let Inst{15-12} = 0b1111;
837 let Inst{20} = 1; // L bit
838 let Inst{21} = 0; // W bit
839 let Inst{22} = 0; // B bit
840 let Inst{24} = 1; // P bit
841 let Inst{27-25} = 0b011;
843 def BR_JTadd : JTI<(outs),
844 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
845 IIC_Br, "add\tpc, $target, $idx \n$jt",
846 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
848 let Inst{15-12} = 0b1111;
849 let Inst{20} = 0; // S bit
850 let Inst{24-21} = 0b0100;
851 let Inst{27-25} = 0b000;
853 } // isNotDuplicable = 1, isIndirectBranch = 1
856 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
857 // a two-value operand where a dag node expects two operands. :(
858 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
859 IIC_Br, "b", "\t$target",
860 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
863 // Supervisor call (software interrupt) -- for disassembly only
865 def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
866 [/* For disassembly only; pattern left blank */]>;
869 //===----------------------------------------------------------------------===//
870 // Load / store Instructions.
874 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
875 def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
876 "ldr", "\t$dst, $addr",
877 [(set GPR:$dst, (load addrmode2:$addr))]>;
879 // Special LDR for loads from non-pc-relative constpools.
880 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1,
881 mayHaveSideEffects = 1 in
882 def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
883 "ldr", "\t$dst, $addr", []>;
885 // Loads with zero extension
886 def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
887 IIC_iLoadr, "ldrh", "\t$dst, $addr",
888 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
890 def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
891 IIC_iLoadr, "ldrb", "\t$dst, $addr",
892 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
894 // Loads with sign extension
895 def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
896 IIC_iLoadr, "ldrsh", "\t$dst, $addr",
897 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
899 def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
900 IIC_iLoadr, "ldrsb", "\t$dst, $addr",
901 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
903 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
905 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
906 IIC_iLoadr, "ldrd", "\t$dst1, $addr",
907 []>, Requires<[IsARM, HasV5TE]>;
910 def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
911 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
912 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
914 def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
915 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
916 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
918 def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
919 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
920 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
922 def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
923 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
924 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
926 def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
927 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
928 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
930 def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
931 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
932 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
934 def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
935 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
936 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
938 def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
939 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
940 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
942 def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
943 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
944 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
946 def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
947 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
948 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
951 // LDRT and LDRBT are for disassembly only.
953 def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
954 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
955 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
956 let Inst{21} = 1; // overwrite
959 def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
960 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
961 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
962 let Inst{21} = 1; // overwrite
966 def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
967 "str", "\t$src, $addr",
968 [(store GPR:$src, addrmode2:$addr)]>;
970 // Stores with truncate
971 def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, IIC_iStorer,
972 "strh", "\t$src, $addr",
973 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
975 def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
976 "strb", "\t$src, $addr",
977 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
980 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
981 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
982 StMiscFrm, IIC_iStorer,
983 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
986 def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
987 (ins GPR:$src, GPR:$base, am2offset:$offset),
989 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
991 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
993 def STR_POST : AI2stwpo<(outs GPR:$base_wb),
994 (ins GPR:$src, GPR:$base,am2offset:$offset),
996 "str", "\t$src, [$base], $offset", "$base = $base_wb",
998 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1000 def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
1001 (ins GPR:$src, GPR:$base,am3offset:$offset),
1002 StMiscFrm, IIC_iStoreru,
1003 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
1005 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1007 def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
1008 (ins GPR:$src, GPR:$base,am3offset:$offset),
1009 StMiscFrm, IIC_iStoreru,
1010 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
1011 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1012 GPR:$base, am3offset:$offset))]>;
1014 def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
1015 (ins GPR:$src, GPR:$base,am2offset:$offset),
1016 StFrm, IIC_iStoreru,
1017 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
1018 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
1019 GPR:$base, am2offset:$offset))]>;
1021 def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
1022 (ins GPR:$src, GPR:$base,am2offset:$offset),
1023 StFrm, IIC_iStoreru,
1024 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
1025 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
1026 GPR:$base, am2offset:$offset))]>;
1028 // STRT and STRBT are for disassembly only.
1030 def STRT : AI2stwpo<(outs GPR:$base_wb),
1031 (ins GPR:$src, GPR:$base,am2offset:$offset),
1032 StFrm, IIC_iStoreru,
1033 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1034 [/* For disassembly only; pattern left blank */]> {
1035 let Inst{21} = 1; // overwrite
1038 def STRBT : AI2stbpo<(outs GPR:$base_wb),
1039 (ins GPR:$src, GPR:$base,am2offset:$offset),
1040 StFrm, IIC_iStoreru,
1041 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1042 [/* For disassembly only; pattern left blank */]> {
1043 let Inst{21} = 1; // overwrite
1046 //===----------------------------------------------------------------------===//
1047 // Load / store multiple Instructions.
1050 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
1051 def LDM : AXI4ld<(outs),
1052 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
1053 LdStMulFrm, IIC_iLoadm, "ldm${addr:submode}${p}\t$addr, $wb",
1056 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
1057 def STM : AXI4st<(outs),
1058 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
1059 LdStMulFrm, IIC_iStorem, "stm${addr:submode}${p}\t$addr, $wb",
1062 //===----------------------------------------------------------------------===//
1063 // Move Instructions.
1066 let neverHasSideEffects = 1 in
1067 def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
1068 "mov", "\t$dst, $src", []>, UnaryDP {
1069 let Inst{11-4} = 0b00000000;
1073 def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src),
1074 DPSoRegFrm, IIC_iMOVsr,
1075 "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP {
1079 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1080 def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi,
1081 "mov", "\t$dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP {
1085 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1086 def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src),
1088 "movw", "\t$dst, $src",
1089 [(set GPR:$dst, imm0_65535:$src)]>,
1090 Requires<[IsARM, HasV6T2]>, UnaryDP {
1095 let Constraints = "$src = $dst" in
1096 def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
1098 "movt", "\t$dst, $imm",
1100 (or (and GPR:$src, 0xffff),
1101 lo16AllZero:$imm))]>, UnaryDP,
1102 Requires<[IsARM, HasV6T2]> {
1107 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1108 Requires<[IsARM, HasV6T2]>;
1110 let Uses = [CPSR] in
1111 def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi,
1112 "mov", "\t$dst, $src, rrx",
1113 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
1115 // These aren't really mov instructions, but we have to define them this way
1116 // due to flag operands.
1118 let Defs = [CPSR] in {
1119 def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
1120 IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1",
1121 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
1122 def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
1123 IIC_iMOVsi, "movs", "\t$dst, $src, asr #1",
1124 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
1127 //===----------------------------------------------------------------------===//
1128 // Extend Instructions.
1133 defm SXTB : AI_unary_rrot<0b01101010,
1134 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1135 defm SXTH : AI_unary_rrot<0b01101011,
1136 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
1138 defm SXTAB : AI_bin_rrot<0b01101010,
1139 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1140 defm SXTAH : AI_bin_rrot<0b01101011,
1141 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
1143 // TODO: SXT(A){B|H}16
1147 let AddedComplexity = 16 in {
1148 defm UXTB : AI_unary_rrot<0b01101110,
1149 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1150 defm UXTH : AI_unary_rrot<0b01101111,
1151 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1152 defm UXTB16 : AI_unary_rrot<0b01101100,
1153 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
1155 def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
1156 (UXTB16r_rot GPR:$Src, 24)>;
1157 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
1158 (UXTB16r_rot GPR:$Src, 8)>;
1160 defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
1161 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
1162 defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
1163 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1166 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1167 //defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1169 // TODO: UXT(A){B|H}16
1171 def SBFX : I<(outs GPR:$dst),
1172 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1173 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
1174 "sbfx", "\t$dst, $src, $lsb, $width", "", []>,
1175 Requires<[IsARM, HasV6T2]> {
1176 let Inst{27-21} = 0b0111101;
1177 let Inst{6-4} = 0b101;
1180 def UBFX : I<(outs GPR:$dst),
1181 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1182 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
1183 "ubfx", "\t$dst, $src, $lsb, $width", "", []>,
1184 Requires<[IsARM, HasV6T2]> {
1185 let Inst{27-21} = 0b0111111;
1186 let Inst{6-4} = 0b101;
1189 //===----------------------------------------------------------------------===//
1190 // Arithmetic Instructions.
1193 defm ADD : AsI1_bin_irs<0b0100, "add",
1194 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
1195 defm SUB : AsI1_bin_irs<0b0010, "sub",
1196 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
1198 // ADD and SUB with 's' bit set.
1199 defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1200 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1201 defm SUBS : AI1_bin_s_irs<0b0010, "subs",
1202 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
1204 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
1205 BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>;
1206 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
1207 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
1208 defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
1209 BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>;
1210 defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
1211 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
1213 // These don't define reg/reg forms, because they are handled above.
1214 def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
1215 IIC_iALUi, "rsb", "\t$dst, $a, $b",
1216 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> {
1220 def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
1221 IIC_iALUsr, "rsb", "\t$dst, $a, $b",
1222 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> {
1226 // RSB with 's' bit set.
1227 let Defs = [CPSR] in {
1228 def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
1229 IIC_iALUi, "rsbs", "\t$dst, $a, $b",
1230 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> {
1234 def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
1235 IIC_iALUsr, "rsbs", "\t$dst, $a, $b",
1236 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> {
1242 let Uses = [CPSR] in {
1243 def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
1244 DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b",
1245 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
1246 Requires<[IsARM, CarryDefIsUnused]> {
1249 def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
1250 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b",
1251 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
1252 Requires<[IsARM, CarryDefIsUnused]> {
1257 // FIXME: Allow these to be predicated.
1258 let Defs = [CPSR], Uses = [CPSR] in {
1259 def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
1260 DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b",
1261 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
1262 Requires<[IsARM, CarryDefIsUnused]> {
1266 def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
1267 DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b",
1268 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
1269 Requires<[IsARM, CarryDefIsUnused]> {
1275 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1276 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1277 (SUBri GPR:$src, so_imm_neg:$imm)>;
1279 //def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1280 // (SUBSri GPR:$src, so_imm_neg:$imm)>;
1281 //def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1282 // (SBCri GPR:$src, so_imm_neg:$imm)>;
1284 // Note: These are implemented in C++ code, because they have to generate
1285 // ADD/SUBrs instructions, which use a complex pattern that a xform function
1287 // (mul X, 2^n+1) -> (add (X << n), X)
1288 // (mul X, 2^n-1) -> (rsb X, (X << n))
1291 //===----------------------------------------------------------------------===//
1292 // Bitwise Instructions.
1295 defm AND : AsI1_bin_irs<0b0000, "and",
1296 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1297 defm ORR : AsI1_bin_irs<0b1100, "orr",
1298 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1299 defm EOR : AsI1_bin_irs<0b0001, "eor",
1300 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
1301 defm BIC : AsI1_bin_irs<0b1110, "bic",
1302 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1304 def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
1305 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1306 "bfc", "\t$dst, $imm", "$src = $dst",
1307 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1308 Requires<[IsARM, HasV6T2]> {
1309 let Inst{27-21} = 0b0111110;
1310 let Inst{6-0} = 0b0011111;
1313 def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
1314 "mvn", "\t$dst, $src",
1315 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP {
1317 let Inst{11-4} = 0b00000000;
1319 def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
1320 IIC_iMOVsr, "mvn", "\t$dst, $src",
1321 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP {
1324 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1325 def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
1326 IIC_iMOVi, "mvn", "\t$dst, $imm",
1327 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP {
1331 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1332 (BICri GPR:$src, so_imm_not:$imm)>;
1334 //===----------------------------------------------------------------------===//
1335 // Multiply Instructions.
1338 let isCommutable = 1 in
1339 def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1340 IIC_iMUL32, "mul", "\t$dst, $a, $b",
1341 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
1343 def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1344 IIC_iMAC32, "mla", "\t$dst, $a, $b, $c",
1345 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
1347 def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1348 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
1349 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1350 Requires<[IsARM, HasV6T2]>;
1352 // Extra precision multiplies with low / high results
1353 let neverHasSideEffects = 1 in {
1354 let isCommutable = 1 in {
1355 def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
1356 (ins GPR:$a, GPR:$b), IIC_iMUL64,
1357 "smull", "\t$ldst, $hdst, $a, $b", []>;
1359 def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
1360 (ins GPR:$a, GPR:$b), IIC_iMUL64,
1361 "umull", "\t$ldst, $hdst, $a, $b", []>;
1364 // Multiply + accumulate
1365 def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
1366 (ins GPR:$a, GPR:$b), IIC_iMAC64,
1367 "smlal", "\t$ldst, $hdst, $a, $b", []>;
1369 def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
1370 (ins GPR:$a, GPR:$b), IIC_iMAC64,
1371 "umlal", "\t$ldst, $hdst, $a, $b", []>;
1373 def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
1374 (ins GPR:$a, GPR:$b), IIC_iMAC64,
1375 "umaal", "\t$ldst, $hdst, $a, $b", []>,
1376 Requires<[IsARM, HasV6]>;
1377 } // neverHasSideEffects
1379 // Most significant word multiply
1380 def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1381 IIC_iMUL32, "smmul", "\t$dst, $a, $b",
1382 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
1383 Requires<[IsARM, HasV6]> {
1384 let Inst{7-4} = 0b0001;
1385 let Inst{15-12} = 0b1111;
1388 def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1389 IIC_iMAC32, "smmla", "\t$dst, $a, $b, $c",
1390 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
1391 Requires<[IsARM, HasV6]> {
1392 let Inst{7-4} = 0b0001;
1396 def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1397 IIC_iMAC32, "smmls", "\t$dst, $a, $b, $c",
1398 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
1399 Requires<[IsARM, HasV6]> {
1400 let Inst{7-4} = 0b1101;
1403 multiclass AI_smul<string opc, PatFrag opnode> {
1404 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1405 IIC_iMUL32, !strconcat(opc, "bb"), "\t$dst, $a, $b",
1406 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1407 (sext_inreg GPR:$b, i16)))]>,
1408 Requires<[IsARM, HasV5TE]> {
1413 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1414 IIC_iMUL32, !strconcat(opc, "bt"), "\t$dst, $a, $b",
1415 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1416 (sra GPR:$b, (i32 16))))]>,
1417 Requires<[IsARM, HasV5TE]> {
1422 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1423 IIC_iMUL32, !strconcat(opc, "tb"), "\t$dst, $a, $b",
1424 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1425 (sext_inreg GPR:$b, i16)))]>,
1426 Requires<[IsARM, HasV5TE]> {
1431 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1432 IIC_iMUL32, !strconcat(opc, "tt"), "\t$dst, $a, $b",
1433 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1434 (sra GPR:$b, (i32 16))))]>,
1435 Requires<[IsARM, HasV5TE]> {
1440 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1441 IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b",
1442 [(set GPR:$dst, (sra (opnode GPR:$a,
1443 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
1444 Requires<[IsARM, HasV5TE]> {
1449 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1450 IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b",
1451 [(set GPR:$dst, (sra (opnode GPR:$a,
1452 (sra GPR:$b, (i32 16))), (i32 16)))]>,
1453 Requires<[IsARM, HasV5TE]> {
1460 multiclass AI_smla<string opc, PatFrag opnode> {
1461 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1462 IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
1463 [(set GPR:$dst, (add GPR:$acc,
1464 (opnode (sext_inreg GPR:$a, i16),
1465 (sext_inreg GPR:$b, i16))))]>,
1466 Requires<[IsARM, HasV5TE]> {
1471 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1472 IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
1473 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
1474 (sra GPR:$b, (i32 16)))))]>,
1475 Requires<[IsARM, HasV5TE]> {
1480 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1481 IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
1482 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1483 (sext_inreg GPR:$b, i16))))]>,
1484 Requires<[IsARM, HasV5TE]> {
1489 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1490 IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
1491 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1492 (sra GPR:$b, (i32 16)))))]>,
1493 Requires<[IsARM, HasV5TE]> {
1498 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1499 IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
1500 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1501 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
1502 Requires<[IsARM, HasV5TE]> {
1507 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1508 IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
1509 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1510 (sra GPR:$b, (i32 16))), (i32 16))))]>,
1511 Requires<[IsARM, HasV5TE]> {
1517 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1518 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1520 // TODO: Halfword multiple accumulate long: SMLAL<x><y>
1521 // TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1523 //===----------------------------------------------------------------------===//
1524 // Misc. Arithmetic Instructions.
1527 def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1528 "clz", "\t$dst, $src",
1529 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1530 let Inst{7-4} = 0b0001;
1531 let Inst{11-8} = 0b1111;
1532 let Inst{19-16} = 0b1111;
1535 def RBIT : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1536 "rbit", "\t$dst, $src",
1537 [(set GPR:$dst, (ARMrbit GPR:$src))]>,
1538 Requires<[IsARM, HasV6T2]> {
1539 let Inst{7-4} = 0b0011;
1540 let Inst{11-8} = 0b1111;
1541 let Inst{19-16} = 0b1111;
1544 def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1545 "rev", "\t$dst, $src",
1546 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1547 let Inst{7-4} = 0b0011;
1548 let Inst{11-8} = 0b1111;
1549 let Inst{19-16} = 0b1111;
1552 def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1553 "rev16", "\t$dst, $src",
1555 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1556 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1557 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1558 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
1559 Requires<[IsARM, HasV6]> {
1560 let Inst{7-4} = 0b1011;
1561 let Inst{11-8} = 0b1111;
1562 let Inst{19-16} = 0b1111;
1565 def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
1566 "revsh", "\t$dst, $src",
1569 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1570 (shl GPR:$src, (i32 8))), i16))]>,
1571 Requires<[IsARM, HasV6]> {
1572 let Inst{7-4} = 0b1011;
1573 let Inst{11-8} = 0b1111;
1574 let Inst{19-16} = 0b1111;
1577 def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1578 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1579 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2, LSL $shamt",
1580 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1581 (and (shl GPR:$src2, (i32 imm:$shamt)),
1583 Requires<[IsARM, HasV6]> {
1584 let Inst{6-4} = 0b001;
1587 // Alternate cases for PKHBT where identities eliminate some nodes.
1588 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1589 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1590 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1591 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1594 def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1595 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1596 IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2, ASR $shamt",
1597 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1598 (and (sra GPR:$src2, imm16_31:$shamt),
1599 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1600 let Inst{6-4} = 0b101;
1603 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
1604 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
1605 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
1606 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1607 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1608 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1609 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1611 //===----------------------------------------------------------------------===//
1612 // Comparison Instructions...
1615 defm CMP : AI1_cmp_irs<0b1010, "cmp",
1616 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
1617 //FIXME: Disable CMN, as CCodes are backwards from compare expectations
1618 // Compare-to-zero still works out, just not the relationals
1619 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
1620 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
1622 // Note that TST/TEQ don't set all the same flags that CMP does!
1623 defm TST : AI1_cmp_irs<0b1000, "tst",
1624 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
1625 defm TEQ : AI1_cmp_irs<0b1001, "teq",
1626 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
1628 defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1629 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1630 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1631 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
1633 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1634 // (CMNri GPR:$src, so_imm_neg:$imm)>;
1636 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
1637 (CMNzri GPR:$src, so_imm_neg:$imm)>;
1640 // Conditional moves
1641 // FIXME: should be able to write a pattern for ARMcmov, but can't use
1642 // a two-value operand where a dag node expects two operands. :(
1643 def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
1644 IIC_iCMOVr, "mov", "\t$dst, $true",
1645 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
1646 RegConstraint<"$false = $dst">, UnaryDP {
1647 let Inst{11-4} = 0b00000000;
1651 def MOVCCs : AI1<0b1101, (outs GPR:$dst),
1652 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
1653 "mov", "\t$dst, $true",
1654 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
1655 RegConstraint<"$false = $dst">, UnaryDP {
1659 def MOVCCi : AI1<0b1101, (outs GPR:$dst),
1660 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
1661 "mov", "\t$dst, $true",
1662 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
1663 RegConstraint<"$false = $dst">, UnaryDP {
1667 //===----------------------------------------------------------------------===//
1668 // Atomic operations intrinsics
1671 // memory barriers protect the atomic sequences
1672 let hasSideEffects = 1 in {
1673 def Int_MemBarrierV7 : AInoP<(outs), (ins),
1674 Pseudo, NoItinerary,
1676 [(ARMMemBarrierV7)]>,
1677 Requires<[IsARM, HasV7]> {
1678 let Inst{31-4} = 0xf57ff05;
1679 // FIXME: add support for options other than a full system DMB
1680 let Inst{3-0} = 0b1111;
1683 def Int_SyncBarrierV7 : AInoP<(outs), (ins),
1684 Pseudo, NoItinerary,
1686 [(ARMSyncBarrierV7)]>,
1687 Requires<[IsARM, HasV7]> {
1688 let Inst{31-4} = 0xf57ff04;
1689 // FIXME: add support for options other than a full system DSB
1690 let Inst{3-0} = 0b1111;
1693 def Int_MemBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1694 Pseudo, NoItinerary,
1695 "mcr", "\tp15, 0, $zero, c7, c10, 5",
1696 [(ARMMemBarrierV6 GPR:$zero)]>,
1697 Requires<[IsARM, HasV6]> {
1698 // FIXME: add support for options other than a full system DMB
1699 // FIXME: add encoding
1702 def Int_SyncBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1703 Pseudo, NoItinerary,
1704 "mcr", "\tp15, 0, $zero, c7, c10, 4",
1705 [(ARMSyncBarrierV6 GPR:$zero)]>,
1706 Requires<[IsARM, HasV6]> {
1707 // FIXME: add support for options other than a full system DSB
1708 // FIXME: add encoding
1712 let usesCustomInserter = 1 in {
1713 let Uses = [CPSR] in {
1714 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
1715 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1716 "${:comment} ATOMIC_LOAD_ADD_I8 PSEUDO!",
1717 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
1718 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
1719 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1720 "${:comment} ATOMIC_LOAD_SUB_I8 PSEUDO!",
1721 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
1722 def ATOMIC_LOAD_AND_I8 : PseudoInst<
1723 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1724 "${:comment} ATOMIC_LOAD_AND_I8 PSEUDO!",
1725 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
1726 def ATOMIC_LOAD_OR_I8 : PseudoInst<
1727 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1728 "${:comment} ATOMIC_LOAD_OR_I8 PSEUDO!",
1729 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
1730 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
1731 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1732 "${:comment} ATOMIC_LOAD_XOR_I8 PSEUDO!",
1733 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
1734 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
1735 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1736 "${:comment} ATOMIC_LOAD_NAND_I8 PSEUDO!",
1737 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
1738 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
1739 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1740 "${:comment} ATOMIC_LOAD_ADD_I16 PSEUDO!",
1741 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
1742 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
1743 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1744 "${:comment} ATOMIC_LOAD_SUB_I16 PSEUDO!",
1745 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
1746 def ATOMIC_LOAD_AND_I16 : PseudoInst<
1747 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1748 "${:comment} ATOMIC_LOAD_AND_I16 PSEUDO!",
1749 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
1750 def ATOMIC_LOAD_OR_I16 : PseudoInst<
1751 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1752 "${:comment} ATOMIC_LOAD_OR_I16 PSEUDO!",
1753 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
1754 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
1755 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1756 "${:comment} ATOMIC_LOAD_XOR_I16 PSEUDO!",
1757 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
1758 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
1759 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1760 "${:comment} ATOMIC_LOAD_NAND_I16 PSEUDO!",
1761 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
1762 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
1763 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1764 "${:comment} ATOMIC_LOAD_ADD_I32 PSEUDO!",
1765 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
1766 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
1767 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1768 "${:comment} ATOMIC_LOAD_SUB_I32 PSEUDO!",
1769 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
1770 def ATOMIC_LOAD_AND_I32 : PseudoInst<
1771 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1772 "${:comment} ATOMIC_LOAD_AND_I32 PSEUDO!",
1773 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
1774 def ATOMIC_LOAD_OR_I32 : PseudoInst<
1775 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1776 "${:comment} ATOMIC_LOAD_OR_I32 PSEUDO!",
1777 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
1778 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
1779 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1780 "${:comment} ATOMIC_LOAD_XOR_I32 PSEUDO!",
1781 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
1782 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
1783 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1784 "${:comment} ATOMIC_LOAD_NAND_I32 PSEUDO!",
1785 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
1787 def ATOMIC_SWAP_I8 : PseudoInst<
1788 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1789 "${:comment} ATOMIC_SWAP_I8 PSEUDO!",
1790 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
1791 def ATOMIC_SWAP_I16 : PseudoInst<
1792 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1793 "${:comment} ATOMIC_SWAP_I16 PSEUDO!",
1794 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
1795 def ATOMIC_SWAP_I32 : PseudoInst<
1796 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1797 "${:comment} ATOMIC_SWAP_I32 PSEUDO!",
1798 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
1800 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
1801 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1802 "${:comment} ATOMIC_CMP_SWAP_I8 PSEUDO!",
1803 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
1804 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
1805 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1806 "${:comment} ATOMIC_CMP_SWAP_I16 PSEUDO!",
1807 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
1808 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
1809 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1810 "${:comment} ATOMIC_CMP_SWAP_I32 PSEUDO!",
1811 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
1815 let mayLoad = 1 in {
1816 def LDREXB : AIldrex<0b10, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1817 "ldrexb", "\t$dest, [$ptr]",
1819 def LDREXH : AIldrex<0b11, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1820 "ldrexh", "\t$dest, [$ptr]",
1822 def LDREX : AIldrex<0b00, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1823 "ldrex", "\t$dest, [$ptr]",
1825 def LDREXD : AIldrex<0b01, (outs GPR:$dest, GPR:$dest2), (ins GPR:$ptr),
1827 "ldrexd", "\t$dest, $dest2, [$ptr]",
1831 let mayStore = 1, Constraints = "@earlyclobber $success" in {
1832 def STREXB : AIstrex<0b10, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
1834 "strexb", "\t$success, $src, [$ptr]",
1836 def STREXH : AIstrex<0b11, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
1838 "strexh", "\t$success, $src, [$ptr]",
1840 def STREX : AIstrex<0b00, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
1842 "strex", "\t$success, $src, [$ptr]",
1844 def STREXD : AIstrex<0b01, (outs GPR:$success),
1845 (ins GPR:$src, GPR:$src2, GPR:$ptr),
1847 "strexd", "\t$success, $src, $src2, [$ptr]",
1851 //===----------------------------------------------------------------------===//
1855 // __aeabi_read_tp preserves the registers r1-r3.
1857 Defs = [R0, R12, LR, CPSR] in {
1858 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
1859 "bl\t__aeabi_read_tp",
1860 [(set R0, ARMthread_pointer)]>;
1863 //===----------------------------------------------------------------------===//
1864 // SJLJ Exception handling intrinsics
1865 // eh_sjlj_setjmp() is an instruction sequence to store the return
1866 // address and save #0 in R0 for the non-longjmp case.
1867 // Since by its nature we may be coming from some other function to get
1868 // here, and we're using the stack frame for the containing function to
1869 // save/restore registers, we can't keep anything live in regs across
1870 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
1871 // when we get here from a longjmp(). We force everthing out of registers
1872 // except for our own input by listing the relevant registers in Defs. By
1873 // doing so, we also cause the prologue/epilogue code to actively preserve
1874 // all of the callee-saved resgisters, which is exactly what we want.
1875 // A constant value is passed in $val, and we use the location as a scratch.
1877 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
1878 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
1879 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
1881 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
1882 AddrModeNone, SizeSpecial, IndexModeNone,
1883 Pseudo, NoItinerary,
1884 "str\tsp, [$src, #+8] @ eh_setjmp begin\n\t"
1885 "add\t$val, pc, #8\n\t"
1886 "str\t$val, [$src, #+4]\n\t"
1888 "add\tpc, pc, #0\n\t"
1889 "mov\tr0, #1 @ eh_setjmp end", "",
1890 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>;
1893 //===----------------------------------------------------------------------===//
1894 // Non-Instruction Patterns
1897 // Large immediate handling.
1899 // Two piece so_imms.
1900 let isReMaterializable = 1 in
1901 def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
1903 "mov", "\t$dst, $src",
1904 [(set GPR:$dst, so_imm2part:$src)]>,
1905 Requires<[IsARM, NoV6T2]>;
1907 def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
1908 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1909 (so_imm2part_2 imm:$RHS))>;
1910 def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
1911 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1912 (so_imm2part_2 imm:$RHS))>;
1913 def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
1914 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1915 (so_imm2part_2 imm:$RHS))>;
1916 def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
1917 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
1918 (so_neg_imm2part_2 imm:$RHS))>;
1920 // 32-bit immediate using movw + movt.
1921 // This is a single pseudo instruction, the benefit is that it can be remat'd
1922 // as a single unit instead of having to handle reg inputs.
1923 // FIXME: Remove this when we can do generalized remat.
1924 let isReMaterializable = 1 in
1925 def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi,
1926 "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}",
1927 [(set GPR:$dst, (i32 imm:$src))]>,
1928 Requires<[IsARM, HasV6T2]>;
1930 // ConstantPool, GlobalAddress, and JumpTable
1931 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
1932 Requires<[IsARM, DontUseMovt]>;
1933 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1934 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
1935 Requires<[IsARM, UseMovt]>;
1936 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
1937 (LEApcrelJT tjumptable:$dst, imm:$id)>;
1939 // TODO: add,sub,and, 3-instr forms?
1943 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
1944 Requires<[IsARM, IsNotDarwin]>;
1945 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
1946 Requires<[IsARM, IsDarwin]>;
1948 // zextload i1 -> zextload i8
1949 def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1951 // extload -> zextload
1952 def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1953 def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1954 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
1956 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
1957 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
1960 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1961 (sra (shl GPR:$b, (i32 16)), (i32 16))),
1962 (SMULBB GPR:$a, GPR:$b)>;
1963 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1964 (SMULBB GPR:$a, GPR:$b)>;
1965 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1966 (sra GPR:$b, (i32 16))),
1967 (SMULBT GPR:$a, GPR:$b)>;
1968 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
1969 (SMULBT GPR:$a, GPR:$b)>;
1970 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
1971 (sra (shl GPR:$b, (i32 16)), (i32 16))),
1972 (SMULTB GPR:$a, GPR:$b)>;
1973 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
1974 (SMULTB GPR:$a, GPR:$b)>;
1975 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1977 (SMULWB GPR:$a, GPR:$b)>;
1978 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
1979 (SMULWB GPR:$a, GPR:$b)>;
1981 def : ARMV5TEPat<(add GPR:$acc,
1982 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1983 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
1984 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1985 def : ARMV5TEPat<(add GPR:$acc,
1986 (mul sext_16_node:$a, sext_16_node:$b)),
1987 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1988 def : ARMV5TEPat<(add GPR:$acc,
1989 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1990 (sra GPR:$b, (i32 16)))),
1991 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1992 def : ARMV5TEPat<(add GPR:$acc,
1993 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
1994 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1995 def : ARMV5TEPat<(add GPR:$acc,
1996 (mul (sra GPR:$a, (i32 16)),
1997 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
1998 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1999 def : ARMV5TEPat<(add GPR:$acc,
2000 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
2001 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2002 def : ARMV5TEPat<(add GPR:$acc,
2003 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2005 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2006 def : ARMV5TEPat<(add GPR:$acc,
2007 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
2008 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2010 //===----------------------------------------------------------------------===//
2014 include "ARMInstrThumb.td"
2016 //===----------------------------------------------------------------------===//
2020 include "ARMInstrThumb2.td"
2022 //===----------------------------------------------------------------------===//
2023 // Floating Point Support
2026 include "ARMInstrVFP.td"
2028 //===----------------------------------------------------------------------===//
2029 // Advanced SIMD (NEON) Support
2032 include "ARMInstrNEON.td"
2034 //===----------------------------------------------------------------------===//
2035 // Coprocessor Instructions. For disassembly only.
2038 def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2039 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2040 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2041 [/* For disassembly only; pattern left blank */]> {
2045 def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2046 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2047 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2048 [/* For disassembly only; pattern left blank */]> {
2049 let Inst{31-28} = 0b1111;
2053 def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2054 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2055 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2056 [/* For disassembly only; pattern left blank */]> {
2061 def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2062 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2063 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2064 [/* For disassembly only; pattern left blank */]> {
2065 let Inst{31-28} = 0b1111;
2070 def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2071 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2072 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2073 [/* For disassembly only; pattern left blank */]> {
2078 def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2079 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2080 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2081 [/* For disassembly only; pattern left blank */]> {
2082 let Inst{31-28} = 0b1111;
2087 def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2088 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2089 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2090 [/* For disassembly only; pattern left blank */]> {
2091 let Inst{23-20} = 0b0100;
2094 def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2095 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2096 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2097 [/* For disassembly only; pattern left blank */]> {
2098 let Inst{31-28} = 0b1111;
2099 let Inst{23-20} = 0b0100;
2102 def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2103 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2104 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2105 [/* For disassembly only; pattern left blank */]> {
2106 let Inst{23-20} = 0b0101;
2109 def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2110 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2111 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2112 [/* For disassembly only; pattern left blank */]> {
2113 let Inst{31-28} = 0b1111;
2114 let Inst{23-20} = 0b0101;