blob: d1793d099c021750c04bcb691cc91f52d17a22b2 [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 Chen33cb4182010-02-16 21:59:54 +0000947// Secure Monitor Call is a system instruction -- for disassembly only
948def SMC : ABI<0b0001, (outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt",
949 [/* For disassembly only; pattern left blank */]> {
950 let Inst{23-20} = 0b0110;
951 let Inst{7-4} = 0b0111;
952}
953
Johnny Chena6ad7432010-02-16 20:04:27 +0000954// Supervisor Call (Software Interrupt) -- for disassembly only
Johnny Chen1b6d4f72010-02-10 18:02:25 +0000955let isCall = 1 in {
956def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc",
957 [/* For disassembly only; pattern left blank */]>;
958}
959
Johnny Chen9412fa882010-02-17 21:39:10 +0000960// Store Return State is a system instruction -- for disassembly only
Johnny Chen33cb4182010-02-16 21:59:54 +0000961def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
962 NoItinerary, "srs${addr:submode}\tsp!, $mode",
Johnny Chena6ad7432010-02-16 20:04:27 +0000963 [/* For disassembly only; pattern left blank */]> {
964 let Inst{31-28} = 0b1111;
965 let Inst{22-20} = 0b110; // W = 1
966}
967
968def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode),
969 NoItinerary, "srs${addr:submode}\tsp, $mode",
970 [/* For disassembly only; pattern left blank */]> {
971 let Inst{31-28} = 0b1111;
972 let Inst{22-20} = 0b100; // W = 0
973}
974
Johnny Chen9412fa882010-02-17 21:39:10 +0000975// Return From Exception is a system instruction -- for disassembly only
976def RFEW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base),
977 NoItinerary, "rfe${addr:submode}\t$base!",
978 [/* For disassembly only; pattern left blank */]> {
979 let Inst{31-28} = 0b1111;
980 let Inst{22-20} = 0b011; // W = 1
981}
982
983def RFE : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base),
984 NoItinerary, "rfe${addr:submode}\t$base",
985 [/* For disassembly only; pattern left blank */]> {
986 let Inst{31-28} = 0b1111;
987 let Inst{22-20} = 0b001; // W = 0
988}
989
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990//===----------------------------------------------------------------------===//
991// Load / store Instructions.
992//
993
994// Load
Jim Grosbach09b5e1b2010-02-16 21:07:46 +0000995let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +0000996def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Evan Chengd3f9bc42009-10-26 23:45:59 +0000997 "ldr", "\t$dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GPR:$dst, (load addrmode2:$addr))]>;
999
1000// Special LDR for loads from non-pc-relative constpools.
Evan Cheng2f6bfd42009-11-20 19:57:15 +00001001let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1,
1002 mayHaveSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001003def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001004 "ldr", "\t$dst, $addr", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005
1006// Loads with zero extension
David Goodwin236ccb52009-08-19 18:00:44 +00001007def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001008 IIC_iLoadr, "ldrh", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +00001009 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001011def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001012 IIC_iLoadr, "ldrb", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +00001013 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014
1015// Loads with sign extension
David Goodwin236ccb52009-08-19 18:00:44 +00001016def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001017 IIC_iLoadr, "ldrsh", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +00001018 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019
David Goodwin236ccb52009-08-19 18:00:44 +00001020def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001021 IIC_iLoadr, "ldrsb", "\t$dst, $addr",
David Goodwin236ccb52009-08-19 18:00:44 +00001022 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001024let mayLoad = 1, hasExtraDefRegAllocReq = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025// Load doubleword
Evan Cheng41169552009-06-15 08:28:29 +00001026def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001027 IIC_iLoadr, "ldrd", "\t$dst1, $addr",
Misha Brukman9daa0672009-08-27 14:14:21 +00001028 []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029
1030// Indexed loads
Evan Chengbe998242008-11-06 08:47:38 +00001031def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001032 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001033 "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034
Evan Chengbe998242008-11-06 08:47:38 +00001035def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001036 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001037 "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038
Evan Chengbe998242008-11-06 08:47:38 +00001039def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001040 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001041 "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042
Evan Chengbe998242008-11-06 08:47:38 +00001043def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001044 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001045 "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046
Evan Chengbe998242008-11-06 08:47:38 +00001047def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001048 (ins addrmode2:$addr), LdFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001049 "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050
Evan Chengbe998242008-11-06 08:47:38 +00001051def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001052 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001053 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054
Evan Chengbe998242008-11-06 08:47:38 +00001055def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001056 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001057 "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058
Evan Chengbe998242008-11-06 08:47:38 +00001059def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001060 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001061 "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062
Evan Chengbe998242008-11-06 08:47:38 +00001063def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001064 (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001065 "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066
Evan Chengbe998242008-11-06 08:47:38 +00001067def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb),
David Goodwin236ccb52009-08-19 18:00:44 +00001068 (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001069 "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>;
Chris Lattnerca4e0fe2008-01-10 05:12:37 +00001070}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071
Johnny Chenb47fed82010-02-11 20:31:08 +00001072// LDRT and LDRBT are for disassembly only.
1073
1074def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb),
1075 (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru,
1076 "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1077 let Inst{21} = 1; // overwrite
1078}
1079
1080def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb),
1081 (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru,
1082 "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
1083 let Inst{21} = 1; // overwrite
1084}
1085
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086// Store
David Goodwin236ccb52009-08-19 18:00:44 +00001087def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001088 "str", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(store GPR:$src, addrmode2:$addr)]>;
1090
1091// Stores with truncate
Jim Grosbach60030482010-02-16 21:23:02 +00001092def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
1093 IIC_iStorer, "strh", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
1095
David Goodwin236ccb52009-08-19 18:00:44 +00001096def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +00001097 "strb", "\t$src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
1099
1100// Store doubleword
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001101let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
David Goodwincfd67652009-08-06 16:52:47 +00001102def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),
David Goodwin236ccb52009-08-19 18:00:44 +00001103 StMiscFrm, IIC_iStorer,
Jim Grosbache2fda532009-11-09 00:11:35 +00001104 "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105
1106// Indexed stores
Evan Chengbe998242008-11-06 08:47:38 +00001107def STR_PRE : AI2stwpr<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001108 (ins GPR:$src, GPR:$base, am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001109 StFrm, IIC_iStoreru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001110 "str", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set GPR:$base_wb,
1112 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1113
Evan Chengbe998242008-11-06 08:47:38 +00001114def STR_POST : AI2stwpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001115 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001116 StFrm, IIC_iStoreru,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001117 "str", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 [(set GPR:$base_wb,
1119 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
1120
Evan Chengbe998242008-11-06 08:47:38 +00001121def STRH_PRE : AI3sthpr<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001122 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001123 StMiscFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001124 "strh", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125 [(set GPR:$base_wb,
1126 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
1127
Evan Chengbe998242008-11-06 08:47:38 +00001128def STRH_POST: AI3sthpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001129 (ins GPR:$src, GPR:$base,am3offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001130 StMiscFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001131 "strh", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
1133 GPR:$base, am3offset:$offset))]>;
1134
Evan Chengbe998242008-11-06 08:47:38 +00001135def STRB_PRE : AI2stbpr<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001136 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001137 StFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001138 "strb", "\t$src, [$base, $offset]!", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
1140 GPR:$base, am2offset:$offset))]>;
1141
Evan Chengbe998242008-11-06 08:47:38 +00001142def STRB_POST: AI2stbpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001143 (ins GPR:$src, GPR:$base,am2offset:$offset),
David Goodwin236ccb52009-08-19 18:00:44 +00001144 StFrm, IIC_iStoreru,
Jim Grosbache2fda532009-11-09 00:11:35 +00001145 "strb", "\t$src, [$base], $offset", "$base = $base_wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
1147 GPR:$base, am2offset:$offset))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148
Johnny Chenb47fed82010-02-11 20:31:08 +00001149// STRT and STRBT are for disassembly only.
1150
1151def STRT : AI2stwpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001152 (ins GPR:$src, GPR:$base,am2offset:$offset),
Johnny Chenb47fed82010-02-11 20:31:08 +00001153 StFrm, IIC_iStoreru,
1154 "strt", "\t$src, [$base], $offset", "$base = $base_wb",
1155 [/* For disassembly only; pattern left blank */]> {
1156 let Inst{21} = 1; // overwrite
1157}
1158
1159def STRBT : AI2stbpo<(outs GPR:$base_wb),
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001160 (ins GPR:$src, GPR:$base,am2offset:$offset),
Johnny Chenb47fed82010-02-11 20:31:08 +00001161 StFrm, IIC_iStoreru,
1162 "strbt", "\t$src, [$base], $offset", "$base = $base_wb",
1163 [/* For disassembly only; pattern left blank */]> {
1164 let Inst{21} = 1; // overwrite
1165}
1166
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167//===----------------------------------------------------------------------===//
1168// Load / store multiple Instructions.
1169//
1170
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001171let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +00001172def LDM : AXI4ld<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +00001173 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +00001174 LdStMulFrm, IIC_iLoadm, "ldm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 []>;
1176
Evan Cheng7c8d5ea2009-10-01 08:22:27 +00001177let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
Evan Chengbe998242008-11-06 08:47:38 +00001178def STM : AXI4st<(outs),
Evan Chengb43a20e2009-10-01 01:33:39 +00001179 (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops),
Jim Grosbache2fda532009-11-09 00:11:35 +00001180 LdStMulFrm, IIC_iStorem, "stm${addr:submode}${p}\t$addr, $wb",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 []>;
1182
1183//===----------------------------------------------------------------------===//
1184// Move Instructions.
1185//
1186
Evan Chengd97d7142009-06-12 20:46:18 +00001187let neverHasSideEffects = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001188def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001189 "mov", "\t$dst, $src", []>, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +00001190 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001191 let Inst{25} = 0;
1192}
1193
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001194def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src),
Anton Korobeynikov60928952009-09-27 23:52:58 +00001195 DPSoRegFrm, IIC_iMOVsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001196 "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001197 let Inst{25} = 0;
1198}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001200let isReMaterializable = 1, isAsCheapAsAMove = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001201def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001202 "mov", "\t$dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP {
Anton Korobeynikov60928952009-09-27 23:52:58 +00001203 let Inst{25} = 1;
1204}
1205
1206let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001207def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src),
Anton Korobeynikov60928952009-09-27 23:52:58 +00001208 DPFrm, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001209 "movw", "\t$dst, $src",
Anton Korobeynikov60928952009-09-27 23:52:58 +00001210 [(set GPR:$dst, imm0_65535:$src)]>,
Johnny Chenba9fbe72010-02-01 23:06:04 +00001211 Requires<[IsARM, HasV6T2]>, UnaryDP {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +00001212 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001213 let Inst{25} = 1;
1214}
1215
Evan Cheng16c012d2009-09-28 09:14:39 +00001216let Constraints = "$src = $dst" in
Anton Korobeynikov60928952009-09-27 23:52:58 +00001217def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm),
1218 DPFrm, IIC_iMOVi,
Anton Korobeynikova414f362009-11-24 00:44:37 +00001219 "movt", "\t$dst, $imm",
Anton Korobeynikov60928952009-09-27 23:52:58 +00001220 [(set GPR:$dst,
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001221 (or (and GPR:$src, 0xffff),
Anton Korobeynikov60928952009-09-27 23:52:58 +00001222 lo16AllZero:$imm))]>, UnaryDP,
1223 Requires<[IsARM, HasV6T2]> {
Bob Wilsonce7c9eb2009-10-13 17:35:30 +00001224 let Inst{20} = 0;
Anton Korobeynikov60928952009-09-27 23:52:58 +00001225 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001226}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227
Evan Cheng89ef2852009-10-21 08:15:52 +00001228def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
1229 Requires<[IsARM, HasV6T2]>;
1230
David Goodwin02b0e352009-09-01 18:32:09 +00001231let Uses = [CPSR] in
David Goodwin236ccb52009-08-19 18:00:44 +00001232def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001233 "mov", "\t$dst, $src, rrx",
Evan Cheng86a926a2008-11-05 18:35:52 +00001234 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235
1236// These aren't really mov instructions, but we have to define them this way
1237// due to flag operands.
1238
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001239let Defs = [CPSR] in {
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001240def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
Jim Grosbache2fda532009-11-09 00:11:35 +00001241 IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +00001242 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
Evan Cheng7f240d22008-11-14 20:09:11 +00001243def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo,
Jim Grosbache2fda532009-11-09 00:11:35 +00001244 IIC_iMOVsi, "movs", "\t$dst, $src, asr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +00001245 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001246}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247
1248//===----------------------------------------------------------------------===//
1249// Extend Instructions.
1250//
1251
1252// Sign extenders
1253
Evan Cheng37afa432008-11-06 22:15:19 +00001254defm SXTB : AI_unary_rrot<0b01101010,
1255 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
1256defm SXTH : AI_unary_rrot<0b01101011,
1257 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258
Evan Cheng37afa432008-11-06 22:15:19 +00001259defm SXTAB : AI_bin_rrot<0b01101010,
1260 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
1261defm SXTAH : AI_bin_rrot<0b01101011,
1262 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263
1264// TODO: SXT(A){B|H}16
1265
1266// Zero extenders
1267
1268let AddedComplexity = 16 in {
Evan Cheng37afa432008-11-06 22:15:19 +00001269defm UXTB : AI_unary_rrot<0b01101110,
1270 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
1271defm UXTH : AI_unary_rrot<0b01101111,
1272 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
1273defm UXTB16 : AI_unary_rrot<0b01101100,
1274 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275
Bob Wilson74590a02009-06-22 22:08:29 +00001276def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 (UXTB16r_rot GPR:$Src, 24)>;
Bob Wilson74590a02009-06-22 22:08:29 +00001278def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 (UXTB16r_rot GPR:$Src, 8)>;
1280
Evan Cheng37afa432008-11-06 22:15:19 +00001281defm UXTAB : AI_bin_rrot<0b01101110, "uxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Cheng37afa432008-11-06 22:15:19 +00001283defm UXTAH : AI_bin_rrot<0b01101111, "uxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
1285}
1286
1287// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1288//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1289
1290// TODO: UXT(A){B|H}16
1291
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001292def SBFX : I<(outs GPR:$dst),
1293 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1294 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001295 "sbfx", "\t$dst, $src, $lsb, $width", "", []>,
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001296 Requires<[IsARM, HasV6T2]> {
1297 let Inst{27-21} = 0b0111101;
1298 let Inst{6-4} = 0b101;
1299}
1300
1301def UBFX : I<(outs GPR:$dst),
1302 (ins GPR:$src, imm0_31:$lsb, imm0_31:$width),
1303 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001304 "ubfx", "\t$dst, $src, $lsb, $width", "", []>,
Sandeep Patelbb4648a2009-10-13 18:59:48 +00001305 Requires<[IsARM, HasV6T2]> {
1306 let Inst{27-21} = 0b0111111;
1307 let Inst{6-4} = 0b101;
1308}
1309
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310//===----------------------------------------------------------------------===//
1311// Arithmetic Instructions.
1312//
1313
Jim Grosbach88c246f2008-10-14 20:36:24 +00001314defm ADD : AsI1_bin_irs<0b0100, "add",
Evan Chengbdd679a2009-06-26 00:19:44 +00001315 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001316defm SUB : AsI1_bin_irs<0b0010, "sub",
Evan Cheng469bc762008-09-17 07:53:38 +00001317 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318
1319// ADD and SUB with 's' bit set.
Jim Grosbache2fda532009-11-09 00:11:35 +00001320defm ADDS : AI1_bin_s_irs<0b0100, "adds",
1321 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
1322defm SUBS : AI1_bin_s_irs<0b0010, "subs",
Evan Chengd4e2f052009-06-25 20:59:23 +00001323 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001325defm ADC : AI1_adde_sube_irs<0b0101, "adc",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001326 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>;
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001327defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001328 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>;
Jim Grosbache2fda532009-11-09 00:11:35 +00001329defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001330 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
Jim Grosbache2fda532009-11-09 00:11:35 +00001331defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001332 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333
1334// These don't define reg/reg forms, because they are handled above.
Evan Cheng86a926a2008-11-05 18:35:52 +00001335def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001336 IIC_iALUi, "rsb", "\t$dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001337 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> {
1338 let Inst{25} = 1;
1339}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340
Evan Cheng86a926a2008-11-05 18:35:52 +00001341def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001342 IIC_iALUsr, "rsb", "\t$dst, $a, $b",
Bob Wilson3a308522009-10-26 22:34:44 +00001343 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001344 let Inst{25} = 0;
1345}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346
1347// RSB with 's' bit set.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001348let Defs = [CPSR] in {
Evan Cheng86a926a2008-11-05 18:35:52 +00001349def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001350 IIC_iALUi, "rsbs", "\t$dst, $a, $b",
Evan Chenga9892932009-09-09 01:47:07 +00001351 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001352 let Inst{20} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001353 let Inst{25} = 1;
1354}
Evan Cheng86a926a2008-11-05 18:35:52 +00001355def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Jim Grosbache2fda532009-11-09 00:11:35 +00001356 IIC_iALUsr, "rsbs", "\t$dst, $a, $b",
Bob Wilson3a308522009-10-26 22:34:44 +00001357 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> {
Bob Wilson3a308522009-10-26 22:34:44 +00001358 let Inst{20} = 1;
1359 let Inst{25} = 0;
1360}
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001361}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001363let Uses = [CPSR] in {
1364def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001365 DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001366 [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>,
1367 Requires<[IsARM]> {
Evan Chenga9892932009-09-09 01:47:07 +00001368 let Inst{25} = 1;
1369}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001370def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001371 DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001372 [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>,
1373 Requires<[IsARM]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001374 let Inst{25} = 0;
1375}
Evan Cheng9b4d26f2009-06-25 23:34:10 +00001376}
1377
1378// FIXME: Allow these to be predicated.
Evan Chengd4e2f052009-06-25 20:59:23 +00001379let Defs = [CPSR], Uses = [CPSR] in {
1380def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001381 DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001382 [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>,
1383 Requires<[IsARM]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001384 let Inst{20} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001385 let Inst{25} = 1;
1386}
Evan Chengd4e2f052009-06-25 20:59:23 +00001387def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001388 DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b",
Jim Grosbachdba8f2c2010-02-16 20:17:57 +00001389 [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>,
1390 Requires<[IsARM]> {
Bob Wilson2aec46e2009-10-26 22:59:12 +00001391 let Inst{20} = 1;
1392 let Inst{25} = 0;
1393}
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001394}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395
1396// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1397def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1398 (SUBri GPR:$src, so_imm_neg:$imm)>;
1399
1400//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1401// (SUBSri GPR:$src, so_imm_neg:$imm)>;
1402//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1403// (SBCri GPR:$src, so_imm_neg:$imm)>;
1404
1405// Note: These are implemented in C++ code, because they have to generate
1406// ADD/SUBrs instructions, which use a complex pattern that a xform function
1407// cannot produce.
1408// (mul X, 2^n+1) -> (add (X << n), X)
1409// (mul X, 2^n-1) -> (rsb X, (X << n))
1410
Johnny Chen8e135702010-02-13 01:21:01 +00001411// Saturating adds/subtracts -- for disassembly only
1412
Johnny Chen2e3f1e52010-02-14 06:32:20 +00001413// GPR:$dst = GPR:$a op GPR:$b
Bob Wilsondf89a642010-02-15 23:43:47 +00001414class AQI<bits<8> op27_20, bits<4> op7_4, string opc>
Johnny Chen2e3f1e52010-02-14 06:32:20 +00001415 : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, IIC_iALUr,
Bob Wilsondf89a642010-02-15 23:43:47 +00001416 opc, "\t$dst, $a, $b",
1417 [/* For disassembly only; pattern left blank */]> {
Johnny Chen8e135702010-02-13 01:21:01 +00001418 let Inst{27-20} = op27_20;
1419 let Inst{7-4} = op7_4;
1420}
1421
Bob Wilsondf89a642010-02-15 23:43:47 +00001422def QADD : AQI<0b00010000, 0b0101, "qadd">;
1423def QADD16 : AQI<0b01100010, 0b0001, "qadd16">;
1424def QADD8 : AQI<0b01100010, 0b1001, "qadd8">;
1425def QASX : AQI<0b01100010, 0b0011, "qasx">;
1426def QDADD : AQI<0b00010100, 0b0101, "qdadd">;
1427def QDSUB : AQI<0b00010110, 0b0101, "qdsub">;
1428def QSAX : AQI<0b01100010, 0b0101, "qsax">;
1429def QSUB : AQI<0b00010010, 0b0101, "qsub">;
1430def QSUB16 : AQI<0b01100010, 0b0111, "qsub16">;
1431def QSUB8 : AQI<0b01100010, 0b1111, "qsub8">;
1432def UQADD16 : AQI<0b01100110, 0b0001, "uqadd16">;
1433def UQADD8 : AQI<0b01100110, 0b1001, "uqadd8">;
1434def UQASX : AQI<0b01100110, 0b0011, "uqasx">;
1435def UQSAX : AQI<0b01100110, 0b0101, "uqsax">;
1436def UQSUB16 : AQI<0b01100110, 0b0111, "uqsub16">;
1437def UQSUB8 : AQI<0b01100110, 0b1111, "uqsub8">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438
1439//===----------------------------------------------------------------------===//
1440// Bitwise Instructions.
1441//
1442
Jim Grosbach88c246f2008-10-14 20:36:24 +00001443defm AND : AsI1_bin_irs<0b0000, "and",
Evan Chengbdd679a2009-06-26 00:19:44 +00001444 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001445defm ORR : AsI1_bin_irs<0b1100, "orr",
Evan Chengbdd679a2009-06-26 00:19:44 +00001446 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001447defm EOR : AsI1_bin_irs<0b0001, "eor",
Evan Chengbdd679a2009-06-26 00:19:44 +00001448 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001449defm BIC : AsI1_bin_irs<0b1110, "bic",
Evan Cheng469bc762008-09-17 07:53:38 +00001450 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451
Evan Cheng299ee652009-07-06 22:23:46 +00001452def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
David Goodwin9a8ec822009-11-02 17:28:36 +00001453 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001454 "bfc", "\t$dst, $imm", "$src = $dst",
Evan Cheng299ee652009-07-06 22:23:46 +00001455 [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
1456 Requires<[IsARM, HasV6T2]> {
1457 let Inst{27-21} = 0b0111110;
1458 let Inst{6-0} = 0b0011111;
1459}
1460
Johnny Chen8d0907f2010-02-17 06:31:48 +00001461// A8.6.18 BFI - Bitfield insert (Encoding A1)
1462// Added for disassembler with the pattern field purposely left blank.
1463def BFI : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm),
1464 AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi,
1465 "bfi", "\t$dst, $src, $imm", "",
1466 [/* For disassembly only; pattern left blank */]>,
1467 Requires<[IsARM, HasV6T2]> {
1468 let Inst{27-21} = 0b0111110;
1469 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
1470}
1471
David Goodwin236ccb52009-08-19 18:00:44 +00001472def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001473 "mvn", "\t$dst, $src",
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001474 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP {
Johnny Chen9063a772010-01-31 11:22:28 +00001475 let Inst{25} = 0;
Johnny Chend139b942009-11-07 00:54:36 +00001476 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001477}
Evan Cheng86a926a2008-11-05 18:35:52 +00001478def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001479 IIC_iMOVsr, "mvn", "\t$dst, $src",
Johnny Chen9063a772010-01-31 11:22:28 +00001480 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP {
1481 let Inst{25} = 0;
1482}
Evan Chengbd0ca9c2009-02-05 08:42:55 +00001483let isReMaterializable = 1, isAsCheapAsAMove = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001484def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001485 IIC_iMOVi, "mvn", "\t$dst, $imm",
Evan Chenga9892932009-09-09 01:47:07 +00001486 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP {
1487 let Inst{25} = 1;
1488}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489
1490def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1491 (BICri GPR:$src, so_imm_not:$imm)>;
1492
1493//===----------------------------------------------------------------------===//
1494// Multiply Instructions.
1495//
1496
Evan Chengbdd679a2009-06-26 00:19:44 +00001497let isCommutable = 1 in
David Goodwin236ccb52009-08-19 18:00:44 +00001498def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001499 IIC_iMUL32, "mul", "\t$dst, $a, $b",
Evan Chengf8e8b622008-11-06 17:48:05 +00001500 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501
Evan Chengee80fb72008-11-06 01:21:28 +00001502def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001503 IIC_iMAC32, "mla", "\t$dst, $a, $b, $c",
Evan Chengf8e8b622008-11-06 17:48:05 +00001504 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505
David Goodwincfd67652009-08-06 16:52:47 +00001506def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001507 IIC_iMAC32, "mls", "\t$dst, $a, $b, $c",
Evan Chengc8147e12009-07-06 22:05:45 +00001508 [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>,
1509 Requires<[IsARM, HasV6T2]>;
1510
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511// Extra precision multiplies with low / high results
Evan Chengd97d7142009-06-12 20:46:18 +00001512let neverHasSideEffects = 1 in {
Evan Chengbdd679a2009-06-26 00:19:44 +00001513let isCommutable = 1 in {
Evan Chengee80fb72008-11-06 01:21:28 +00001514def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001515 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001516 "smull", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517
Evan Chengee80fb72008-11-06 01:21:28 +00001518def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001519 (ins GPR:$a, GPR:$b), IIC_iMUL64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001520 "umull", "\t$ldst, $hdst, $a, $b", []>;
Evan Chengbdd679a2009-06-26 00:19:44 +00001521}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522
1523// Multiply + accumulate
Evan Chengee80fb72008-11-06 01:21:28 +00001524def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001525 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001526 "smlal", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527
Evan Chengee80fb72008-11-06 01:21:28 +00001528def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001529 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001530 "umlal", "\t$ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531
Evan Chengee80fb72008-11-06 01:21:28 +00001532def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst),
David Goodwin236ccb52009-08-19 18:00:44 +00001533 (ins GPR:$a, GPR:$b), IIC_iMAC64,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001534 "umaal", "\t$ldst, $hdst, $a, $b", []>,
Evan Chengee80fb72008-11-06 01:21:28 +00001535 Requires<[IsARM, HasV6]>;
Evan Chengd97d7142009-06-12 20:46:18 +00001536} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537
1538// Most significant word multiply
Evan Chengee80fb72008-11-06 01:21:28 +00001539def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001540 IIC_iMUL32, "smmul", "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001542 Requires<[IsARM, HasV6]> {
1543 let Inst{7-4} = 0b0001;
1544 let Inst{15-12} = 0b1111;
1545}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546
Evan Chengee80fb72008-11-06 01:21:28 +00001547def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001548 IIC_iMAC32, "smmla", "\t$dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001550 Requires<[IsARM, HasV6]> {
1551 let Inst{7-4} = 0b0001;
1552}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553
1554
Evan Chengee80fb72008-11-06 01:21:28 +00001555def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001556 IIC_iMAC32, "smmls", "\t$dst, $a, $b, $c",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
Evan Chengee80fb72008-11-06 01:21:28 +00001558 Requires<[IsARM, HasV6]> {
1559 let Inst{7-4} = 0b1101;
1560}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001562multiclass AI_smul<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001563 def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001564 IIC_iMUL32, !strconcat(opc, "bb"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1566 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001567 Requires<[IsARM, HasV5TE]> {
1568 let Inst{5} = 0;
1569 let Inst{6} = 0;
1570 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001571
Evan Cheng38396be2008-11-06 03:35:07 +00001572 def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001573 IIC_iMUL32, !strconcat(opc, "bt"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
Bob Wilson74590a02009-06-22 22:08:29 +00001575 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001576 Requires<[IsARM, HasV5TE]> {
1577 let Inst{5} = 0;
1578 let Inst{6} = 1;
1579 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001580
Evan Cheng38396be2008-11-06 03:35:07 +00001581 def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001582 IIC_iMUL32, !strconcat(opc, "tb"), "\t$dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001583 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 (sext_inreg GPR:$b, i16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001585 Requires<[IsARM, HasV5TE]> {
1586 let Inst{5} = 1;
1587 let Inst{6} = 0;
1588 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001589
Evan Cheng38396be2008-11-06 03:35:07 +00001590 def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001591 IIC_iMUL32, !strconcat(opc, "tt"), "\t$dst, $a, $b",
Bob Wilson74590a02009-06-22 22:08:29 +00001592 [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)),
1593 (sra GPR:$b, (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001594 Requires<[IsARM, HasV5TE]> {
1595 let Inst{5} = 1;
1596 let Inst{6} = 1;
1597 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001598
Evan Cheng38396be2008-11-06 03:35:07 +00001599 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001600 IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001602 (sext_inreg GPR:$b, i16)), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001603 Requires<[IsARM, HasV5TE]> {
1604 let Inst{5} = 1;
1605 let Inst{6} = 0;
1606 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001607
Evan Cheng38396be2008-11-06 03:35:07 +00001608 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001609 IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 [(set GPR:$dst, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001611 (sra GPR:$b, (i32 16))), (i32 16)))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001612 Requires<[IsARM, HasV5TE]> {
1613 let Inst{5} = 1;
1614 let Inst{6} = 1;
1615 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616}
1617
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001618
1619multiclass AI_smla<string opc, PatFrag opnode> {
Evan Cheng38396be2008-11-06 03:35:07 +00001620 def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001621 IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 [(set GPR:$dst, (add GPR:$acc,
1623 (opnode (sext_inreg GPR:$a, i16),
1624 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001625 Requires<[IsARM, HasV5TE]> {
1626 let Inst{5} = 0;
1627 let Inst{6} = 0;
1628 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001629
Evan Cheng38396be2008-11-06 03:35:07 +00001630 def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001631 IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
Jim Grosbach60030482010-02-16 21:23:02 +00001633 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001634 Requires<[IsARM, HasV5TE]> {
1635 let Inst{5} = 0;
1636 let Inst{6} = 1;
1637 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001638
Evan Cheng38396be2008-11-06 03:35:07 +00001639 def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001640 IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc",
Bob Wilson74590a02009-06-22 22:08:29 +00001641 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 (sext_inreg GPR:$b, i16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001643 Requires<[IsARM, HasV5TE]> {
1644 let Inst{5} = 1;
1645 let Inst{6} = 0;
1646 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001647
Evan Cheng38396be2008-11-06 03:35:07 +00001648 def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001649 IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc",
1650 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)),
1651 (sra GPR:$b, (i32 16)))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001652 Requires<[IsARM, HasV5TE]> {
1653 let Inst{5} = 1;
1654 let Inst{6} = 1;
1655 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656
Evan Cheng38396be2008-11-06 03:35:07 +00001657 def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001658 IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001660 (sext_inreg GPR:$b, i16)), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001661 Requires<[IsARM, HasV5TE]> {
1662 let Inst{5} = 0;
1663 let Inst{6} = 0;
1664 }
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001665
Evan Cheng38396be2008-11-06 03:35:07 +00001666 def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001667 IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
Bob Wilson74590a02009-06-22 22:08:29 +00001669 (sra GPR:$b, (i32 16))), (i32 16))))]>,
Evan Cheng38396be2008-11-06 03:35:07 +00001670 Requires<[IsARM, HasV5TE]> {
1671 let Inst{5} = 0;
1672 let Inst{6} = 1;
1673 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001674}
1675
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001676defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1677defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678
Johnny Chen10014222010-02-12 21:59:23 +00001679// Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only
1680def SMLALBB : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1681 IIC_iMAC64, "smlalbb", "\t$ldst, $hdst, $a, $b",
1682 [/* For disassembly only; pattern left blank */]>,
1683 Requires<[IsARM, HasV5TE]> {
1684 let Inst{5} = 0;
1685 let Inst{6} = 0;
1686}
1687
1688def SMLALBT : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1689 IIC_iMAC64, "smlalbt", "\t$ldst, $hdst, $a, $b",
1690 [/* For disassembly only; pattern left blank */]>,
1691 Requires<[IsARM, HasV5TE]> {
1692 let Inst{5} = 0;
1693 let Inst{6} = 1;
1694}
1695
1696def SMLALTB : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1697 IIC_iMAC64, "smlaltb", "\t$ldst, $hdst, $a, $b",
1698 [/* For disassembly only; pattern left blank */]>,
1699 Requires<[IsARM, HasV5TE]> {
1700 let Inst{5} = 1;
1701 let Inst{6} = 0;
1702}
1703
1704def SMLALTT : AMulxyI<0b0001010,(outs GPR:$ldst,GPR:$hdst),(ins GPR:$a,GPR:$b),
1705 IIC_iMAC64, "smlaltt", "\t$ldst, $hdst, $a, $b",
1706 [/* For disassembly only; pattern left blank */]>,
1707 Requires<[IsARM, HasV5TE]> {
1708 let Inst{5} = 1;
1709 let Inst{6} = 1;
1710}
1711
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1713
1714//===----------------------------------------------------------------------===//
1715// Misc. Arithmetic Instructions.
1716//
1717
David Goodwin236ccb52009-08-19 18:00:44 +00001718def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001719 "clz", "\t$dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001720 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> {
1721 let Inst{7-4} = 0b0001;
1722 let Inst{11-8} = 0b1111;
1723 let Inst{19-16} = 0b1111;
1724}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725
Jim Grosbachf1f92ff2010-01-18 19:58:49 +00001726def RBIT : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd7da8fc2010-01-19 00:44:15 +00001727 "rbit", "\t$dst, $src",
1728 [(set GPR:$dst, (ARMrbit GPR:$src))]>,
1729 Requires<[IsARM, HasV6T2]> {
Jim Grosbachf1f92ff2010-01-18 19:58:49 +00001730 let Inst{7-4} = 0b0011;
1731 let Inst{11-8} = 0b1111;
1732 let Inst{19-16} = 0b1111;
1733}
1734
David Goodwin236ccb52009-08-19 18:00:44 +00001735def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001736 "rev", "\t$dst, $src",
Evan Chengc2121a22008-11-07 01:41:35 +00001737 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> {
1738 let Inst{7-4} = 0b0011;
1739 let Inst{11-8} = 0b1111;
1740 let Inst{19-16} = 0b1111;
1741}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742
David Goodwin236ccb52009-08-19 18:00:44 +00001743def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001744 "rev16", "\t$dst, $src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 [(set GPR:$dst,
Bob Wilson74590a02009-06-22 22:08:29 +00001746 (or (and (srl GPR:$src, (i32 8)), 0xFF),
1747 (or (and (shl GPR:$src, (i32 8)), 0xFF00),
1748 (or (and (srl GPR:$src, (i32 8)), 0xFF0000),
1749 (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001750 Requires<[IsARM, HasV6]> {
1751 let Inst{7-4} = 0b1011;
1752 let Inst{11-8} = 0b1111;
1753 let Inst{19-16} = 0b1111;
1754}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755
David Goodwin236ccb52009-08-19 18:00:44 +00001756def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001757 "revsh", "\t$dst, $src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(set GPR:$dst,
1759 (sext_inreg
Bob Wilson74590a02009-06-22 22:08:29 +00001760 (or (srl (and GPR:$src, 0xFF00), (i32 8)),
1761 (shl GPR:$src, (i32 8))), i16))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001762 Requires<[IsARM, HasV6]> {
1763 let Inst{7-4} = 0b1011;
1764 let Inst{11-8} = 0b1111;
1765 let Inst{19-16} = 0b1111;
1766}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767
Evan Chengc2121a22008-11-07 01:41:35 +00001768def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst),
1769 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001770 IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2, LSL $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1772 (and (shl GPR:$src2, (i32 imm:$shamt)),
1773 0xFFFF0000)))]>,
Evan Chengc2121a22008-11-07 01:41:35 +00001774 Requires<[IsARM, HasV6]> {
1775 let Inst{6-4} = 0b001;
1776}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777
1778// Alternate cases for PKHBT where identities eliminate some nodes.
1779def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1780 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1781def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1782 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1783
1784
Evan Chengc2121a22008-11-07 01:41:35 +00001785def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst),
1786 (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
Evan Chengd3f9bc42009-10-26 23:45:59 +00001787 IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2, ASR $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1789 (and (sra GPR:$src2, imm16_31:$shamt),
Evan Chengc2121a22008-11-07 01:41:35 +00001790 0xFFFF)))]>, Requires<[IsARM, HasV6]> {
1791 let Inst{6-4} = 0b101;
1792}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793
1794// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1795// a shift amount of 0 is *not legal* here, it is PKHBT instead.
Bob Wilson74590a02009-06-22 22:08:29 +00001796def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1798def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1799 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1800 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1801
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802//===----------------------------------------------------------------------===//
1803// Comparison Instructions...
1804//
1805
Jim Grosbach88c246f2008-10-14 20:36:24 +00001806defm CMP : AI1_cmp_irs<0b1010, "cmp",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001807 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
Jim Grosbach40e4b112010-01-22 00:08:13 +00001808//FIXME: Disable CMN, as CCodes are backwards from compare expectations
1809// Compare-to-zero still works out, just not the relationals
1810//defm CMN : AI1_cmp_irs<0b1011, "cmn",
1811// BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812
1813// Note that TST/TEQ don't set all the same flags that CMP does!
Evan Chengbe998242008-11-06 08:47:38 +00001814defm TST : AI1_cmp_irs<0b1000, "tst",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001815 BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>;
Evan Chengbe998242008-11-06 08:47:38 +00001816defm TEQ : AI1_cmp_irs<0b1001, "teq",
David Goodwin8bdcbb32009-06-29 15:33:01 +00001817 BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818
David Goodwin8bdcbb32009-06-29 15:33:01 +00001819defm CMPz : AI1_cmp_irs<0b1010, "cmp",
1820 BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>;
1821defm CMNz : AI1_cmp_irs<0b1011, "cmn",
1822 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823
Jim Grosbach40e4b112010-01-22 00:08:13 +00001824//def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1825// (CMNri GPR:$src, so_imm_neg:$imm)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826
David Goodwin8bdcbb32009-06-29 15:33:01 +00001827def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
Jim Grosbach40e4b112010-01-22 00:08:13 +00001828 (CMNzri GPR:$src, so_imm_neg:$imm)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829
1830
1831// Conditional moves
1832// FIXME: should be able to write a pattern for ARMcmov, but can't use
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00001833// a two-value operand where a dag node expects two operands. :(
Evan Chengbe998242008-11-06 08:47:38 +00001834def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001835 IIC_iCMOVr, "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001837 RegConstraint<"$false = $dst">, UnaryDP {
Johnny Chend139b942009-11-07 00:54:36 +00001838 let Inst{11-4} = 0b00000000;
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001839 let Inst{25} = 0;
1840}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841
Evan Chengbe998242008-11-06 08:47:38 +00001842def MOVCCs : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001843 (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001844 "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001846 RegConstraint<"$false = $dst">, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001847 let Inst{25} = 0;
1848}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849
Evan Chengbe998242008-11-06 08:47:38 +00001850def MOVCCi : AI1<0b1101, (outs GPR:$dst),
David Goodwin236ccb52009-08-19 18:00:44 +00001851 (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00001852 "mov", "\t$dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Chenga9892932009-09-09 01:47:07 +00001854 RegConstraint<"$false = $dst">, UnaryDP {
Bob Wilsoncfb46c52009-10-14 19:00:24 +00001855 let Inst{25} = 1;
Evan Chenga9892932009-09-09 01:47:07 +00001856}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857
Jim Grosbachba744f62009-12-10 00:11:09 +00001858//===----------------------------------------------------------------------===//
1859// Atomic operations intrinsics
1860//
1861
1862// memory barriers protect the atomic sequences
Jim Grosbach63437d92009-12-14 18:31:20 +00001863let hasSideEffects = 1 in {
1864def Int_MemBarrierV7 : AInoP<(outs), (ins),
Jim Grosbachba744f62009-12-10 00:11:09 +00001865 Pseudo, NoItinerary,
1866 "dmb", "",
Jim Grosbach6eee9032009-12-14 21:24:16 +00001867 [(ARMMemBarrierV7)]>,
Jim Grosbach2d6e2492009-12-14 19:24:11 +00001868 Requires<[IsARM, HasV7]> {
Jim Grosbach37582c32009-12-10 18:35:32 +00001869 let Inst{31-4} = 0xf57ff05;
1870 // FIXME: add support for options other than a full system DMB
1871 let Inst{3-0} = 0b1111;
1872}
Jim Grosbachba744f62009-12-10 00:11:09 +00001873
Jim Grosbach63437d92009-12-14 18:31:20 +00001874def Int_SyncBarrierV7 : AInoP<(outs), (ins),
Jim Grosbachba744f62009-12-10 00:11:09 +00001875 Pseudo, NoItinerary,
1876 "dsb", "",
Jim Grosbach6eee9032009-12-14 21:24:16 +00001877 [(ARMSyncBarrierV7)]>,
Jim Grosbach2d6e2492009-12-14 19:24:11 +00001878 Requires<[IsARM, HasV7]> {
Jim Grosbach37582c32009-12-10 18:35:32 +00001879 let Inst{31-4} = 0xf57ff04;
1880 // FIXME: add support for options other than a full system DSB
1881 let Inst{3-0} = 0b1111;
1882}
Jim Grosbach6eee9032009-12-14 21:24:16 +00001883
1884def Int_MemBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1885 Pseudo, NoItinerary,
1886 "mcr", "\tp15, 0, $zero, c7, c10, 5",
1887 [(ARMMemBarrierV6 GPR:$zero)]>,
1888 Requires<[IsARM, HasV6]> {
1889 // FIXME: add support for options other than a full system DMB
1890 // FIXME: add encoding
1891}
1892
1893def Int_SyncBarrierV6 : AInoP<(outs), (ins GPR:$zero),
1894 Pseudo, NoItinerary,
Jim Grosbachba16e072009-12-14 21:33:32 +00001895 "mcr", "\tp15, 0, $zero, c7, c10, 4",
Jim Grosbach6eee9032009-12-14 21:24:16 +00001896 [(ARMSyncBarrierV6 GPR:$zero)]>,
1897 Requires<[IsARM, HasV6]> {
1898 // FIXME: add support for options other than a full system DSB
1899 // FIXME: add encoding
1900}
Jim Grosbachba744f62009-12-10 00:11:09 +00001901}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902
Jim Grosbach78539672009-12-11 18:52:41 +00001903let usesCustomInserter = 1 in {
Jim Grosbach24189692009-12-12 01:40:06 +00001904 let Uses = [CPSR] in {
1905 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
1906 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1907 "${:comment} ATOMIC_LOAD_ADD_I8 PSEUDO!",
1908 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
1909 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
1910 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1911 "${:comment} ATOMIC_LOAD_SUB_I8 PSEUDO!",
1912 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
1913 def ATOMIC_LOAD_AND_I8 : PseudoInst<
1914 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1915 "${:comment} ATOMIC_LOAD_AND_I8 PSEUDO!",
1916 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
1917 def ATOMIC_LOAD_OR_I8 : PseudoInst<
1918 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1919 "${:comment} ATOMIC_LOAD_OR_I8 PSEUDO!",
1920 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
1921 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
1922 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1923 "${:comment} ATOMIC_LOAD_XOR_I8 PSEUDO!",
1924 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
1925 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
1926 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1927 "${:comment} ATOMIC_LOAD_NAND_I8 PSEUDO!",
1928 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
1929 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
1930 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1931 "${:comment} ATOMIC_LOAD_ADD_I16 PSEUDO!",
1932 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
1933 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
1934 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1935 "${:comment} ATOMIC_LOAD_SUB_I16 PSEUDO!",
1936 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
1937 def ATOMIC_LOAD_AND_I16 : PseudoInst<
1938 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1939 "${:comment} ATOMIC_LOAD_AND_I16 PSEUDO!",
1940 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
1941 def ATOMIC_LOAD_OR_I16 : PseudoInst<
1942 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1943 "${:comment} ATOMIC_LOAD_OR_I16 PSEUDO!",
1944 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
1945 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
1946 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1947 "${:comment} ATOMIC_LOAD_XOR_I16 PSEUDO!",
1948 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
1949 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
1950 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1951 "${:comment} ATOMIC_LOAD_NAND_I16 PSEUDO!",
1952 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
1953 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
1954 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1955 "${:comment} ATOMIC_LOAD_ADD_I32 PSEUDO!",
1956 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
1957 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
1958 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1959 "${:comment} ATOMIC_LOAD_SUB_I32 PSEUDO!",
1960 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
1961 def ATOMIC_LOAD_AND_I32 : PseudoInst<
1962 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1963 "${:comment} ATOMIC_LOAD_AND_I32 PSEUDO!",
1964 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
1965 def ATOMIC_LOAD_OR_I32 : PseudoInst<
1966 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1967 "${:comment} ATOMIC_LOAD_OR_I32 PSEUDO!",
1968 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
1969 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
1970 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1971 "${:comment} ATOMIC_LOAD_XOR_I32 PSEUDO!",
1972 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
1973 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
1974 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
1975 "${:comment} ATOMIC_LOAD_NAND_I32 PSEUDO!",
1976 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
1977
1978 def ATOMIC_SWAP_I8 : PseudoInst<
1979 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1980 "${:comment} ATOMIC_SWAP_I8 PSEUDO!",
1981 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
1982 def ATOMIC_SWAP_I16 : PseudoInst<
1983 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1984 "${:comment} ATOMIC_SWAP_I16 PSEUDO!",
1985 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
1986 def ATOMIC_SWAP_I32 : PseudoInst<
1987 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
1988 "${:comment} ATOMIC_SWAP_I32 PSEUDO!",
1989 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
1990
Jim Grosbach24189692009-12-12 01:40:06 +00001991 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
1992 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1993 "${:comment} ATOMIC_CMP_SWAP_I8 PSEUDO!",
1994 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
1995 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
1996 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
1997 "${:comment} ATOMIC_CMP_SWAP_I16 PSEUDO!",
1998 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
1999 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
2000 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
2001 "${:comment} ATOMIC_CMP_SWAP_I32 PSEUDO!",
2002 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
2003}
Jim Grosbach437d6992009-12-11 01:42:04 +00002004}
2005
2006let mayLoad = 1 in {
2007def LDREXB : AIldrex<0b10, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
2008 "ldrexb", "\t$dest, [$ptr]",
2009 []>;
2010def LDREXH : AIldrex<0b11, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
2011 "ldrexh", "\t$dest, [$ptr]",
2012 []>;
2013def LDREX : AIldrex<0b00, (outs GPR:$dest), (ins GPR:$ptr), NoItinerary,
2014 "ldrex", "\t$dest, [$ptr]",
2015 []>;
Johnny Chen8ac1d372009-12-14 21:01:46 +00002016def LDREXD : AIldrex<0b01, (outs GPR:$dest, GPR:$dest2), (ins GPR:$ptr),
Jim Grosbachc83030d2009-12-14 17:02:55 +00002017 NoItinerary,
2018 "ldrexd", "\t$dest, $dest2, [$ptr]",
2019 []>;
Jim Grosbach437d6992009-12-11 01:42:04 +00002020}
2021
Jim Grosbach724d7a12009-12-16 19:44:06 +00002022let mayStore = 1, Constraints = "@earlyclobber $success" in {
Jim Grosbach437d6992009-12-11 01:42:04 +00002023def STREXB : AIstrex<0b10, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
Jim Grosbachc83030d2009-12-14 17:02:55 +00002024 NoItinerary,
Jim Grosbach437d6992009-12-11 01:42:04 +00002025 "strexb", "\t$success, $src, [$ptr]",
2026 []>;
2027def STREXH : AIstrex<0b11, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
2028 NoItinerary,
2029 "strexh", "\t$success, $src, [$ptr]",
2030 []>;
2031def STREX : AIstrex<0b00, (outs GPR:$success), (ins GPR:$src, GPR:$ptr),
Jim Grosbachc83030d2009-12-14 17:02:55 +00002032 NoItinerary,
Jim Grosbach437d6992009-12-11 01:42:04 +00002033 "strex", "\t$success, $src, [$ptr]",
2034 []>;
Johnny Chen8ac1d372009-12-14 21:01:46 +00002035def STREXD : AIstrex<0b01, (outs GPR:$success),
Jim Grosbachc83030d2009-12-14 17:02:55 +00002036 (ins GPR:$src, GPR:$src2, GPR:$ptr),
2037 NoItinerary,
2038 "strexd", "\t$success, $src, $src2, [$ptr]",
2039 []>;
Jim Grosbach437d6992009-12-11 01:42:04 +00002040}
2041
Johnny Chen1d7e5c82010-02-12 20:48:24 +00002042// SWP/SWPB are deprecated in V6/V7 and for disassembly only.
2043let mayLoad = 1 in {
2044def SWP : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2045 "swp", "\t$dst, $src, [$ptr]",
2046 [/* For disassembly only; pattern left blank */]> {
2047 let Inst{27-23} = 0b00010;
2048 let Inst{22} = 0; // B = 0
2049 let Inst{21-20} = 0b00;
2050 let Inst{7-4} = 0b1001;
2051}
2052
2053def SWPB : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary,
2054 "swpb", "\t$dst, $src, [$ptr]",
2055 [/* For disassembly only; pattern left blank */]> {
2056 let Inst{27-23} = 0b00010;
2057 let Inst{22} = 1; // B = 1
2058 let Inst{21-20} = 0b00;
2059 let Inst{7-4} = 0b1001;
2060}
2061}
2062
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063//===----------------------------------------------------------------------===//
2064// TLS Instructions
2065//
2066
2067// __aeabi_read_tp preserves the registers r1-r3.
2068let isCall = 1,
2069 Defs = [R0, R12, LR, CPSR] in {
David Goodwincfd67652009-08-06 16:52:47 +00002070 def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br,
Evan Chengd3f9bc42009-10-26 23:45:59 +00002071 "bl\t__aeabi_read_tp",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(set R0, ARMthread_pointer)]>;
2073}
2074
2075//===----------------------------------------------------------------------===//
Jim Grosbachc10915b2009-05-12 23:59:14 +00002076// SJLJ Exception handling intrinsics
Jim Grosbach207a4ba2009-08-13 15:11:43 +00002077// eh_sjlj_setjmp() is an instruction sequence to store the return
Jim Grosbach4a9025e2009-05-14 00:46:35 +00002078// address and save #0 in R0 for the non-longjmp case.
Jim Grosbachc10915b2009-05-12 23:59:14 +00002079// Since by its nature we may be coming from some other function to get
2080// here, and we're using the stack frame for the containing function to
2081// save/restore registers, we can't keep anything live in regs across
Jim Grosbach4a9025e2009-05-14 00:46:35 +00002082// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
Jim Grosbachc10915b2009-05-12 23:59:14 +00002083// when we get here from a longjmp(). We force everthing out of registers
Jim Grosbach4a9025e2009-05-14 00:46:35 +00002084// except for our own input by listing the relevant registers in Defs. By
2085// doing so, we also cause the prologue/epilogue code to actively preserve
2086// all of the callee-saved resgisters, which is exactly what we want.
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002087// A constant value is passed in $val, and we use the location as a scratch.
2088let Defs =
Jim Grosbach3990e392009-08-13 16:59:44 +00002089 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0,
2090 D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15,
Evan Cheng80ab2a82009-07-29 20:10:36 +00002091 D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30,
Evan Cheng27396a62009-07-22 06:46:53 +00002092 D31 ] in {
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002093 def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val),
David Goodwincfd67652009-08-06 16:52:47 +00002094 AddrModeNone, SizeSpecial, IndexModeNone,
2095 Pseudo, NoItinerary,
Evan Chengd3f9bc42009-10-26 23:45:59 +00002096 "str\tsp, [$src, #+8] @ eh_setjmp begin\n\t"
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002097 "add\t$val, pc, #8\n\t"
2098 "str\t$val, [$src, #+4]\n\t"
Evan Chengd3f9bc42009-10-26 23:45:59 +00002099 "mov\tr0, #0\n\t"
2100 "add\tpc, pc, #0\n\t"
2101 "mov\tr0, #1 @ eh_setjmp end", "",
Jim Grosbach8d96fc12010-02-08 23:22:00 +00002102 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>;
Jim Grosbachc10915b2009-05-12 23:59:14 +00002103}
2104
2105//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106// Non-Instruction Patterns
2107//
2108
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109// Large immediate handling.
2110
2111// Two piece so_imms.
2112let isReMaterializable = 1 in
Jim Grosbach09b5e1b2010-02-16 21:07:46 +00002113def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src),
David Goodwin236ccb52009-08-19 18:00:44 +00002114 Pseudo, IIC_iMOVi,
Evan Chengd3f9bc42009-10-26 23:45:59 +00002115 "mov", "\t$dst, $src",
Evan Cheng16c012d2009-09-28 09:14:39 +00002116 [(set GPR:$dst, so_imm2part:$src)]>,
2117 Requires<[IsARM, NoV6T2]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118
2119def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00002120 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2121 (so_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
Evan Cheng8be2a5b2009-07-08 21:03:57 +00002123 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2124 (so_imm2part_2 imm:$RHS))>;
Jim Grosbach1afc8e22009-10-21 20:44:34 +00002125def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS),
2126 (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
2127 (so_imm2part_2 imm:$RHS))>;
Jim Grosbach66e70cd2009-11-23 20:35:53 +00002128def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS),
2129 (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)),
2130 (so_neg_imm2part_2 imm:$RHS))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131
Evan Cheng16c012d2009-09-28 09:14:39 +00002132// 32-bit immediate using movw + movt.
Chris Lattnere4eb7342009-10-20 00:40:56 +00002133// This is a single pseudo instruction, the benefit is that it can be remat'd
2134// as a single unit instead of having to handle reg inputs.
2135// FIXME: Remove this when we can do generalized remat.
Evan Cheng16c012d2009-09-28 09:14:39 +00002136let isReMaterializable = 1 in
2137def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi,
Jim Grosbach60030482010-02-16 21:23:02 +00002138 "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}",
Evan Cheng16c012d2009-09-28 09:14:39 +00002139 [(set GPR:$dst, (i32 imm:$src))]>,
2140 Requires<[IsARM, HasV6T2]>;
Anton Korobeynikov60928952009-09-27 23:52:58 +00002141
Anton Korobeynikova414f362009-11-24 00:44:37 +00002142// ConstantPool, GlobalAddress, and JumpTable
2143def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
2144 Requires<[IsARM, DontUseMovt]>;
2145def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
2146def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
2147 Requires<[IsARM, UseMovt]>;
2148def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
2149 (LEApcrelJT tjumptable:$dst, imm:$id)>;
2150
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151// TODO: add,sub,and, 3-instr forms?
2152
2153
2154// Direct calls
Bob Wilson243b37c2009-06-22 21:01:46 +00002155def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00002156 Requires<[IsARM, IsNotDarwin]>;
Bob Wilson243b37c2009-06-22 21:01:46 +00002157def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
Evan Cheng9e734482009-07-29 21:26:42 +00002158 Requires<[IsARM, IsDarwin]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159
2160// zextload i1 -> zextload i8
2161def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2162
2163// extload -> zextload
2164def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2165def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
2166def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
2167
Evan Chengc41fb3152008-11-05 23:22:34 +00002168def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
2169def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
2170
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171// smul* and smla*
Bob Wilson74590a02009-06-22 22:08:29 +00002172def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2173 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 (SMULBB GPR:$a, GPR:$b)>;
2175def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
2176 (SMULBB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002177def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2178 (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002180def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 (SMULBT GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002182def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
2183 (sra (shl GPR:$b, (i32 16)), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002185def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 (SMULTB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002187def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2188 (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 (SMULWB GPR:$a, GPR:$b)>;
Bob Wilson74590a02009-06-22 22:08:29 +00002190def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 (SMULWB GPR:$a, GPR:$b)>;
2192
2193def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002194 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2195 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
2197def : ARMV5TEPat<(add GPR:$acc,
2198 (mul sext_16_node:$a, sext_16_node:$b)),
2199 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
2200def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002201 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
2202 (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
2204def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002205 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
2207def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002208 (mul (sra GPR:$a, (i32 16)),
2209 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2211def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002212 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
2214def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002215 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
2216 (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2218def : ARMV5TEPat<(add GPR:$acc,
Bob Wilson74590a02009-06-22 22:08:29 +00002219 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
2221
2222//===----------------------------------------------------------------------===//
2223// Thumb Support
2224//
2225
2226include "ARMInstrThumb.td"
2227
2228//===----------------------------------------------------------------------===//
Anton Korobeynikovac869fc2009-06-17 18:13:58 +00002229// Thumb2 Support
2230//
2231
2232include "ARMInstrThumb2.td"
2233
2234//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235// Floating Point Support
2236//
2237
2238include "ARMInstrVFP.td"
Bob Wilsone60fee02009-06-22 23:27:02 +00002239
2240//===----------------------------------------------------------------------===//
2241// Advanced SIMD (NEON) Support
2242//
2243
2244include "ARMInstrNEON.td"
Johnny Chenedf090c2010-02-12 01:44:23 +00002245
2246//===----------------------------------------------------------------------===//
2247// Coprocessor Instructions. For disassembly only.
2248//
2249
2250def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2251 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2252 NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2253 [/* For disassembly only; pattern left blank */]> {
2254 let Inst{4} = 0;
2255}
2256
2257def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2258 nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2259 NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2",
2260 [/* For disassembly only; pattern left blank */]> {
2261 let Inst{31-28} = 0b1111;
2262 let Inst{4} = 0;
2263}
2264
Johnny Chena6ad7432010-02-16 20:04:27 +00002265class ACI<dag oops, dag iops, string opc, string asm>
2266 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
2267 opc, asm, "", [/* For disassembly only; pattern left blank */]> {
2268 let Inst{27-25} = 0b110;
2269}
2270
2271multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
2272
2273 def _OFFSET : ACI<(outs),
2274 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2275 opc, "\tp$cop, cr$CRd, $addr"> {
2276 let Inst{31-28} = op31_28;
2277 let Inst{24} = 1; // P = 1
2278 let Inst{21} = 0; // W = 0
2279 let Inst{22} = 0; // D = 0
2280 let Inst{20} = load;
2281 }
2282
2283 def _PRE : ACI<(outs),
2284 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2285 opc, "\tp$cop, cr$CRd, $addr!"> {
2286 let Inst{31-28} = op31_28;
2287 let Inst{24} = 1; // P = 1
2288 let Inst{21} = 1; // W = 1
2289 let Inst{22} = 0; // D = 0
2290 let Inst{20} = load;
2291 }
2292
2293 def _POST : ACI<(outs),
2294 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
2295 opc, "\tp$cop, cr$CRd, [$base], $offset"> {
2296 let Inst{31-28} = op31_28;
2297 let Inst{24} = 0; // P = 0
2298 let Inst{21} = 1; // W = 1
2299 let Inst{22} = 0; // D = 0
2300 let Inst{20} = load;
2301 }
2302
2303 def _OPTION : ACI<(outs),
2304 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option),
2305 opc, "\tp$cop, cr$CRd, [$base], $option"> {
2306 let Inst{31-28} = op31_28;
2307 let Inst{24} = 0; // P = 0
2308 let Inst{23} = 1; // U = 1
2309 let Inst{21} = 0; // W = 0
2310 let Inst{22} = 0; // D = 0
2311 let Inst{20} = load;
2312 }
2313
2314 def L_OFFSET : ACI<(outs),
2315 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2316 opc, "l\tp$cop, cr$CRd, $addr"> {
2317 let Inst{31-28} = op31_28;
2318 let Inst{24} = 1; // P = 1
2319 let Inst{21} = 0; // W = 0
2320 let Inst{22} = 1; // D = 1
2321 let Inst{20} = load;
2322 }
2323
2324 def L_PRE : ACI<(outs),
2325 (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
2326 opc, "l\tp$cop, cr$CRd, $addr!"> {
2327 let Inst{31-28} = op31_28;
2328 let Inst{24} = 1; // P = 1
2329 let Inst{21} = 1; // W = 1
2330 let Inst{22} = 1; // D = 1
2331 let Inst{20} = load;
2332 }
2333
2334 def L_POST : ACI<(outs),
2335 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset),
2336 opc, "l\tp$cop, cr$CRd, [$base], $offset"> {
2337 let Inst{31-28} = op31_28;
2338 let Inst{24} = 0; // P = 0
2339 let Inst{21} = 1; // W = 1
2340 let Inst{22} = 1; // D = 1
2341 let Inst{20} = load;
2342 }
2343
2344 def L_OPTION : ACI<(outs),
2345 (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option),
2346 opc, "l\tp$cop, cr$CRd, [$base], $option"> {
2347 let Inst{31-28} = op31_28;
2348 let Inst{24} = 0; // P = 0
2349 let Inst{23} = 1; // U = 1
2350 let Inst{21} = 0; // W = 0
2351 let Inst{22} = 1; // D = 1
2352 let Inst{20} = load;
2353 }
2354}
2355
2356defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">;
2357defm LDC2 : LdStCop<0b1111, 1, "ldc2">;
2358defm STC : LdStCop<{?,?,?,?}, 0, "stc">;
2359defm STC2 : LdStCop<0b1111, 0, "stc2">;
2360
Johnny Chenedf090c2010-02-12 01:44:23 +00002361def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2362 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2363 NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2364 [/* For disassembly only; pattern left blank */]> {
2365 let Inst{20} = 0;
2366 let Inst{4} = 1;
2367}
2368
2369def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2370 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2371 NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2372 [/* For disassembly only; pattern left blank */]> {
2373 let Inst{31-28} = 0b1111;
2374 let Inst{20} = 0;
2375 let Inst{4} = 1;
2376}
2377
2378def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2379 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2380 NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2381 [/* For disassembly only; pattern left blank */]> {
2382 let Inst{20} = 1;
2383 let Inst{4} = 1;
2384}
2385
2386def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1,
2387 GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2),
2388 NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2",
2389 [/* For disassembly only; pattern left blank */]> {
2390 let Inst{31-28} = 0b1111;
2391 let Inst{20} = 1;
2392 let Inst{4} = 1;
2393}
2394
2395def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2396 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2397 NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2398 [/* For disassembly only; pattern left blank */]> {
2399 let Inst{23-20} = 0b0100;
2400}
2401
2402def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2403 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2404 NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2405 [/* For disassembly only; pattern left blank */]> {
2406 let Inst{31-28} = 0b1111;
2407 let Inst{23-20} = 0b0100;
2408}
2409
2410def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2411 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2412 NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2413 [/* For disassembly only; pattern left blank */]> {
2414 let Inst{23-20} = 0b0101;
2415}
2416
2417def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc,
2418 GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm),
2419 NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm",
2420 [/* For disassembly only; pattern left blank */]> {
2421 let Inst{31-28} = 0b1111;
2422 let Inst{23-20} = 0b0101;
2423}
2424
Johnny Chenb8689012010-02-12 18:55:33 +00002425//===----------------------------------------------------------------------===//
2426// Move between special register and ARM core register -- for disassembly only
2427//
2428
2429def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr",
2430 [/* For disassembly only; pattern left blank */]> {
2431 let Inst{23-20} = 0b0000;
2432 let Inst{7-4} = 0b0000;
2433}
2434
2435def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr",
2436 [/* For disassembly only; pattern left blank */]> {
2437 let Inst{23-20} = 0b0100;
2438 let Inst{7-4} = 0b0000;
2439}
2440
2441// FIXME: mask is ignored for the time being.
Johnny Chena6ad7432010-02-16 20:04:27 +00002442def MSR : ABI<0b0001,(outs),(ins GPR:$src), NoItinerary, "msr", "\tcpsr, $src",
Johnny Chenb8689012010-02-12 18:55:33 +00002443 [/* For disassembly only; pattern left blank */]> {
2444 let Inst{23-20} = 0b0010;
2445 let Inst{7-4} = 0b0000;
2446}
2447
2448// FIXME: mask is ignored for the time being.
Johnny Chena6ad7432010-02-16 20:04:27 +00002449def MSRi : ABI<0b0011,(outs),(ins so_imm:$a), NoItinerary, "msr", "\tcpsr, $a",
2450 [/* For disassembly only; pattern left blank */]> {
2451 let Inst{23-20} = 0b0010;
2452 let Inst{7-4} = 0b0000;
2453}
2454
2455// FIXME: mask is ignored for the time being.
2456def MSRsys : ABI<0b0001,(outs),(ins GPR:$src),NoItinerary,"msr","\tspsr, $src",
2457 [/* For disassembly only; pattern left blank */]> {
2458 let Inst{23-20} = 0b0110;
2459 let Inst{7-4} = 0b0000;
2460}
2461
2462// FIXME: mask is ignored for the time being.
2463def MSRsysi : ABI<0b0011,(outs),(ins so_imm:$a),NoItinerary,"msr","\tspsr, $a",
Johnny Chenb8689012010-02-12 18:55:33 +00002464 [/* For disassembly only; pattern left blank */]> {
2465 let Inst{23-20} = 0b0110;
2466 let Inst{7-4} = 0b0000;
2467}