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>,
36 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
38 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
40 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
42 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
43 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
45 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
46 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisPtrTy<1>]>;
49 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
50 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
52 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
53 [SDNPHasChain, SDNPOutFlag]>;
54 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
55 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
57 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
58 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
59 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
60 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
61 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
62 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
64 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
65 [SDNPHasChain, SDNPOptInFlag]>;
67 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
69 def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
72 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
73 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
75 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
78 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
81 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
84 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
85 [SDNPOutFlag,SDNPCommutative]>;
87 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
89 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
90 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
91 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
93 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
94 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", SDT_ARMEH_SJLJ_Setjmp>;
96 //===----------------------------------------------------------------------===//
97 // ARM Instruction Predicate Definitions.
99 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
100 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
101 def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
102 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">;
103 def HasV7 : Predicate<"Subtarget->hasV7Ops()">;
104 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">;
105 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">;
106 def HasNEON : Predicate<"Subtarget->hasNEON()">;
107 def IsThumb : Predicate<"Subtarget->isThumb()">;
108 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
109 def IsThumb2 : Predicate<"Subtarget->isThumb2()">;
110 def IsARM : Predicate<"!Subtarget->isThumb()">;
111 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
112 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
113 def CarryDefIsUnused : Predicate<"!N.getNode()->hasAnyUseOfValue(1)">;
114 def CarryDefIsUsed : Predicate<"N.getNode()->hasAnyUseOfValue(1)">;
116 //===----------------------------------------------------------------------===//
117 // ARM Flag Definitions.
119 class RegConstraint<string C> {
120 string Constraints = C;
123 //===----------------------------------------------------------------------===//
124 // ARM specific transformation functions and pattern fragments.
127 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
128 // so_imm_neg def below.
129 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
130 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
133 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
134 // so_imm_not def below.
135 def so_imm_not_XFORM : SDNodeXForm<imm, [{
136 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
139 // rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
140 def rot_imm : PatLeaf<(i32 imm), [{
141 int32_t v = (int32_t)N->getZExtValue();
142 return v == 8 || v == 16 || v == 24;
145 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
146 def imm1_15 : PatLeaf<(i32 imm), [{
147 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
150 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
151 def imm16_31 : PatLeaf<(i32 imm), [{
152 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
157 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
158 }], so_imm_neg_XFORM>;
162 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
163 }], so_imm_not_XFORM>;
165 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
166 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
167 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
170 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
172 def bf_inv_mask_imm : Operand<i32>,
174 uint32_t v = (uint32_t)N->getZExtValue();
177 // there can be 1's on either or both "outsides", all the "inside"
179 unsigned int lsb = 0, msb = 31;
180 while (v & (1 << msb)) --msb;
181 while (v & (1 << lsb)) ++lsb;
182 for (unsigned int i = lsb; i <= msb; ++i) {
188 let PrintMethod = "printBitfieldInvMaskImmOperand";
191 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
192 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
194 //===----------------------------------------------------------------------===//
195 // Operand Definitions.
199 def brtarget : Operand<OtherVT>;
201 // A list of registers separated by comma. Used by load/store multiple.
202 def reglist : Operand<i32> {
203 let PrintMethod = "printRegisterList";
206 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
207 def cpinst_operand : Operand<i32> {
208 let PrintMethod = "printCPInstOperand";
211 def jtblock_operand : Operand<i32> {
212 let PrintMethod = "printJTBlockOperand";
214 def jt2block_operand : Operand<i32> {
215 let PrintMethod = "printJT2BlockOperand";
219 def pclabel : Operand<i32> {
220 let PrintMethod = "printPCLabel";
223 // shifter_operand operands: so_reg and so_imm.
224 def so_reg : Operand<i32>, // reg reg imm
225 ComplexPattern<i32, 3, "SelectShifterOperandReg",
226 [shl,srl,sra,rotr]> {
227 let PrintMethod = "printSORegOperand";
228 let MIOperandInfo = (ops GPR, GPR, i32imm);
231 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
232 // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
233 // represented in the imm field in the same 12-bit form that they are encoded
234 // into so_imm instructions: the 8-bit immediate is the least significant bits
235 // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
236 def so_imm : Operand<i32>,
238 return ARM_AM::getSOImmVal(N->getZExtValue()) != -1;
240 let PrintMethod = "printSOImmOperand";
243 // Break so_imm's up into two pieces. This handles immediates with up to 16
244 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
245 // get the first/second pieces.
246 def so_imm2part : Operand<i32>,
248 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
250 let PrintMethod = "printSOImm2PartOperand";
253 def so_imm2part_1 : SDNodeXForm<imm, [{
254 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
255 return CurDAG->getTargetConstant(V, MVT::i32);
258 def so_imm2part_2 : SDNodeXForm<imm, [{
259 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
260 return CurDAG->getTargetConstant(V, MVT::i32);
264 // Define ARM specific addressing modes.
266 // addrmode2 := reg +/- reg shop imm
267 // addrmode2 := reg +/- imm12
269 def addrmode2 : Operand<i32>,
270 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
271 let PrintMethod = "printAddrMode2Operand";
272 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
275 def am2offset : Operand<i32>,
276 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
277 let PrintMethod = "printAddrMode2OffsetOperand";
278 let MIOperandInfo = (ops GPR, i32imm);
281 // addrmode3 := reg +/- reg
282 // addrmode3 := reg +/- imm8
284 def addrmode3 : Operand<i32>,
285 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
286 let PrintMethod = "printAddrMode3Operand";
287 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
290 def am3offset : Operand<i32>,
291 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
292 let PrintMethod = "printAddrMode3OffsetOperand";
293 let MIOperandInfo = (ops GPR, i32imm);
296 // addrmode4 := reg, <mode|W>
298 def addrmode4 : Operand<i32>,
299 ComplexPattern<i32, 2, "", []> {
300 let PrintMethod = "printAddrMode4Operand";
301 let MIOperandInfo = (ops GPR, i32imm);
304 // addrmode5 := reg +/- imm8*4
306 def addrmode5 : Operand<i32>,
307 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
308 let PrintMethod = "printAddrMode5Operand";
309 let MIOperandInfo = (ops GPR, i32imm);
312 // addrmode6 := reg with optional writeback
314 def addrmode6 : Operand<i32>,
315 ComplexPattern<i32, 3, "SelectAddrMode6", []> {
316 let PrintMethod = "printAddrMode6Operand";
317 let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm);
320 // addrmodepc := pc + reg
322 def addrmodepc : Operand<i32>,
323 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
324 let PrintMethod = "printAddrModePCOperand";
325 let MIOperandInfo = (ops GPR, i32imm);
328 //===----------------------------------------------------------------------===//
330 include "ARMInstrFormats.td"
332 //===----------------------------------------------------------------------===//
333 // Multiclass helpers...
336 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
337 /// binop that produces a value.
338 multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
339 bit Commutable = 0> {
340 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
341 opc, " $dst, $a, $b",
342 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
345 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
346 opc, " $dst, $a, $b",
347 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
349 let isCommutable = Commutable;
351 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
352 opc, " $dst, $a, $b",
353 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
358 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
359 /// instruction modifies the CSPR register.
360 let Defs = [CPSR] in {
361 multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
362 bit Commutable = 0> {
363 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
364 opc, "s $dst, $a, $b",
365 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
368 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
369 opc, "s $dst, $a, $b",
370 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
371 let isCommutable = Commutable;
374 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
375 opc, "s $dst, $a, $b",
376 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
382 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
383 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
384 /// a explicit result, only implicitly set CPSR.
385 let Defs = [CPSR] in {
386 multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode,
387 bit Commutable = 0> {
388 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm,
390 [(opnode GPR:$a, so_imm:$b)]> {
393 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm,
395 [(opnode GPR:$a, GPR:$b)]> {
397 let isCommutable = Commutable;
399 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
401 [(opnode GPR:$a, so_reg:$b)]> {
407 /// AI_unary_rrot - A unary operation with two forms: one whose operand is a
408 /// register and one whose operand is a register rotated by 8/16/24.
409 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
410 multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> {
411 def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$Src),
413 [(set GPR:$dst, (opnode GPR:$Src))]>,
414 Requires<[IsARM, HasV6]> {
415 let Inst{19-16} = 0b1111;
417 def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$Src, i32imm:$rot),
418 opc, " $dst, $Src, ror $rot",
419 [(set GPR:$dst, (opnode (rotr GPR:$Src, rot_imm:$rot)))]>,
420 Requires<[IsARM, HasV6]> {
421 let Inst{19-16} = 0b1111;
425 /// AI_bin_rrot - A binary operation with two forms: one whose operand is a
426 /// register and one whose operand is a register rotated by 8/16/24.
427 multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> {
428 def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
429 opc, " $dst, $LHS, $RHS",
430 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
431 Requires<[IsARM, HasV6]>;
432 def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot),
433 opc, " $dst, $LHS, $RHS, ror $rot",
434 [(set GPR:$dst, (opnode GPR:$LHS,
435 (rotr GPR:$RHS, rot_imm:$rot)))]>,
436 Requires<[IsARM, HasV6]>;
439 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
440 let Uses = [CPSR] in {
441 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
442 bit Commutable = 0> {
443 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
444 DPFrm, opc, " $dst, $a, $b",
445 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
446 Requires<[IsARM, CarryDefIsUnused]> {
449 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
450 DPFrm, opc, " $dst, $a, $b",
451 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
452 Requires<[IsARM, CarryDefIsUnused]> {
453 let isCommutable = Commutable;
456 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
457 DPSoRegFrm, opc, " $dst, $a, $b",
458 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
459 Requires<[IsARM, CarryDefIsUnused]> {
462 // Carry setting variants
463 def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
464 DPFrm, !strconcat(opc, "s $dst, $a, $b"),
465 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
466 Requires<[IsARM, CarryDefIsUsed]> {
470 def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
471 DPFrm, !strconcat(opc, "s $dst, $a, $b"),
472 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
473 Requires<[IsARM, CarryDefIsUsed]> {
477 def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
478 DPSoRegFrm, !strconcat(opc, "s $dst, $a, $b"),
479 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
480 Requires<[IsARM, CarryDefIsUsed]> {
487 //===----------------------------------------------------------------------===//
489 //===----------------------------------------------------------------------===//
491 //===----------------------------------------------------------------------===//
492 // Miscellaneous Instructions.
495 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
496 /// the function. The first operand is the ID# for this instruction, the second
497 /// is the index into the MachineConstantPool that this is, the third is the
498 /// size in bytes of this constant pool entry.
499 let neverHasSideEffects = 1, isNotDuplicable = 1 in
500 def CONSTPOOL_ENTRY :
501 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
503 "${instid:label} ${cpidx:cpentry}", []>;
505 let Defs = [SP], Uses = [SP] in {
507 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p),
508 "@ ADJCALLSTACKUP $amt1",
509 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
511 def ADJCALLSTACKDOWN :
512 PseudoInst<(outs), (ins i32imm:$amt, pred:$p),
513 "@ ADJCALLSTACKDOWN $amt",
514 [(ARMcallseq_start timm:$amt)]>;
518 PseudoInst<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
519 ".loc $file, $line, $col",
520 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
523 // Address computation and loads and stores in PIC mode.
524 let isNotDuplicable = 1 in {
525 def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
526 Pseudo, "$cp:\n\tadd$p $dst, pc, $a",
527 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
529 let AddedComplexity = 10 in {
530 let canFoldAsLoad = 1 in
531 def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
532 Pseudo, "${addr:label}:\n\tldr$p $dst, $addr",
533 [(set GPR:$dst, (load addrmodepc:$addr))]>;
535 def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
536 Pseudo, "${addr:label}:\n\tldr${p}h $dst, $addr",
537 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
539 def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
540 Pseudo, "${addr:label}:\n\tldr${p}b $dst, $addr",
541 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
543 def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
544 Pseudo, "${addr:label}:\n\tldr${p}sh $dst, $addr",
545 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
547 def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
548 Pseudo, "${addr:label}:\n\tldr${p}sb $dst, $addr",
549 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
551 let AddedComplexity = 10 in {
552 def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
553 Pseudo, "${addr:label}:\n\tstr$p $src, $addr",
554 [(store GPR:$src, addrmodepc:$addr)]>;
556 def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
557 Pseudo, "${addr:label}:\n\tstr${p}h $src, $addr",
558 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
560 def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
561 Pseudo, "${addr:label}:\n\tstr${p}b $src, $addr",
562 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
564 } // isNotDuplicable = 1
567 // LEApcrel - Load a pc-relative address into a register without offending the
569 def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p), Pseudo,
570 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(",
571 "${:private}PCRELL${:uid}+8))\n"),
572 !strconcat("${:private}PCRELL${:uid}:\n\t",
573 "add$p $dst, pc, #${:private}PCRELV${:uid}")),
576 def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
577 (ins i32imm:$label, i32imm:$id, pred:$p),
579 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, "
580 "(${label}_${id:no_hash}-(",
581 "${:private}PCRELL${:uid}+8))\n"),
582 !strconcat("${:private}PCRELL${:uid}:\n\t",
583 "add$p $dst, pc, #${:private}PCRELV${:uid}")),
588 //===----------------------------------------------------------------------===//
589 // Control Flow Instructions.
592 let isReturn = 1, isTerminator = 1 in
593 def BX_RET : AI<(outs), (ins), BrMiscFrm, "bx", " lr", [(ARMretflag)]> {
594 let Inst{7-4} = 0b0001;
595 let Inst{19-8} = 0b111111111111;
596 let Inst{27-20} = 0b00010010;
599 // FIXME: remove when we have a way to marking a MI with these properties.
600 // FIXME: $dst1 should be a def. But the extra ops must be in the end of the
602 // FIXME: Should pc be an implicit operand like PICADD, etc?
603 let isReturn = 1, isTerminator = 1, mayLoad = 1 in
604 def LDM_RET : AXI4ld<(outs),
605 (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
606 LdStMulFrm, "ldm${p}${addr:submode} $addr, $dst1",
609 // On non-Darwin platforms R9 is callee-saved.
610 let isCall = 1, Itinerary = IIC_Br,
611 Defs = [R0, R1, R2, R3, R12, LR,
612 D0, D1, D2, D3, D4, D5, D6, D7,
613 D16, D17, D18, D19, D20, D21, D22, D23,
614 D24, D25, D26, D27, D28, D29, D31, D31, CPSR] in {
615 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
617 [(ARMcall tglobaladdr:$func)]>, Requires<[IsNotDarwin]>;
619 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
620 "bl", " ${func:call}",
621 [(ARMcall_pred tglobaladdr:$func)]>, Requires<[IsNotDarwin]>;
624 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
626 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsNotDarwin]> {
627 let Inst{7-4} = 0b0011;
628 let Inst{19-8} = 0b111111111111;
629 let Inst{27-20} = 0b00010010;
633 def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops),
634 "mov lr, pc\n\tbx $func",
635 [(ARMcall_nolink GPR:$func)]>, Requires<[IsNotDarwin]> {
636 let Inst{7-4} = 0b0001;
637 let Inst{19-8} = 0b111111111111;
638 let Inst{27-20} = 0b00010010;
642 // On Darwin R9 is call-clobbered.
643 let isCall = 1, Itinerary = IIC_Br,
644 Defs = [R0, R1, R2, R3, R9, R12, LR,
645 D0, D1, D2, D3, D4, D5, D6, D7,
646 D16, D17, D18, D19, D20, D21, D22, D23,
647 D24, D25, D26, D27, D28, D29, D31, D31, CPSR] in {
648 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
650 [(ARMcall tglobaladdr:$func)]>, Requires<[IsDarwin]>;
652 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
653 "bl", " ${func:call}",
654 [(ARMcall_pred tglobaladdr:$func)]>, Requires<[IsDarwin]>;
657 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
659 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
660 let Inst{7-4} = 0b0011;
661 let Inst{19-8} = 0b111111111111;
662 let Inst{27-20} = 0b00010010;
666 def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops),
667 "mov lr, pc\n\tbx $func",
668 [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> {
669 let Inst{7-4} = 0b0001;
670 let Inst{19-8} = 0b111111111111;
671 let Inst{27-20} = 0b00010010;
675 let isBranch = 1, isTerminator = 1, Itinerary = IIC_Br in {
676 // B is "predicable" since it can be xformed into a Bcc.
677 let isBarrier = 1 in {
678 let isPredicable = 1 in
679 def B : ABXI<0b1010, (outs), (ins brtarget:$target), "b $target",
682 let isNotDuplicable = 1, isIndirectBranch = 1 in {
683 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
684 "mov pc, $target \n$jt",
685 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
686 let Inst{20} = 0; // S Bit
687 let Inst{24-21} = 0b1101;
688 let Inst{27-25} = 0b000;
690 def BR_JTm : JTI<(outs),
691 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
692 "ldr pc, $target \n$jt",
693 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
695 let Inst{20} = 1; // L bit
696 let Inst{21} = 0; // W bit
697 let Inst{22} = 0; // B bit
698 let Inst{24} = 1; // P bit
699 let Inst{27-25} = 0b011;
701 def BR_JTadd : JTI<(outs),
702 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
703 "add pc, $target, $idx \n$jt",
704 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
706 let Inst{20} = 0; // S bit
707 let Inst{24-21} = 0b0100;
708 let Inst{27-25} = 0b000;
710 } // isNotDuplicable = 1, isIndirectBranch = 1
713 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
714 // a two-value operand where a dag node expects two operands. :(
715 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
717 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
720 //===----------------------------------------------------------------------===//
721 // Load / store Instructions.
725 let canFoldAsLoad = 1 in
726 def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
727 "ldr", " $dst, $addr",
728 [(set GPR:$dst, (load addrmode2:$addr))]>;
730 // Special LDR for loads from non-pc-relative constpools.
731 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
732 def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
733 "ldr", " $dst, $addr", []>;
735 // Loads with zero extension
736 def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
737 "ldr", "h $dst, $addr",
738 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
740 def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
741 "ldr", "b $dst, $addr",
742 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
744 // Loads with sign extension
745 def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
746 "ldr", "sh $dst, $addr",
747 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
749 def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
750 "ldr", "sb $dst, $addr",
751 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
755 def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
756 "ldr", "d $dst1, $addr", []>, Requires<[IsARM, HasV5T]>;
759 def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
760 (ins addrmode2:$addr), LdFrm,
761 "ldr", " $dst, $addr!", "$addr.base = $base_wb", []>;
763 def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
764 (ins GPR:$base, am2offset:$offset), LdFrm,
765 "ldr", " $dst, [$base], $offset", "$base = $base_wb", []>;
767 def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
768 (ins addrmode3:$addr), LdMiscFrm,
769 "ldr", "h $dst, $addr!", "$addr.base = $base_wb", []>;
771 def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
772 (ins GPR:$base,am3offset:$offset), LdMiscFrm,
773 "ldr", "h $dst, [$base], $offset", "$base = $base_wb", []>;
775 def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
776 (ins addrmode2:$addr), LdFrm,
777 "ldr", "b $dst, $addr!", "$addr.base = $base_wb", []>;
779 def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
780 (ins GPR:$base,am2offset:$offset), LdFrm,
781 "ldr", "b $dst, [$base], $offset", "$base = $base_wb", []>;
783 def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
784 (ins addrmode3:$addr), LdMiscFrm,
785 "ldr", "sh $dst, $addr!", "$addr.base = $base_wb", []>;
787 def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
788 (ins GPR:$base,am3offset:$offset), LdMiscFrm,
789 "ldr", "sh $dst, [$base], $offset", "$base = $base_wb", []>;
791 def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
792 (ins addrmode3:$addr), LdMiscFrm,
793 "ldr", "sb $dst, $addr!", "$addr.base = $base_wb", []>;
795 def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
796 (ins GPR:$base,am3offset:$offset), LdMiscFrm,
797 "ldr", "sb $dst, [$base], $offset", "$base = $base_wb", []>;
801 def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm,
802 "str", " $src, $addr",
803 [(store GPR:$src, addrmode2:$addr)]>;
805 // Stores with truncate
806 def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
807 "str", "h $src, $addr",
808 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
810 def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm,
811 "str", "b $src, $addr",
812 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
816 def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),StMiscFrm,
817 "str", "d $src1, $addr", []>, Requires<[IsARM, HasV5T]>;
820 def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
821 (ins GPR:$src, GPR:$base, am2offset:$offset), StFrm,
822 "str", " $src, [$base, $offset]!", "$base = $base_wb",
824 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
826 def STR_POST : AI2stwpo<(outs GPR:$base_wb),
827 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
828 "str", " $src, [$base], $offset", "$base = $base_wb",
830 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
832 def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
833 (ins GPR:$src, GPR:$base,am3offset:$offset), StMiscFrm,
834 "str", "h $src, [$base, $offset]!", "$base = $base_wb",
836 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
838 def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
839 (ins GPR:$src, GPR:$base,am3offset:$offset), StMiscFrm,
840 "str", "h $src, [$base], $offset", "$base = $base_wb",
841 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
842 GPR:$base, am3offset:$offset))]>;
844 def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
845 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
846 "str", "b $src, [$base, $offset]!", "$base = $base_wb",
847 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
848 GPR:$base, am2offset:$offset))]>;
850 def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
851 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
852 "str", "b $src, [$base], $offset", "$base = $base_wb",
853 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
854 GPR:$base, am2offset:$offset))]>;
856 //===----------------------------------------------------------------------===//
857 // Load / store multiple Instructions.
860 // FIXME: $dst1 should be a def.
862 def LDM : AXI4ld<(outs),
863 (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
864 LdStMulFrm, "ldm${p}${addr:submode} $addr, $dst1",
868 def STM : AXI4st<(outs),
869 (ins addrmode4:$addr, pred:$p, reglist:$src1, variable_ops),
870 LdStMulFrm, "stm${p}${addr:submode} $addr, $src1",
873 //===----------------------------------------------------------------------===//
874 // Move Instructions.
877 let neverHasSideEffects = 1 in
878 def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm,
879 "mov", " $dst, $src", []>, UnaryDP;
880 def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
881 "mov", " $dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP;
883 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
884 def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm,
885 "mov", " $dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP;
887 def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
888 "mov", " $dst, $src, rrx",
889 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
891 // These aren't really mov instructions, but we have to define them this way
892 // due to flag operands.
894 let Defs = [CPSR] in {
895 def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
896 "mov", "s $dst, $src, lsr #1",
897 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
898 def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
899 "mov", "s $dst, $src, asr #1",
900 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
903 //===----------------------------------------------------------------------===//
904 // Extend Instructions.
909 defm SXTB : AI_unary_rrot<0b01101010,
910 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
911 defm SXTH : AI_unary_rrot<0b01101011,
912 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
914 defm SXTAB : AI_bin_rrot<0b01101010,
915 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
916 defm SXTAH : AI_bin_rrot<0b01101011,
917 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
919 // TODO: SXT(A){B|H}16
923 let AddedComplexity = 16 in {
924 defm UXTB : AI_unary_rrot<0b01101110,
925 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
926 defm UXTH : AI_unary_rrot<0b01101111,
927 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
928 defm UXTB16 : AI_unary_rrot<0b01101100,
929 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
931 def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
932 (UXTB16r_rot GPR:$Src, 24)>;
933 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
934 (UXTB16r_rot GPR:$Src, 8)>;
936 defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
937 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
938 defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
939 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
942 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
943 //defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
945 // TODO: UXT(A){B|H}16
947 //===----------------------------------------------------------------------===//
948 // Arithmetic Instructions.
951 defm ADD : AsI1_bin_irs<0b0100, "add",
952 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
953 defm SUB : AsI1_bin_irs<0b0010, "sub",
954 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
956 // ADD and SUB with 's' bit set.
957 defm ADDS : AI1_bin_s_irs<0b0100, "add",
958 BinOpFrag<(addc node:$LHS, node:$RHS)>>;
959 defm SUBS : AI1_bin_s_irs<0b0010, "sub",
960 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
962 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
963 BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>;
964 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
965 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
967 // These don't define reg/reg forms, because they are handled above.
968 def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
969 "rsb", " $dst, $a, $b",
970 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]>;
972 def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
973 "rsb", " $dst, $a, $b",
974 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]>;
976 // RSB with 's' bit set.
977 let Defs = [CPSR] in {
978 def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
979 "rsb", "s $dst, $a, $b",
980 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]>;
981 def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
982 "rsb", "s $dst, $a, $b",
983 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]>;
986 let Uses = [CPSR] in {
987 def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
988 DPFrm, "rsc", " $dst, $a, $b",
989 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
990 Requires<[IsARM, CarryDefIsUnused]>;
991 def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
992 DPSoRegFrm, "rsc", " $dst, $a, $b",
993 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
994 Requires<[IsARM, CarryDefIsUnused]>;
997 // FIXME: Allow these to be predicated.
998 let Defs = [CPSR], Uses = [CPSR] in {
999 def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
1000 DPFrm, "rscs $dst, $a, $b",
1001 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
1002 Requires<[IsARM, CarryDefIsUnused]>;
1003 def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
1004 DPSoRegFrm, "rscs $dst, $a, $b",
1005 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
1006 Requires<[IsARM, CarryDefIsUnused]>;
1009 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1010 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1011 (SUBri GPR:$src, so_imm_neg:$imm)>;
1013 //def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1014 // (SUBSri GPR:$src, so_imm_neg:$imm)>;
1015 //def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1016 // (SBCri GPR:$src, so_imm_neg:$imm)>;
1018 // Note: These are implemented in C++ code, because they have to generate
1019 // ADD/SUBrs instructions, which use a complex pattern that a xform function
1021 // (mul X, 2^n+1) -> (add (X << n), X)
1022 // (mul X, 2^n-1) -> (rsb X, (X << n))
1025 //===----------------------------------------------------------------------===//
1026 // Bitwise Instructions.
1029 defm AND : AsI1_bin_irs<0b0000, "and",
1030 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
1031 defm ORR : AsI1_bin_irs<0b1100, "orr",
1032 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
1033 defm EOR : AsI1_bin_irs<0b0001, "eor",
1034 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
1035 defm BIC : AsI1_bin_irs<0b1110, "bic",
1036 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1038 def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
1039 AddrMode1, Size4Bytes, IndexModeNone, DPFrm,
1040 "bfc", " $dst, $imm", "$src = $dst",
1041 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1042 Requires<[IsARM, HasV6T2]> {
1043 let Inst{27-21} = 0b0111110;
1044 let Inst{6-0} = 0b0011111;
1047 def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm,
1048 "mvn", " $dst, $src",
1049 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP;
1050 def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
1051 "mvn", " $dst, $src",
1052 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP;
1053 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
1054 def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
1055 "mvn", " $dst, $imm",
1056 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP;
1058 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1059 (BICri GPR:$src, so_imm_not:$imm)>;
1061 //===----------------------------------------------------------------------===//
1062 // Multiply Instructions.
1065 let isCommutable = 1 in
1066 def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1067 "mul", " $dst, $a, $b",
1068 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
1070 def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1071 "mla", " $dst, $a, $b, $c",
1072 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
1074 def MLS : AMul1I <0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1075 "mls", " $dst, $a, $b, $c",
1076 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1077 Requires<[IsARM, HasV6T2]>;
1079 // Extra precision multiplies with low / high results
1080 let neverHasSideEffects = 1 in {
1081 let isCommutable = 1 in {
1082 def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
1083 (ins GPR:$a, GPR:$b),
1084 "smull", " $ldst, $hdst, $a, $b", []>;
1086 def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
1087 (ins GPR:$a, GPR:$b),
1088 "umull", " $ldst, $hdst, $a, $b", []>;
1091 // Multiply + accumulate
1092 def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
1093 (ins GPR:$a, GPR:$b),
1094 "smlal", " $ldst, $hdst, $a, $b", []>;
1096 def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
1097 (ins GPR:$a, GPR:$b),
1098 "umlal", " $ldst, $hdst, $a, $b", []>;
1100 def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
1101 (ins GPR:$a, GPR:$b),
1102 "umaal", " $ldst, $hdst, $a, $b", []>,
1103 Requires<[IsARM, HasV6]>;
1104 } // neverHasSideEffects
1106 // Most significant word multiply
1107 def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1108 "smmul", " $dst, $a, $b",
1109 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
1110 Requires<[IsARM, HasV6]> {
1111 let Inst{7-4} = 0b0001;
1112 let Inst{15-12} = 0b1111;
1115 def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1116 "smmla", " $dst, $a, $b, $c",
1117 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
1118 Requires<[IsARM, HasV6]> {
1119 let Inst{7-4} = 0b0001;
1123 def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1124 "smmls", " $dst, $a, $b, $c",
1125 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
1126 Requires<[IsARM, HasV6]> {
1127 let Inst{7-4} = 0b1101;
1130 multiclass AI_smul<string opc, PatFrag opnode> {
1131 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1132 !strconcat(opc, "bb"), " $dst, $a, $b",
1133 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1134 (sext_inreg GPR:$b, i16)))]>,
1135 Requires<[IsARM, HasV5TE]> {
1140 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1141 !strconcat(opc, "bt"), " $dst, $a, $b",
1142 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1143 (sra GPR:$b, (i32 16))))]>,
1144 Requires<[IsARM, HasV5TE]> {
1149 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1150 !strconcat(opc, "tb"), " $dst, $a, $b",
1151 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1152 (sext_inreg GPR:$b, i16)))]>,
1153 Requires<[IsARM, HasV5TE]> {
1158 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1159 !strconcat(opc, "tt"), " $dst, $a, $b",
1160 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1161 (sra GPR:$b, (i32 16))))]>,
1162 Requires<[IsARM, HasV5TE]> {
1167 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1168 !strconcat(opc, "wb"), " $dst, $a, $b",
1169 [(set GPR:$dst, (sra (opnode GPR:$a,
1170 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
1171 Requires<[IsARM, HasV5TE]> {
1176 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1177 !strconcat(opc, "wt"), " $dst, $a, $b",
1178 [(set GPR:$dst, (sra (opnode GPR:$a,
1179 (sra GPR:$b, (i32 16))), (i32 16)))]>,
1180 Requires<[IsARM, HasV5TE]> {
1187 multiclass AI_smla<string opc, PatFrag opnode> {
1188 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1189 !strconcat(opc, "bb"), " $dst, $a, $b, $acc",
1190 [(set GPR:$dst, (add GPR:$acc,
1191 (opnode (sext_inreg GPR:$a, i16),
1192 (sext_inreg GPR:$b, i16))))]>,
1193 Requires<[IsARM, HasV5TE]> {
1198 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1199 !strconcat(opc, "bt"), " $dst, $a, $b, $acc",
1200 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
1201 (sra GPR:$b, (i32 16)))))]>,
1202 Requires<[IsARM, HasV5TE]> {
1207 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1208 !strconcat(opc, "tb"), " $dst, $a, $b, $acc",
1209 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1210 (sext_inreg GPR:$b, i16))))]>,
1211 Requires<[IsARM, HasV5TE]> {
1216 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1217 !strconcat(opc, "tt"), " $dst, $a, $b, $acc",
1218 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1219 (sra GPR:$b, (i32 16)))))]>,
1220 Requires<[IsARM, HasV5TE]> {
1225 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1226 !strconcat(opc, "wb"), " $dst, $a, $b, $acc",
1227 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1228 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
1229 Requires<[IsARM, HasV5TE]> {
1234 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
1235 !strconcat(opc, "wt"), " $dst, $a, $b, $acc",
1236 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1237 (sra GPR:$b, (i32 16))), (i32 16))))]>,
1238 Requires<[IsARM, HasV5TE]> {
1244 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1245 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1247 // TODO: Halfword multiple accumulate long: SMLAL<x><y>
1248 // TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1250 //===----------------------------------------------------------------------===//
1251 // Misc. Arithmetic Instructions.
1254 def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src),
1255 "clz", " $dst, $src",
1256 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1257 let Inst{7-4} = 0b0001;
1258 let Inst{11-8} = 0b1111;
1259 let Inst{19-16} = 0b1111;
1262 def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src),
1263 "rev", " $dst, $src",
1264 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1265 let Inst{7-4} = 0b0011;
1266 let Inst{11-8} = 0b1111;
1267 let Inst{19-16} = 0b1111;
1270 def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src),
1271 "rev16", " $dst, $src",
1273 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1274 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1275 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1276 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
1277 Requires<[IsARM, HasV6]> {
1278 let Inst{7-4} = 0b1011;
1279 let Inst{11-8} = 0b1111;
1280 let Inst{19-16} = 0b1111;
1283 def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src),
1284 "revsh", " $dst, $src",
1287 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1288 (shl GPR:$src, (i32 8))), i16))]>,
1289 Requires<[IsARM, HasV6]> {
1290 let Inst{7-4} = 0b1011;
1291 let Inst{11-8} = 0b1111;
1292 let Inst{19-16} = 0b1111;
1295 def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1296 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1297 "pkhbt", " $dst, $src1, $src2, LSL $shamt",
1298 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1299 (and (shl GPR:$src2, (i32 imm:$shamt)),
1301 Requires<[IsARM, HasV6]> {
1302 let Inst{6-4} = 0b001;
1305 // Alternate cases for PKHBT where identities eliminate some nodes.
1306 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1307 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1308 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1309 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1312 def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1313 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1314 "pkhtb", " $dst, $src1, $src2, ASR $shamt",
1315 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1316 (and (sra GPR:$src2, imm16_31:$shamt),
1317 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1318 let Inst{6-4} = 0b101;
1321 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
1322 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
1323 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
1324 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1325 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1326 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1327 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1329 //===----------------------------------------------------------------------===//
1330 // Comparison Instructions...
1333 defm CMP : AI1_cmp_irs<0b1010, "cmp",
1334 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
1335 defm CMN : AI1_cmp_irs<0b1011, "cmn",
1336 BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
1338 // Note that TST/TEQ don't set all the same flags that CMP does!
1339 defm TST : AI1_cmp_irs<0b1000, "tst",
1340 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
1341 defm TEQ : AI1_cmp_irs<0b1001, "teq",
1342 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
1344 defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1345 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1346 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1347 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
1349 def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1350 (CMNri GPR:$src, so_imm_neg:$imm)>;
1352 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
1353 (CMNri GPR:$src, so_imm_neg:$imm)>;
1356 // Conditional moves
1357 // FIXME: should be able to write a pattern for ARMcmov, but can't use
1358 // a two-value operand where a dag node expects two operands. :(
1359 def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
1360 "mov", " $dst, $true",
1361 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
1362 RegConstraint<"$false = $dst">, UnaryDP;
1364 def MOVCCs : AI1<0b1101, (outs GPR:$dst),
1365 (ins GPR:$false, so_reg:$true), DPSoRegFrm,
1366 "mov", " $dst, $true",
1367 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
1368 RegConstraint<"$false = $dst">, UnaryDP;
1370 def MOVCCi : AI1<0b1101, (outs GPR:$dst),
1371 (ins GPR:$false, so_imm:$true), DPFrm,
1372 "mov", " $dst, $true",
1373 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
1374 RegConstraint<"$false = $dst">, UnaryDP;
1377 //===----------------------------------------------------------------------===//
1381 // __aeabi_read_tp preserves the registers r1-r3.
1383 Defs = [R0, R12, LR, CPSR] in {
1384 def TPsoft : ABXI<0b1011, (outs), (ins),
1385 "bl __aeabi_read_tp",
1386 [(set R0, ARMthread_pointer)]>;
1389 //===----------------------------------------------------------------------===//
1390 // SJLJ Exception handling intrinsics
1391 // eh_sjlj_setjmp() is a three instruction sequence to store the return
1392 // address and save #0 in R0 for the non-longjmp case.
1393 // Since by its nature we may be coming from some other function to get
1394 // here, and we're using the stack frame for the containing function to
1395 // save/restore registers, we can't keep anything live in regs across
1396 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
1397 // when we get here from a longjmp(). We force everthing out of registers
1398 // except for our own input by listing the relevant registers in Defs. By
1399 // doing so, we also cause the prologue/epilogue code to actively preserve
1400 // all of the callee-saved resgisters, which is exactly what we want.
1402 [ R0, R1, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR,
1403 D0, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
1404 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D31,
1406 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src),
1407 AddrModeNone, SizeSpecial, IndexModeNone, Pseudo,
1408 "add r0, pc, #4\n\t"
1409 "str r0, [$src, #+4]\n\t"
1410 "mov r0, #0 @ eh_setjmp", "",
1411 [(set R0, (ARMeh_sjlj_setjmp GPR:$src))]>;
1414 //===----------------------------------------------------------------------===//
1415 // Non-Instruction Patterns
1418 // ConstantPool, GlobalAddress, and JumpTable
1419 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1420 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1421 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
1422 (LEApcrelJT tjumptable:$dst, imm:$id)>;
1424 // Large immediate handling.
1426 // Two piece so_imms.
1427 let isReMaterializable = 1 in
1428 def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src), Pseudo,
1429 "mov", " $dst, $src",
1430 [(set GPR:$dst, so_imm2part:$src)]>;
1432 def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
1433 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1434 (so_imm2part_2 imm:$RHS))>;
1435 def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
1436 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1437 (so_imm2part_2 imm:$RHS))>;
1439 // TODO: add,sub,and, 3-instr forms?
1443 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
1444 Requires<[IsNotDarwin]>;
1445 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
1446 Requires<[IsDarwin]>;
1448 // zextload i1 -> zextload i8
1449 def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1451 // extload -> zextload
1452 def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1453 def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1454 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
1456 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
1457 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
1460 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1461 (sra (shl GPR:$b, (i32 16)), (i32 16))),
1462 (SMULBB GPR:$a, GPR:$b)>;
1463 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1464 (SMULBB GPR:$a, GPR:$b)>;
1465 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1466 (sra GPR:$b, (i32 16))),
1467 (SMULBT GPR:$a, GPR:$b)>;
1468 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
1469 (SMULBT GPR:$a, GPR:$b)>;
1470 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
1471 (sra (shl GPR:$b, (i32 16)), (i32 16))),
1472 (SMULTB GPR:$a, GPR:$b)>;
1473 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
1474 (SMULTB GPR:$a, GPR:$b)>;
1475 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1477 (SMULWB GPR:$a, GPR:$b)>;
1478 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
1479 (SMULWB GPR:$a, GPR:$b)>;
1481 def : ARMV5TEPat<(add GPR:$acc,
1482 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1483 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
1484 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1485 def : ARMV5TEPat<(add GPR:$acc,
1486 (mul sext_16_node:$a, sext_16_node:$b)),
1487 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1488 def : ARMV5TEPat<(add GPR:$acc,
1489 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1490 (sra GPR:$b, (i32 16)))),
1491 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1492 def : ARMV5TEPat<(add GPR:$acc,
1493 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
1494 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1495 def : ARMV5TEPat<(add GPR:$acc,
1496 (mul (sra GPR:$a, (i32 16)),
1497 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
1498 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1499 def : ARMV5TEPat<(add GPR:$acc,
1500 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
1501 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1502 def : ARMV5TEPat<(add GPR:$acc,
1503 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1505 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1506 def : ARMV5TEPat<(add GPR:$acc,
1507 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
1508 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1510 //===----------------------------------------------------------------------===//
1514 include "ARMInstrThumb.td"
1516 //===----------------------------------------------------------------------===//
1520 include "ARMInstrThumb2.td"
1522 //===----------------------------------------------------------------------===//
1523 // Floating Point Support
1526 include "ARMInstrVFP.td"
1528 //===----------------------------------------------------------------------===//
1529 // Advanced SIMD (NEON) Support
1532 include "ARMInstrNEON.td"