blob: 41932fc29cbeea87f45ced0b8cbc287906ebdfd9 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the ARM instructions in TableGen format.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// ARM specific DAG Nodes.
16//
17
18// Type profiles.
Bill Wendling7173da52007-11-13 09:19:02 +000019def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021
22def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
23
24def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
25
26def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
28 SDTCisVT<3, i32>]>;
29
30def SDT_ARMBrcond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
32
33def SDT_ARMBrJT : SDTypeProfile<0, 3,
34 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
35 SDTCisVT<2, i32>]>;
36
Evan Cheng1b2b3e22009-07-29 02:18:14 +000037def SDT_ARMBr2JT : SDTypeProfile<0, 4,
38 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
39 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
40
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
42
43def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
44 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
45
46def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
Jim Grosbach4a9025e2009-05-14 00:46:35 +000047def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisPtrTy<1>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000048
49// Node definitions.
50def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
51def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
52
Bill Wendling7173da52007-11-13 09:19:02 +000053def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
Bill Wendling6c02cd22008-02-27 06:33:05 +000054 [SDNPHasChain, SDNPOutFlag]>;
Bill Wendling7173da52007-11-13 09:19:02 +000055def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
Bill Wendling6c02cd22008-02-27 06:33:05 +000056 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
58def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
59 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
60def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
61 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
62def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
63 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
64
Chris Lattner3d254552008-01-15 22:02:54 +000065def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066 [SDNPHasChain, SDNPOptInFlag]>;
67
68def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
69 [SDNPInFlag]>;
70def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
71 [SDNPInFlag]>;
72
73def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
74 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
75
76def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
77 [SDNPHasChain]>;
Evan Cheng1b2b3e22009-07-29 02:18:14 +000078def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
79 [SDNPHasChain]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080
81def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
82 [SDNPOutFlag]>;
83
David Goodwin8bdcbb32009-06-29 15:33:01 +000084def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
85 [SDNPOutFlag,SDNPCommutative]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
87def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
88
89def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
90def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
91def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
92
93def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
Jim Grosbach4a9025e2009-05-14 00:46:35 +000094def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", SDT_ARMEH_SJLJ_Setjmp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095
96//===----------------------------------------------------------------------===//
97// ARM Instruction Predicate Definitions.
98//
Anton Korobeynikovcba02692009-06-15 21:46:20 +000099def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
100def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
101def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
Evan Chengc8147e12009-07-06 22:05:45 +0000102def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">;
Evan Cheng16c012d2009-09-28 09:14:39 +0000103def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
Bob Wilsone60fee02009-06-22 23:27:02 +0000104def HasV7 : Predicate<"Subtarget->hasV7Ops()">;
105def HasVFP2 : Predicate<"Subtarget->hasVFP2()">;
106def HasVFP3 : Predicate<"Subtarget->hasVFP3()">;
107def HasNEON : Predicate<"Subtarget->hasNEON()">;
David Goodwindd19ce42009-08-04 17:53:06 +0000108def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
109def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000110def IsThumb : Predicate<"Subtarget->isThumb()">;
Evan Cheng36173712009-06-23 17:48:47 +0000111def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
Evan Chengb1b2abc2009-07-02 06:38:40 +0000112def IsThumb2 : Predicate<"Subtarget->isThumb2()">;
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000113def IsARM : Predicate<"!Subtarget->isThumb()">;
Bob Wilson243b37c2009-06-22 21:01:46 +0000114def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
115def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
Evan Cheng3e9a99e2009-06-26 06:10:18 +0000116def CarryDefIsUnused : Predicate<"!N.getNode()->hasAnyUseOfValue(1)">;
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000117def CarryDefIsUsed : Predicate<"N.getNode()->hasAnyUseOfValue(1)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118
119//===----------------------------------------------------------------------===//
120// ARM Flag Definitions.
121
122class RegConstraint<string C> {
123 string Constraints = C;
124}
125
126//===----------------------------------------------------------------------===//
127// ARM specific transformation functions and pattern fragments.
128//
129
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130// so_imm_neg_XFORM - Return a so_imm value packed into the format described for
131// so_imm_neg def below.
132def so_imm_neg_XFORM : SDNodeXForm<imm, [{
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000133 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134}]>;
135
136// so_imm_not_XFORM - Return a so_imm value packed into the format described for
137// so_imm_not def below.
138def so_imm_not_XFORM : SDNodeXForm<imm, [{
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000139 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000140}]>;
141
142// rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
143def rot_imm : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000144 int32_t v = (int32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145 return v == 8 || v == 16 || v == 24;
146}]>;
147
148/// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
149def imm1_15 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000150 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000151}]>;
152
153/// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
154def imm16_31 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000155 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156}]>;
157
158def so_imm_neg :
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000159 PatLeaf<(imm), [{
160 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
161 }], so_imm_neg_XFORM>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162
163def so_imm_not :
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000164 PatLeaf<(imm), [{
165 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
166 }], so_imm_not_XFORM>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167
168// sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
169def sext_16_node : PatLeaf<(i32 GPR:$a), [{
Dan Gohman8181bd12008-07-27 21:46:04 +0000170 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171}]>;
172
Evan Cheng299ee652009-07-06 22:23:46 +0000173/// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
174/// e.g., 0xf000ffff
175def bf_inv_mask_imm : Operand<i32>,
176 PatLeaf<(imm), [{
177 uint32_t v = (uint32_t)N->getZExtValue();
178 if (v == 0xffffffff)
179 return 0;
David Goodwinf354d362009-07-14 00:57:56 +0000180 // there can be 1's on either or both "outsides", all the "inside"
181 // bits must be 0's
182 unsigned int lsb = 0, msb = 31;
183 while (v & (1 << msb)) --msb;
184 while (v & (1 << lsb)) ++lsb;
185 for (unsigned int i = lsb; i <= msb; ++i) {
186 if (v & (1 << i))
187 return 0;
188 }
189 return 1;
Evan Cheng299ee652009-07-06 22:23:46 +0000190}] > {
191 let PrintMethod = "printBitfieldInvMaskImmOperand";
192}
193
Anton Korobeynikov60928952009-09-27 23:52:58 +0000194/// Split a 32-bit immediate into two 16 bit parts.
195def lo16 : SDNodeXForm<imm, [{
196 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() & 0xffff,
197 MVT::i32);
198}]>;
199
200def hi16 : SDNodeXForm<imm, [{
201 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
202}]>;
203
204def lo16AllZero : PatLeaf<(i32 imm), [{
205 // Returns true if all low 16-bits are 0.
206 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
207 }], hi16>;
208
209/// imm0_65535 predicate - True if the 32-bit immediate is in the range
210/// [0.65535].
211def imm0_65535 : PatLeaf<(i32 imm), [{
212 return (uint32_t)N->getZExtValue() < 65536;
213}]>;
214
Evan Cheng7b0249b2008-08-28 23:39:26 +0000215class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
216class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217
218//===----------------------------------------------------------------------===//
219// Operand Definitions.
220//
221
222// Branch target.
223def brtarget : Operand<OtherVT>;
224
225// A list of registers separated by comma. Used by load/store multiple.
226def reglist : Operand<i32> {
227 let PrintMethod = "printRegisterList";
228}
229
230// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
231def cpinst_operand : Operand<i32> {
232 let PrintMethod = "printCPInstOperand";
233}
234
235def jtblock_operand : Operand<i32> {
236 let PrintMethod = "printJTBlockOperand";
237}
Evan Cheng6e2ebc92009-07-25 00:33:29 +0000238def jt2block_operand : Operand<i32> {
239 let PrintMethod = "printJT2BlockOperand";
240}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241
242// Local PC labels.
243def pclabel : Operand<i32> {
244 let PrintMethod = "printPCLabel";
245}
246
247// shifter_operand operands: so_reg and so_imm.
248def so_reg : Operand<i32>, // reg reg imm
249 ComplexPattern<i32, 3, "SelectShifterOperandReg",
250 [shl,srl,sra,rotr]> {
251 let PrintMethod = "printSORegOperand";
252 let MIOperandInfo = (ops GPR, GPR, i32imm);
253}
254
255// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
256// 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
257// represented in the imm field in the same 12-bit form that they are encoded
258// into so_imm instructions: the 8-bit immediate is the least significant bits
259// [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
260def so_imm : Operand<i32>,
Evan Cheng8be2a5b2009-07-08 21:03:57 +0000261 PatLeaf<(imm), [{
262 return ARM_AM::getSOImmVal(N->getZExtValue()) != -1;
263 }]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 let PrintMethod = "printSOImmOperand";
265}
266
267// Break so_imm's up into two pieces. This handles immediates with up to 16
268// bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
269// get the first/second pieces.
270def so_imm2part : Operand<i32>,
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000271 PatLeaf<(imm), [{
272 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
273 }]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274 let PrintMethod = "printSOImm2PartOperand";
275}
276
277def so_imm2part_1 : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000278 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000279 return CurDAG->getTargetConstant(V, MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280}]>;
281
282def so_imm2part_2 : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000283 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000284 return CurDAG->getTargetConstant(V, MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285}]>;
286
287
288// Define ARM specific addressing modes.
289
290// addrmode2 := reg +/- reg shop imm
291// addrmode2 := reg +/- imm12
292//
293def addrmode2 : Operand<i32>,
294 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
295 let PrintMethod = "printAddrMode2Operand";
296 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
297}
298
299def am2offset : Operand<i32>,
300 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
301 let PrintMethod = "printAddrMode2OffsetOperand";
302 let MIOperandInfo = (ops GPR, i32imm);
303}
304
305// addrmode3 := reg +/- reg
306// addrmode3 := reg +/- imm8
307//
308def addrmode3 : Operand<i32>,
309 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
310 let PrintMethod = "printAddrMode3Operand";
311 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
312}
313
314def am3offset : Operand<i32>,
315 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
316 let PrintMethod = "printAddrMode3OffsetOperand";
317 let MIOperandInfo = (ops GPR, i32imm);
318}
319
320// addrmode4 := reg, <mode|W>
321//
322def addrmode4 : Operand<i32>,
Anton Korobeynikov3f087662009-08-08 13:35:48 +0000323 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 let PrintMethod = "printAddrMode4Operand";
325 let MIOperandInfo = (ops GPR, i32imm);
326}
327
328// addrmode5 := reg +/- imm8*4
329//
330def addrmode5 : Operand<i32>,
331 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
332 let PrintMethod = "printAddrMode5Operand";
333 let MIOperandInfo = (ops GPR, i32imm);
334}
335
Bob Wilson970a10d2009-07-01 23:16:05 +0000336// addrmode6 := reg with optional writeback
337//
338def addrmode6 : Operand<i32>,
339 ComplexPattern<i32, 3, "SelectAddrMode6", []> {
340 let PrintMethod = "printAddrMode6Operand";
341 let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm);
342}
343
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344// addrmodepc := pc + reg
345//
346def addrmodepc : Operand<i32>,
347 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
348 let PrintMethod = "printAddrModePCOperand";
349 let MIOperandInfo = (ops GPR, i32imm);
350}
351
Bob Wilson30ff4492009-08-21 21:58:55 +0000352def nohash_imm : Operand<i32> {
353 let PrintMethod = "printNoHashImmediate";
Anton Korobeynikove2be3382009-08-08 23:10:41 +0000354}
355
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356//===----------------------------------------------------------------------===//
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000357
Evan Cheng7b0249b2008-08-28 23:39:26 +0000358include "ARMInstrFormats.td"
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000359
360//===----------------------------------------------------------------------===//
Evan Cheng7b0249b2008-08-28 23:39:26 +0000361// Multiclass helpers...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362//
363
Evan Cheng40d64532008-08-29 07:36:24 +0000364/// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365/// binop that produces a value.
Evan Chengbdd679a2009-06-26 00:19:44 +0000366multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
367 bit Commutable = 0> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000368 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000369 IIC_iALUi, opc, " $dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000370 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
371 let Inst{25} = 1;
372 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000373 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000374 IIC_iALUr, opc, " $dst, $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000375 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000376 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000377 let isCommutable = Commutable;
378 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000379 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000380 IIC_iALUsr, opc, " $dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000381 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
382 let Inst{25} = 0;
383 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384}
385
Evan Chengd4e2f052009-06-25 20:59:23 +0000386/// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
Bob Wilson3443c212009-10-06 20:18:46 +0000387/// instruction modifies the CPSR register.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000388let Defs = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000389multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
390 bit Commutable = 0> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000391 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000392 IIC_iALUi, opc, "s $dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000393 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
394 let Inst{25} = 1;
395 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000396 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000397 IIC_iALUr, opc, "s $dst, $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000398 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
399 let isCommutable = Commutable;
Bob Wilsonb072c752009-10-13 15:27:23 +0000400 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000401 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000402 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000403 IIC_iALUsr, opc, "s $dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000404 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
405 let Inst{25} = 0;
406 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000407}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408}
409
410/// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
411/// patterns. Similar to AsI1_bin_irs except the instruction does not produce
412/// a explicit result, only implicitly set CPSR.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000413let Defs = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000414multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode,
415 bit Commutable = 0> {
David Goodwin236ccb52009-08-19 18:00:44 +0000416 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iCMPi,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 opc, " $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000418 [(opnode GPR:$a, so_imm:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000419 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000420 let Inst{25} = 1;
421 }
David Goodwin236ccb52009-08-19 18:00:44 +0000422 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm, IIC_iCMPr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 opc, " $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000424 [(opnode GPR:$a, GPR:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000425 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000426 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000427 let isCommutable = Commutable;
428 }
David Goodwin236ccb52009-08-19 18:00:44 +0000429 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iCMPsr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430 opc, " $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000431 [(opnode GPR:$a, so_reg:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000432 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000433 let Inst{25} = 0;
434 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000435}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436}
437
438/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
439/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng37afa432008-11-06 22:15:19 +0000440/// FIXME: Remove the 'r' variant. Its rot_imm is zero.
441multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> {
David Goodwin236ccb52009-08-19 18:00:44 +0000442 def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src),
443 IIC_iUNAr, opc, " $dst, $src",
444 [(set GPR:$dst, (opnode GPR:$src))]>,
Evan Cheng37afa432008-11-06 22:15:19 +0000445 Requires<[IsARM, HasV6]> {
446 let Inst{19-16} = 0b1111;
447 }
David Goodwin236ccb52009-08-19 18:00:44 +0000448 def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src, i32imm:$rot),
449 IIC_iUNAsi, opc, " $dst, $src, ror $rot",
450 [(set GPR:$dst, (opnode (rotr GPR:$src, rot_imm:$rot)))]>,
Evan Cheng37afa432008-11-06 22:15:19 +0000451 Requires<[IsARM, HasV6]> {
452 let Inst{19-16} = 0b1111;
453 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454}
455
456/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
457/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng37afa432008-11-06 22:15:19 +0000458multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> {
459 def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
David Goodwin236ccb52009-08-19 18:00:44 +0000460 IIC_iALUr, opc, " $dst, $LHS, $RHS",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000461 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
462 Requires<[IsARM, HasV6]>;
Evan Cheng37afa432008-11-06 22:15:19 +0000463 def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot),
David Goodwin236ccb52009-08-19 18:00:44 +0000464 IIC_iALUsi, opc, " $dst, $LHS, $RHS, ror $rot",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465 [(set GPR:$dst, (opnode GPR:$LHS,
466 (rotr GPR:$RHS, rot_imm:$rot)))]>,
467 Requires<[IsARM, HasV6]>;
468}
469
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000470/// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
471let Uses = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000472multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
473 bit Commutable = 0> {
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000474 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
David Goodwin236ccb52009-08-19 18:00:44 +0000475 DPFrm, IIC_iALUi, opc, " $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000476 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
Evan Cheng83a32b42009-07-07 23:40:25 +0000477 Requires<[IsARM, CarryDefIsUnused]> {
478 let Inst{25} = 1;
479 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000480 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +0000481 DPFrm, IIC_iALUr, opc, " $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000482 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
Evan Chengbdd679a2009-06-26 00:19:44 +0000483 Requires<[IsARM, CarryDefIsUnused]> {
484 let isCommutable = Commutable;
Evan Cheng83a32b42009-07-07 23:40:25 +0000485 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000486 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000487 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
David Goodwin236ccb52009-08-19 18:00:44 +0000488 DPSoRegFrm, IIC_iALUsr, opc, " $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000489 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
Evan Cheng83a32b42009-07-07 23:40:25 +0000490 Requires<[IsARM, CarryDefIsUnused]> {
491 let Inst{25} = 0;
492 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000493 // Carry setting variants
494 def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
David Goodwin236ccb52009-08-19 18:00:44 +0000495 DPFrm, IIC_iALUi, !strconcat(opc, "s $dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000496 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
497 Requires<[IsARM, CarryDefIsUsed]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000498 let Defs = [CPSR];
499 let Inst{25} = 1;
Evan Chengbdd679a2009-06-26 00:19:44 +0000500 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000501 def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +0000502 DPFrm, IIC_iALUr, !strconcat(opc, "s $dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000503 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
504 Requires<[IsARM, CarryDefIsUsed]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000505 let Defs = [CPSR];
506 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000507 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000508 def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
David Goodwin236ccb52009-08-19 18:00:44 +0000509 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "s $dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000510 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
511 Requires<[IsARM, CarryDefIsUsed]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000512 let Defs = [CPSR];
513 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000514 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000515}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516}
517
518//===----------------------------------------------------------------------===//
519// Instructions
520//===----------------------------------------------------------------------===//
521
522//===----------------------------------------------------------------------===//
523// Miscellaneous Instructions.
524//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
526/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
527/// the function. The first operand is the ID# for this instruction, the second
528/// is the index into the MachineConstantPool that this is, the third is the
529/// size in bytes of this constant pool entry.
Evan Chengd97d7142009-06-12 20:46:18 +0000530let neverHasSideEffects = 1, isNotDuplicable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531def CONSTPOOL_ENTRY :
Evan Chengb783fa32007-07-19 01:14:50 +0000532PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
David Goodwincfd67652009-08-06 16:52:47 +0000533 i32imm:$size), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 "${instid:label} ${cpidx:cpentry}", []>;
535
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000536let Defs = [SP], Uses = [SP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537def ADJCALLSTACKUP :
David Goodwincfd67652009-08-06 16:52:47 +0000538PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
Bill Wendling22f8deb2007-11-13 00:44:25 +0000539 "@ ADJCALLSTACKUP $amt1",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000540 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541
542def ADJCALLSTACKDOWN :
David Goodwincfd67652009-08-06 16:52:47 +0000543PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 "@ ADJCALLSTACKDOWN $amt",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000545 [(ARMcallseq_start timm:$amt)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000546}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547
548def DWARF_LOC :
David Goodwincfd67652009-08-06 16:52:47 +0000549PseudoInst<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 ".loc $file, $line, $col",
551 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
552
Evan Chengf8e8b622008-11-06 17:48:05 +0000553
554// Address computation and loads and stores in PIC mode.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555let isNotDuplicable = 1 in {
Evan Cheng0d28b382008-10-31 19:11:09 +0000556def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000557 Pseudo, IIC_iALUr, "\n$cp:\n\tadd$p $dst, pc, $a",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
559
Evan Cheng8610a3b2008-01-07 23:56:57 +0000560let AddedComplexity = 10 in {
Dan Gohman5574cc72008-12-03 18:15:48 +0000561let canFoldAsLoad = 1 in
Evan Chengbe998242008-11-06 08:47:38 +0000562def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000563 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr$p $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 [(set GPR:$dst, (load addrmodepc:$addr))]>;
565
Evan Chengbe998242008-11-06 08:47:38 +0000566def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000567 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}h $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
569
Evan Chengbe998242008-11-06 08:47:38 +0000570def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000571 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}b $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
573
Evan Chengbe998242008-11-06 08:47:38 +0000574def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000575 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sh $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
577
Evan Chengbe998242008-11-06 08:47:38 +0000578def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000579 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sb $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
581}
Chris Lattnerf823faf2008-01-06 05:55:01 +0000582let AddedComplexity = 10 in {
Evan Chengbe998242008-11-06 08:47:38 +0000583def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000584 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr$p $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 [(store GPR:$src, addrmodepc:$addr)]>;
586
Evan Chengbe998242008-11-06 08:47:38 +0000587def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000588 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr${p}h $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
590
Evan Chengbe998242008-11-06 08:47:38 +0000591def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Cheng3ab67152009-08-28 06:59:37 +0000592 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr${p}b $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
594}
Evan Chengf8e8b622008-11-06 17:48:05 +0000595} // isNotDuplicable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
Evan Chenga1366cd2009-06-23 05:25:29 +0000597
598// LEApcrel - Load a pc-relative address into a register without offending the
599// assembler.
David Goodwincfd67652009-08-06 16:52:47 +0000600def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
David Goodwin236ccb52009-08-19 18:00:44 +0000601 Pseudo, IIC_iALUi,
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000602 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(",
603 "${:private}PCRELL${:uid}+8))\n"),
604 !strconcat("${:private}PCRELL${:uid}:\n\t",
605 "add$p $dst, pc, #${:private}PCRELV${:uid}")),
Evan Chenga1366cd2009-06-23 05:25:29 +0000606 []>;
607
Evan Chengba83d7c2009-06-24 23:14:45 +0000608def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
Bob Wilson30ff4492009-08-21 21:58:55 +0000609 (ins i32imm:$label, nohash_imm:$id, pred:$p),
David Goodwin236ccb52009-08-19 18:00:44 +0000610 Pseudo, IIC_iALUi,
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000611 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, "
Anton Korobeynikove2be3382009-08-08 23:10:41 +0000612 "(${label}_${id}-(",
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000613 "${:private}PCRELL${:uid}+8))\n"),
614 !strconcat("${:private}PCRELL${:uid}:\n\t",
615 "add$p $dst, pc, #${:private}PCRELV${:uid}")),
Evan Cheng83a32b42009-07-07 23:40:25 +0000616 []> {
617 let Inst{25} = 1;
618}
Evan Chenga1366cd2009-06-23 05:25:29 +0000619
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620//===----------------------------------------------------------------------===//
621// Control Flow Instructions.
622//
623
Jim Grosbachc6f0c022009-09-30 01:35:11 +0000624let isReturn = 1, isTerminator = 1, isBarrier = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000625 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
626 "bx", " lr", [(ARMretflag)]> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000627 let Inst{7-4} = 0b0001;
628 let Inst{19-8} = 0b111111111111;
629 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000630}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631
632// FIXME: remove when we have a way to marking a MI with these properties.
Evan Chengf8e8b622008-11-06 17:48:05 +0000633// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000634let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
635 hasExtraDefRegAllocReq = 1 in
Evan Chengf8e8b622008-11-06 17:48:05 +0000636 def LDM_RET : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000637 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
638 LdStMulFrm, IIC_Br, "ldm${p}${addr:submode} $addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 []>;
640
Bob Wilson243b37c2009-06-22 21:01:46 +0000641// On non-Darwin platforms R9 is callee-saved.
David Goodwin4b6e4982009-08-12 18:31:53 +0000642let isCall = 1,
Evan Cheng27396a62009-07-22 06:46:53 +0000643 Defs = [R0, R1, R2, R3, R12, LR,
644 D0, D1, D2, D3, D4, D5, D6, D7,
645 D16, D17, D18, D19, D20, D21, D22, D23,
David Goodwin3d88e912009-09-03 22:12:28 +0000646 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
Evan Chengf8e8b622008-11-06 17:48:05 +0000647 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
David Goodwincfd67652009-08-06 16:52:47 +0000648 IIC_Br, "bl ${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000649 [(ARMcall tglobaladdr:$func)]>,
650 Requires<[IsARM, IsNotDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651
Evan Chengf8e8b622008-11-06 17:48:05 +0000652 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
David Goodwincfd67652009-08-06 16:52:47 +0000653 IIC_Br, "bl", " ${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000654 [(ARMcall_pred tglobaladdr:$func)]>,
655 Requires<[IsARM, IsNotDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656
657 // ARMv5T and above
Evan Chengf8e8b622008-11-06 17:48:05 +0000658 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
David Goodwincfd67652009-08-06 16:52:47 +0000659 IIC_Br, "blx $func",
Evan Cheng9e734482009-07-29 21:26:42 +0000660 [(ARMcall GPR:$func)]>,
661 Requires<[IsARM, HasV5T, IsNotDarwin]> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000662 let Inst{7-4} = 0b0011;
663 let Inst{19-8} = 0b111111111111;
664 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000665 }
666
Evan Chengfb1d1472009-07-14 01:49:27 +0000667 // ARMv4T
668 def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops),
David Goodwincfd67652009-08-06 16:52:47 +0000669 IIC_Br, "mov lr, pc\n\tbx $func",
Evan Cheng9e734482009-07-29 21:26:42 +0000670 [(ARMcall_nolink GPR:$func)]>,
671 Requires<[IsARM, IsNotDarwin]> {
Evan Chengfb1d1472009-07-14 01:49:27 +0000672 let Inst{7-4} = 0b0001;
673 let Inst{19-8} = 0b111111111111;
674 let Inst{27-20} = 0b00010010;
Bob Wilson243b37c2009-06-22 21:01:46 +0000675 }
676}
677
678// On Darwin R9 is call-clobbered.
David Goodwin4b6e4982009-08-12 18:31:53 +0000679let isCall = 1,
Evan Cheng27396a62009-07-22 06:46:53 +0000680 Defs = [R0, R1, R2, R3, R9, R12, LR,
681 D0, D1, D2, D3, D4, D5, D6, D7,
682 D16, D17, D18, D19, D20, D21, D22, D23,
David Goodwin3d88e912009-09-03 22:12:28 +0000683 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
Bob Wilson243b37c2009-06-22 21:01:46 +0000684 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
David Goodwincfd67652009-08-06 16:52:47 +0000685 IIC_Br, "bl ${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000686 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +0000687
688 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
David Goodwincfd67652009-08-06 16:52:47 +0000689 IIC_Br, "bl", " ${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000690 [(ARMcall_pred tglobaladdr:$func)]>,
691 Requires<[IsARM, IsDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +0000692
693 // ARMv5T and above
694 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
David Goodwincfd67652009-08-06 16:52:47 +0000695 IIC_Br, "blx $func",
Bob Wilson243b37c2009-06-22 21:01:46 +0000696 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
697 let Inst{7-4} = 0b0011;
698 let Inst{19-8} = 0b111111111111;
699 let Inst{27-20} = 0b00010010;
700 }
701
Evan Chengfb1d1472009-07-14 01:49:27 +0000702 // ARMv4T
703 def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops),
David Goodwincfd67652009-08-06 16:52:47 +0000704 IIC_Br, "mov lr, pc\n\tbx $func",
Evan Chengfb1d1472009-07-14 01:49:27 +0000705 [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> {
706 let Inst{7-4} = 0b0001;
707 let Inst{19-8} = 0b111111111111;
708 let Inst{27-20} = 0b00010010;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 }
710}
711
David Goodwin4b6e4982009-08-12 18:31:53 +0000712let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 // B is "predicable" since it can be xformed into a Bcc.
714 let isBarrier = 1 in {
715 let isPredicable = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000716 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
717 "b $target", [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718
Owen Andersonf8053082007-11-12 07:39:39 +0000719 let isNotDuplicable = 1, isIndirectBranch = 1 in {
Evan Cheng0f63ae12008-11-07 09:06:08 +0000720 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
David Goodwincfd67652009-08-06 16:52:47 +0000721 IIC_Br, "mov pc, $target \n$jt",
Evan Cheng0f63ae12008-11-07 09:06:08 +0000722 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
723 let Inst{20} = 0; // S Bit
724 let Inst{24-21} = 0b1101;
Evan Chenge5f32ae2009-07-07 23:45:10 +0000725 let Inst{27-25} = 0b000;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 }
Evan Cheng0f63ae12008-11-07 09:06:08 +0000727 def BR_JTm : JTI<(outs),
728 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
David Goodwincfd67652009-08-06 16:52:47 +0000729 IIC_Br, "ldr pc, $target \n$jt",
730 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
731 imm:$id)]> {
Evan Cheng0f63ae12008-11-07 09:06:08 +0000732 let Inst{20} = 1; // L bit
733 let Inst{21} = 0; // W bit
734 let Inst{22} = 0; // B bit
735 let Inst{24} = 1; // P bit
Evan Chenge5f32ae2009-07-07 23:45:10 +0000736 let Inst{27-25} = 0b011;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 }
Evan Cheng0f63ae12008-11-07 09:06:08 +0000738 def BR_JTadd : JTI<(outs),
739 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
David Goodwincfd67652009-08-06 16:52:47 +0000740 IIC_Br, "add pc, $target, $idx \n$jt",
Evan Cheng0f63ae12008-11-07 09:06:08 +0000741 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
742 imm:$id)]> {
743 let Inst{20} = 0; // S bit
744 let Inst{24-21} = 0b0100;
Evan Chenge5f32ae2009-07-07 23:45:10 +0000745 let Inst{27-25} = 0b000;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000746 }
747 } // isNotDuplicable = 1, isIndirectBranch = 1
748 } // isBarrier = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749
750 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
751 // a two-value operand where a dag node expects two operands. :(
Evan Chengf8e8b622008-11-06 17:48:05 +0000752 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
David Goodwincfd67652009-08-06 16:52:47 +0000753 IIC_Br, "b", " $target",
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000754 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755}
756
757//===----------------------------------------------------------------------===//
758// Load / store Instructions.
759//
760
761// Load
Dan Gohman78e1a772009-10-09 23:28:27 +0000762let canFoldAsLoad = 1, isReMaterializable = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000763def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 "ldr", " $dst, $addr",
765 [(set GPR:$dst, (load addrmode2:$addr))]>;
766
767// Special LDR for loads from non-pc-relative constpools.
Dan Gohman5574cc72008-12-03 18:15:48 +0000768let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000769def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 "ldr", " $dst, $addr", []>;
771
772// Loads with zero extension
David Goodwin236ccb52009-08-19 18:00:44 +0000773def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
774 IIC_iLoadr, "ldr", "h $dst, $addr",
775 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776
David Goodwin236ccb52009-08-19 18:00:44 +0000777def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
778 IIC_iLoadr, "ldr", "b $dst, $addr",
779 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780
781// Loads with sign extension
David Goodwin236ccb52009-08-19 18:00:44 +0000782def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
783 IIC_iLoadr, "ldr", "sh $dst, $addr",
784 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785
David Goodwin236ccb52009-08-19 18:00:44 +0000786def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
787 IIC_iLoadr, "ldr", "sb $dst, $addr",
788 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000790let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791// Load doubleword
Evan Cheng41169552009-06-15 08:28:29 +0000792def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
David Goodwin236ccb52009-08-19 18:00:44 +0000793 IIC_iLoadr, "ldr", "d $dst1, $addr",
Misha Brukman9daa0672009-08-27 14:14:21 +0000794 []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795
796// Indexed loads
Evan Chengbe998242008-11-06 08:47:38 +0000797def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000798 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000799 "ldr", " $dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800
Evan Chengbe998242008-11-06 08:47:38 +0000801def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000802 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000803 "ldr", " $dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804
Evan Chengbe998242008-11-06 08:47:38 +0000805def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000806 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 "ldr", "h $dst, $addr!", "$addr.base = $base_wb", []>;
808
Evan Chengbe998242008-11-06 08:47:38 +0000809def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000810 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 "ldr", "h $dst, [$base], $offset", "$base = $base_wb", []>;
812
Evan Chengbe998242008-11-06 08:47:38 +0000813def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000814 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 "ldr", "b $dst, $addr!", "$addr.base = $base_wb", []>;
816
Evan Chengbe998242008-11-06 08:47:38 +0000817def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000818 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 "ldr", "b $dst, [$base], $offset", "$base = $base_wb", []>;
820
Evan Chengbe998242008-11-06 08:47:38 +0000821def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000822 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 "ldr", "sh $dst, $addr!", "$addr.base = $base_wb", []>;
824
Evan Chengbe998242008-11-06 08:47:38 +0000825def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000826 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Evan Cheng81794bb2008-11-13 07:34:59 +0000827 "ldr", "sh $dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828
Evan Chengbe998242008-11-06 08:47:38 +0000829def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000830 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 "ldr", "sb $dst, $addr!", "$addr.base = $base_wb", []>;
832
Evan Chengbe998242008-11-06 08:47:38 +0000833def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000834 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Evan Chengb04191f2009-07-02 01:30:04 +0000835 "ldr", "sb $dst, [$base], $offset", "$base = $base_wb", []>;
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000836}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837
838// Store
David Goodwin236ccb52009-08-19 18:00:44 +0000839def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 "str", " $src, $addr",
841 [(store GPR:$src, addrmode2:$addr)]>;
842
843// Stores with truncate
David Goodwin236ccb52009-08-19 18:00:44 +0000844def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, IIC_iStorer,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 "str", "h $src, $addr",
846 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
847
David Goodwin236ccb52009-08-19 18:00:44 +0000848def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 "str", "b $src, $addr",
850 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
851
852// Store doubleword
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000853let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000854def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
David Goodwin236ccb52009-08-19 18:00:44 +0000855 StMiscFrm, IIC_iStorer,
Misha Brukman9daa0672009-08-27 14:14:21 +0000856 "str", "d $src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857
858// Indexed stores
Evan Chengbe998242008-11-06 08:47:38 +0000859def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000860 (ins GPR:$src, GPR:$base, am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000861 StFrm, IIC_iStoreru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 "str", " $src, [$base, $offset]!", "$base = $base_wb",
863 [(set GPR:$base_wb,
864 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
865
Evan Chengbe998242008-11-06 08:47:38 +0000866def STR_POST : AI2stwpo<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000867 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000868 StFrm, IIC_iStoreru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 "str", " $src, [$base], $offset", "$base = $base_wb",
870 [(set GPR:$base_wb,
871 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
872
Evan Chengbe998242008-11-06 08:47:38 +0000873def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000874 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000875 StMiscFrm, IIC_iStoreru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 "str", "h $src, [$base, $offset]!", "$base = $base_wb",
877 [(set GPR:$base_wb,
878 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
879
Evan Chengbe998242008-11-06 08:47:38 +0000880def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000881 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000882 StMiscFrm, IIC_iStoreru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 "str", "h $src, [$base], $offset", "$base = $base_wb",
884 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
885 GPR:$base, am3offset:$offset))]>;
886
Evan Chengbe998242008-11-06 08:47:38 +0000887def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000888 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000889 StFrm, IIC_iStoreru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 "str", "b $src, [$base, $offset]!", "$base = $base_wb",
891 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
892 GPR:$base, am2offset:$offset))]>;
893
Evan Chengbe998242008-11-06 08:47:38 +0000894def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000895 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000896 StFrm, IIC_iStoreru,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 "str", "b $src, [$base], $offset", "$base = $base_wb",
898 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
899 GPR:$base, am2offset:$offset))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900
901//===----------------------------------------------------------------------===//
902// Load / store multiple Instructions.
903//
904
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000905let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +0000906def LDM : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000907 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
908 LdStMulFrm, IIC_iLoadm, "ldm${p}${addr:submode} $addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 []>;
910
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000911let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +0000912def STM : AXI4st<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000913 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
914 LdStMulFrm, IIC_iStorem, "stm${p}${addr:submode} $addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 []>;
916
917//===----------------------------------------------------------------------===//
918// Move Instructions.
919//
920
Evan Chengd97d7142009-06-12 20:46:18 +0000921let neverHasSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000922def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Anton Korobeynikov60928952009-09-27 23:52:58 +0000923 "mov", " $dst, $src", []>, UnaryDP;
David Goodwincfd67652009-08-06 16:52:47 +0000924def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src),
Anton Korobeynikov60928952009-09-27 23:52:58 +0000925 DPSoRegFrm, IIC_iMOVsr,
926 "mov", " $dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927
Evan Chengbd0ca9c2009-02-05 08:42:55 +0000928let isReMaterializable = 1, isAsCheapAsAMove = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000929def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi,
Anton Korobeynikov60928952009-09-27 23:52:58 +0000930 "mov", " $dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP {
931 let Inst{25} = 1;
932}
933
934let isReMaterializable = 1, isAsCheapAsAMove = 1 in
935def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src),
936 DPFrm, IIC_iMOVi,
937 "movw", " $dst, $src",
938 [(set GPR:$dst, imm0_65535:$src)]>,
939 Requires<[IsARM, HasV6T2]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000940 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +0000941 let Inst{25} = 1;
942}
943
Evan Cheng16c012d2009-09-28 09:14:39 +0000944let Constraints = "$src = $dst" in
Anton Korobeynikov60928952009-09-27 23:52:58 +0000945def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
946 DPFrm, IIC_iMOVi,
947 "movt", " $dst, $imm",
948 [(set GPR:$dst,
949 (or (and GPR:$src, 0xffff),
950 lo16AllZero:$imm))]>, UnaryDP,
951 Requires<[IsARM, HasV6T2]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000952 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +0000953 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +0000954}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955
David Goodwin02b0e352009-09-01 18:32:09 +0000956let Uses = [CPSR] in
David Goodwin236ccb52009-08-19 18:00:44 +0000957def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi,
Evan Chengb783fa32007-07-19 01:14:50 +0000958 "mov", " $dst, $src, rrx",
Evan Cheng86a926a2008-11-05 18:35:52 +0000959 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960
961// These aren't really mov instructions, but we have to define them this way
962// due to flag operands.
963
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000964let Defs = [CPSR] in {
David Goodwincfd67652009-08-06 16:52:47 +0000965def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
David Goodwin236ccb52009-08-19 18:00:44 +0000966 IIC_iMOVsi, "mov", "s $dst, $src, lsr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +0000967 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
Evan Cheng7f240d22008-11-14 20:09:11 +0000968def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
David Goodwin236ccb52009-08-19 18:00:44 +0000969 IIC_iMOVsi, "mov", "s $dst, $src, asr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +0000970 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000971}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972
973//===----------------------------------------------------------------------===//
974// Extend Instructions.
975//
976
977// Sign extenders
978
Evan Cheng37afa432008-11-06 22:15:19 +0000979defm SXTB : AI_unary_rrot<0b01101010,
980 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
981defm SXTH : AI_unary_rrot<0b01101011,
982 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983
Evan Cheng37afa432008-11-06 22:15:19 +0000984defm SXTAB : AI_bin_rrot<0b01101010,
985 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
986defm SXTAH : AI_bin_rrot<0b01101011,
987 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988
989// TODO: SXT(A){B|H}16
990
991// Zero extenders
992
993let AddedComplexity = 16 in {
Evan Cheng37afa432008-11-06 22:15:19 +0000994defm UXTB : AI_unary_rrot<0b01101110,
995 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
996defm UXTH : AI_unary_rrot<0b01101111,
997 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
998defm UXTB16 : AI_unary_rrot<0b01101100,
999 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000
Bob Wilson74590a02009-06-22 22:08:29 +00001001def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 (UXTB16r_rot GPR:$Src, 24)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001003def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 (UXTB16r_rot GPR:$Src, 8)>;
1005
Evan Cheng37afa432008-11-06 22:15:19 +00001006defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng37afa432008-11-06 22:15:19 +00001008defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1010}
1011
1012// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1013//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1014
1015// TODO: UXT(A){B|H}16
1016
1017//===----------------------------------------------------------------------===//
1018// Arithmetic Instructions.
1019//
1020
Jim Grosbach88c246f2008-10-14 20:36:24 +00001021defm ADD : AsI1_bin_irs<0b0100, "add",
Evan Chengbdd679a2009-06-26 00:19:44 +00001022 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001023defm SUB : AsI1_bin_irs<0b0010, "sub",
Evan Cheng469bc762008-09-17 07:53:38 +00001024 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025
1026// ADD and SUB with 's' bit set.
Evan Chengd4e2f052009-06-25 20:59:23 +00001027defm ADDS : AI1_bin_s_irs<0b0100, "add",
1028 BinOpFrag<(addc node:$LHS, node:$RHS)>>;
1029defm SUBS : AI1_bin_s_irs<0b0010, "sub",
1030 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001032defm ADC : AI1_adde_sube_irs<0b0101, "adc",
Evan Chengbdd679a2009-06-26 00:19:44 +00001033 BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>;
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001034defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
1035 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036
1037// These don't define reg/reg forms, because they are handled above.
Evan Cheng86a926a2008-11-05 18:35:52 +00001038def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +00001039 IIC_iALUi, "rsb", " $dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001040 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> {
1041 let Inst{25} = 1;
1042}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043
Evan Cheng86a926a2008-11-05 18:35:52 +00001044def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
David Goodwin236ccb52009-08-19 18:00:44 +00001045 IIC_iALUsr, "rsb", " $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]>;
1047
1048// RSB with 's' bit set.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001049let Defs = [CPSR] in {
Evan Cheng86a926a2008-11-05 18:35:52 +00001050def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +00001051 IIC_iALUi, "rsb", "s $dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001052 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> {
1053 let Inst{25} = 1;
1054}
Evan Cheng86a926a2008-11-05 18:35:52 +00001055def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
David Goodwin236ccb52009-08-19 18:00:44 +00001056 IIC_iALUsr, "rsb", "s $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001057 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]>;
1058}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001060let Uses = [CPSR] in {
1061def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001062 DPFrm, IIC_iALUi, "rsc", " $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001063 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
Evan Chenga9892932009-09-09 01:47:07 +00001064 Requires<[IsARM, CarryDefIsUnused]> {
1065 let Inst{25} = 1;
1066}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001067def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001068 DPSoRegFrm, IIC_iALUsr, "rsc", " $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001069 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
1070 Requires<[IsARM, CarryDefIsUnused]>;
1071}
1072
1073// FIXME: Allow these to be predicated.
Evan Chengd4e2f052009-06-25 20:59:23 +00001074let Defs = [CPSR], Uses = [CPSR] in {
1075def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001076 DPFrm, IIC_iALUi, "rscs $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001077 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
Evan Chenga9892932009-09-09 01:47:07 +00001078 Requires<[IsARM, CarryDefIsUnused]> {
1079 let Inst{25} = 1;
1080}
Evan Chengd4e2f052009-06-25 20:59:23 +00001081def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001082 DPSoRegFrm, IIC_iALUsr, "rscs $dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001083 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
1084 Requires<[IsARM, CarryDefIsUnused]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001085}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086
1087// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1088def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1089 (SUBri GPR:$src, so_imm_neg:$imm)>;
1090
1091//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1092// (SUBSri GPR:$src, so_imm_neg:$imm)>;
1093//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1094// (SBCri GPR:$src, so_imm_neg:$imm)>;
1095
1096// Note: These are implemented in C++ code, because they have to generate
1097// ADD/SUBrs instructions, which use a complex pattern that a xform function
1098// cannot produce.
1099// (mul X, 2^n+1) -> (add (X << n), X)
1100// (mul X, 2^n-1) -> (rsb X, (X << n))
1101
1102
1103//===----------------------------------------------------------------------===//
1104// Bitwise Instructions.
1105//
1106
Jim Grosbach88c246f2008-10-14 20:36:24 +00001107defm AND : AsI1_bin_irs<0b0000, "and",
Evan Chengbdd679a2009-06-26 00:19:44 +00001108 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001109defm ORR : AsI1_bin_irs<0b1100, "orr",
Evan Chengbdd679a2009-06-26 00:19:44 +00001110 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001111defm EOR : AsI1_bin_irs<0b0001, "eor",
Evan Chengbdd679a2009-06-26 00:19:44 +00001112 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001113defm BIC : AsI1_bin_irs<0b1110, "bic",
Evan Cheng469bc762008-09-17 07:53:38 +00001114 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115
Evan Cheng299ee652009-07-06 22:23:46 +00001116def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
David Goodwin236ccb52009-08-19 18:00:44 +00001117 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Cheng299ee652009-07-06 22:23:46 +00001118 "bfc", " $dst, $imm", "$src = $dst",
1119 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1120 Requires<[IsARM, HasV6T2]> {
1121 let Inst{27-21} = 0b0111110;
1122 let Inst{6-0} = 0b0011111;
1123}
1124
David Goodwin236ccb52009-08-19 18:00:44 +00001125def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Cheng86a926a2008-11-05 18:35:52 +00001126 "mvn", " $dst, $src",
1127 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP;
1128def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
David Goodwin236ccb52009-08-19 18:00:44 +00001129 IIC_iMOVsr, "mvn", " $dst, $src",
Evan Cheng86a926a2008-11-05 18:35:52 +00001130 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001131let isReMaterializable = 1, isAsCheapAsAMove = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001132def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
1133 IIC_iMOVi, "mvn", " $dst, $imm",
Evan Chenga9892932009-09-09 01:47:07 +00001134 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP {
1135 let Inst{25} = 1;
1136}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137
1138def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1139 (BICri GPR:$src, so_imm_not:$imm)>;
1140
1141//===----------------------------------------------------------------------===//
1142// Multiply Instructions.
1143//
1144
Evan Chengbdd679a2009-06-26 00:19:44 +00001145let isCommutable = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001146def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
1147 IIC_iMUL32, "mul", " $dst, $a, $b",
Evan Chengf8e8b622008-11-06 17:48:05 +00001148 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149
Evan Chengee80fb72008-11-06 01:21:28 +00001150def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
David Goodwin236ccb52009-08-19 18:00:44 +00001151 IIC_iMAC32, "mla", " $dst, $a, $b, $c",
Evan Chengf8e8b622008-11-06 17:48:05 +00001152 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153
David Goodwincfd67652009-08-06 16:52:47 +00001154def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
David Goodwin236ccb52009-08-19 18:00:44 +00001155 IIC_iMAC32, "mls", " $dst, $a, $b, $c",
Evan Chengc8147e12009-07-06 22:05:45 +00001156 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1157 Requires<[IsARM, HasV6T2]>;
1158
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159// Extra precision multiplies with low / high results
Evan Chengd97d7142009-06-12 20:46:18 +00001160let neverHasSideEffects = 1 in {
Evan Chengbdd679a2009-06-26 00:19:44 +00001161let isCommutable = 1 in {
Evan Chengee80fb72008-11-06 01:21:28 +00001162def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001163 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengee80fb72008-11-06 01:21:28 +00001164 "smull", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165
Evan Chengee80fb72008-11-06 01:21:28 +00001166def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001167 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengee80fb72008-11-06 01:21:28 +00001168 "umull", " $ldst, $hdst, $a, $b", []>;
Evan Chengbdd679a2009-06-26 00:19:44 +00001169}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170
1171// Multiply + accumulate
Evan Chengee80fb72008-11-06 01:21:28 +00001172def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001173 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengee80fb72008-11-06 01:21:28 +00001174 "smlal", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175
Evan Chengee80fb72008-11-06 01:21:28 +00001176def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001177 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengee80fb72008-11-06 01:21:28 +00001178 "umlal", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179
Evan Chengee80fb72008-11-06 01:21:28 +00001180def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001181 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengee80fb72008-11-06 01:21:28 +00001182 "umaal", " $ldst, $hdst, $a, $b", []>,
1183 Requires<[IsARM, HasV6]>;
Evan Chengd97d7142009-06-12 20:46:18 +00001184} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185
1186// Most significant word multiply
Evan Chengee80fb72008-11-06 01:21:28 +00001187def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001188 IIC_iMUL32, "smmul", " $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001190 Requires<[IsARM, HasV6]> {
1191 let Inst{7-4} = 0b0001;
1192 let Inst{15-12} = 0b1111;
1193}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194
Evan Chengee80fb72008-11-06 01:21:28 +00001195def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
David Goodwin236ccb52009-08-19 18:00:44 +00001196 IIC_iMAC32, "smmla", " $dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001198 Requires<[IsARM, HasV6]> {
1199 let Inst{7-4} = 0b0001;
1200}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201
1202
Evan Chengee80fb72008-11-06 01:21:28 +00001203def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
David Goodwin236ccb52009-08-19 18:00:44 +00001204 IIC_iMAC32, "smmls", " $dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001206 Requires<[IsARM, HasV6]> {
1207 let Inst{7-4} = 0b1101;
1208}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001210multiclass AI_smul<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001211 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001212 IIC_iMUL32, !strconcat(opc, "bb"), " $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1214 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001215 Requires<[IsARM, HasV5TE]> {
1216 let Inst{5} = 0;
1217 let Inst{6} = 0;
1218 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001219
Evan Cheng38396be2008-11-06 03:35:07 +00001220 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001221 IIC_iMUL32, !strconcat(opc, "bt"), " $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
Bob Wilson74590a02009-06-22 22:08:29 +00001223 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001224 Requires<[IsARM, HasV5TE]> {
1225 let Inst{5} = 0;
1226 let Inst{6} = 1;
1227 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001228
Evan Cheng38396be2008-11-06 03:35:07 +00001229 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001230 IIC_iMUL32, !strconcat(opc, "tb"), " $dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001231 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001233 Requires<[IsARM, HasV5TE]> {
1234 let Inst{5} = 1;
1235 let Inst{6} = 0;
1236 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001237
Evan Cheng38396be2008-11-06 03:35:07 +00001238 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001239 IIC_iMUL32, !strconcat(opc, "tt"), " $dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001240 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1241 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001242 Requires<[IsARM, HasV5TE]> {
1243 let Inst{5} = 1;
1244 let Inst{6} = 1;
1245 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001246
Evan Cheng38396be2008-11-06 03:35:07 +00001247 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001248 IIC_iMUL16, !strconcat(opc, "wb"), " $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001250 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001251 Requires<[IsARM, HasV5TE]> {
1252 let Inst{5} = 1;
1253 let Inst{6} = 0;
1254 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001255
Evan Cheng38396be2008-11-06 03:35:07 +00001256 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
David Goodwin236ccb52009-08-19 18:00:44 +00001257 IIC_iMUL16, !strconcat(opc, "wt"), " $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001259 (sra GPR:$b, (i32 16))), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001260 Requires<[IsARM, HasV5TE]> {
1261 let Inst{5} = 1;
1262 let Inst{6} = 1;
1263 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264}
1265
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001266
1267multiclass AI_smla<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001268 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
David Goodwin236ccb52009-08-19 18:00:44 +00001269 IIC_iMAC16, !strconcat(opc, "bb"), " $dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set GPR:$dst, (add GPR:$acc,
1271 (opnode (sext_inreg GPR:$a, i16),
1272 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001273 Requires<[IsARM, HasV5TE]> {
1274 let Inst{5} = 0;
1275 let Inst{6} = 0;
1276 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001277
Evan Cheng38396be2008-11-06 03:35:07 +00001278 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
David Goodwin236ccb52009-08-19 18:00:44 +00001279 IIC_iMAC16, !strconcat(opc, "bt"), " $dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
Bob Wilson74590a02009-06-22 22:08:29 +00001281 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001282 Requires<[IsARM, HasV5TE]> {
1283 let Inst{5} = 0;
1284 let Inst{6} = 1;
1285 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001286
Evan Cheng38396be2008-11-06 03:35:07 +00001287 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
David Goodwin236ccb52009-08-19 18:00:44 +00001288 IIC_iMAC16, !strconcat(opc, "tb"), " $dst, $a, $b, $acc",
Bob Wilson74590a02009-06-22 22:08:29 +00001289 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001291 Requires<[IsARM, HasV5TE]> {
1292 let Inst{5} = 1;
1293 let Inst{6} = 0;
1294 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001295
Evan Cheng38396be2008-11-06 03:35:07 +00001296 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
David Goodwin236ccb52009-08-19 18:00:44 +00001297 IIC_iMAC16, !strconcat(opc, "tt"), " $dst, $a, $b, $acc",
Bob Wilson74590a02009-06-22 22:08:29 +00001298 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1299 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001300 Requires<[IsARM, HasV5TE]> {
1301 let Inst{5} = 1;
1302 let Inst{6} = 1;
1303 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304
Evan Cheng38396be2008-11-06 03:35:07 +00001305 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
David Goodwin236ccb52009-08-19 18:00:44 +00001306 IIC_iMAC16, !strconcat(opc, "wb"), " $dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001308 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001309 Requires<[IsARM, HasV5TE]> {
1310 let Inst{5} = 0;
1311 let Inst{6} = 0;
1312 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001313
Evan Cheng38396be2008-11-06 03:35:07 +00001314 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
David Goodwin236ccb52009-08-19 18:00:44 +00001315 IIC_iMAC16, !strconcat(opc, "wt"), " $dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001317 (sra GPR:$b, (i32 16))), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001318 Requires<[IsARM, HasV5TE]> {
1319 let Inst{5} = 0;
1320 let Inst{6} = 1;
1321 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322}
1323
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001324defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1325defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326
1327// TODO: Halfword multiple accumulate long: SMLAL<x><y>
1328// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1329
1330//===----------------------------------------------------------------------===//
1331// Misc. Arithmetic Instructions.
1332//
1333
David Goodwin236ccb52009-08-19 18:00:44 +00001334def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 "clz", " $dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001336 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1337 let Inst{7-4} = 0b0001;
1338 let Inst{11-8} = 0b1111;
1339 let Inst{19-16} = 0b1111;
1340}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341
David Goodwin236ccb52009-08-19 18:00:44 +00001342def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 "rev", " $dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001344 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1345 let Inst{7-4} = 0b0011;
1346 let Inst{11-8} = 0b1111;
1347 let Inst{19-16} = 0b1111;
1348}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349
David Goodwin236ccb52009-08-19 18:00:44 +00001350def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 "rev16", " $dst, $src",
1352 [(set GPR:$dst,
Bob Wilson74590a02009-06-22 22:08:29 +00001353 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1354 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1355 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1356 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001357 Requires<[IsARM, HasV6]> {
1358 let Inst{7-4} = 0b1011;
1359 let Inst{11-8} = 0b1111;
1360 let Inst{19-16} = 0b1111;
1361}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362
David Goodwin236ccb52009-08-19 18:00:44 +00001363def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 "revsh", " $dst, $src",
1365 [(set GPR:$dst,
1366 (sext_inreg
Bob Wilson74590a02009-06-22 22:08:29 +00001367 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1368 (shl GPR:$src, (i32 8))), i16))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001369 Requires<[IsARM, HasV6]> {
1370 let Inst{7-4} = 0b1011;
1371 let Inst{11-8} = 0b1111;
1372 let Inst{19-16} = 0b1111;
1373}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374
Evan Chengc2121a22008-11-07 01:41:35 +00001375def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1376 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
David Goodwin236ccb52009-08-19 18:00:44 +00001377 IIC_iALUsi, "pkhbt", " $dst, $src1, $src2, LSL $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1379 (and (shl GPR:$src2, (i32 imm:$shamt)),
1380 0xFFFF0000)))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001381 Requires<[IsARM, HasV6]> {
1382 let Inst{6-4} = 0b001;
1383}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384
1385// Alternate cases for PKHBT where identities eliminate some nodes.
1386def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1387 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1388def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1389 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1390
1391
Evan Chengc2121a22008-11-07 01:41:35 +00001392def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1393 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
David Goodwin236ccb52009-08-19 18:00:44 +00001394 IIC_iALUsi, "pkhtb", " $dst, $src1, $src2, ASR $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1396 (and (sra GPR:$src2, imm16_31:$shamt),
Evan Chengc2121a22008-11-07 01:41:35 +00001397 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1398 let Inst{6-4} = 0b101;
1399}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400
1401// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1402// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilson74590a02009-06-22 22:08:29 +00001403def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1405def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1406 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1407 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1408
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409//===----------------------------------------------------------------------===//
1410// Comparison Instructions...
1411//
1412
Jim Grosbach88c246f2008-10-14 20:36:24 +00001413defm CMP : AI1_cmp_irs<0b1010, "cmp",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001414 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001415defm CMN : AI1_cmp_irs<0b1011, "cmn",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001416 BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417
1418// Note that TST/TEQ don't set all the same flags that CMP does!
Evan Chengbe998242008-11-06 08:47:38 +00001419defm TST : AI1_cmp_irs<0b1000, "tst",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001420 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
Evan Chengbe998242008-11-06 08:47:38 +00001421defm TEQ : AI1_cmp_irs<0b1001, "teq",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001422 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423
David Goodwin8bdcbb32009-06-29 15:33:01 +00001424defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1425 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1426defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1427 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428
1429def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1430 (CMNri GPR:$src, so_imm_neg:$imm)>;
1431
David Goodwin8bdcbb32009-06-29 15:33:01 +00001432def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433 (CMNri GPR:$src, so_imm_neg:$imm)>;
1434
1435
1436// Conditional moves
1437// FIXME: should be able to write a pattern for ARMcmov, but can't use
1438// a two-value operand where a dag node expects two operands. :(
Evan Chengbe998242008-11-06 08:47:38 +00001439def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
David Goodwin236ccb52009-08-19 18:00:44 +00001440 IIC_iCMOVr, "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Chengbe998242008-11-06 08:47:38 +00001442 RegConstraint<"$false = $dst">, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443
Evan Chengbe998242008-11-06 08:47:38 +00001444def MOVCCs : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001445 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
Evan Cheng86a926a2008-11-05 18:35:52 +00001446 "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Cheng86a926a2008-11-05 18:35:52 +00001448 RegConstraint<"$false = $dst">, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449
Evan Chengbe998242008-11-06 08:47:38 +00001450def MOVCCi : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001451 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
Evan Cheng86a926a2008-11-05 18:35:52 +00001452 "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Chenga9892932009-09-09 01:47:07 +00001454 RegConstraint<"$false = $dst">, UnaryDP {
1455 let Inst{25} = 1;
1456}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001457
1458
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459//===----------------------------------------------------------------------===//
1460// TLS Instructions
1461//
1462
1463// __aeabi_read_tp preserves the registers r1-r3.
1464let isCall = 1,
1465 Defs = [R0, R12, LR, CPSR] in {
David Goodwincfd67652009-08-06 16:52:47 +00001466 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 "bl __aeabi_read_tp",
1468 [(set R0, ARMthread_pointer)]>;
1469}
1470
1471//===----------------------------------------------------------------------===//
Jim Grosbachc10915b2009-05-12 23:59:14 +00001472// SJLJ Exception handling intrinsics
Jim Grosbach207a4ba2009-08-13 15:11:43 +00001473// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001474// address and save #0 in R0 for the non-longjmp case.
Jim Grosbachc10915b2009-05-12 23:59:14 +00001475// Since by its nature we may be coming from some other function to get
1476// here, and we're using the stack frame for the containing function to
1477// save/restore registers, we can't keep anything live in regs across
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001478// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
Jim Grosbachc10915b2009-05-12 23:59:14 +00001479// when we get here from a longjmp(). We force everthing out of registers
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001480// except for our own input by listing the relevant registers in Defs. By
1481// doing so, we also cause the prologue/epilogue code to actively preserve
1482// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbachc10915b2009-05-12 23:59:14 +00001483let Defs =
Jim Grosbach3990e392009-08-13 16:59:44 +00001484 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
1485 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Evan Cheng80ab2a82009-07-29 20:10:36 +00001486 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Evan Cheng27396a62009-07-22 06:46:53 +00001487 D31 ] in {
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001488 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src),
David Goodwincfd67652009-08-06 16:52:47 +00001489 AddrModeNone, SizeSpecial, IndexModeNone,
1490 Pseudo, NoItinerary,
Jim Grosbach29feb6a2009-08-11 00:09:57 +00001491 "str sp, [$src, #+8] @ eh_setjmp begin\n\t"
Jim Grosbach23c001b2009-08-12 15:21:13 +00001492 "add r12, pc, #8\n\t"
1493 "str r12, [$src, #+4]\n\t"
Jim Grosbach29feb6a2009-08-11 00:09:57 +00001494 "mov r0, #0\n\t"
1495 "add pc, pc, #0\n\t"
Jim Grosbachdd4f75b2009-08-13 15:12:16 +00001496 "mov r0, #1 @ eh_setjmp end", "",
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001497 [(set R0, (ARMeh_sjlj_setjmp GPR:$src))]>;
Jim Grosbachc10915b2009-05-12 23:59:14 +00001498}
1499
1500//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501// Non-Instruction Patterns
1502//
1503
1504// ConstantPool, GlobalAddress, and JumpTable
1505def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1506def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1507def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
1508 (LEApcrelJT tjumptable:$dst, imm:$id)>;
1509
1510// Large immediate handling.
1511
1512// Two piece so_imms.
1513let isReMaterializable = 1 in
David Goodwincfd67652009-08-06 16:52:47 +00001514def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
David Goodwin236ccb52009-08-19 18:00:44 +00001515 Pseudo, IIC_iMOVi,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 "mov", " $dst, $src",
Evan Cheng16c012d2009-09-28 09:14:39 +00001517 [(set GPR:$dst, so_imm2part:$src)]>,
1518 Requires<[IsARM, NoV6T2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519
1520def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00001521 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1522 (so_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00001524 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1525 (so_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526
Evan Cheng16c012d2009-09-28 09:14:39 +00001527// 32-bit immediate using movw + movt.
1528// This is a single pseudo instruction to make it re-materializable. Remove
1529// when we can do generalized remat.
1530let isReMaterializable = 1 in
1531def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi,
1532 "movw", " $dst, ${src:lo16}\n\tmovt${p} $dst, ${src:hi16}",
1533 [(set GPR:$dst, (i32 imm:$src))]>,
1534 Requires<[IsARM, HasV6T2]>;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001535
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536// TODO: add,sub,and, 3-instr forms?
1537
1538
1539// Direct calls
Bob Wilson243b37c2009-06-22 21:01:46 +00001540def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00001541 Requires<[IsARM, IsNotDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +00001542def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00001543 Requires<[IsARM, IsDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544
1545// zextload i1 -> zextload i8
1546def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1547
1548// extload -> zextload
1549def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1550def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1551def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
1552
Evan Chengc41fb3152008-11-05 23:22:34 +00001553def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
1554def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
1555
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556// smul* and smla*
Bob Wilson74590a02009-06-22 22:08:29 +00001557def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1558 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559 (SMULBB GPR:$a, GPR:$b)>;
1560def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1561 (SMULBB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001562def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1563 (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001565def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001567def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
1568 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001570def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001572def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1573 (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574 (SMULWB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001575def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 (SMULWB GPR:$a, GPR:$b)>;
1577
1578def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001579 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1580 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1582def : ARMV5TEPat<(add GPR:$acc,
1583 (mul sext_16_node:$a, sext_16_node:$b)),
1584 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1585def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001586 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1587 (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1589def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001590 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1592def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001593 (mul (sra GPR:$a, (i32 16)),
1594 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1596def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001597 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1599def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001600 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1601 (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1603def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001604 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1606
1607//===----------------------------------------------------------------------===//
1608// Thumb Support
1609//
1610
1611include "ARMInstrThumb.td"
1612
1613//===----------------------------------------------------------------------===//
Anton Korobeynikovac869fc2009-06-17 18:13:58 +00001614// Thumb2 Support
1615//
1616
1617include "ARMInstrThumb2.td"
1618
1619//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620// Floating Point Support
1621//
1622
1623include "ARMInstrVFP.td"
Bob Wilsone60fee02009-06-22 23:27:02 +00001624
1625//===----------------------------------------------------------------------===//
1626// Advanced SIMD (NEON) Support
1627//
1628
1629include "ARMInstrNEON.td"