blob: adad51637610ba2d492299fc93c09814fd39e8a4 [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 Grosbach8d96fc12010-02-08 23:22:00 +000047def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
48 SDTCisInt<2>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049
Jim Grosbach6eee9032009-12-14 21:24:16 +000050def SDT_ARMMEMBARRIERV7 : SDTypeProfile<0, 0, []>;
51def SDT_ARMSYNCBARRIERV7 : SDTypeProfile<0, 0, []>;
52def SDT_ARMMEMBARRIERV6 : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
53def SDT_ARMSYNCBARRIERV6 : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Jim Grosbachba744f62009-12-10 00:11:09 +000054
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055// Node definitions.
56def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
57def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
58
Bill Wendling7173da52007-11-13 09:19:02 +000059def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
Bill Wendling6c02cd22008-02-27 06:33:05 +000060 [SDNPHasChain, SDNPOutFlag]>;
Bill Wendling7173da52007-11-13 09:19:02 +000061def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
Bill Wendling6c02cd22008-02-27 06:33:05 +000062 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063
64def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
65 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
66def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
67 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
68def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
69 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
70
Chris Lattner3d254552008-01-15 22:02:54 +000071def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072 [SDNPHasChain, SDNPOptInFlag]>;
73
74def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
75 [SDNPInFlag]>;
76def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
77 [SDNPInFlag]>;
78
79def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
80 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
81
82def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
83 [SDNPHasChain]>;
Evan Cheng1b2b3e22009-07-29 02:18:14 +000084def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
85 [SDNPHasChain]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
87def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
88 [SDNPOutFlag]>;
89
David Goodwin8bdcbb32009-06-29 15:33:01 +000090def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
91 [SDNPOutFlag,SDNPCommutative]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092
93def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
94
95def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
96def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
97def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
98
99def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
Jim Grosbach4a9025e2009-05-14 00:46:35 +0000100def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", SDT_ARMEH_SJLJ_Setjmp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000101
Jim Grosbach6eee9032009-12-14 21:24:16 +0000102def ARMMemBarrierV7 : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERV7,
Jim Grosbachba744f62009-12-10 00:11:09 +0000103 [SDNPHasChain]>;
Jim Grosbach6eee9032009-12-14 21:24:16 +0000104def ARMSyncBarrierV7 : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERV7,
105 [SDNPHasChain]>;
106def ARMMemBarrierV6 : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERV6,
107 [SDNPHasChain]>;
108def ARMSyncBarrierV6 : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERV6,
Jim Grosbachba744f62009-12-10 00:11:09 +0000109 [SDNPHasChain]>;
110
Evan Chengd7da8fc2010-01-19 00:44:15 +0000111def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
112
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113//===----------------------------------------------------------------------===//
114// ARM Instruction Predicate Definitions.
115//
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000116def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
117def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
118def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
Evan Chengc8147e12009-07-06 22:05:45 +0000119def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">;
Evan Cheng16c012d2009-09-28 09:14:39 +0000120def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
Bob Wilsone60fee02009-06-22 23:27:02 +0000121def HasV7 : Predicate<"Subtarget->hasV7Ops()">;
122def HasVFP2 : Predicate<"Subtarget->hasVFP2()">;
123def HasVFP3 : Predicate<"Subtarget->hasVFP3()">;
124def HasNEON : Predicate<"Subtarget->hasNEON()">;
David Goodwindd19ce42009-08-04 17:53:06 +0000125def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
126def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000127def IsThumb : Predicate<"Subtarget->isThumb()">;
Evan Cheng36173712009-06-23 17:48:47 +0000128def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
Evan Chengb1b2abc2009-07-02 06:38:40 +0000129def IsThumb2 : Predicate<"Subtarget->isThumb2()">;
Anton Korobeynikovcba02692009-06-15 21:46:20 +0000130def IsARM : Predicate<"!Subtarget->isThumb()">;
Bob Wilson243b37c2009-06-22 21:01:46 +0000131def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
132def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133
Anton Korobeynikova414f362009-11-24 00:44:37 +0000134// FIXME: Eventually this will be just "hasV6T2Ops".
135def UseMovt : Predicate<"Subtarget->useMovt()">;
136def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
137
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138//===----------------------------------------------------------------------===//
139// ARM Flag Definitions.
140
141class RegConstraint<string C> {
142 string Constraints = C;
143}
144
145//===----------------------------------------------------------------------===//
146// ARM specific transformation functions and pattern fragments.
147//
148
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149// so_imm_neg_XFORM - Return a so_imm value packed into the format described for
150// so_imm_neg def below.
151def so_imm_neg_XFORM : SDNodeXForm<imm, [{
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000152 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153}]>;
154
155// so_imm_not_XFORM - Return a so_imm value packed into the format described for
156// so_imm_not def below.
157def so_imm_not_XFORM : SDNodeXForm<imm, [{
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000158 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159}]>;
160
161// rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
162def rot_imm : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000163 int32_t v = (int32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164 return v == 8 || v == 16 || v == 24;
165}]>;
166
167/// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
168def imm1_15 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000169 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170}]>;
171
172/// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
173def imm16_31 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000174 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175}]>;
176
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000177def so_imm_neg :
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000178 PatLeaf<(imm), [{
179 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
180 }], so_imm_neg_XFORM>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181
182def so_imm_not :
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000183 PatLeaf<(imm), [{
184 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
185 }], so_imm_not_XFORM>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186
187// sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
188def sext_16_node : PatLeaf<(i32 GPR:$a), [{
Dan Gohman8181bd12008-07-27 21:46:04 +0000189 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190}]>;
191
Evan Cheng299ee652009-07-06 22:23:46 +0000192/// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
193/// e.g., 0xf000ffff
194def bf_inv_mask_imm : Operand<i32>,
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000195 PatLeaf<(imm), [{
Evan Cheng299ee652009-07-06 22:23:46 +0000196 uint32_t v = (uint32_t)N->getZExtValue();
197 if (v == 0xffffffff)
198 return 0;
David Goodwinf354d362009-07-14 00:57:56 +0000199 // there can be 1's on either or both "outsides", all the "inside"
200 // bits must be 0's
201 unsigned int lsb = 0, msb = 31;
202 while (v & (1 << msb)) --msb;
203 while (v & (1 << lsb)) ++lsb;
204 for (unsigned int i = lsb; i <= msb; ++i) {
205 if (v & (1 << i))
206 return 0;
207 }
208 return 1;
Evan Cheng299ee652009-07-06 22:23:46 +0000209}] > {
210 let PrintMethod = "printBitfieldInvMaskImmOperand";
211}
212
Anton Korobeynikov60928952009-09-27 23:52:58 +0000213/// Split a 32-bit immediate into two 16 bit parts.
214def lo16 : SDNodeXForm<imm, [{
215 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() & 0xffff,
216 MVT::i32);
217}]>;
218
219def hi16 : SDNodeXForm<imm, [{
220 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
221}]>;
222
223def lo16AllZero : PatLeaf<(i32 imm), [{
224 // Returns true if all low 16-bits are 0.
225 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
Anton Korobeynikova414f362009-11-24 00:44:37 +0000226}], hi16>;
Anton Korobeynikov60928952009-09-27 23:52:58 +0000227
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000228/// imm0_65535 predicate - True if the 32-bit immediate is in the range
Anton Korobeynikov60928952009-09-27 23:52:58 +0000229/// [0.65535].
230def imm0_65535 : PatLeaf<(i32 imm), [{
231 return (uint32_t)N->getZExtValue() < 65536;
232}]>;
233
Evan Cheng7b0249b2008-08-28 23:39:26 +0000234class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
235class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000237/// adde and sube predicates - True based on whether the carry flag output
238/// will be needed or not.
239def adde_dead_carry :
240 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
241 [{return !N->hasAnyUseOfValue(1);}]>;
242def sube_dead_carry :
243 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
244 [{return !N->hasAnyUseOfValue(1);}]>;
245def adde_live_carry :
246 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
247 [{return N->hasAnyUseOfValue(1);}]>;
248def sube_live_carry :
249 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
250 [{return N->hasAnyUseOfValue(1);}]>;
251
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252//===----------------------------------------------------------------------===//
253// Operand Definitions.
254//
255
256// Branch target.
257def brtarget : Operand<OtherVT>;
258
259// A list of registers separated by comma. Used by load/store multiple.
260def reglist : Operand<i32> {
261 let PrintMethod = "printRegisterList";
262}
263
264// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
265def cpinst_operand : Operand<i32> {
266 let PrintMethod = "printCPInstOperand";
267}
268
269def jtblock_operand : Operand<i32> {
270 let PrintMethod = "printJTBlockOperand";
271}
Evan Cheng6e2ebc92009-07-25 00:33:29 +0000272def jt2block_operand : Operand<i32> {
273 let PrintMethod = "printJT2BlockOperand";
274}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275
276// Local PC labels.
277def pclabel : Operand<i32> {
278 let PrintMethod = "printPCLabel";
279}
280
281// shifter_operand operands: so_reg and so_imm.
282def so_reg : Operand<i32>, // reg reg imm
283 ComplexPattern<i32, 3, "SelectShifterOperandReg",
284 [shl,srl,sra,rotr]> {
285 let PrintMethod = "printSORegOperand";
286 let MIOperandInfo = (ops GPR, GPR, i32imm);
287}
288
289// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
290// 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
291// represented in the imm field in the same 12-bit form that they are encoded
292// into so_imm instructions: the 8-bit immediate is the least significant bits
293// [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
294def so_imm : Operand<i32>,
Evan Cheng8be2a5b2009-07-08 21:03:57 +0000295 PatLeaf<(imm), [{
296 return ARM_AM::getSOImmVal(N->getZExtValue()) != -1;
297 }]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 let PrintMethod = "printSOImmOperand";
299}
300
301// Break so_imm's up into two pieces. This handles immediates with up to 16
302// bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
303// get the first/second pieces.
304def so_imm2part : Operand<i32>,
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000305 PatLeaf<(imm), [{
306 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
307 }]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 let PrintMethod = "printSOImm2PartOperand";
309}
310
311def so_imm2part_1 : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000312 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000313 return CurDAG->getTargetConstant(V, MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314}]>;
315
316def so_imm2part_2 : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000317 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
Owen Anderson36e3a6e2009-08-11 20:47:22 +0000318 return CurDAG->getTargetConstant(V, MVT::i32);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319}]>;
320
Jim Grosbach66e70cd2009-11-23 20:35:53 +0000321def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{
322 return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue());
323 }]> {
324 let PrintMethod = "printSOImm2PartOperand";
325}
326
327def so_neg_imm2part_1 : SDNodeXForm<imm, [{
328 unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue());
329 return CurDAG->getTargetConstant(V, MVT::i32);
330}]>;
331
332def so_neg_imm2part_2 : SDNodeXForm<imm, [{
333 unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue());
334 return CurDAG->getTargetConstant(V, MVT::i32);
335}]>;
336
Sandeep Patelbb4648a2009-10-13 18:59:48 +0000337/// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
338def imm0_31 : Operand<i32>, PatLeaf<(imm), [{
339 return (int32_t)N->getZExtValue() < 32;
340}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341
342// Define ARM specific addressing modes.
343
344// addrmode2 := reg +/- reg shop imm
345// addrmode2 := reg +/- imm12
346//
347def addrmode2 : Operand<i32>,
348 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
349 let PrintMethod = "printAddrMode2Operand";
350 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
351}
352
353def am2offset : Operand<i32>,
354 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
355 let PrintMethod = "printAddrMode2OffsetOperand";
356 let MIOperandInfo = (ops GPR, i32imm);
357}
358
359// addrmode3 := reg +/- reg
360// addrmode3 := reg +/- imm8
361//
362def addrmode3 : Operand<i32>,
363 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
364 let PrintMethod = "printAddrMode3Operand";
365 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
366}
367
368def am3offset : Operand<i32>,
369 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
370 let PrintMethod = "printAddrMode3OffsetOperand";
371 let MIOperandInfo = (ops GPR, i32imm);
372}
373
374// addrmode4 := reg, <mode|W>
375//
376def addrmode4 : Operand<i32>,
Anton Korobeynikov3f087662009-08-08 13:35:48 +0000377 ComplexPattern<i32, 2, "SelectAddrMode4", []> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 let PrintMethod = "printAddrMode4Operand";
379 let MIOperandInfo = (ops GPR, i32imm);
380}
381
382// addrmode5 := reg +/- imm8*4
383//
384def addrmode5 : Operand<i32>,
385 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
386 let PrintMethod = "printAddrMode5Operand";
387 let MIOperandInfo = (ops GPR, i32imm);
388}
389
Bob Wilson970a10d2009-07-01 23:16:05 +0000390// addrmode6 := reg with optional writeback
391//
392def addrmode6 : Operand<i32>,
Jim Grosbach04d92822009-11-07 21:25:39 +0000393 ComplexPattern<i32, 4, "SelectAddrMode6", []> {
Bob Wilson970a10d2009-07-01 23:16:05 +0000394 let PrintMethod = "printAddrMode6Operand";
Jim Grosbach04d92822009-11-07 21:25:39 +0000395 let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm);
Bob Wilson970a10d2009-07-01 23:16:05 +0000396}
397
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398// addrmodepc := pc + reg
399//
400def addrmodepc : Operand<i32>,
401 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
402 let PrintMethod = "printAddrModePCOperand";
403 let MIOperandInfo = (ops GPR, i32imm);
404}
405
Bob Wilson30ff4492009-08-21 21:58:55 +0000406def nohash_imm : Operand<i32> {
407 let PrintMethod = "printNoHashImmediate";
Anton Korobeynikove2be3382009-08-08 23:10:41 +0000408}
409
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410//===----------------------------------------------------------------------===//
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000411
Evan Cheng7b0249b2008-08-28 23:39:26 +0000412include "ARMInstrFormats.td"
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000413
414//===----------------------------------------------------------------------===//
Evan Cheng7b0249b2008-08-28 23:39:26 +0000415// Multiclass helpers...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416//
417
Evan Cheng40d64532008-08-29 07:36:24 +0000418/// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419/// binop that produces a value.
Evan Chengbdd679a2009-06-26 00:19:44 +0000420multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode,
421 bit Commutable = 0> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000422 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000423 IIC_iALUi, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000424 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
425 let Inst{25} = 1;
426 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000427 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000428 IIC_iALUr, opc, "\t$dst, $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000429 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
Johnny Chend139b942009-11-07 00:54:36 +0000430 let Inst{11-4} = 0b00000000;
Evan Cheng83a32b42009-07-07 23:40:25 +0000431 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000432 let isCommutable = Commutable;
433 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000434 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000435 IIC_iALUsr, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000436 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
437 let Inst{25} = 0;
438 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439}
440
Evan Chengd4e2f052009-06-25 20:59:23 +0000441/// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
Bob Wilson3443c212009-10-06 20:18:46 +0000442/// instruction modifies the CPSR register.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000443let Defs = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000444multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode,
445 bit Commutable = 0> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000446 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000447 IIC_iALUi, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000448 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> {
Bob Wilson3a308522009-10-26 22:34:44 +0000449 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000450 let Inst{25} = 1;
451 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000452 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000453 IIC_iALUr, opc, "\t$dst, $a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000454 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> {
455 let isCommutable = Commutable;
Johnny Chend139b942009-11-07 00:54:36 +0000456 let Inst{11-4} = 0b00000000;
Bob Wilson3a308522009-10-26 22:34:44 +0000457 let Inst{20} = 1;
Bob Wilsonb072c752009-10-13 15:27:23 +0000458 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000459 }
Evan Cheng86a926a2008-11-05 18:35:52 +0000460 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000461 IIC_iALUsr, opc, "\t$dst, $a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000462 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> {
Bob Wilson3a308522009-10-26 22:34:44 +0000463 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000464 let Inst{25} = 0;
465 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000466}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467}
468
469/// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
470/// patterns. Similar to AsI1_bin_irs except the instruction does not produce
471/// a explicit result, only implicitly set CPSR.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000472let Defs = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000473multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode,
474 bit Commutable = 0> {
David Goodwin236ccb52009-08-19 18:00:44 +0000475 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iCMPi,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000476 opc, "\t$a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000477 [(opnode GPR:$a, so_imm:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000478 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000479 let Inst{25} = 1;
480 }
David Goodwin236ccb52009-08-19 18:00:44 +0000481 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm, IIC_iCMPr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000482 opc, "\t$a, $b",
Evan Chengbdd679a2009-06-26 00:19:44 +0000483 [(opnode GPR:$a, GPR:$b)]> {
Johnny Chend139b942009-11-07 00:54:36 +0000484 let Inst{11-4} = 0b00000000;
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000485 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000486 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000487 let isCommutable = Commutable;
488 }
David Goodwin236ccb52009-08-19 18:00:44 +0000489 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iCMPsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000490 opc, "\t$a, $b",
Evan Cheng83a32b42009-07-07 23:40:25 +0000491 [(opnode GPR:$a, so_reg:$b)]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +0000492 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000493 let Inst{25} = 0;
494 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000495}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496}
497
498/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
499/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng37afa432008-11-06 22:15:19 +0000500/// FIXME: Remove the 'r' variant. Its rot_imm is zero.
501multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> {
David Goodwin236ccb52009-08-19 18:00:44 +0000502 def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000503 IIC_iUNAr, opc, "\t$dst, $src",
David Goodwin236ccb52009-08-19 18:00:44 +0000504 [(set GPR:$dst, (opnode GPR:$src))]>,
Evan Cheng37afa432008-11-06 22:15:19 +0000505 Requires<[IsARM, HasV6]> {
Johnny Chen1bf79442009-10-27 18:44:24 +0000506 let Inst{11-10} = 0b00;
507 let Inst{19-16} = 0b1111;
508 }
David Goodwin236ccb52009-08-19 18:00:44 +0000509 def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src, i32imm:$rot),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000510 IIC_iUNAsi, opc, "\t$dst, $src, ror $rot",
David Goodwin236ccb52009-08-19 18:00:44 +0000511 [(set GPR:$dst, (opnode (rotr GPR:$src, rot_imm:$rot)))]>,
Evan Cheng37afa432008-11-06 22:15:19 +0000512 Requires<[IsARM, HasV6]> {
Johnny Chen1bf79442009-10-27 18:44:24 +0000513 let Inst{19-16} = 0b1111;
514 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515}
516
517/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
518/// register and one whose operand is a register rotated by 8/16/24.
Evan Cheng37afa432008-11-06 22:15:19 +0000519multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> {
520 def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000521 IIC_iALUr, opc, "\t$dst, $LHS, $RHS",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
Johnny Chen1bf79442009-10-27 18:44:24 +0000523 Requires<[IsARM, HasV6]> {
524 let Inst{11-10} = 0b00;
525 }
Jim Grosbach60030482010-02-16 21:23:02 +0000526 def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS,
527 i32imm:$rot),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000528 IIC_iALUsi, opc, "\t$dst, $LHS, $RHS, ror $rot",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(set GPR:$dst, (opnode GPR:$LHS,
530 (rotr GPR:$RHS, rot_imm:$rot)))]>,
531 Requires<[IsARM, HasV6]>;
532}
533
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000534/// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
535let Uses = [CPSR] in {
Evan Chengbdd679a2009-06-26 00:19:44 +0000536multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
537 bit Commutable = 0> {
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000538 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000539 DPFrm, IIC_iALUi, opc, "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000540 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000541 Requires<[IsARM]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000542 let Inst{25} = 1;
543 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000544 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000545 DPFrm, IIC_iALUr, opc, "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000546 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000547 Requires<[IsARM]> {
Evan Chengbdd679a2009-06-26 00:19:44 +0000548 let isCommutable = Commutable;
Johnny Chend139b942009-11-07 00:54:36 +0000549 let Inst{11-4} = 0b00000000;
Evan Cheng83a32b42009-07-07 23:40:25 +0000550 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000551 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000552 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000553 DPSoRegFrm, IIC_iALUsr, opc, "\t$dst, $a, $b",
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000554 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000555 Requires<[IsARM]> {
Evan Cheng83a32b42009-07-07 23:40:25 +0000556 let Inst{25} = 0;
557 }
Jim Grosbache2fda532009-11-09 00:11:35 +0000558}
559// Carry setting variants
560let Defs = [CPSR] in {
561multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode,
562 bit Commutable = 0> {
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000563 def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Jim Grosbache2fda532009-11-09 00:11:35 +0000564 DPFrm, IIC_iALUi, !strconcat(opc, "\t$dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000565 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>,
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000566 Requires<[IsARM]> {
Bob Wilson3a308522009-10-26 22:34:44 +0000567 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000568 let Inst{25} = 1;
Evan Chengbdd679a2009-06-26 00:19:44 +0000569 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000570 def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Jim Grosbache2fda532009-11-09 00:11:35 +0000571 DPFrm, IIC_iALUr, !strconcat(opc, "\t$dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000572 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>,
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000573 Requires<[IsARM]> {
Johnny Chend139b942009-11-07 00:54:36 +0000574 let Inst{11-4} = 0b00000000;
Bob Wilson3a308522009-10-26 22:34:44 +0000575 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000576 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000577 }
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000578 def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Jim Grosbache2fda532009-11-09 00:11:35 +0000579 DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$dst, $a, $b"),
Evan Cheng9b4d26f2009-06-25 23:34:10 +0000580 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>,
Jim Grosbachdba8f2c2010-02-16 20:17:57 +0000581 Requires<[IsARM]> {
Bob Wilson3a308522009-10-26 22:34:44 +0000582 let Inst{20} = 1;
Evan Cheng83a32b42009-07-07 23:40:25 +0000583 let Inst{25} = 0;
Evan Chengbdd679a2009-06-26 00:19:44 +0000584 }
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000585}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586}
Jim Grosbache2fda532009-11-09 00:11:35 +0000587}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588
589//===----------------------------------------------------------------------===//
590// Instructions
591//===----------------------------------------------------------------------===//
592
593//===----------------------------------------------------------------------===//
594// Miscellaneous Instructions.
595//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
597/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
598/// the function. The first operand is the ID# for this instruction, the second
599/// is the index into the MachineConstantPool that this is, the third is the
600/// size in bytes of this constant pool entry.
Evan Chengd97d7142009-06-12 20:46:18 +0000601let neverHasSideEffects = 1, isNotDuplicable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602def CONSTPOOL_ENTRY :
Evan Chengb783fa32007-07-19 01:14:50 +0000603PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
David Goodwincfd67652009-08-06 16:52:47 +0000604 i32imm:$size), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 "${instid:label} ${cpidx:cpentry}", []>;
606
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000607let Defs = [SP], Uses = [SP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608def ADJCALLSTACKUP :
David Goodwincfd67652009-08-06 16:52:47 +0000609PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
Bill Wendling22f8deb2007-11-13 00:44:25 +0000610 "@ ADJCALLSTACKUP $amt1",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000611 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000613def ADJCALLSTACKDOWN :
David Goodwincfd67652009-08-06 16:52:47 +0000614PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615 "@ ADJCALLSTACKDOWN $amt",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000616 [(ARMcallseq_start timm:$amt)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000617}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618
Johnny Chen5a79afa2010-02-12 22:53:19 +0000619def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "",
Johnny Chen1b6d4f72010-02-10 18:02:25 +0000620 [/* For disassembly only; pattern left blank */]>,
621 Requires<[IsARM, HasV6T2]> {
622 let Inst{27-16} = 0b001100100000;
623 let Inst{7-0} = 0b00000000;
624}
625
Johnny Chen5a79afa2010-02-12 22:53:19 +0000626def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "",
627 [/* For disassembly only; pattern left blank */]>,
628 Requires<[IsARM, HasV6T2]> {
629 let Inst{27-16} = 0b001100100000;
630 let Inst{7-0} = 0b00000001;
631}
632
633def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "",
634 [/* For disassembly only; pattern left blank */]>,
635 Requires<[IsARM, HasV6T2]> {
636 let Inst{27-16} = 0b001100100000;
637 let Inst{7-0} = 0b00000010;
638}
639
640def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "",
641 [/* For disassembly only; pattern left blank */]>,
642 Requires<[IsARM, HasV6T2]> {
643 let Inst{27-16} = 0b001100100000;
644 let Inst{7-0} = 0b00000011;
645}
646
647def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
648 [/* For disassembly only; pattern left blank */]>,
649 Requires<[IsARM, HasV6T2]> {
650 let Inst{27-16} = 0b001100100000;
651 let Inst{7-0} = 0b00000100;
652}
653
Johnny Chen37dfb592010-02-11 18:12:29 +0000654// The i32imm operand $val can be used by a debugger to store more information
655// about the breakpoint.
Johnny Chen5a79afa2010-02-12 22:53:19 +0000656def BKPT : AI<(outs), (ins i32imm:$val), MiscFrm, NoItinerary, "bkpt", "\t$val",
Johnny Chen37dfb592010-02-11 18:12:29 +0000657 [/* For disassembly only; pattern left blank */]>,
658 Requires<[IsARM]> {
659 let Inst{27-20} = 0b00010010;
660 let Inst{7-4} = 0b0111;
661}
662
Johnny Chenb8689012010-02-12 18:55:33 +0000663// Change Processor State is a system instruction -- for disassembly only.
664// The singleton $opt operand contains the following information:
665// opt{4-0} = mode from Inst{4-0}
666// opt{5} = changemode from Inst{17}
667// opt{8-6} = AIF from Inst{8-6}
668// opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable
Johnny Chen5a79afa2010-02-12 22:53:19 +0000669def CPS : AXI<(outs),(ins i32imm:$opt), MiscFrm, NoItinerary, "cps${opt:cps}",
Johnny Chenb8689012010-02-12 18:55:33 +0000670 [/* For disassembly only; pattern left blank */]>,
671 Requires<[IsARM]> {
672 let Inst{31-28} = 0b1111;
673 let Inst{27-20} = 0b00010000;
674 let Inst{16} = 0;
675 let Inst{5} = 0;
676}
677
Johnny Chen8f3e19d2010-02-13 02:51:09 +0000678def SETENDBE : AXI<(outs),(ins), MiscFrm, NoItinerary, "setend\tbe",
679 [/* For disassembly only; pattern left blank */]>,
680 Requires<[IsARM]> {
681 let Inst{31-28} = 0b1111;
682 let Inst{27-20} = 0b00010000;
683 let Inst{16} = 1;
684 let Inst{9} = 1;
685 let Inst{7-4} = 0b0000;
686}
687
688def SETENDLE : AXI<(outs),(ins), MiscFrm, NoItinerary, "setend\tle",
689 [/* For disassembly only; pattern left blank */]>,
690 Requires<[IsARM]> {
691 let Inst{31-28} = 0b1111;
692 let Inst{27-20} = 0b00010000;
693 let Inst{16} = 1;
694 let Inst{9} = 0;
695 let Inst{7-4} = 0b0000;
696}
697
Johnny Chen5a79afa2010-02-12 22:53:19 +0000698def DBG : AI<(outs), (ins i32imm:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
Johnny Chen1b6d4f72010-02-10 18:02:25 +0000699 [/* For disassembly only; pattern left blank */]>,
700 Requires<[IsARM, HasV7]> {
701 let Inst{27-16} = 0b001100100000;
702 let Inst{7-4} = 0b1111;
703}
704
Johnny Chen44ad4432010-02-11 17:14:31 +0000705// A5.4 Permanently UNDEFINED instructions.
Johnny Chen5a79afa2010-02-12 22:53:19 +0000706def TRAP : AI<(outs), (ins), MiscFrm, NoItinerary, "trap", "",
Johnny Chen44ad4432010-02-11 17:14:31 +0000707 [/* For disassembly only; pattern left blank */]>,
708 Requires<[IsARM]> {
709 let Inst{27-25} = 0b011;
710 let Inst{24-20} = 0b11111;
711 let Inst{7-5} = 0b111;
712 let Inst{4} = 0b1;
713}
714
Evan Chengf8e8b622008-11-06 17:48:05 +0000715// Address computation and loads and stores in PIC mode.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716let isNotDuplicable = 1 in {
Evan Cheng0d28b382008-10-31 19:11:09 +0000717def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000718 Pseudo, IIC_iALUr, "\n$cp:\n\tadd$p\t$dst, pc, $a",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
720
Evan Cheng8610a3b2008-01-07 23:56:57 +0000721let AddedComplexity = 10 in {
Evan Chengbe998242008-11-06 08:47:38 +0000722def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000723 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr$p\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 [(set GPR:$dst, (load addrmodepc:$addr))]>;
725
Evan Chengbe998242008-11-06 08:47:38 +0000726def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Bob Wilson3bff42e2009-11-30 17:47:19 +0000727 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrh${p}\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
729
Evan Chengbe998242008-11-06 08:47:38 +0000730def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Bob Wilson3bff42e2009-11-30 17:47:19 +0000731 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrb${p}\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
733
Evan Chengbe998242008-11-06 08:47:38 +0000734def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Bob Wilson3bff42e2009-11-30 17:47:19 +0000735 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsh${p}\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
737
Evan Chengbe998242008-11-06 08:47:38 +0000738def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Bob Wilson3bff42e2009-11-30 17:47:19 +0000739 Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsb${p}\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
741}
Chris Lattnerf823faf2008-01-06 05:55:01 +0000742let AddedComplexity = 10 in {
Evan Chengbe998242008-11-06 08:47:38 +0000743def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000744 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr$p\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(store GPR:$src, addrmodepc:$addr)]>;
746
Evan Chengbe998242008-11-06 08:47:38 +0000747def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Bob Wilsonecce4b72009-11-18 18:10:35 +0000748 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrh${p}\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
750
Evan Chengbe998242008-11-06 08:47:38 +0000751def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Bob Wilsonecce4b72009-11-18 18:10:35 +0000752 Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrb${p}\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
754}
Evan Chengf8e8b622008-11-06 17:48:05 +0000755} // isNotDuplicable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756
Evan Chenga1366cd2009-06-23 05:25:29 +0000757
758// LEApcrel - Load a pc-relative address into a register without offending the
759// assembler.
David Goodwincfd67652009-08-06 16:52:47 +0000760def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p),
David Goodwin236ccb52009-08-19 18:00:44 +0000761 Pseudo, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000762 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(",
763 "${:private}PCRELL${:uid}+8))\n"),
764 !strconcat("${:private}PCRELL${:uid}:\n\t",
765 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
Evan Chenga1366cd2009-06-23 05:25:29 +0000766 []>;
767
Evan Chengba83d7c2009-06-24 23:14:45 +0000768def LEApcrelJT : AXI1<0x0, (outs GPR:$dst),
Bob Wilson30ff4492009-08-21 21:58:55 +0000769 (ins i32imm:$label, nohash_imm:$id, pred:$p),
David Goodwin236ccb52009-08-19 18:00:44 +0000770 Pseudo, IIC_iALUi,
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000771 !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, "
Anton Korobeynikove2be3382009-08-08 23:10:41 +0000772 "(${label}_${id}-(",
Evan Cheng9cf1e3e2009-07-22 22:03:29 +0000773 "${:private}PCRELL${:uid}+8))\n"),
774 !strconcat("${:private}PCRELL${:uid}:\n\t",
Jim Grosbach60030482010-02-16 21:23:02 +0000775 "add$p\t$dst, pc, #${:private}PCRELV${:uid}")),
Evan Cheng83a32b42009-07-07 23:40:25 +0000776 []> {
777 let Inst{25} = 1;
778}
Evan Chenga1366cd2009-06-23 05:25:29 +0000779
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780//===----------------------------------------------------------------------===//
781// Control Flow Instructions.
782//
783
Jim Grosbachc6f0c022009-09-30 01:35:11 +0000784let isReturn = 1, isTerminator = 1, isBarrier = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000785 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000786 "bx", "\tlr", [(ARMretflag)]> {
Johnny Chenff43a622009-11-16 23:57:56 +0000787 let Inst{3-0} = 0b1110;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000788 let Inst{7-4} = 0b0001;
789 let Inst{19-8} = 0b111111111111;
790 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000791}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792
Bob Wilsonf061fc82009-10-28 00:37:03 +0000793// Indirect branches
794let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Bob Wilsonea698652009-10-28 18:26:41 +0000795 def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
Bob Wilsonf061fc82009-10-28 00:37:03 +0000796 [(brind GPR:$dst)]> {
797 let Inst{7-4} = 0b0001;
798 let Inst{19-8} = 0b111111111111;
799 let Inst{27-20} = 0b00010010;
Johnny Chenff43a622009-11-16 23:57:56 +0000800 let Inst{31-28} = 0b1110;
Bob Wilsonf061fc82009-10-28 00:37:03 +0000801 }
802}
803
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804// FIXME: remove when we have a way to marking a MI with these properties.
Evan Chengf8e8b622008-11-06 17:48:05 +0000805// FIXME: Should pc be an implicit operand like PICADD, etc?
Evan Cheng7c8d5ea2009-10-01 08:22:27 +0000806let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
807 hasExtraDefRegAllocReq = 1 in
Evan Chengf8e8b622008-11-06 17:48:05 +0000808 def LDM_RET : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +0000809 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +0000810 LdStMulFrm, IIC_Br, "ldm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 []>;
812
Bob Wilson243b37c2009-06-22 21:01:46 +0000813// On non-Darwin platforms R9 is callee-saved.
David Goodwin4b6e4982009-08-12 18:31:53 +0000814let isCall = 1,
Evan Cheng27396a62009-07-22 06:46:53 +0000815 Defs = [R0, R1, R2, R3, R12, LR,
816 D0, D1, D2, D3, D4, D5, D6, D7,
817 D16, D17, D18, D19, D20, D21, D22, D23,
David Goodwin3d88e912009-09-03 22:12:28 +0000818 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
Evan Chengf8e8b622008-11-06 17:48:05 +0000819 def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000820 IIC_Br, "bl\t${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000821 [(ARMcall tglobaladdr:$func)]>,
Johnny Chen2b4d1db2009-10-27 20:45:15 +0000822 Requires<[IsARM, IsNotDarwin]> {
823 let Inst{31-28} = 0b1110;
824 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825
Evan Chengf8e8b622008-11-06 17:48:05 +0000826 def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000827 IIC_Br, "bl", "\t${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000828 [(ARMcall_pred tglobaladdr:$func)]>,
829 Requires<[IsARM, IsNotDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830
831 // ARMv5T and above
Evan Chengf8e8b622008-11-06 17:48:05 +0000832 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000833 IIC_Br, "blx\t$func",
Evan Cheng9e734482009-07-29 21:26:42 +0000834 [(ARMcall GPR:$func)]>,
835 Requires<[IsARM, HasV5T, IsNotDarwin]> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000836 let Inst{7-4} = 0b0011;
837 let Inst{19-8} = 0b111111111111;
838 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000839 }
840
Evan Chengfb1d1472009-07-14 01:49:27 +0000841 // ARMv4T
Bob Wilson8776f3e2010-02-16 17:24:15 +0000842 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
843 def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000844 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
Bob Wilson8776f3e2010-02-16 17:24:15 +0000845 [(ARMcall_nolink tGPR:$func)]>,
Evan Cheng9e734482009-07-29 21:26:42 +0000846 Requires<[IsARM, IsNotDarwin]> {
Evan Chengfb1d1472009-07-14 01:49:27 +0000847 let Inst{7-4} = 0b0001;
848 let Inst{19-8} = 0b111111111111;
849 let Inst{27-20} = 0b00010010;
Bob Wilson243b37c2009-06-22 21:01:46 +0000850 }
851}
852
853// On Darwin R9 is call-clobbered.
David Goodwin4b6e4982009-08-12 18:31:53 +0000854let isCall = 1,
Evan Cheng27396a62009-07-22 06:46:53 +0000855 Defs = [R0, R1, R2, R3, R9, R12, LR,
856 D0, D1, D2, D3, D4, D5, D6, D7,
857 D16, D17, D18, D19, D20, D21, D22, D23,
David Goodwin3d88e912009-09-03 22:12:28 +0000858 D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in {
Bob Wilson243b37c2009-06-22 21:01:46 +0000859 def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000860 IIC_Br, "bl\t${func:call}",
Johnny Chen2b4d1db2009-10-27 20:45:15 +0000861 [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> {
862 let Inst{31-28} = 0b1110;
863 }
Bob Wilson243b37c2009-06-22 21:01:46 +0000864
865 def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000866 IIC_Br, "bl", "\t${func:call}",
Evan Cheng9e734482009-07-29 21:26:42 +0000867 [(ARMcall_pred tglobaladdr:$func)]>,
868 Requires<[IsARM, IsDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +0000869
870 // ARMv5T and above
871 def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000872 IIC_Br, "blx\t$func",
Bob Wilson243b37c2009-06-22 21:01:46 +0000873 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> {
874 let Inst{7-4} = 0b0011;
875 let Inst{19-8} = 0b111111111111;
876 let Inst{27-20} = 0b00010010;
877 }
878
Evan Chengfb1d1472009-07-14 01:49:27 +0000879 // ARMv4T
Bob Wilson8776f3e2010-02-16 17:24:15 +0000880 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
881 def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000882 IIC_Br, "mov\tlr, pc\n\tbx\t$func",
Bob Wilson8776f3e2010-02-16 17:24:15 +0000883 [(ARMcall_nolink tGPR:$func)]>, Requires<[IsARM, IsDarwin]> {
Evan Chengfb1d1472009-07-14 01:49:27 +0000884 let Inst{7-4} = 0b0001;
885 let Inst{19-8} = 0b111111111111;
886 let Inst{27-20} = 0b00010010;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 }
888}
889
David Goodwin4b6e4982009-08-12 18:31:53 +0000890let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 // B is "predicable" since it can be xformed into a Bcc.
892 let isBarrier = 1 in {
893 let isPredicable = 1 in
David Goodwincfd67652009-08-06 16:52:47 +0000894 def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000895 "b\t$target", [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896
Owen Andersonf8053082007-11-12 07:39:39 +0000897 let isNotDuplicable = 1, isIndirectBranch = 1 in {
Evan Cheng0f63ae12008-11-07 09:06:08 +0000898 def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000899 IIC_Br, "mov\tpc, $target \n$jt",
Evan Cheng0f63ae12008-11-07 09:06:08 +0000900 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> {
Johnny Chen6fdbe652009-12-14 21:51:34 +0000901 let Inst{11-4} = 0b00000000;
Johnny Chen3f647402009-11-17 17:17:50 +0000902 let Inst{15-12} = 0b1111;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000903 let Inst{20} = 0; // S Bit
904 let Inst{24-21} = 0b1101;
Evan Chenge5f32ae2009-07-07 23:45:10 +0000905 let Inst{27-25} = 0b000;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 }
Evan Cheng0f63ae12008-11-07 09:06:08 +0000907 def BR_JTm : JTI<(outs),
908 (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000909 IIC_Br, "ldr\tpc, $target \n$jt",
David Goodwincfd67652009-08-06 16:52:47 +0000910 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
911 imm:$id)]> {
Johnny Chen3f647402009-11-17 17:17:50 +0000912 let Inst{15-12} = 0b1111;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000913 let Inst{20} = 1; // L bit
914 let Inst{21} = 0; // W bit
915 let Inst{22} = 0; // B bit
916 let Inst{24} = 1; // P bit
Evan Chenge5f32ae2009-07-07 23:45:10 +0000917 let Inst{27-25} = 0b011;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 }
Evan Cheng0f63ae12008-11-07 09:06:08 +0000919 def BR_JTadd : JTI<(outs),
920 (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000921 IIC_Br, "add\tpc, $target, $idx \n$jt",
Evan Cheng0f63ae12008-11-07 09:06:08 +0000922 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
923 imm:$id)]> {
Johnny Chen3f647402009-11-17 17:17:50 +0000924 let Inst{15-12} = 0b1111;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000925 let Inst{20} = 0; // S bit
926 let Inst{24-21} = 0b0100;
Evan Chenge5f32ae2009-07-07 23:45:10 +0000927 let Inst{27-25} = 0b000;
Evan Cheng0f63ae12008-11-07 09:06:08 +0000928 }
929 } // isNotDuplicable = 1, isIndirectBranch = 1
930 } // isBarrier = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931
932 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000933 // a two-value operand where a dag node expects two operands. :(
Evan Chengf8e8b622008-11-06 17:48:05 +0000934 def Bcc : ABI<0b1010, (outs), (ins brtarget:$target),
Evan Chengd3f9bc42009-10-26 23:45:59 +0000935 IIC_Br, "b", "\t$target",
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000936 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937}
938
Johnny Chen8f3e19d2010-02-13 02:51:09 +0000939// Branch and Exchange Jazelle -- for disassembly only
940def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
941 [/* For disassembly only; pattern left blank */]> {
942 let Inst{23-20} = 0b0010;
943 //let Inst{19-8} = 0xfff;
944 let Inst{7-4} = 0b0010;
945}
946
Johnny Chena6ad7432010-02-16 20:04:27 +0000947// Supervisor Call (Software Interrupt) -- for disassembly only
Johnny Chen1b6d4f72010-02-10 18:02:25 +0000948let isCall = 1 in {
949def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
950 [/* For disassembly only; pattern left blank */]>;
951}
952
Johnny Chena6ad7432010-02-16 20:04:27 +0000953// Store Return State -- for disassembly only
954def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$opt),
955 NoItinerary, "srs${addr:submode}\tsp!, $opt",
956 [/* For disassembly only; pattern left blank */]> {
957 let Inst{31-28} = 0b1111;
958 let Inst{22-20} = 0b110; // W = 1
959}
960
961def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
962 NoItinerary, "srs${addr:submode}\tsp, $mode",
963 [/* For disassembly only; pattern left blank */]> {
964 let Inst{31-28} = 0b1111;
965 let Inst{22-20} = 0b100; // W = 0
966}
967
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968//===----------------------------------------------------------------------===//
969// Load / store Instructions.
970//
971
972// Load
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000973let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000974def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000975 "ldr", "\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GPR:$dst, (load addrmode2:$addr))]>;
977
978// Special LDR for loads from non-pc-relative constpools.
Evan Cheng2f6bfd42009-11-20 19:57:15 +0000979let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1,
980 mayHaveSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000981def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000982 "ldr", "\t$dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983
984// Loads with zero extension
David Goodwin236ccb52009-08-19 18:00:44 +0000985def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000986 IIC_iLoadr, "ldrh", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000987 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000989def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000990 IIC_iLoadr, "ldrb", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000991 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992
993// Loads with sign extension
David Goodwin236ccb52009-08-19 18:00:44 +0000994def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000995 IIC_iLoadr, "ldrsh", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +0000996 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997
David Goodwin236ccb52009-08-19 18:00:44 +0000998def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +0000999 IIC_iLoadr, "ldrsb", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +00001000 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001002let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003// Load doubleword
Evan Cheng41169552009-06-15 08:28:29 +00001004def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001005 IIC_iLoadr, "ldrd", "\t$dst1, $addr",
Misha Brukman9daa0672009-08-27 14:14:21 +00001006 []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007
1008// Indexed loads
Evan Chengbe998242008-11-06 08:47:38 +00001009def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001010 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001011 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012
Evan Chengbe998242008-11-06 08:47:38 +00001013def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001014 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001015 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016
Evan Chengbe998242008-11-06 08:47:38 +00001017def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001018 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001019 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020
Evan Chengbe998242008-11-06 08:47:38 +00001021def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001022 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001023 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024
Evan Chengbe998242008-11-06 08:47:38 +00001025def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001026 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001027 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028
Evan Chengbe998242008-11-06 08:47:38 +00001029def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001030 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001031 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032
Evan Chengbe998242008-11-06 08:47:38 +00001033def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001034 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001035 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036
Evan Chengbe998242008-11-06 08:47:38 +00001037def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001038 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001039 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040
Evan Chengbe998242008-11-06 08:47:38 +00001041def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001042 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001043 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044
Evan Chengbe998242008-11-06 08:47:38 +00001045def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001046 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001047 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Chris Lattnerca4e0fe2008-01-10 05:12:37 +00001048}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049
Johnny Chenb47fed82010-02-11 20:31:08 +00001050// LDRT and LDRBT are for disassembly only.
1051
1052def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1053 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
1054 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1055 let Inst{21} = 1; // overwrite
1056}
1057
1058def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1059 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
1060 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1061 let Inst{21} = 1; // overwrite
1062}
1063
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064// Store
David Goodwin236ccb52009-08-19 18:00:44 +00001065def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001066 "str", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(store GPR:$src, addrmode2:$addr)]>;
1068
1069// Stores with truncate
Jim Grosbach60030482010-02-16 21:23:02 +00001070def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
1071 IIC_iStorer, "strh", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
1073
David Goodwin236ccb52009-08-19 18:00:44 +00001074def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +00001075 "strb", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
1077
1078// Store doubleword
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001079let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
David Goodwincfd67652009-08-06 16:52:47 +00001080def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
David Goodwin236ccb52009-08-19 18:00:44 +00001081 StMiscFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +00001082 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083
1084// Indexed stores
Evan Chengbe998242008-11-06 08:47:38 +00001085def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001086 (ins GPR:$src, GPR:$base, am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001087 StFrm, IIC_iStoreru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001088 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GPR:$base_wb,
1090 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1091
Evan Chengbe998242008-11-06 08:47:38 +00001092def STR_POST : AI2stwpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001093 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001094 StFrm, IIC_iStoreru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001095 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 [(set GPR:$base_wb,
1097 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1098
Evan Chengbe998242008-11-06 08:47:38 +00001099def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001100 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001101 StMiscFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001102 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 [(set GPR:$base_wb,
1104 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1105
Evan Chengbe998242008-11-06 08:47:38 +00001106def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001107 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001108 StMiscFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001109 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1111 GPR:$base, am3offset:$offset))]>;
1112
Evan Chengbe998242008-11-06 08:47:38 +00001113def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001114 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001115 StFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001116 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
1118 GPR:$base, am2offset:$offset))]>;
1119
Evan Chengbe998242008-11-06 08:47:38 +00001120def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001121 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001122 StFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001123 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
1125 GPR:$base, am2offset:$offset))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126
Johnny Chenb47fed82010-02-11 20:31:08 +00001127// STRT and STRBT are for disassembly only.
1128
1129def STRT : AI2stwpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001130 (ins GPR:$src, GPR:$base,am2offset:$offset),
Johnny Chenb47fed82010-02-11 20:31:08 +00001131 StFrm, IIC_iStoreru,
1132 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1133 [/* For disassembly only; pattern left blank */]> {
1134 let Inst{21} = 1; // overwrite
1135}
1136
1137def STRBT : AI2stbpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001138 (ins GPR:$src, GPR:$base,am2offset:$offset),
Johnny Chenb47fed82010-02-11 20:31:08 +00001139 StFrm, IIC_iStoreru,
1140 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1141 [/* For disassembly only; pattern left blank */]> {
1142 let Inst{21} = 1; // overwrite
1143}
1144
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145//===----------------------------------------------------------------------===//
1146// Load / store multiple Instructions.
1147//
1148
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001149let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +00001150def LDM : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +00001151 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +00001152 LdStMulFrm, IIC_iLoadm, "ldm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 []>;
1154
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001155let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +00001156def STM : AXI4st<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +00001157 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +00001158 LdStMulFrm, IIC_iStorem, "stm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159 []>;
1160
1161//===----------------------------------------------------------------------===//
1162// Move Instructions.
1163//
1164
Evan Chengd97d7142009-06-12 20:46:18 +00001165let neverHasSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001166def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001167 "mov", "\t$dst, $src", []>, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +00001168 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001169 let Inst{25} = 0;
1170}
1171
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001172def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src),
Anton Korobeynikov60928952009-09-27 23:52:58 +00001173 DPSoRegFrm, IIC_iMOVsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001174 "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001175 let Inst{25} = 0;
1176}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001178let isReMaterializable = 1, isAsCheapAsAMove = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001179def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001180 "mov", "\t$dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP {
Anton Korobeynikov60928952009-09-27 23:52:58 +00001181 let Inst{25} = 1;
1182}
1183
1184let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001185def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src),
Anton Korobeynikov60928952009-09-27 23:52:58 +00001186 DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001187 "movw", "\t$dst, $src",
Anton Korobeynikov60928952009-09-27 23:52:58 +00001188 [(set GPR:$dst, imm0_65535:$src)]>,
Johnny Chenba9fbe72010-02-01 23:06:04 +00001189 Requires<[IsARM, HasV6T2]>, UnaryDP {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +00001190 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001191 let Inst{25} = 1;
1192}
1193
Evan Cheng16c012d2009-09-28 09:14:39 +00001194let Constraints = "$src = $dst" in
Anton Korobeynikov60928952009-09-27 23:52:58 +00001195def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
1196 DPFrm, IIC_iMOVi,
Anton Korobeynikova414f362009-11-24 00:44:37 +00001197 "movt", "\t$dst, $imm",
Anton Korobeynikov60928952009-09-27 23:52:58 +00001198 [(set GPR:$dst,
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001199 (or (and GPR:$src, 0xffff),
Anton Korobeynikov60928952009-09-27 23:52:58 +00001200 lo16AllZero:$imm))]>, UnaryDP,
1201 Requires<[IsARM, HasV6T2]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +00001202 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001203 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001204}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205
Evan Cheng89ef2852009-10-21 08:15:52 +00001206def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1207 Requires<[IsARM, HasV6T2]>;
1208
David Goodwin02b0e352009-09-01 18:32:09 +00001209let Uses = [CPSR] in
David Goodwin236ccb52009-08-19 18:00:44 +00001210def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001211 "mov", "\t$dst, $src, rrx",
Evan Cheng86a926a2008-11-05 18:35:52 +00001212 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213
1214// These aren't really mov instructions, but we have to define them this way
1215// due to flag operands.
1216
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001217let Defs = [CPSR] in {
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001218def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
Jim Grosbache2fda532009-11-09 00:11:35 +00001219 IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +00001220 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
Evan Cheng7f240d22008-11-14 20:09:11 +00001221def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
Jim Grosbache2fda532009-11-09 00:11:35 +00001222 IIC_iMOVsi, "movs", "\t$dst, $src, asr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +00001223 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001224}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225
1226//===----------------------------------------------------------------------===//
1227// Extend Instructions.
1228//
1229
1230// Sign extenders
1231
Evan Cheng37afa432008-11-06 22:15:19 +00001232defm SXTB : AI_unary_rrot<0b01101010,
1233 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1234defm SXTH : AI_unary_rrot<0b01101011,
1235 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236
Evan Cheng37afa432008-11-06 22:15:19 +00001237defm SXTAB : AI_bin_rrot<0b01101010,
1238 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1239defm SXTAH : AI_bin_rrot<0b01101011,
1240 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241
1242// TODO: SXT(A){B|H}16
1243
1244// Zero extenders
1245
1246let AddedComplexity = 16 in {
Evan Cheng37afa432008-11-06 22:15:19 +00001247defm UXTB : AI_unary_rrot<0b01101110,
1248 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1249defm UXTH : AI_unary_rrot<0b01101111,
1250 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1251defm UXTB16 : AI_unary_rrot<0b01101100,
1252 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253
Bob Wilson74590a02009-06-22 22:08:29 +00001254def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255 (UXTB16r_rot GPR:$Src, 24)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001256def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 (UXTB16r_rot GPR:$Src, 8)>;
1258
Evan Cheng37afa432008-11-06 22:15:19 +00001259defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng37afa432008-11-06 22:15:19 +00001261defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1263}
1264
1265// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1266//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1267
1268// TODO: UXT(A){B|H}16
1269
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001270def SBFX : I<(outs GPR:$dst),
1271 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1272 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001273 "sbfx", "\t$dst, $src, $lsb, $width", "", []>,
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001274 Requires<[IsARM, HasV6T2]> {
1275 let Inst{27-21} = 0b0111101;
1276 let Inst{6-4} = 0b101;
1277}
1278
1279def UBFX : I<(outs GPR:$dst),
1280 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1281 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001282 "ubfx", "\t$dst, $src, $lsb, $width", "", []>,
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001283 Requires<[IsARM, HasV6T2]> {
1284 let Inst{27-21} = 0b0111111;
1285 let Inst{6-4} = 0b101;
1286}
1287
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288//===----------------------------------------------------------------------===//
1289// Arithmetic Instructions.
1290//
1291
Jim Grosbach88c246f2008-10-14 20:36:24 +00001292defm ADD : AsI1_bin_irs<0b0100, "add",
Evan Chengbdd679a2009-06-26 00:19:44 +00001293 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001294defm SUB : AsI1_bin_irs<0b0010, "sub",
Evan Cheng469bc762008-09-17 07:53:38 +00001295 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296
1297// ADD and SUB with 's' bit set.
Jim Grosbache2fda532009-11-09 00:11:35 +00001298defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1299 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1300defm SUBS : AI1_bin_s_irs<0b0010, "subs",
Evan Chengd4e2f052009-06-25 20:59:23 +00001301 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001303defm ADC : AI1_adde_sube_irs<0b0101, "adc",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001304 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001305defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001306 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Jim Grosbache2fda532009-11-09 00:11:35 +00001307defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001308 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Jim Grosbache2fda532009-11-09 00:11:35 +00001309defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001310 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311
1312// These don't define reg/reg forms, because they are handled above.
Evan Cheng86a926a2008-11-05 18:35:52 +00001313def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001314 IIC_iALUi, "rsb", "\t$dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001315 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> {
1316 let Inst{25} = 1;
1317}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318
Evan Cheng86a926a2008-11-05 18:35:52 +00001319def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001320 IIC_iALUsr, "rsb", "\t$dst, $a, $b",
Bob Wilson3a308522009-10-26 22:34:44 +00001321 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001322 let Inst{25} = 0;
1323}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324
1325// RSB with 's' bit set.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001326let Defs = [CPSR] in {
Evan Cheng86a926a2008-11-05 18:35:52 +00001327def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001328 IIC_iALUi, "rsbs", "\t$dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001329 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001330 let Inst{20} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001331 let Inst{25} = 1;
1332}
Evan Cheng86a926a2008-11-05 18:35:52 +00001333def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001334 IIC_iALUsr, "rsbs", "\t$dst, $a, $b",
Bob Wilson3a308522009-10-26 22:34:44 +00001335 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001336 let Inst{20} = 1;
1337 let Inst{25} = 0;
1338}
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001339}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001341let Uses = [CPSR] in {
1342def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001343 DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001344 [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>,
1345 Requires<[IsARM]> {
Evan Chenga9892932009-09-09 01:47:07 +00001346 let Inst{25} = 1;
1347}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001348def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001349 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001350 [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>,
1351 Requires<[IsARM]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001352 let Inst{25} = 0;
1353}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001354}
1355
1356// FIXME: Allow these to be predicated.
Evan Chengd4e2f052009-06-25 20:59:23 +00001357let Defs = [CPSR], Uses = [CPSR] in {
1358def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001359 DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001360 [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>,
1361 Requires<[IsARM]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001362 let Inst{20} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001363 let Inst{25} = 1;
1364}
Evan Chengd4e2f052009-06-25 20:59:23 +00001365def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001366 DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001367 [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>,
1368 Requires<[IsARM]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001369 let Inst{20} = 1;
1370 let Inst{25} = 0;
1371}
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001372}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373
1374// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1375def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1376 (SUBri GPR:$src, so_imm_neg:$imm)>;
1377
1378//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1379// (SUBSri GPR:$src, so_imm_neg:$imm)>;
1380//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1381// (SBCri GPR:$src, so_imm_neg:$imm)>;
1382
1383// Note: These are implemented in C++ code, because they have to generate
1384// ADD/SUBrs instructions, which use a complex pattern that a xform function
1385// cannot produce.
1386// (mul X, 2^n+1) -> (add (X << n), X)
1387// (mul X, 2^n-1) -> (rsb X, (X << n))
1388
Johnny Chen8e135702010-02-13 01:21:01 +00001389// Saturating adds/subtracts -- for disassembly only
1390
Johnny Chen2e3f1e52010-02-14 06:32:20 +00001391// GPR:$dst = GPR:$a op GPR:$b
Bob Wilsondf89a642010-02-15 23:43:47 +00001392class AQI<bits<8> op27_20, bits<4> op7_4, string opc>
Johnny Chen2e3f1e52010-02-14 06:32:20 +00001393 : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, IIC_iALUr,
Bob Wilsondf89a642010-02-15 23:43:47 +00001394 opc, "\t$dst, $a, $b",
1395 [/* For disassembly only; pattern left blank */]> {
Johnny Chen8e135702010-02-13 01:21:01 +00001396 let Inst{27-20} = op27_20;
1397 let Inst{7-4} = op7_4;
1398}
1399
Bob Wilsondf89a642010-02-15 23:43:47 +00001400def QADD : AQI<0b00010000, 0b0101, "qadd">;
1401def QADD16 : AQI<0b01100010, 0b0001, "qadd16">;
1402def QADD8 : AQI<0b01100010, 0b1001, "qadd8">;
1403def QASX : AQI<0b01100010, 0b0011, "qasx">;
1404def QDADD : AQI<0b00010100, 0b0101, "qdadd">;
1405def QDSUB : AQI<0b00010110, 0b0101, "qdsub">;
1406def QSAX : AQI<0b01100010, 0b0101, "qsax">;
1407def QSUB : AQI<0b00010010, 0b0101, "qsub">;
1408def QSUB16 : AQI<0b01100010, 0b0111, "qsub16">;
1409def QSUB8 : AQI<0b01100010, 0b1111, "qsub8">;
1410def UQADD16 : AQI<0b01100110, 0b0001, "uqadd16">;
1411def UQADD8 : AQI<0b01100110, 0b1001, "uqadd8">;
1412def UQASX : AQI<0b01100110, 0b0011, "uqasx">;
1413def UQSAX : AQI<0b01100110, 0b0101, "uqsax">;
1414def UQSUB16 : AQI<0b01100110, 0b0111, "uqsub16">;
1415def UQSUB8 : AQI<0b01100110, 0b1111, "uqsub8">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416
1417//===----------------------------------------------------------------------===//
1418// Bitwise Instructions.
1419//
1420
Jim Grosbach88c246f2008-10-14 20:36:24 +00001421defm AND : AsI1_bin_irs<0b0000, "and",
Evan Chengbdd679a2009-06-26 00:19:44 +00001422 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001423defm ORR : AsI1_bin_irs<0b1100, "orr",
Evan Chengbdd679a2009-06-26 00:19:44 +00001424 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001425defm EOR : AsI1_bin_irs<0b0001, "eor",
Evan Chengbdd679a2009-06-26 00:19:44 +00001426 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001427defm BIC : AsI1_bin_irs<0b1110, "bic",
Evan Cheng469bc762008-09-17 07:53:38 +00001428 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429
Evan Cheng299ee652009-07-06 22:23:46 +00001430def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
David Goodwin9a8ec822009-11-02 17:28:36 +00001431 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001432 "bfc", "\t$dst, $imm", "$src = $dst",
Evan Cheng299ee652009-07-06 22:23:46 +00001433 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1434 Requires<[IsARM, HasV6T2]> {
1435 let Inst{27-21} = 0b0111110;
1436 let Inst{6-0} = 0b0011111;
1437}
1438
David Goodwin236ccb52009-08-19 18:00:44 +00001439def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001440 "mvn", "\t$dst, $src",
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001441 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP {
Johnny Chen9063a772010-01-31 11:22:28 +00001442 let Inst{25} = 0;
Johnny Chend139b942009-11-07 00:54:36 +00001443 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001444}
Evan Cheng86a926a2008-11-05 18:35:52 +00001445def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001446 IIC_iMOVsr, "mvn", "\t$dst, $src",
Johnny Chen9063a772010-01-31 11:22:28 +00001447 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP {
1448 let Inst{25} = 0;
1449}
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001450let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001451def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001452 IIC_iMOVi, "mvn", "\t$dst, $imm",
Evan Chenga9892932009-09-09 01:47:07 +00001453 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP {
1454 let Inst{25} = 1;
1455}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456
1457def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1458 (BICri GPR:$src, so_imm_not:$imm)>;
1459
1460//===----------------------------------------------------------------------===//
1461// Multiply Instructions.
1462//
1463
Evan Chengbdd679a2009-06-26 00:19:44 +00001464let isCommutable = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001465def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001466 IIC_iMUL32, "mul", "\t$dst, $a, $b",
Evan Chengf8e8b622008-11-06 17:48:05 +00001467 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468
Evan Chengee80fb72008-11-06 01:21:28 +00001469def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001470 IIC_iMAC32, "mla", "\t$dst, $a, $b, $c",
Evan Chengf8e8b622008-11-06 17:48:05 +00001471 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001472
David Goodwincfd67652009-08-06 16:52:47 +00001473def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001474 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
Evan Chengc8147e12009-07-06 22:05:45 +00001475 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1476 Requires<[IsARM, HasV6T2]>;
1477
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478// Extra precision multiplies with low / high results
Evan Chengd97d7142009-06-12 20:46:18 +00001479let neverHasSideEffects = 1 in {
Evan Chengbdd679a2009-06-26 00:19:44 +00001480let isCommutable = 1 in {
Evan Chengee80fb72008-11-06 01:21:28 +00001481def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001482 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001483 "smull", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484
Evan Chengee80fb72008-11-06 01:21:28 +00001485def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001486 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001487 "umull", "\t$ldst, $hdst, $a, $b", []>;
Evan Chengbdd679a2009-06-26 00:19:44 +00001488}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489
1490// Multiply + accumulate
Evan Chengee80fb72008-11-06 01:21:28 +00001491def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001492 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001493 "smlal", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494
Evan Chengee80fb72008-11-06 01:21:28 +00001495def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001496 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001497 "umlal", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498
Evan Chengee80fb72008-11-06 01:21:28 +00001499def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001500 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001501 "umaal", "\t$ldst, $hdst, $a, $b", []>,
Evan Chengee80fb72008-11-06 01:21:28 +00001502 Requires<[IsARM, HasV6]>;
Evan Chengd97d7142009-06-12 20:46:18 +00001503} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504
1505// Most significant word multiply
Evan Chengee80fb72008-11-06 01:21:28 +00001506def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001507 IIC_iMUL32, "smmul", "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001509 Requires<[IsARM, HasV6]> {
1510 let Inst{7-4} = 0b0001;
1511 let Inst{15-12} = 0b1111;
1512}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513
Evan Chengee80fb72008-11-06 01:21:28 +00001514def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001515 IIC_iMAC32, "smmla", "\t$dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001517 Requires<[IsARM, HasV6]> {
1518 let Inst{7-4} = 0b0001;
1519}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520
1521
Evan Chengee80fb72008-11-06 01:21:28 +00001522def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001523 IIC_iMAC32, "smmls", "\t$dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001525 Requires<[IsARM, HasV6]> {
1526 let Inst{7-4} = 0b1101;
1527}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001529multiclass AI_smul<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001530 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001531 IIC_iMUL32, !strconcat(opc, "bb"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1533 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001534 Requires<[IsARM, HasV5TE]> {
1535 let Inst{5} = 0;
1536 let Inst{6} = 0;
1537 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001538
Evan Cheng38396be2008-11-06 03:35:07 +00001539 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001540 IIC_iMUL32, !strconcat(opc, "bt"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
Bob Wilson74590a02009-06-22 22:08:29 +00001542 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001543 Requires<[IsARM, HasV5TE]> {
1544 let Inst{5} = 0;
1545 let Inst{6} = 1;
1546 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001547
Evan Cheng38396be2008-11-06 03:35:07 +00001548 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001549 IIC_iMUL32, !strconcat(opc, "tb"), "\t$dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001550 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001552 Requires<[IsARM, HasV5TE]> {
1553 let Inst{5} = 1;
1554 let Inst{6} = 0;
1555 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001556
Evan Cheng38396be2008-11-06 03:35:07 +00001557 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001558 IIC_iMUL32, !strconcat(opc, "tt"), "\t$dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001559 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1560 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001561 Requires<[IsARM, HasV5TE]> {
1562 let Inst{5} = 1;
1563 let Inst{6} = 1;
1564 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001565
Evan Cheng38396be2008-11-06 03:35:07 +00001566 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001567 IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001569 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001570 Requires<[IsARM, HasV5TE]> {
1571 let Inst{5} = 1;
1572 let Inst{6} = 0;
1573 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001574
Evan Cheng38396be2008-11-06 03:35:07 +00001575 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001576 IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001578 (sra GPR:$b, (i32 16))), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001579 Requires<[IsARM, HasV5TE]> {
1580 let Inst{5} = 1;
1581 let Inst{6} = 1;
1582 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583}
1584
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001585
1586multiclass AI_smla<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001587 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001588 IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589 [(set GPR:$dst, (add GPR:$acc,
1590 (opnode (sext_inreg GPR:$a, i16),
1591 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001592 Requires<[IsARM, HasV5TE]> {
1593 let Inst{5} = 0;
1594 let Inst{6} = 0;
1595 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001596
Evan Cheng38396be2008-11-06 03:35:07 +00001597 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001598 IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
Jim Grosbach60030482010-02-16 21:23:02 +00001600 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001601 Requires<[IsARM, HasV5TE]> {
1602 let Inst{5} = 0;
1603 let Inst{6} = 1;
1604 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001605
Evan Cheng38396be2008-11-06 03:35:07 +00001606 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001607 IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Bob Wilson74590a02009-06-22 22:08:29 +00001608 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001610 Requires<[IsARM, HasV5TE]> {
1611 let Inst{5} = 1;
1612 let Inst{6} = 0;
1613 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001614
Evan Cheng38396be2008-11-06 03:35:07 +00001615 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001616 IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
1617 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1618 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001619 Requires<[IsARM, HasV5TE]> {
1620 let Inst{5} = 1;
1621 let Inst{6} = 1;
1622 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623
Evan Cheng38396be2008-11-06 03:35:07 +00001624 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001625 IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001627 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001628 Requires<[IsARM, HasV5TE]> {
1629 let Inst{5} = 0;
1630 let Inst{6} = 0;
1631 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001632
Evan Cheng38396be2008-11-06 03:35:07 +00001633 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001634 IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001636 (sra GPR:$b, (i32 16))), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001637 Requires<[IsARM, HasV5TE]> {
1638 let Inst{5} = 0;
1639 let Inst{6} = 1;
1640 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641}
1642
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001643defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1644defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645
Johnny Chen10014222010-02-12 21:59:23 +00001646// Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only
1647def SMLALBB : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1648 IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
1649 [/* For disassembly only; pattern left blank */]>,
1650 Requires<[IsARM, HasV5TE]> {
1651 let Inst{5} = 0;
1652 let Inst{6} = 0;
1653}
1654
1655def SMLALBT : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1656 IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
1657 [/* For disassembly only; pattern left blank */]>,
1658 Requires<[IsARM, HasV5TE]> {
1659 let Inst{5} = 0;
1660 let Inst{6} = 1;
1661}
1662
1663def SMLALTB : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1664 IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
1665 [/* For disassembly only; pattern left blank */]>,
1666 Requires<[IsARM, HasV5TE]> {
1667 let Inst{5} = 1;
1668 let Inst{6} = 0;
1669}
1670
1671def SMLALTT : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1672 IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
1673 [/* For disassembly only; pattern left blank */]>,
1674 Requires<[IsARM, HasV5TE]> {
1675 let Inst{5} = 1;
1676 let Inst{6} = 1;
1677}
1678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1680
1681//===----------------------------------------------------------------------===//
1682// Misc. Arithmetic Instructions.
1683//
1684
David Goodwin236ccb52009-08-19 18:00:44 +00001685def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001686 "clz", "\t$dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001687 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1688 let Inst{7-4} = 0b0001;
1689 let Inst{11-8} = 0b1111;
1690 let Inst{19-16} = 0b1111;
1691}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692
Jim Grosbachf1f92ff2010-01-18 19:58:49 +00001693def RBIT : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd7da8fc2010-01-19 00:44:15 +00001694 "rbit", "\t$dst, $src",
1695 [(set GPR:$dst, (ARMrbit GPR:$src))]>,
1696 Requires<[IsARM, HasV6T2]> {
Jim Grosbachf1f92ff2010-01-18 19:58:49 +00001697 let Inst{7-4} = 0b0011;
1698 let Inst{11-8} = 0b1111;
1699 let Inst{19-16} = 0b1111;
1700}
1701
David Goodwin236ccb52009-08-19 18:00:44 +00001702def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001703 "rev", "\t$dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001704 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1705 let Inst{7-4} = 0b0011;
1706 let Inst{11-8} = 0b1111;
1707 let Inst{19-16} = 0b1111;
1708}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709
David Goodwin236ccb52009-08-19 18:00:44 +00001710def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001711 "rev16", "\t$dst, $src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 [(set GPR:$dst,
Bob Wilson74590a02009-06-22 22:08:29 +00001713 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1714 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1715 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1716 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001717 Requires<[IsARM, HasV6]> {
1718 let Inst{7-4} = 0b1011;
1719 let Inst{11-8} = 0b1111;
1720 let Inst{19-16} = 0b1111;
1721}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722
David Goodwin236ccb52009-08-19 18:00:44 +00001723def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001724 "revsh", "\t$dst, $src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 [(set GPR:$dst,
1726 (sext_inreg
Bob Wilson74590a02009-06-22 22:08:29 +00001727 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1728 (shl GPR:$src, (i32 8))), i16))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001729 Requires<[IsARM, HasV6]> {
1730 let Inst{7-4} = 0b1011;
1731 let Inst{11-8} = 0b1111;
1732 let Inst{19-16} = 0b1111;
1733}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734
Evan Chengc2121a22008-11-07 01:41:35 +00001735def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1736 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001737 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2, LSL $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1739 (and (shl GPR:$src2, (i32 imm:$shamt)),
1740 0xFFFF0000)))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001741 Requires<[IsARM, HasV6]> {
1742 let Inst{6-4} = 0b001;
1743}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744
1745// Alternate cases for PKHBT where identities eliminate some nodes.
1746def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1747 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1748def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1749 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1750
1751
Evan Chengc2121a22008-11-07 01:41:35 +00001752def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1753 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001754 IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2, ASR $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1756 (and (sra GPR:$src2, imm16_31:$shamt),
Evan Chengc2121a22008-11-07 01:41:35 +00001757 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1758 let Inst{6-4} = 0b101;
1759}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760
1761// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1762// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilson74590a02009-06-22 22:08:29 +00001763def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1765def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1766 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1767 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1768
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769//===----------------------------------------------------------------------===//
1770// Comparison Instructions...
1771//
1772
Jim Grosbach88c246f2008-10-14 20:36:24 +00001773defm CMP : AI1_cmp_irs<0b1010, "cmp",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001774 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
Jim Grosbach40e4b112010-01-22 00:08:13 +00001775//FIXME: Disable CMN, as CCodes are backwards from compare expectations
1776// Compare-to-zero still works out, just not the relationals
1777//defm CMN : AI1_cmp_irs<0b1011, "cmn",
1778// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779
1780// Note that TST/TEQ don't set all the same flags that CMP does!
Evan Chengbe998242008-11-06 08:47:38 +00001781defm TST : AI1_cmp_irs<0b1000, "tst",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001782 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
Evan Chengbe998242008-11-06 08:47:38 +00001783defm TEQ : AI1_cmp_irs<0b1001, "teq",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001784 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785
David Goodwin8bdcbb32009-06-29 15:33:01 +00001786defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1787 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1788defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1789 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790
Jim Grosbach40e4b112010-01-22 00:08:13 +00001791//def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1792// (CMNri GPR:$src, so_imm_neg:$imm)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793
David Goodwin8bdcbb32009-06-29 15:33:01 +00001794def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
Jim Grosbach40e4b112010-01-22 00:08:13 +00001795 (CMNzri GPR:$src, so_imm_neg:$imm)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796
1797
1798// Conditional moves
1799// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001800// a two-value operand where a dag node expects two operands. :(
Evan Chengbe998242008-11-06 08:47:38 +00001801def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001802 IIC_iCMOVr, "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001804 RegConstraint<"$false = $dst">, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +00001805 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001806 let Inst{25} = 0;
1807}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808
Evan Chengbe998242008-11-06 08:47:38 +00001809def MOVCCs : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001810 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001811 "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001813 RegConstraint<"$false = $dst">, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001814 let Inst{25} = 0;
1815}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816
Evan Chengbe998242008-11-06 08:47:38 +00001817def MOVCCi : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001818 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001819 "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Chenga9892932009-09-09 01:47:07 +00001821 RegConstraint<"$false = $dst">, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001822 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001823}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824
Jim Grosbachba744f62009-12-10 00:11:09 +00001825//===----------------------------------------------------------------------===//
1826// Atomic operations intrinsics
1827//
1828
1829// memory barriers protect the atomic sequences
Jim Grosbach63437d92009-12-14 18:31:20 +00001830let hasSideEffects = 1 in {
1831def Int_MemBarrierV7 : AInoP<(outs), (ins),
Jim Grosbachba744f62009-12-10 00:11:09 +00001832 Pseudo, NoItinerary,
1833 "dmb", "",
Jim Grosbach6eee9032009-12-14 21:24:16 +00001834 [(ARMMemBarrierV7)]>,
Jim Grosbach2d6e2492009-12-14 19:24:11 +00001835 Requires<[IsARM, HasV7]> {
Jim Grosbach37582c32009-12-10 18:35:32 +00001836 let Inst{31-4} = 0xf57ff05;
1837 // FIXME: add support for options other than a full system DMB
1838 let Inst{3-0} = 0b1111;
1839}
Jim Grosbachba744f62009-12-10 00:11:09 +00001840
Jim Grosbach63437d92009-12-14 18:31:20 +00001841def Int_SyncBarrierV7 : AInoP<(outs), (ins),
Jim Grosbachba744f62009-12-10 00:11:09 +00001842 Pseudo, NoItinerary,
1843 "dsb", "",
Jim Grosbach6eee9032009-12-14 21:24:16 +00001844 [(ARMSyncBarrierV7)]>,
Jim Grosbach2d6e2492009-12-14 19:24:11 +00001845 Requires<[IsARM, HasV7]> {
Jim Grosbach37582c32009-12-10 18:35:32 +00001846 let Inst{31-4} = 0xf57ff04;
1847 // FIXME: add support for options other than a full system DSB
1848 let Inst{3-0} = 0b1111;
1849}
Jim Grosbach6eee9032009-12-14 21:24:16 +00001850
1851def Int_MemBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1852 Pseudo, NoItinerary,
1853 "mcr", "\tp15, 0, $zero, c7, c10, 5",
1854 [(ARMMemBarrierV6 GPR:$zero)]>,
1855 Requires<[IsARM, HasV6]> {
1856 // FIXME: add support for options other than a full system DMB
1857 // FIXME: add encoding
1858}
1859
1860def Int_SyncBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1861 Pseudo, NoItinerary,
Jim Grosbachba16e072009-12-14 21:33:32 +00001862 "mcr", "\tp15, 0, $zero, c7, c10, 4",
Jim Grosbach6eee9032009-12-14 21:24:16 +00001863 [(ARMSyncBarrierV6 GPR:$zero)]>,
1864 Requires<[IsARM, HasV6]> {
1865 // FIXME: add support for options other than a full system DSB
1866 // FIXME: add encoding
1867}
Jim Grosbachba744f62009-12-10 00:11:09 +00001868}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869
Jim Grosbach78539672009-12-11 18:52:41 +00001870let usesCustomInserter = 1 in {
Jim Grosbach24189692009-12-12 01:40:06 +00001871 let Uses = [CPSR] in {
1872 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
1873 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1874 "${:comment} ATOMIC_LOAD_ADD_I8 PSEUDO!",
1875 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
1876 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
1877 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1878 "${:comment} ATOMIC_LOAD_SUB_I8 PSEUDO!",
1879 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
1880 def ATOMIC_LOAD_AND_I8 : PseudoInst<
1881 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1882 "${:comment} ATOMIC_LOAD_AND_I8 PSEUDO!",
1883 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
1884 def ATOMIC_LOAD_OR_I8 : PseudoInst<
1885 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1886 "${:comment} ATOMIC_LOAD_OR_I8 PSEUDO!",
1887 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
1888 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
1889 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1890 "${:comment} ATOMIC_LOAD_XOR_I8 PSEUDO!",
1891 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
1892 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
1893 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1894 "${:comment} ATOMIC_LOAD_NAND_I8 PSEUDO!",
1895 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
1896 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
1897 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1898 "${:comment} ATOMIC_LOAD_ADD_I16 PSEUDO!",
1899 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
1900 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
1901 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1902 "${:comment} ATOMIC_LOAD_SUB_I16 PSEUDO!",
1903 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
1904 def ATOMIC_LOAD_AND_I16 : PseudoInst<
1905 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1906 "${:comment} ATOMIC_LOAD_AND_I16 PSEUDO!",
1907 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
1908 def ATOMIC_LOAD_OR_I16 : PseudoInst<
1909 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1910 "${:comment} ATOMIC_LOAD_OR_I16 PSEUDO!",
1911 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
1912 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
1913 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1914 "${:comment} ATOMIC_LOAD_XOR_I16 PSEUDO!",
1915 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
1916 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
1917 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1918 "${:comment} ATOMIC_LOAD_NAND_I16 PSEUDO!",
1919 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
1920 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
1921 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1922 "${:comment} ATOMIC_LOAD_ADD_I32 PSEUDO!",
1923 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
1924 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
1925 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1926 "${:comment} ATOMIC_LOAD_SUB_I32 PSEUDO!",
1927 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
1928 def ATOMIC_LOAD_AND_I32 : PseudoInst<
1929 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1930 "${:comment} ATOMIC_LOAD_AND_I32 PSEUDO!",
1931 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
1932 def ATOMIC_LOAD_OR_I32 : PseudoInst<
1933 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1934 "${:comment} ATOMIC_LOAD_OR_I32 PSEUDO!",
1935 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
1936 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
1937 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1938 "${:comment} ATOMIC_LOAD_XOR_I32 PSEUDO!",
1939 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
1940 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
1941 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1942 "${:comment} ATOMIC_LOAD_NAND_I32 PSEUDO!",
1943 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
1944
1945 def ATOMIC_SWAP_I8 : PseudoInst<
1946 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1947 "${:comment} ATOMIC_SWAP_I8 PSEUDO!",
1948 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
1949 def ATOMIC_SWAP_I16 : PseudoInst<
1950 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1951 "${:comment} ATOMIC_SWAP_I16 PSEUDO!",
1952 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
1953 def ATOMIC_SWAP_I32 : PseudoInst<
1954 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1955 "${:comment} ATOMIC_SWAP_I32 PSEUDO!",
1956 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
1957
Jim Grosbach24189692009-12-12 01:40:06 +00001958 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
1959 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1960 "${:comment} ATOMIC_CMP_SWAP_I8 PSEUDO!",
1961 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
1962 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
1963 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1964 "${:comment} ATOMIC_CMP_SWAP_I16 PSEUDO!",
1965 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
1966 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
1967 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1968 "${:comment} ATOMIC_CMP_SWAP_I32 PSEUDO!",
1969 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
1970}
Jim Grosbach437d6992009-12-11 01:42:04 +00001971}
1972
1973let mayLoad = 1 in {
1974def LDREXB : AIldrex<0b10, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1975 "ldrexb", "\t$dest, [$ptr]",
1976 []>;
1977def LDREXH : AIldrex<0b11, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1978 "ldrexh", "\t$dest, [$ptr]",
1979 []>;
1980def LDREX : AIldrex<0b00, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
1981 "ldrex", "\t$dest, [$ptr]",
1982 []>;
Johnny Chen8ac1d372009-12-14 21:01:46 +00001983def LDREXD : AIldrex<0b01, (outs GPR:$dest, GPR:$dest2), (ins GPR:$ptr),
Jim Grosbachc83030d2009-12-14 17:02:55 +00001984 NoItinerary,
1985 "ldrexd", "\t$dest, $dest2, [$ptr]",
1986 []>;
Jim Grosbach437d6992009-12-11 01:42:04 +00001987}
1988
Jim Grosbach724d7a12009-12-16 19:44:06 +00001989let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach437d6992009-12-11 01:42:04 +00001990def STREXB : AIstrex<0b10, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
Jim Grosbachc83030d2009-12-14 17:02:55 +00001991 NoItinerary,
Jim Grosbach437d6992009-12-11 01:42:04 +00001992 "strexb", "\t$success, $src, [$ptr]",
1993 []>;
1994def STREXH : AIstrex<0b11, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
1995 NoItinerary,
1996 "strexh", "\t$success, $src, [$ptr]",
1997 []>;
1998def STREX : AIstrex<0b00, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
Jim Grosbachc83030d2009-12-14 17:02:55 +00001999 NoItinerary,
Jim Grosbach437d6992009-12-11 01:42:04 +00002000 "strex", "\t$success, $src, [$ptr]",
2001 []>;
Johnny Chen8ac1d372009-12-14 21:01:46 +00002002def STREXD : AIstrex<0b01, (outs GPR:$success),
Jim Grosbachc83030d2009-12-14 17:02:55 +00002003 (ins GPR:$src, GPR:$src2, GPR:$ptr),
2004 NoItinerary,
2005 "strexd", "\t$success, $src, $src2, [$ptr]",
2006 []>;
Jim Grosbach437d6992009-12-11 01:42:04 +00002007}
2008
Johnny Chen1d7e5c82010-02-12 20:48:24 +00002009// SWP/SWPB are deprecated in V6/V7 and for disassembly only.
2010let mayLoad = 1 in {
2011def SWP : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2012 "swp", "\t$dst, $src, [$ptr]",
2013 [/* For disassembly only; pattern left blank */]> {
2014 let Inst{27-23} = 0b00010;
2015 let Inst{22} = 0; // B = 0
2016 let Inst{21-20} = 0b00;
2017 let Inst{7-4} = 0b1001;
2018}
2019
2020def SWPB : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2021 "swpb", "\t$dst, $src, [$ptr]",
2022 [/* For disassembly only; pattern left blank */]> {
2023 let Inst{27-23} = 0b00010;
2024 let Inst{22} = 1; // B = 1
2025 let Inst{21-20} = 0b00;
2026 let Inst{7-4} = 0b1001;
2027}
2028}
2029
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030//===----------------------------------------------------------------------===//
2031// TLS Instructions
2032//
2033
2034// __aeabi_read_tp preserves the registers r1-r3.
2035let isCall = 1,
2036 Defs = [R0, R12, LR, CPSR] in {
David Goodwincfd67652009-08-06 16:52:47 +00002037 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +00002038 "bl\t__aeabi_read_tp",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set R0, ARMthread_pointer)]>;
2040}
2041
2042//===----------------------------------------------------------------------===//
Jim Grosbachc10915b2009-05-12 23:59:14 +00002043// SJLJ Exception handling intrinsics
Jim Grosbach207a4ba2009-08-13 15:11:43 +00002044// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach4a9025e2009-05-14 00:46:35 +00002045// address and save #0 in R0 for the non-longjmp case.
Jim Grosbachc10915b2009-05-12 23:59:14 +00002046// Since by its nature we may be coming from some other function to get
2047// here, and we're using the stack frame for the containing function to
2048// save/restore registers, we can't keep anything live in regs across
Jim Grosbach4a9025e2009-05-14 00:46:35 +00002049// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
Jim Grosbachc10915b2009-05-12 23:59:14 +00002050// when we get here from a longjmp(). We force everthing out of registers
Jim Grosbach4a9025e2009-05-14 00:46:35 +00002051// except for our own input by listing the relevant registers in Defs. By
2052// doing so, we also cause the prologue/epilogue code to actively preserve
2053// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002054// A constant value is passed in $val, and we use the location as a scratch.
2055let Defs =
Jim Grosbach3990e392009-08-13 16:59:44 +00002056 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2057 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Evan Cheng80ab2a82009-07-29 20:10:36 +00002058 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Evan Cheng27396a62009-07-22 06:46:53 +00002059 D31 ] in {
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002060 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
David Goodwincfd67652009-08-06 16:52:47 +00002061 AddrModeNone, SizeSpecial, IndexModeNone,
2062 Pseudo, NoItinerary,
Evan Chengd3f9bc42009-10-26 23:45:59 +00002063 "str\tsp, [$src, #+8] @ eh_setjmp begin\n\t"
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002064 "add\t$val, pc, #8\n\t"
2065 "str\t$val, [$src, #+4]\n\t"
Evan Chengd3f9bc42009-10-26 23:45:59 +00002066 "mov\tr0, #0\n\t"
2067 "add\tpc, pc, #0\n\t"
2068 "mov\tr0, #1 @ eh_setjmp end", "",
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002069 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>;
Jim Grosbachc10915b2009-05-12 23:59:14 +00002070}
2071
2072//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073// Non-Instruction Patterns
2074//
2075
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076// Large immediate handling.
2077
2078// Two piece so_imms.
2079let isReMaterializable = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00002080def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
David Goodwin236ccb52009-08-19 18:00:44 +00002081 Pseudo, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00002082 "mov", "\t$dst, $src",
Evan Cheng16c012d2009-09-28 09:14:39 +00002083 [(set GPR:$dst, so_imm2part:$src)]>,
2084 Requires<[IsARM, NoV6T2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085
2086def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00002087 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2088 (so_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00002090 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2091 (so_imm2part_2 imm:$RHS))>;
Jim Grosbach1afc8e22009-10-21 20:44:34 +00002092def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
2093 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2094 (so_imm2part_2 imm:$RHS))>;
Jim Grosbach66e70cd2009-11-23 20:35:53 +00002095def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
2096 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
2097 (so_neg_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098
Evan Cheng16c012d2009-09-28 09:14:39 +00002099// 32-bit immediate using movw + movt.
Chris Lattnere4eb7342009-10-20 00:40:56 +00002100// This is a single pseudo instruction, the benefit is that it can be remat'd
2101// as a single unit instead of having to handle reg inputs.
2102// FIXME: Remove this when we can do generalized remat.
Evan Cheng16c012d2009-09-28 09:14:39 +00002103let isReMaterializable = 1 in
2104def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi,
Jim Grosbach60030482010-02-16 21:23:02 +00002105 "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}",
Evan Cheng16c012d2009-09-28 09:14:39 +00002106 [(set GPR:$dst, (i32 imm:$src))]>,
2107 Requires<[IsARM, HasV6T2]>;
Anton Korobeynikov60928952009-09-27 23:52:58 +00002108
Anton Korobeynikova414f362009-11-24 00:44:37 +00002109// ConstantPool, GlobalAddress, and JumpTable
2110def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
2111 Requires<[IsARM, DontUseMovt]>;
2112def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
2113def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
2114 Requires<[IsARM, UseMovt]>;
2115def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
2116 (LEApcrelJT tjumptable:$dst, imm:$id)>;
2117
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118// TODO: add,sub,and, 3-instr forms?
2119
2120
2121// Direct calls
Bob Wilson243b37c2009-06-22 21:01:46 +00002122def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00002123 Requires<[IsARM, IsNotDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +00002124def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00002125 Requires<[IsARM, IsDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126
2127// zextload i1 -> zextload i8
2128def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2129
2130// extload -> zextload
2131def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2132def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2133def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
2134
Evan Chengc41fb3152008-11-05 23:22:34 +00002135def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
2136def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
2137
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138// smul* and smla*
Bob Wilson74590a02009-06-22 22:08:29 +00002139def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2140 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 (SMULBB GPR:$a, GPR:$b)>;
2142def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
2143 (SMULBB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002144def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2145 (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002147def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002149def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
2150 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002152def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002154def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2155 (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 (SMULWB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002157def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 (SMULWB GPR:$a, GPR:$b)>;
2159
2160def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002161 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2162 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
2164def : ARMV5TEPat<(add GPR:$acc,
2165 (mul sext_16_node:$a, sext_16_node:$b)),
2166 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
2167def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002168 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2169 (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
2171def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002172 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
2174def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002175 (mul (sra GPR:$a, (i32 16)),
2176 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2178def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002179 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2181def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002182 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2183 (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2185def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002186 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2188
2189//===----------------------------------------------------------------------===//
2190// Thumb Support
2191//
2192
2193include "ARMInstrThumb.td"
2194
2195//===----------------------------------------------------------------------===//
Anton Korobeynikovac869fc2009-06-17 18:13:58 +00002196// Thumb2 Support
2197//
2198
2199include "ARMInstrThumb2.td"
2200
2201//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202// Floating Point Support
2203//
2204
2205include "ARMInstrVFP.td"
Bob Wilsone60fee02009-06-22 23:27:02 +00002206
2207//===----------------------------------------------------------------------===//
2208// Advanced SIMD (NEON) Support
2209//
2210
2211include "ARMInstrNEON.td"
Johnny Chenedf090c2010-02-12 01:44:23 +00002212
2213//===----------------------------------------------------------------------===//
2214// Coprocessor Instructions. For disassembly only.
2215//
2216
2217def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2218 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2219 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2220 [/* For disassembly only; pattern left blank */]> {
2221 let Inst{4} = 0;
2222}
2223
2224def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2225 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2226 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2227 [/* For disassembly only; pattern left blank */]> {
2228 let Inst{31-28} = 0b1111;
2229 let Inst{4} = 0;
2230}
2231
Johnny Chena6ad7432010-02-16 20:04:27 +00002232class ACI<dag oops, dag iops, string opc, string asm>
2233 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
2234 opc, asm, "", [/* For disassembly only; pattern left blank */]> {
2235 let Inst{27-25} = 0b110;
2236}
2237
2238multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
2239
2240 def _OFFSET : ACI<(outs),
2241 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2242 opc, "\tp$cop, cr$CRd, $addr"> {
2243 let Inst{31-28} = op31_28;
2244 let Inst{24} = 1; // P = 1
2245 let Inst{21} = 0; // W = 0
2246 let Inst{22} = 0; // D = 0
2247 let Inst{20} = load;
2248 }
2249
2250 def _PRE : ACI<(outs),
2251 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2252 opc, "\tp$cop, cr$CRd, $addr!"> {
2253 let Inst{31-28} = op31_28;
2254 let Inst{24} = 1; // P = 1
2255 let Inst{21} = 1; // W = 1
2256 let Inst{22} = 0; // D = 0
2257 let Inst{20} = load;
2258 }
2259
2260 def _POST : ACI<(outs),
2261 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
2262 opc, "\tp$cop, cr$CRd, [$base], $offset"> {
2263 let Inst{31-28} = op31_28;
2264 let Inst{24} = 0; // P = 0
2265 let Inst{21} = 1; // W = 1
2266 let Inst{22} = 0; // D = 0
2267 let Inst{20} = load;
2268 }
2269
2270 def _OPTION : ACI<(outs),
2271 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option),
2272 opc, "\tp$cop, cr$CRd, [$base], $option"> {
2273 let Inst{31-28} = op31_28;
2274 let Inst{24} = 0; // P = 0
2275 let Inst{23} = 1; // U = 1
2276 let Inst{21} = 0; // W = 0
2277 let Inst{22} = 0; // D = 0
2278 let Inst{20} = load;
2279 }
2280
2281 def L_OFFSET : ACI<(outs),
2282 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2283 opc, "l\tp$cop, cr$CRd, $addr"> {
2284 let Inst{31-28} = op31_28;
2285 let Inst{24} = 1; // P = 1
2286 let Inst{21} = 0; // W = 0
2287 let Inst{22} = 1; // D = 1
2288 let Inst{20} = load;
2289 }
2290
2291 def L_PRE : ACI<(outs),
2292 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2293 opc, "l\tp$cop, cr$CRd, $addr!"> {
2294 let Inst{31-28} = op31_28;
2295 let Inst{24} = 1; // P = 1
2296 let Inst{21} = 1; // W = 1
2297 let Inst{22} = 1; // D = 1
2298 let Inst{20} = load;
2299 }
2300
2301 def L_POST : ACI<(outs),
2302 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
2303 opc, "l\tp$cop, cr$CRd, [$base], $offset"> {
2304 let Inst{31-28} = op31_28;
2305 let Inst{24} = 0; // P = 0
2306 let Inst{21} = 1; // W = 1
2307 let Inst{22} = 1; // D = 1
2308 let Inst{20} = load;
2309 }
2310
2311 def L_OPTION : ACI<(outs),
2312 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option),
2313 opc, "l\tp$cop, cr$CRd, [$base], $option"> {
2314 let Inst{31-28} = op31_28;
2315 let Inst{24} = 0; // P = 0
2316 let Inst{23} = 1; // U = 1
2317 let Inst{21} = 0; // W = 0
2318 let Inst{22} = 1; // D = 1
2319 let Inst{20} = load;
2320 }
2321}
2322
2323defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">;
2324defm LDC2 : LdStCop<0b1111, 1, "ldc2">;
2325defm STC : LdStCop<{?,?,?,?}, 0, "stc">;
2326defm STC2 : LdStCop<0b1111, 0, "stc2">;
2327
Johnny Chenedf090c2010-02-12 01:44:23 +00002328def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2329 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2330 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2331 [/* For disassembly only; pattern left blank */]> {
2332 let Inst{20} = 0;
2333 let Inst{4} = 1;
2334}
2335
2336def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2337 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2338 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2339 [/* For disassembly only; pattern left blank */]> {
2340 let Inst{31-28} = 0b1111;
2341 let Inst{20} = 0;
2342 let Inst{4} = 1;
2343}
2344
2345def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2346 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2347 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2348 [/* For disassembly only; pattern left blank */]> {
2349 let Inst{20} = 1;
2350 let Inst{4} = 1;
2351}
2352
2353def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2354 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2355 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2356 [/* For disassembly only; pattern left blank */]> {
2357 let Inst{31-28} = 0b1111;
2358 let Inst{20} = 1;
2359 let Inst{4} = 1;
2360}
2361
2362def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2363 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2364 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2365 [/* For disassembly only; pattern left blank */]> {
2366 let Inst{23-20} = 0b0100;
2367}
2368
2369def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2370 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2371 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2372 [/* For disassembly only; pattern left blank */]> {
2373 let Inst{31-28} = 0b1111;
2374 let Inst{23-20} = 0b0100;
2375}
2376
2377def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2378 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2379 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2380 [/* For disassembly only; pattern left blank */]> {
2381 let Inst{23-20} = 0b0101;
2382}
2383
2384def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2385 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2386 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2387 [/* For disassembly only; pattern left blank */]> {
2388 let Inst{31-28} = 0b1111;
2389 let Inst{23-20} = 0b0101;
2390}
2391
Johnny Chenb8689012010-02-12 18:55:33 +00002392//===----------------------------------------------------------------------===//
2393// Move between special register and ARM core register -- for disassembly only
2394//
2395
2396def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr",
2397 [/* For disassembly only; pattern left blank */]> {
2398 let Inst{23-20} = 0b0000;
2399 let Inst{7-4} = 0b0000;
2400}
2401
2402def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr",
2403 [/* For disassembly only; pattern left blank */]> {
2404 let Inst{23-20} = 0b0100;
2405 let Inst{7-4} = 0b0000;
2406}
2407
2408// FIXME: mask is ignored for the time being.
Johnny Chena6ad7432010-02-16 20:04:27 +00002409def MSR : ABI<0b0001,(outs),(ins GPR:$src), NoItinerary, "msr", "\tcpsr, $src",
Johnny Chenb8689012010-02-12 18:55:33 +00002410 [/* For disassembly only; pattern left blank */]> {
2411 let Inst{23-20} = 0b0010;
2412 let Inst{7-4} = 0b0000;
2413}
2414
2415// FIXME: mask is ignored for the time being.
Johnny Chena6ad7432010-02-16 20:04:27 +00002416def MSRi : ABI<0b0011,(outs),(ins so_imm:$a), NoItinerary, "msr", "\tcpsr, $a",
2417 [/* For disassembly only; pattern left blank */]> {
2418 let Inst{23-20} = 0b0010;
2419 let Inst{7-4} = 0b0000;
2420}
2421
2422// FIXME: mask is ignored for the time being.
2423def MSRsys : ABI<0b0001,(outs),(ins GPR:$src),NoItinerary,"msr","\tspsr, $src",
2424 [/* For disassembly only; pattern left blank */]> {
2425 let Inst{23-20} = 0b0110;
2426 let Inst{7-4} = 0b0000;
2427}
2428
2429// FIXME: mask is ignored for the time being.
2430def MSRsysi : ABI<0b0011,(outs),(ins so_imm:$a),NoItinerary,"msr","\tspsr, $a",
Johnny Chenb8689012010-02-12 18:55:33 +00002431 [/* For disassembly only; pattern left blank */]> {
2432 let Inst{23-20} = 0b0110;
2433 let Inst{7-4} = 0b0000;
2434}