blob: 92972f1e3a95b79067b94517264b94aa7166859c [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
Jim Grosbach66e70cd2009-11-23 20:35:53 +0000287def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
288 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
289 }]> {
290 let PrintMethod = "printSOImm2PartOperand";
291}
292
293def so_neg_imm2part_1 : SDNodeXForm<imm, [{
294 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
295 return CurDAG->getTargetConstant(V, MVT::i32);
296}]>;
297
298def so_neg_imm2part_2 : SDNodeXForm<imm, [{
299 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
300 return CurDAG->getTargetConstant(V, MVT::i32);
301}]>;
302
Sandeep Patelbb4648a2009-10-13 18:59:48 +0000303/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
304def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
305 return (int32_t)N->getZExtValue() < 32;
306}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307
308// Define ARM specific addressing modes.
309
310// addrmode2 := reg +/- reg shop imm
311// addrmode2 := reg +/- imm12
312//
313def addrmode2 : Operand<i32>,
314 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
315 let PrintMethod = "printAddrMode2Operand";
316 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
317}
318
319def am2offset : Operand<i32>,
320 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
321 let PrintMethod = "printAddrMode2OffsetOperand";
322 let MIOperandInfo = (ops GPR, i32imm);
323}
324
325// addrmode3 := reg +/- reg
326// addrmode3 := reg +/- imm8
327//
328def addrmode3 : Operand<i32>,
329 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
330 let PrintMethod = "printAddrMode3Operand";
331 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
332}
333
334def am3offset : Operand<i32>,
335 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
336 let PrintMethod = "printAddrMode3OffsetOperand";
337 let MIOperandInfo = (ops GPR, i32imm);
338}
339
340// addrmode4 := reg, <mode|W>
341//
342def addrmode4 : Operand<i32>,
Anton Korobeynikov3f087662009-08-08 13:35:48 +0000343 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344 let PrintMethod = "printAddrMode4Operand";
345 let MIOperandInfo = (ops GPR, i32imm);
346}
347
348// addrmode5 := reg +/- imm8*4
349//
350def addrmode5 : Operand<i32>,
351 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
352 let PrintMethod = "printAddrMode5Operand";
353 let MIOperandInfo = (ops GPR, i32imm);
354}
355
Bob Wilson970a10d2009-07-01 23:16:05 +0000356// addrmode6 := reg with optional writeback
357//
358def addrmode6 : Operand<i32>,
Jim Grosbach04d92822009-11-07 21:25:39 +0000359 ComplexPattern<i32, 4, "SelectAddrMode6", []> {
Bob Wilson970a10d2009-07-01 23:16:05 +0000360 let PrintMethod = "printAddrMode6Operand";
Jim Grosbach04d92822009-11-07 21:25:39 +0000361 let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm);
Bob Wilson970a10d2009-07-01 23:16:05 +0000362}
363
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364// addrmodepc := pc + reg
365//
366def addrmodepc : Operand<i32>,
367 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
368 let PrintMethod = "printAddrModePCOperand";
369 let MIOperandInfo = (ops GPR, i32imm);
370}
371
Bob Wilson30ff4492009-08-21 21:58:55 +0000372def nohash_imm : Operand<i32> {
373 let PrintMethod = "printNoHashImmediate";
Anton Korobeynikove2be3382009-08-08 23:10:41 +0000374}
375
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376//===----------------------------------------------------------------------===//
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000377
Evan Cheng7b0249b2008-08-28 23:39:26 +0000378include "ARMInstrFormats.td"
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000379
380//===----------------------------------------------------------------------===//
Evan Cheng7b0249b2008-08-28 23:39:26 +0000381// Multiclass helpers...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382//
383
Evan Cheng40d64532008-08-29 07:36:24 +0000384/// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385/// binop that produces a value.
Evan Chengbdd679a2009-06-26 00:19:44 +0000386multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
387 bit Commutable = 0> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000388 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000389 IIC_iALUi, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000390 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
391 let Inst{25} = 1;
392 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000393 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000394 IIC_iALUr, opc, "\t$dst, $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000395 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
Johnny Chend139b942009-11-07 00:54:36 +0000396 let Inst{11-4} = 0b00000000;
Evan Cheng83a32b42009-07-07 23:40:25 +0000397 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000398 let isCommutable = Commutable;
399 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000400 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000401 IIC_iALUsr, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000402 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
403 let Inst{25} = 0;
404 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405}
406
Evan Chengd4e2f052009-06-25 20:59:23 +0000407/// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
Bob Wilson3443c212009-10-06 20:18:46 +0000408/// instruction modifies the CPSR register.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000409let Defs = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000410multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
411 bit Commutable = 0> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000412 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000413 IIC_iALUi, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000414 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
Bob Wilson3a308522009-10-26 22:34:44 +0000415 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000416 let Inst{25} = 1;
417 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000418 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000419 IIC_iALUr, opc, "\t$dst, $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000420 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
421 let isCommutable = Commutable;
Johnny Chend139b942009-11-07 00:54:36 +0000422 let Inst{11-4} = 0b00000000;
Bob Wilson3a308522009-10-26 22:34:44 +0000423 let Inst{20} = 1;
Bob Wilsonb072c752009-10-13 15:27:23 +0000424 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000425 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000426 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000427 IIC_iALUsr, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000428 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
Bob Wilson3a308522009-10-26 22:34:44 +0000429 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000430 let Inst{25} = 0;
431 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000432}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433}
434
435/// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
436/// patterns. Similar to AsI1_bin_irs except the instruction does not produce
437/// a explicit result, only implicitly set CPSR.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000438let Defs = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000439multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode,
440 bit Commutable = 0> {
David Goodwin236ccb52009-08-19 18:00:44 +0000441 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iCMPi,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000442 opc, "\t$a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000443 [(opnode GPR:$a, so_imm:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000444 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000445 let Inst{25} = 1;
446 }
David Goodwin236ccb52009-08-19 18:00:44 +0000447 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm, IIC_iCMPr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000448 opc, "\t$a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000449 [(opnode GPR:$a, GPR:$b)]> {
Johnny Chend139b942009-11-07 00:54:36 +0000450 let Inst{11-4} = 0b00000000;
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000451 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000452 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000453 let isCommutable = Commutable;
454 }
David Goodwin236ccb52009-08-19 18:00:44 +0000455 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iCMPsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000456 opc, "\t$a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000457 [(opnode GPR:$a, so_reg:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000458 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000459 let Inst{25} = 0;
460 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000461}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462}
463
464/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
465/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng37afa432008-11-06 22:15:19 +0000466/// FIXME: Remove the 'r' variant. Its rot_imm is zero.
467multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> {
David Goodwin236ccb52009-08-19 18:00:44 +0000468 def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000469 IIC_iUNAr, opc, "\t$dst, $src",
David Goodwin236ccb52009-08-19 18:00:44 +0000470 [(set GPR:$dst, (opnode GPR:$src))]>,
Evan Cheng37afa432008-11-06 22:15:19 +0000471 Requires<[IsARM, HasV6]> {
Johnny Chen1bf79442009-10-27 18:44:24 +0000472 let Inst{11-10} = 0b00;
473 let Inst{19-16} = 0b1111;
474 }
David Goodwin236ccb52009-08-19 18:00:44 +0000475 def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src, i32imm:$rot),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000476 IIC_iUNAsi, opc, "\t$dst, $src, ror $rot",
David Goodwin236ccb52009-08-19 18:00:44 +0000477 [(set GPR:$dst, (opnode (rotr GPR:$src, rot_imm:$rot)))]>,
Evan Cheng37afa432008-11-06 22:15:19 +0000478 Requires<[IsARM, HasV6]> {
Johnny Chen1bf79442009-10-27 18:44:24 +0000479 let Inst{19-16} = 0b1111;
480 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481}
482
483/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
484/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng37afa432008-11-06 22:15:19 +0000485multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> {
486 def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000487 IIC_iALUr, opc, "\t$dst, $LHS, $RHS",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
Johnny Chen1bf79442009-10-27 18:44:24 +0000489 Requires<[IsARM, HasV6]> {
490 let Inst{11-10} = 0b00;
491 }
Evan Cheng37afa432008-11-06 22:15:19 +0000492 def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000493 IIC_iALUsi, opc, "\t$dst, $LHS, $RHS, ror $rot",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 [(set GPR:$dst, (opnode GPR:$LHS,
495 (rotr GPR:$RHS, rot_imm:$rot)))]>,
496 Requires<[IsARM, HasV6]>;
497}
498
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000499/// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
500let Uses = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000501multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
502 bit Commutable = 0> {
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000503 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000504 DPFrm, IIC_iALUi, opc, "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000505 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
Evan Cheng83a32b42009-07-07 23:40:25 +0000506 Requires<[IsARM, CarryDefIsUnused]> {
507 let Inst{25} = 1;
508 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000509 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000510 DPFrm, IIC_iALUr, opc, "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000511 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
Evan Chengbdd679a2009-06-26 00:19:44 +0000512 Requires<[IsARM, CarryDefIsUnused]> {
513 let isCommutable = Commutable;
Johnny Chend139b942009-11-07 00:54:36 +0000514 let Inst{11-4} = 0b00000000;
Evan Cheng83a32b42009-07-07 23:40:25 +0000515 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000516 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000517 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000518 DPSoRegFrm, IIC_iALUsr, opc, "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000519 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
Evan Cheng83a32b42009-07-07 23:40:25 +0000520 Requires<[IsARM, CarryDefIsUnused]> {
521 let Inst{25} = 0;
522 }
Jim Grosbache2fda532009-11-09 00:11:35 +0000523}
524// Carry setting variants
525let Defs = [CPSR] in {
526multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
527 bit Commutable = 0> {
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000528 def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Jim Grosbache2fda532009-11-09 00:11:35 +0000529 DPFrm, IIC_iALUi, !strconcat(opc, "\t$dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000530 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
531 Requires<[IsARM, CarryDefIsUsed]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000532 let Defs = [CPSR];
Bob Wilson3a308522009-10-26 22:34:44 +0000533 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000534 let Inst{25} = 1;
Evan Chengbdd679a2009-06-26 00:19:44 +0000535 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000536 def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Jim Grosbache2fda532009-11-09 00:11:35 +0000537 DPFrm, IIC_iALUr, !strconcat(opc, "\t$dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000538 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
539 Requires<[IsARM, CarryDefIsUsed]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000540 let Defs = [CPSR];
Johnny Chend139b942009-11-07 00:54:36 +0000541 let Inst{11-4} = 0b00000000;
Bob Wilson3a308522009-10-26 22:34:44 +0000542 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000543 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000544 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000545 def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Jim Grosbache2fda532009-11-09 00:11:35 +0000546 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000547 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
548 Requires<[IsARM, CarryDefIsUsed]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000549 let Defs = [CPSR];
Bob Wilson3a308522009-10-26 22:34:44 +0000550 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000551 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000552 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000553}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554}
Jim Grosbache2fda532009-11-09 00:11:35 +0000555}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556
557//===----------------------------------------------------------------------===//
558// Instructions
559//===----------------------------------------------------------------------===//
560
561//===----------------------------------------------------------------------===//
562// Miscellaneous Instructions.
563//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564
565/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
566/// the function. The first operand is the ID# for this instruction, the second
567/// is the index into the MachineConstantPool that this is, the third is the
568/// size in bytes of this constant pool entry.
Evan Chengd97d7142009-06-12 20:46:18 +0000569let neverHasSideEffects = 1, isNotDuplicable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570def CONSTPOOL_ENTRY :
Evan Chengb783fa32007-07-19 01:14:50 +0000571PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
David Goodwincfd67652009-08-06 16:52:47 +0000572 i32imm:$size), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 "${instid:label} ${cpidx:cpentry}", []>;
574
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000575let Defs = [SP], Uses = [SP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576def ADJCALLSTACKUP :
David Goodwincfd67652009-08-06 16:52:47 +0000577PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
Bill Wendling22f8deb2007-11-13 00:44:25 +0000578 "@ ADJCALLSTACKUP $amt1",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000579 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580
581def ADJCALLSTACKDOWN :
David Goodwincfd67652009-08-06 16:52:47 +0000582PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583 "@ ADJCALLSTACKDOWN $amt",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000584 [(ARMcallseq_start timm:$amt)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000585}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586
Evan Chengf8e8b622008-11-06 17:48:05 +0000587// Address computation and loads and stores in PIC mode.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588let isNotDuplicable = 1 in {
Evan Cheng0d28b382008-10-31 19:11:09 +0000589def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000590 Pseudo, IIC_iALUr, "\n$cp:\n\tadd$p\t$dst, pc, $a",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
592
Evan Cheng8610a3b2008-01-07 23:56:57 +0000593let AddedComplexity = 10 in {
Evan Chengbe998242008-11-06 08:47:38 +0000594def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000595 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr$p\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596 [(set GPR:$dst, (load addrmodepc:$addr))]>;
597
Evan Chengbe998242008-11-06 08:47:38 +0000598def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000599 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}h\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
601
Evan Chengbe998242008-11-06 08:47:38 +0000602def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000603 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}b\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
605
Evan Chengbe998242008-11-06 08:47:38 +0000606def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000607 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sh\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
609
Evan Chengbe998242008-11-06 08:47:38 +0000610def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000611 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sb\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
613}
Chris Lattnerf823faf2008-01-06 05:55:01 +0000614let AddedComplexity = 10 in {
Evan Chengbe998242008-11-06 08:47:38 +0000615def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000616 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr$p\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617 [(store GPR:$src, addrmodepc:$addr)]>;
618
Evan Chengbe998242008-11-06 08:47:38 +0000619def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Bob Wilsonecce4b72009-11-18 18:10:35 +0000620 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrh${p}\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
622
Evan Chengbe998242008-11-06 08:47:38 +0000623def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Bob Wilsonecce4b72009-11-18 18:10:35 +0000624 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrb${p}\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
626}
Evan Chengf8e8b622008-11-06 17:48:05 +0000627} // isNotDuplicable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628
Evan Chenga1366cd2009-06-23 05:25:29 +0000629
630// LEApcrel - Load a pc-relative address into a register without offending the
631// assembler.
David Goodwincfd67652009-08-06 16:52:47 +0000632def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
David Goodwin236ccb52009-08-19 18:00:44 +0000633 Pseudo, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000634 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(",
635 "${:private}PCRELL${:uid}+8))\n"),
636 !strconcat("${:private}PCRELL${:uid}:\n\t",
637 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
Evan Chenga1366cd2009-06-23 05:25:29 +0000638 []>;
639
Evan Chengba83d7c2009-06-24 23:14:45 +0000640def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
Bob Wilson30ff4492009-08-21 21:58:55 +0000641 (ins i32imm:$label, nohash_imm:$id, pred:$p),
David Goodwin236ccb52009-08-19 18:00:44 +0000642 Pseudo, IIC_iALUi,
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000643 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, "
Anton Korobeynikove2be3382009-08-08 23:10:41 +0000644 "(${label}_${id}-(",
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000645 "${:private}PCRELL${:uid}+8))\n"),
646 !strconcat("${:private}PCRELL${:uid}:\n\t",
Evan Chengd3f9bc42009-10-26 23:45:59 +0000647 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
Evan Cheng83a32b42009-07-07 23:40:25 +0000648 []> {
649 let Inst{25} = 1;
650}
Evan Chenga1366cd2009-06-23 05:25:29 +0000651
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652//===----------------------------------------------------------------------===//
653// Control Flow Instructions.
654//
655
Jim Grosbachc6f0c022009-09-30 01:35:11 +0000656let isReturn = 1, isTerminator = 1, isBarrier = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000657 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000658 "bx", "\tlr", [(ARMretflag)]> {
Johnny Chenff43a622009-11-16 23:57:56 +0000659 let Inst{3-0} = 0b1110;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000660 let Inst{7-4} = 0b0001;
661 let Inst{19-8} = 0b111111111111;
662 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000663}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664
Bob Wilsonf061fc82009-10-28 00:37:03 +0000665// Indirect branches
666let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Bob Wilsonea698652009-10-28 18:26:41 +0000667 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
Bob Wilsonf061fc82009-10-28 00:37:03 +0000668 [(brind GPR:$dst)]> {
669 let Inst{7-4} = 0b0001;
670 let Inst{19-8} = 0b111111111111;
671 let Inst{27-20} = 0b00010010;
Johnny Chenff43a622009-11-16 23:57:56 +0000672 let Inst{31-28} = 0b1110;
Bob Wilsonf061fc82009-10-28 00:37:03 +0000673 }
674}
675
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676// FIXME: remove when we have a way to marking a MI with these properties.
Evan Chengf8e8b622008-11-06 17:48:05 +0000677// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000678let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
679 hasExtraDefRegAllocReq = 1 in
Evan Chengf8e8b622008-11-06 17:48:05 +0000680 def LDM_RET : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000681 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +0000682 LdStMulFrm, IIC_Br, "ldm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 []>;
684
Bob Wilson243b37c2009-06-22 21:01:46 +0000685// On non-Darwin platforms R9 is callee-saved.
David Goodwin4b6e4982009-08-12 18:31:53 +0000686let isCall = 1,
Evan Cheng27396a62009-07-22 06:46:53 +0000687 Defs = [R0, R1, R2, R3, R12, LR,
688 D0, D1, D2, D3, D4, D5, D6, D7,
689 D16, D17, D18, D19, D20, D21, D22, D23,
David Goodwin3d88e912009-09-03 22:12:28 +0000690 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
Evan Chengf8e8b622008-11-06 17:48:05 +0000691 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000692 IIC_Br, "bl\t${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000693 [(ARMcall tglobaladdr:$func)]>,
Johnny Chen2b4d1db2009-10-27 20:45:15 +0000694 Requires<[IsARM, IsNotDarwin]> {
695 let Inst{31-28} = 0b1110;
696 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697
Evan Chengf8e8b622008-11-06 17:48:05 +0000698 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000699 IIC_Br, "bl", "\t${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000700 [(ARMcall_pred tglobaladdr:$func)]>,
701 Requires<[IsARM, IsNotDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
703 // ARMv5T and above
Evan Chengf8e8b622008-11-06 17:48:05 +0000704 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000705 IIC_Br, "blx\t$func",
Evan Cheng9e734482009-07-29 21:26:42 +0000706 [(ARMcall GPR:$func)]>,
707 Requires<[IsARM, HasV5T, IsNotDarwin]> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000708 let Inst{7-4} = 0b0011;
709 let Inst{19-8} = 0b111111111111;
710 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000711 }
712
Evan Chengfb1d1472009-07-14 01:49:27 +0000713 // ARMv4T
714 def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000715 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
Evan Cheng9e734482009-07-29 21:26:42 +0000716 [(ARMcall_nolink GPR:$func)]>,
717 Requires<[IsARM, IsNotDarwin]> {
Evan Chengfb1d1472009-07-14 01:49:27 +0000718 let Inst{7-4} = 0b0001;
719 let Inst{19-8} = 0b111111111111;
720 let Inst{27-20} = 0b00010010;
Bob Wilson243b37c2009-06-22 21:01:46 +0000721 }
722}
723
724// On Darwin R9 is call-clobbered.
David Goodwin4b6e4982009-08-12 18:31:53 +0000725let isCall = 1,
Evan Cheng27396a62009-07-22 06:46:53 +0000726 Defs = [R0, R1, R2, R3, R9, R12, LR,
727 D0, D1, D2, D3, D4, D5, D6, D7,
728 D16, D17, D18, D19, D20, D21, D22, D23,
David Goodwin3d88e912009-09-03 22:12:28 +0000729 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
Bob Wilson243b37c2009-06-22 21:01:46 +0000730 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000731 IIC_Br, "bl\t${func:call}",
Johnny Chen2b4d1db2009-10-27 20:45:15 +0000732 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
733 let Inst{31-28} = 0b1110;
734 }
Bob Wilson243b37c2009-06-22 21:01:46 +0000735
736 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000737 IIC_Br, "bl", "\t${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000738 [(ARMcall_pred tglobaladdr:$func)]>,
739 Requires<[IsARM, IsDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +0000740
741 // ARMv5T and above
742 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000743 IIC_Br, "blx\t$func",
Bob Wilson243b37c2009-06-22 21:01:46 +0000744 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
745 let Inst{7-4} = 0b0011;
746 let Inst{19-8} = 0b111111111111;
747 let Inst{27-20} = 0b00010010;
748 }
749
Evan Chengfb1d1472009-07-14 01:49:27 +0000750 // ARMv4T
751 def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000752 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
Evan Chengfb1d1472009-07-14 01:49:27 +0000753 [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> {
754 let Inst{7-4} = 0b0001;
755 let Inst{19-8} = 0b111111111111;
756 let Inst{27-20} = 0b00010010;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 }
758}
759
David Goodwin4b6e4982009-08-12 18:31:53 +0000760let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 // B is "predicable" since it can be xformed into a Bcc.
762 let isBarrier = 1 in {
763 let isPredicable = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000764 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000765 "b\t$target", [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766
Owen Andersonf8053082007-11-12 07:39:39 +0000767 let isNotDuplicable = 1, isIndirectBranch = 1 in {
Evan Cheng0f63ae12008-11-07 09:06:08 +0000768 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000769 IIC_Br, "mov\tpc, $target \n$jt",
Evan Cheng0f63ae12008-11-07 09:06:08 +0000770 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
Johnny Chen3f647402009-11-17 17:17:50 +0000771 let Inst{15-12} = 0b1111;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000772 let Inst{20} = 0; // S Bit
773 let Inst{24-21} = 0b1101;
Evan Chenge5f32ae2009-07-07 23:45:10 +0000774 let Inst{27-25} = 0b000;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 }
Evan Cheng0f63ae12008-11-07 09:06:08 +0000776 def BR_JTm : JTI<(outs),
777 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000778 IIC_Br, "ldr\tpc, $target \n$jt",
David Goodwincfd67652009-08-06 16:52:47 +0000779 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
780 imm:$id)]> {
Johnny Chen3f647402009-11-17 17:17:50 +0000781 let Inst{15-12} = 0b1111;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000782 let Inst{20} = 1; // L bit
783 let Inst{21} = 0; // W bit
784 let Inst{22} = 0; // B bit
785 let Inst{24} = 1; // P bit
Evan Chenge5f32ae2009-07-07 23:45:10 +0000786 let Inst{27-25} = 0b011;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787 }
Evan Cheng0f63ae12008-11-07 09:06:08 +0000788 def BR_JTadd : JTI<(outs),
789 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000790 IIC_Br, "add\tpc, $target, $idx \n$jt",
Evan Cheng0f63ae12008-11-07 09:06:08 +0000791 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
792 imm:$id)]> {
Johnny Chen3f647402009-11-17 17:17:50 +0000793 let Inst{15-12} = 0b1111;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000794 let Inst{20} = 0; // S bit
795 let Inst{24-21} = 0b0100;
Evan Chenge5f32ae2009-07-07 23:45:10 +0000796 let Inst{27-25} = 0b000;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000797 }
798 } // isNotDuplicable = 1, isIndirectBranch = 1
799 } // isBarrier = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800
801 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
802 // a two-value operand where a dag node expects two operands. :(
Evan Chengf8e8b622008-11-06 17:48:05 +0000803 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000804 IIC_Br, "b", "\t$target",
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000805 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806}
807
808//===----------------------------------------------------------------------===//
809// Load / store Instructions.
810//
811
812// Load
Evan Cheng2f6bfd42009-11-20 19:57:15 +0000813let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000814def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000815 "ldr", "\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set GPR:$dst, (load addrmode2:$addr))]>;
817
818// Special LDR for loads from non-pc-relative constpools.
Evan Cheng2f6bfd42009-11-20 19:57:15 +0000819let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1,
820 mayHaveSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000821def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000822 "ldr", "\t$dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823
824// Loads with zero extension
David Goodwin236ccb52009-08-19 18:00:44 +0000825def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000826 IIC_iLoadr, "ldrh", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000827 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828
David Goodwin236ccb52009-08-19 18:00:44 +0000829def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000830 IIC_iLoadr, "ldrb", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000831 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832
833// Loads with sign extension
David Goodwin236ccb52009-08-19 18:00:44 +0000834def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000835 IIC_iLoadr, "ldrsh", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000836 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837
David Goodwin236ccb52009-08-19 18:00:44 +0000838def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000839 IIC_iLoadr, "ldrsb", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000840 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000842let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843// Load doubleword
Evan Cheng41169552009-06-15 08:28:29 +0000844def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000845 IIC_iLoadr, "ldrd", "\t$dst1, $addr",
Misha Brukman9daa0672009-08-27 14:14:21 +0000846 []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847
848// Indexed loads
Evan Chengbe998242008-11-06 08:47:38 +0000849def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000850 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000851 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852
Evan Chengbe998242008-11-06 08:47:38 +0000853def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000854 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000855 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856
Evan Chengbe998242008-11-06 08:47:38 +0000857def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000858 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000859 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860
Evan Chengbe998242008-11-06 08:47:38 +0000861def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000862 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000863 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864
Evan Chengbe998242008-11-06 08:47:38 +0000865def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000866 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000867 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868
Evan Chengbe998242008-11-06 08:47:38 +0000869def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000870 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000871 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872
Evan Chengbe998242008-11-06 08:47:38 +0000873def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000874 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000875 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
Evan Chengbe998242008-11-06 08:47:38 +0000877def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000878 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000879 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880
Evan Chengbe998242008-11-06 08:47:38 +0000881def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000882 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000883 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884
Evan Chengbe998242008-11-06 08:47:38 +0000885def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +0000886 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000887 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000888}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889
890// Store
David Goodwin236ccb52009-08-19 18:00:44 +0000891def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000892 "str", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 [(store GPR:$src, addrmode2:$addr)]>;
894
895// Stores with truncate
David Goodwin236ccb52009-08-19 18:00:44 +0000896def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +0000897 "strh", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
899
David Goodwin236ccb52009-08-19 18:00:44 +0000900def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +0000901 "strb", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
903
904// Store doubleword
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000905let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000906def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
David Goodwin236ccb52009-08-19 18:00:44 +0000907 StMiscFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +0000908 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909
910// Indexed stores
Evan Chengbe998242008-11-06 08:47:38 +0000911def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000912 (ins GPR:$src, GPR:$base, am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000913 StFrm, IIC_iStoreru,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000914 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 [(set GPR:$base_wb,
916 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
917
Evan Chengbe998242008-11-06 08:47:38 +0000918def STR_POST : AI2stwpo<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000919 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000920 StFrm, IIC_iStoreru,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000921 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GPR:$base_wb,
923 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
924
Evan Chengbe998242008-11-06 08:47:38 +0000925def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000926 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000927 StMiscFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000928 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 [(set GPR:$base_wb,
930 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
931
Evan Chengbe998242008-11-06 08:47:38 +0000932def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000933 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000934 StMiscFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000935 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
937 GPR:$base, am3offset:$offset))]>;
938
Evan Chengbe998242008-11-06 08:47:38 +0000939def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000940 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000941 StFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000942 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
944 GPR:$base, am2offset:$offset))]>;
945
Evan Chengbe998242008-11-06 08:47:38 +0000946def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
David Goodwincfd67652009-08-06 16:52:47 +0000947 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +0000948 StFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +0000949 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
951 GPR:$base, am2offset:$offset))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952
953//===----------------------------------------------------------------------===//
954// Load / store multiple Instructions.
955//
956
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000957let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +0000958def LDM : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000959 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +0000960 LdStMulFrm, IIC_iLoadm, "ldm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 []>;
962
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000963let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +0000964def STM : AXI4st<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000965 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +0000966 LdStMulFrm, IIC_iStorem, "stm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 []>;
968
969//===----------------------------------------------------------------------===//
970// Move Instructions.
971//
972
Evan Chengd97d7142009-06-12 20:46:18 +0000973let neverHasSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000974def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000975 "mov", "\t$dst, $src", []>, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +0000976 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +0000977 let Inst{25} = 0;
978}
979
David Goodwincfd67652009-08-06 16:52:47 +0000980def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src),
Anton Korobeynikov60928952009-09-27 23:52:58 +0000981 DPSoRegFrm, IIC_iMOVsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000982 "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +0000983 let Inst{25} = 0;
984}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985
Evan Chengbd0ca9c2009-02-05 08:42:55 +0000986let isReMaterializable = 1, isAsCheapAsAMove = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000987def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000988 "mov", "\t$dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP {
Anton Korobeynikov60928952009-09-27 23:52:58 +0000989 let Inst{25} = 1;
990}
991
992let isReMaterializable = 1, isAsCheapAsAMove = 1 in
993def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src),
994 DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000995 "movw", "\t$dst, $src",
Anton Korobeynikov60928952009-09-27 23:52:58 +0000996 [(set GPR:$dst, imm0_65535:$src)]>,
997 Requires<[IsARM, HasV6T2]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000998 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +0000999 let Inst{25} = 1;
1000}
1001
Evan Cheng16c012d2009-09-28 09:14:39 +00001002let Constraints = "$src = $dst" in
Anton Korobeynikov60928952009-09-27 23:52:58 +00001003def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
1004 DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001005 "movt", "\t$dst, $imm",
Anton Korobeynikov60928952009-09-27 23:52:58 +00001006 [(set GPR:$dst,
1007 (or (and GPR:$src, 0xffff),
1008 lo16AllZero:$imm))]>, UnaryDP,
1009 Requires<[IsARM, HasV6T2]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +00001010 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001011 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001012}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013
Evan Cheng89ef2852009-10-21 08:15:52 +00001014def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1015 Requires<[IsARM, HasV6T2]>;
1016
David Goodwin02b0e352009-09-01 18:32:09 +00001017let Uses = [CPSR] in
David Goodwin236ccb52009-08-19 18:00:44 +00001018def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001019 "mov", "\t$dst, $src, rrx",
Evan Cheng86a926a2008-11-05 18:35:52 +00001020 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021
1022// These aren't really mov instructions, but we have to define them this way
1023// due to flag operands.
1024
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001025let Defs = [CPSR] in {
David Goodwincfd67652009-08-06 16:52:47 +00001026def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
Jim Grosbache2fda532009-11-09 00:11:35 +00001027 IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +00001028 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
Evan Cheng7f240d22008-11-14 20:09:11 +00001029def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
Jim Grosbache2fda532009-11-09 00:11:35 +00001030 IIC_iMOVsi, "movs", "\t$dst, $src, asr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +00001031 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001032}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033
1034//===----------------------------------------------------------------------===//
1035// Extend Instructions.
1036//
1037
1038// Sign extenders
1039
Evan Cheng37afa432008-11-06 22:15:19 +00001040defm SXTB : AI_unary_rrot<0b01101010,
1041 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1042defm SXTH : AI_unary_rrot<0b01101011,
1043 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044
Evan Cheng37afa432008-11-06 22:15:19 +00001045defm SXTAB : AI_bin_rrot<0b01101010,
1046 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1047defm SXTAH : AI_bin_rrot<0b01101011,
1048 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049
1050// TODO: SXT(A){B|H}16
1051
1052// Zero extenders
1053
1054let AddedComplexity = 16 in {
Evan Cheng37afa432008-11-06 22:15:19 +00001055defm UXTB : AI_unary_rrot<0b01101110,
1056 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1057defm UXTH : AI_unary_rrot<0b01101111,
1058 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1059defm UXTB16 : AI_unary_rrot<0b01101100,
1060 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061
Bob Wilson74590a02009-06-22 22:08:29 +00001062def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 (UXTB16r_rot GPR:$Src, 24)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001064def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 (UXTB16r_rot GPR:$Src, 8)>;
1066
Evan Cheng37afa432008-11-06 22:15:19 +00001067defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng37afa432008-11-06 22:15:19 +00001069defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1071}
1072
1073// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1074//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1075
1076// TODO: UXT(A){B|H}16
1077
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001078def SBFX : I<(outs GPR:$dst),
1079 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1080 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001081 "sbfx", "\t$dst, $src, $lsb, $width", "", []>,
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001082 Requires<[IsARM, HasV6T2]> {
1083 let Inst{27-21} = 0b0111101;
1084 let Inst{6-4} = 0b101;
1085}
1086
1087def UBFX : I<(outs GPR:$dst),
1088 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1089 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001090 "ubfx", "\t$dst, $src, $lsb, $width", "", []>,
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001091 Requires<[IsARM, HasV6T2]> {
1092 let Inst{27-21} = 0b0111111;
1093 let Inst{6-4} = 0b101;
1094}
1095
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096//===----------------------------------------------------------------------===//
1097// Arithmetic Instructions.
1098//
1099
Jim Grosbach88c246f2008-10-14 20:36:24 +00001100defm ADD : AsI1_bin_irs<0b0100, "add",
Evan Chengbdd679a2009-06-26 00:19:44 +00001101 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001102defm SUB : AsI1_bin_irs<0b0010, "sub",
Evan Cheng469bc762008-09-17 07:53:38 +00001103 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104
1105// ADD and SUB with 's' bit set.
Jim Grosbache2fda532009-11-09 00:11:35 +00001106defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1107 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1108defm SUBS : AI1_bin_s_irs<0b0010, "subs",
Evan Chengd4e2f052009-06-25 20:59:23 +00001109 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001111defm ADC : AI1_adde_sube_irs<0b0101, "adc",
Evan Chengbdd679a2009-06-26 00:19:44 +00001112 BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>;
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001113defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
1114 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
Jim Grosbache2fda532009-11-09 00:11:35 +00001115defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
1116 BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>;
1117defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
1118 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119
1120// These don't define reg/reg forms, because they are handled above.
Evan Cheng86a926a2008-11-05 18:35:52 +00001121def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001122 IIC_iALUi, "rsb", "\t$dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001123 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> {
1124 let Inst{25} = 1;
1125}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126
Evan Cheng86a926a2008-11-05 18:35:52 +00001127def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001128 IIC_iALUsr, "rsb", "\t$dst, $a, $b",
Bob Wilson3a308522009-10-26 22:34:44 +00001129 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001130 let Inst{25} = 0;
1131}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132
1133// RSB with 's' bit set.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001134let Defs = [CPSR] in {
Evan Cheng86a926a2008-11-05 18:35:52 +00001135def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001136 IIC_iALUi, "rsbs", "\t$dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001137 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001138 let Inst{20} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001139 let Inst{25} = 1;
1140}
Evan Cheng86a926a2008-11-05 18:35:52 +00001141def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001142 IIC_iALUsr, "rsbs", "\t$dst, $a, $b",
Bob Wilson3a308522009-10-26 22:34:44 +00001143 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001144 let Inst{20} = 1;
1145 let Inst{25} = 0;
1146}
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001147}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001149let Uses = [CPSR] in {
1150def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001151 DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001152 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
Evan Chenga9892932009-09-09 01:47:07 +00001153 Requires<[IsARM, CarryDefIsUnused]> {
1154 let Inst{25} = 1;
1155}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001156def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001157 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001158 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
Bob Wilson2aec46e2009-10-26 22:59:12 +00001159 Requires<[IsARM, CarryDefIsUnused]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001160 let Inst{25} = 0;
1161}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001162}
1163
1164// FIXME: Allow these to be predicated.
Evan Chengd4e2f052009-06-25 20:59:23 +00001165let Defs = [CPSR], Uses = [CPSR] in {
1166def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001167 DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001168 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>,
Evan Chenga9892932009-09-09 01:47:07 +00001169 Requires<[IsARM, CarryDefIsUnused]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001170 let Inst{20} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001171 let Inst{25} = 1;
1172}
Evan Chengd4e2f052009-06-25 20:59:23 +00001173def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001174 DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001175 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>,
Bob Wilson2aec46e2009-10-26 22:59:12 +00001176 Requires<[IsARM, CarryDefIsUnused]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001177 let Inst{20} = 1;
1178 let Inst{25} = 0;
1179}
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001180}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181
1182// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1183def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1184 (SUBri GPR:$src, so_imm_neg:$imm)>;
1185
1186//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1187// (SUBSri GPR:$src, so_imm_neg:$imm)>;
1188//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1189// (SBCri GPR:$src, so_imm_neg:$imm)>;
1190
1191// Note: These are implemented in C++ code, because they have to generate
1192// ADD/SUBrs instructions, which use a complex pattern that a xform function
1193// cannot produce.
1194// (mul X, 2^n+1) -> (add (X << n), X)
1195// (mul X, 2^n-1) -> (rsb X, (X << n))
1196
1197
1198//===----------------------------------------------------------------------===//
1199// Bitwise Instructions.
1200//
1201
Jim Grosbach88c246f2008-10-14 20:36:24 +00001202defm AND : AsI1_bin_irs<0b0000, "and",
Evan Chengbdd679a2009-06-26 00:19:44 +00001203 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001204defm ORR : AsI1_bin_irs<0b1100, "orr",
Evan Chengbdd679a2009-06-26 00:19:44 +00001205 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001206defm EOR : AsI1_bin_irs<0b0001, "eor",
Evan Chengbdd679a2009-06-26 00:19:44 +00001207 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001208defm BIC : AsI1_bin_irs<0b1110, "bic",
Evan Cheng469bc762008-09-17 07:53:38 +00001209 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210
Evan Cheng299ee652009-07-06 22:23:46 +00001211def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
David Goodwin9a8ec822009-11-02 17:28:36 +00001212 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001213 "bfc", "\t$dst, $imm", "$src = $dst",
Evan Cheng299ee652009-07-06 22:23:46 +00001214 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1215 Requires<[IsARM, HasV6T2]> {
1216 let Inst{27-21} = 0b0111110;
1217 let Inst{6-0} = 0b0011111;
1218}
1219
David Goodwin236ccb52009-08-19 18:00:44 +00001220def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001221 "mvn", "\t$dst, $src",
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001222 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +00001223 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001224}
Evan Cheng86a926a2008-11-05 18:35:52 +00001225def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001226 IIC_iMOVsr, "mvn", "\t$dst, $src",
Johnny Chend139b942009-11-07 00:54:36 +00001227 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP;
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001228let isReMaterializable = 1, isAsCheapAsAMove = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001229def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001230 IIC_iMOVi, "mvn", "\t$dst, $imm",
Evan Chenga9892932009-09-09 01:47:07 +00001231 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP {
1232 let Inst{25} = 1;
1233}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234
1235def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1236 (BICri GPR:$src, so_imm_not:$imm)>;
1237
1238//===----------------------------------------------------------------------===//
1239// Multiply Instructions.
1240//
1241
Evan Chengbdd679a2009-06-26 00:19:44 +00001242let isCommutable = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001243def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001244 IIC_iMUL32, "mul", "\t$dst, $a, $b",
Evan Chengf8e8b622008-11-06 17:48:05 +00001245 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246
Evan Chengee80fb72008-11-06 01:21:28 +00001247def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001248 IIC_iMAC32, "mla", "\t$dst, $a, $b, $c",
Evan Chengf8e8b622008-11-06 17:48:05 +00001249 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250
David Goodwincfd67652009-08-06 16:52:47 +00001251def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001252 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
Evan Chengc8147e12009-07-06 22:05:45 +00001253 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1254 Requires<[IsARM, HasV6T2]>;
1255
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256// Extra precision multiplies with low / high results
Evan Chengd97d7142009-06-12 20:46:18 +00001257let neverHasSideEffects = 1 in {
Evan Chengbdd679a2009-06-26 00:19:44 +00001258let isCommutable = 1 in {
Evan Chengee80fb72008-11-06 01:21:28 +00001259def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001260 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001261 "smull", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262
Evan Chengee80fb72008-11-06 01:21:28 +00001263def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001264 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001265 "umull", "\t$ldst, $hdst, $a, $b", []>;
Evan Chengbdd679a2009-06-26 00:19:44 +00001266}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267
1268// Multiply + accumulate
Evan Chengee80fb72008-11-06 01:21:28 +00001269def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001270 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001271 "smlal", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272
Evan Chengee80fb72008-11-06 01:21:28 +00001273def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001274 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001275 "umlal", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276
Evan Chengee80fb72008-11-06 01:21:28 +00001277def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001278 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001279 "umaal", "\t$ldst, $hdst, $a, $b", []>,
Evan Chengee80fb72008-11-06 01:21:28 +00001280 Requires<[IsARM, HasV6]>;
Evan Chengd97d7142009-06-12 20:46:18 +00001281} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282
1283// Most significant word multiply
Evan Chengee80fb72008-11-06 01:21:28 +00001284def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001285 IIC_iMUL32, "smmul", "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001287 Requires<[IsARM, HasV6]> {
1288 let Inst{7-4} = 0b0001;
1289 let Inst{15-12} = 0b1111;
1290}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291
Evan Chengee80fb72008-11-06 01:21:28 +00001292def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001293 IIC_iMAC32, "smmla", "\t$dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001295 Requires<[IsARM, HasV6]> {
1296 let Inst{7-4} = 0b0001;
1297}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298
1299
Evan Chengee80fb72008-11-06 01:21:28 +00001300def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001301 IIC_iMAC32, "smmls", "\t$dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001303 Requires<[IsARM, HasV6]> {
1304 let Inst{7-4} = 0b1101;
1305}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001307multiclass AI_smul<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001308 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001309 IIC_iMUL32, !strconcat(opc, "bb"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1311 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001312 Requires<[IsARM, HasV5TE]> {
1313 let Inst{5} = 0;
1314 let Inst{6} = 0;
1315 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001316
Evan Cheng38396be2008-11-06 03:35:07 +00001317 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001318 IIC_iMUL32, !strconcat(opc, "bt"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
Bob Wilson74590a02009-06-22 22:08:29 +00001320 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001321 Requires<[IsARM, HasV5TE]> {
1322 let Inst{5} = 0;
1323 let Inst{6} = 1;
1324 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001325
Evan Cheng38396be2008-11-06 03:35:07 +00001326 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001327 IIC_iMUL32, !strconcat(opc, "tb"), "\t$dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001328 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001330 Requires<[IsARM, HasV5TE]> {
1331 let Inst{5} = 1;
1332 let Inst{6} = 0;
1333 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001334
Evan Cheng38396be2008-11-06 03:35:07 +00001335 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001336 IIC_iMUL32, !strconcat(opc, "tt"), "\t$dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001337 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1338 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001339 Requires<[IsARM, HasV5TE]> {
1340 let Inst{5} = 1;
1341 let Inst{6} = 1;
1342 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001343
Evan Cheng38396be2008-11-06 03:35:07 +00001344 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001345 IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001347 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001348 Requires<[IsARM, HasV5TE]> {
1349 let Inst{5} = 1;
1350 let Inst{6} = 0;
1351 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001352
Evan Cheng38396be2008-11-06 03:35:07 +00001353 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001354 IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001356 (sra GPR:$b, (i32 16))), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001357 Requires<[IsARM, HasV5TE]> {
1358 let Inst{5} = 1;
1359 let Inst{6} = 1;
1360 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361}
1362
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001363
1364multiclass AI_smla<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001365 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001366 IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(set GPR:$dst, (add GPR:$acc,
1368 (opnode (sext_inreg GPR:$a, i16),
1369 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001370 Requires<[IsARM, HasV5TE]> {
1371 let Inst{5} = 0;
1372 let Inst{6} = 0;
1373 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001374
Evan Cheng38396be2008-11-06 03:35:07 +00001375 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001376 IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
Bob Wilson74590a02009-06-22 22:08:29 +00001378 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001379 Requires<[IsARM, HasV5TE]> {
1380 let Inst{5} = 0;
1381 let Inst{6} = 1;
1382 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001383
Evan Cheng38396be2008-11-06 03:35:07 +00001384 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001385 IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Bob Wilson74590a02009-06-22 22:08:29 +00001386 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001388 Requires<[IsARM, HasV5TE]> {
1389 let Inst{5} = 1;
1390 let Inst{6} = 0;
1391 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001392
Evan Cheng38396be2008-11-06 03:35:07 +00001393 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001394 IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
1395 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1396 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001397 Requires<[IsARM, HasV5TE]> {
1398 let Inst{5} = 1;
1399 let Inst{6} = 1;
1400 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401
Evan Cheng38396be2008-11-06 03:35:07 +00001402 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001403 IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001405 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001406 Requires<[IsARM, HasV5TE]> {
1407 let Inst{5} = 0;
1408 let Inst{6} = 0;
1409 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001410
Evan Cheng38396be2008-11-06 03:35:07 +00001411 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001412 IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001414 (sra GPR:$b, (i32 16))), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001415 Requires<[IsARM, HasV5TE]> {
1416 let Inst{5} = 0;
1417 let Inst{6} = 1;
1418 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419}
1420
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001421defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1422defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423
1424// TODO: Halfword multiple accumulate long: SMLAL<x><y>
1425// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1426
1427//===----------------------------------------------------------------------===//
1428// Misc. Arithmetic Instructions.
1429//
1430
David Goodwin236ccb52009-08-19 18:00:44 +00001431def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001432 "clz", "\t$dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001433 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1434 let Inst{7-4} = 0b0001;
1435 let Inst{11-8} = 0b1111;
1436 let Inst{19-16} = 0b1111;
1437}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438
David Goodwin236ccb52009-08-19 18:00:44 +00001439def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001440 "rev", "\t$dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001441 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1442 let Inst{7-4} = 0b0011;
1443 let Inst{11-8} = 0b1111;
1444 let Inst{19-16} = 0b1111;
1445}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446
David Goodwin236ccb52009-08-19 18:00:44 +00001447def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001448 "rev16", "\t$dst, $src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449 [(set GPR:$dst,
Bob Wilson74590a02009-06-22 22:08:29 +00001450 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1451 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1452 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1453 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001454 Requires<[IsARM, HasV6]> {
1455 let Inst{7-4} = 0b1011;
1456 let Inst{11-8} = 0b1111;
1457 let Inst{19-16} = 0b1111;
1458}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459
David Goodwin236ccb52009-08-19 18:00:44 +00001460def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001461 "revsh", "\t$dst, $src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462 [(set GPR:$dst,
1463 (sext_inreg
Bob Wilson74590a02009-06-22 22:08:29 +00001464 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1465 (shl GPR:$src, (i32 8))), i16))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001466 Requires<[IsARM, HasV6]> {
1467 let Inst{7-4} = 0b1011;
1468 let Inst{11-8} = 0b1111;
1469 let Inst{19-16} = 0b1111;
1470}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471
Evan Chengc2121a22008-11-07 01:41:35 +00001472def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1473 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001474 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2, LSL $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1476 (and (shl GPR:$src2, (i32 imm:$shamt)),
1477 0xFFFF0000)))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001478 Requires<[IsARM, HasV6]> {
1479 let Inst{6-4} = 0b001;
1480}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481
1482// Alternate cases for PKHBT where identities eliminate some nodes.
1483def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1484 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1485def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1486 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1487
1488
Evan Chengc2121a22008-11-07 01:41:35 +00001489def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1490 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001491 IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2, ASR $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1493 (and (sra GPR:$src2, imm16_31:$shamt),
Evan Chengc2121a22008-11-07 01:41:35 +00001494 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1495 let Inst{6-4} = 0b101;
1496}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497
1498// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1499// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilson74590a02009-06-22 22:08:29 +00001500def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1502def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1503 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1504 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1505
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506//===----------------------------------------------------------------------===//
1507// Comparison Instructions...
1508//
1509
Jim Grosbach88c246f2008-10-14 20:36:24 +00001510defm CMP : AI1_cmp_irs<0b1010, "cmp",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001511 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001512defm CMN : AI1_cmp_irs<0b1011, "cmn",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001513 BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514
1515// Note that TST/TEQ don't set all the same flags that CMP does!
Evan Chengbe998242008-11-06 08:47:38 +00001516defm TST : AI1_cmp_irs<0b1000, "tst",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001517 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
Evan Chengbe998242008-11-06 08:47:38 +00001518defm TEQ : AI1_cmp_irs<0b1001, "teq",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001519 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520
David Goodwin8bdcbb32009-06-29 15:33:01 +00001521defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1522 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1523defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1524 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525
1526def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1527 (CMNri GPR:$src, so_imm_neg:$imm)>;
1528
David Goodwin8bdcbb32009-06-29 15:33:01 +00001529def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 (CMNri GPR:$src, so_imm_neg:$imm)>;
1531
1532
1533// Conditional moves
1534// FIXME: should be able to write a pattern for ARMcmov, but can't use
1535// a two-value operand where a dag node expects two operands. :(
Evan Chengbe998242008-11-06 08:47:38 +00001536def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001537 IIC_iCMOVr, "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001539 RegConstraint<"$false = $dst">, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +00001540 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001541 let Inst{25} = 0;
1542}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543
Evan Chengbe998242008-11-06 08:47:38 +00001544def MOVCCs : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001545 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001546 "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001548 RegConstraint<"$false = $dst">, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001549 let Inst{25} = 0;
1550}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551
Evan Chengbe998242008-11-06 08:47:38 +00001552def MOVCCi : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001553 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001554 "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Chenga9892932009-09-09 01:47:07 +00001556 RegConstraint<"$false = $dst">, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001557 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001558}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559
1560
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561//===----------------------------------------------------------------------===//
1562// TLS Instructions
1563//
1564
1565// __aeabi_read_tp preserves the registers r1-r3.
1566let isCall = 1,
1567 Defs = [R0, R12, LR, CPSR] in {
David Goodwincfd67652009-08-06 16:52:47 +00001568 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001569 "bl\t__aeabi_read_tp",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 [(set R0, ARMthread_pointer)]>;
1571}
1572
1573//===----------------------------------------------------------------------===//
Jim Grosbachc10915b2009-05-12 23:59:14 +00001574// SJLJ Exception handling intrinsics
Jim Grosbach207a4ba2009-08-13 15:11:43 +00001575// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001576// address and save #0 in R0 for the non-longjmp case.
Jim Grosbachc10915b2009-05-12 23:59:14 +00001577// Since by its nature we may be coming from some other function to get
1578// here, and we're using the stack frame for the containing function to
1579// save/restore registers, we can't keep anything live in regs across
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001580// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
Jim Grosbachc10915b2009-05-12 23:59:14 +00001581// when we get here from a longjmp(). We force everthing out of registers
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001582// except for our own input by listing the relevant registers in Defs. By
1583// doing so, we also cause the prologue/epilogue code to actively preserve
1584// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbachc10915b2009-05-12 23:59:14 +00001585let Defs =
Jim Grosbach3990e392009-08-13 16:59:44 +00001586 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
1587 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Evan Cheng80ab2a82009-07-29 20:10:36 +00001588 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Evan Cheng27396a62009-07-22 06:46:53 +00001589 D31 ] in {
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001590 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src),
David Goodwincfd67652009-08-06 16:52:47 +00001591 AddrModeNone, SizeSpecial, IndexModeNone,
1592 Pseudo, NoItinerary,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001593 "str\tsp, [$src, #+8] @ eh_setjmp begin\n\t"
1594 "add\tr12, pc, #8\n\t"
1595 "str\tr12, [$src, #+4]\n\t"
1596 "mov\tr0, #0\n\t"
1597 "add\tpc, pc, #0\n\t"
1598 "mov\tr0, #1 @ eh_setjmp end", "",
Jim Grosbach4a9025e2009-05-14 00:46:35 +00001599 [(set R0, (ARMeh_sjlj_setjmp GPR:$src))]>;
Jim Grosbachc10915b2009-05-12 23:59:14 +00001600}
1601
1602//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603// Non-Instruction Patterns
1604//
1605
1606// ConstantPool, GlobalAddress, and JumpTable
1607def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1608def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1609def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
1610 (LEApcrelJT tjumptable:$dst, imm:$id)>;
1611
1612// Large immediate handling.
1613
1614// Two piece so_imms.
1615let isReMaterializable = 1 in
David Goodwincfd67652009-08-06 16:52:47 +00001616def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
David Goodwin236ccb52009-08-19 18:00:44 +00001617 Pseudo, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001618 "mov", "\t$dst, $src",
Evan Cheng16c012d2009-09-28 09:14:39 +00001619 [(set GPR:$dst, so_imm2part:$src)]>,
1620 Requires<[IsARM, NoV6T2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621
1622def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00001623 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1624 (so_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00001626 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1627 (so_imm2part_2 imm:$RHS))>;
Jim Grosbach1afc8e22009-10-21 20:44:34 +00001628def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
1629 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1630 (so_imm2part_2 imm:$RHS))>;
Jim Grosbach66e70cd2009-11-23 20:35:53 +00001631def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
1632 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
1633 (so_neg_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634
Evan Cheng16c012d2009-09-28 09:14:39 +00001635// 32-bit immediate using movw + movt.
Chris Lattnere4eb7342009-10-20 00:40:56 +00001636// This is a single pseudo instruction, the benefit is that it can be remat'd
1637// as a single unit instead of having to handle reg inputs.
1638// FIXME: Remove this when we can do generalized remat.
Evan Cheng16c012d2009-09-28 09:14:39 +00001639let isReMaterializable = 1 in
1640def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001641 "movw", "\t$dst, ${src:lo16}\n\tmovt${p} $dst, ${src:hi16}",
Evan Cheng16c012d2009-09-28 09:14:39 +00001642 [(set GPR:$dst, (i32 imm:$src))]>,
1643 Requires<[IsARM, HasV6T2]>;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001644
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645// TODO: add,sub,and, 3-instr forms?
1646
1647
1648// Direct calls
Bob Wilson243b37c2009-06-22 21:01:46 +00001649def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00001650 Requires<[IsARM, IsNotDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +00001651def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00001652 Requires<[IsARM, IsDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653
1654// zextload i1 -> zextload i8
1655def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1656
1657// extload -> zextload
1658def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1659def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1660def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
1661
Evan Chengc41fb3152008-11-05 23:22:34 +00001662def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
1663def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
1664
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665// smul* and smla*
Bob Wilson74590a02009-06-22 22:08:29 +00001666def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1667 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668 (SMULBB GPR:$a, GPR:$b)>;
1669def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1670 (SMULBB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001671def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1672 (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001674def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001676def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
1677 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001679def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001681def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1682 (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683 (SMULWB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001684def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 (SMULWB GPR:$a, GPR:$b)>;
1686
1687def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001688 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1689 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1691def : ARMV5TEPat<(add GPR:$acc,
1692 (mul sext_16_node:$a, sext_16_node:$b)),
1693 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1694def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001695 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
1696 (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1698def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001699 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1701def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001702 (mul (sra GPR:$a, (i32 16)),
1703 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1705def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001706 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1708def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001709 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
1710 (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1712def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00001713 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1715
1716//===----------------------------------------------------------------------===//
1717// Thumb Support
1718//
1719
1720include "ARMInstrThumb.td"
1721
1722//===----------------------------------------------------------------------===//
Anton Korobeynikovac869fc2009-06-17 18:13:58 +00001723// Thumb2 Support
1724//
1725
1726include "ARMInstrThumb2.td"
1727
1728//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729// Floating Point Support
1730//
1731
1732include "ARMInstrVFP.td"
Bob Wilsone60fee02009-06-22 23:27:02 +00001733
1734//===----------------------------------------------------------------------===//
1735// Advanced SIMD (NEON) Support
1736//
1737
1738include "ARMInstrNEON.td"