blob: 07119a2edb92f817aa3f59c3d5ca1a97ab3aa4e1 [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
37def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
38
39def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
40 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
41
42def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
43
44// Node definitions.
45def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
46def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
47
Bill Wendling7173da52007-11-13 09:19:02 +000048def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
Bill Wendling6c02cd22008-02-27 06:33:05 +000049 [SDNPHasChain, SDNPOutFlag]>;
Bill Wendling7173da52007-11-13 09:19:02 +000050def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
Bill Wendling6c02cd22008-02-27 06:33:05 +000051 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
53def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
54 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
55def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
56 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
57def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
58 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
59
Chris Lattner3d254552008-01-15 22:02:54 +000060def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 [SDNPHasChain, SDNPOptInFlag]>;
62
63def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
64 [SDNPInFlag]>;
65def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
66 [SDNPInFlag]>;
67
68def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
69 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
70
71def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
72 [SDNPHasChain]>;
73
74def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
75 [SDNPOutFlag]>;
76
77def ARMcmpNZ : SDNode<"ARMISD::CMPNZ", SDT_ARMCmp,
78 [SDNPOutFlag]>;
79
80def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
81
82def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
83def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
84def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
85
86def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
87
88//===----------------------------------------------------------------------===//
89// ARM Instruction Predicate Definitions.
90//
91def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
92def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
93def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
94def IsThumb : Predicate<"Subtarget->isThumb()">;
95def IsARM : Predicate<"!Subtarget->isThumb()">;
96
97//===----------------------------------------------------------------------===//
98// ARM Flag Definitions.
99
100class RegConstraint<string C> {
101 string Constraints = C;
102}
103
104//===----------------------------------------------------------------------===//
105// ARM specific transformation functions and pattern fragments.
106//
107
108// so_imm_XFORM - Return a so_imm value packed into the format described for
109// so_imm def below.
110def so_imm_XFORM : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000111 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(N->getZExtValue()),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000112 MVT::i32);
113}]>;
114
115// so_imm_neg_XFORM - Return a so_imm value packed into the format described for
116// so_imm_neg def below.
117def so_imm_neg_XFORM : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000118 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(-(int)N->getZExtValue()),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000119 MVT::i32);
120}]>;
121
122// so_imm_not_XFORM - Return a so_imm value packed into the format described for
123// so_imm_not def below.
124def so_imm_not_XFORM : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000125 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(~(int)N->getZExtValue()),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126 MVT::i32);
127}]>;
128
129// rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
130def rot_imm : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000131 int32_t v = (int32_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132 return v == 8 || v == 16 || v == 24;
133}]>;
134
135/// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
136def imm1_15 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000137 return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138}]>;
139
140/// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
141def imm16_31 : PatLeaf<(i32 imm), [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000142 return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143}]>;
144
145def so_imm_neg :
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000146 PatLeaf<(imm), [{
147 return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1;
148 }], so_imm_neg_XFORM>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149
150def so_imm_not :
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000151 PatLeaf<(imm), [{
152 return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1;
153 }], so_imm_not_XFORM>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154
155// sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
156def sext_16_node : PatLeaf<(i32 GPR:$a), [{
Dan Gohman8181bd12008-07-27 21:46:04 +0000157 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158}]>;
159
Evan Cheng7b0249b2008-08-28 23:39:26 +0000160class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
161class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162
163//===----------------------------------------------------------------------===//
164// Operand Definitions.
165//
166
167// Branch target.
168def brtarget : Operand<OtherVT>;
169
170// A list of registers separated by comma. Used by load/store multiple.
171def reglist : Operand<i32> {
172 let PrintMethod = "printRegisterList";
173}
174
175// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
176def cpinst_operand : Operand<i32> {
177 let PrintMethod = "printCPInstOperand";
178}
179
180def jtblock_operand : Operand<i32> {
181 let PrintMethod = "printJTBlockOperand";
182}
183
184// Local PC labels.
185def pclabel : Operand<i32> {
186 let PrintMethod = "printPCLabel";
187}
188
189// shifter_operand operands: so_reg and so_imm.
190def so_reg : Operand<i32>, // reg reg imm
191 ComplexPattern<i32, 3, "SelectShifterOperandReg",
192 [shl,srl,sra,rotr]> {
193 let PrintMethod = "printSORegOperand";
194 let MIOperandInfo = (ops GPR, GPR, i32imm);
195}
196
197// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
198// 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
199// represented in the imm field in the same 12-bit form that they are encoded
200// into so_imm instructions: the 8-bit immediate is the least significant bits
201// [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
202def so_imm : Operand<i32>,
203 PatLeaf<(imm),
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000204 [{ return ARM_AM::getSOImmVal(N->getZExtValue()) != -1; }],
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 so_imm_XFORM> {
206 let PrintMethod = "printSOImmOperand";
207}
208
209// Break so_imm's up into two pieces. This handles immediates with up to 16
210// bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
211// get the first/second pieces.
212def so_imm2part : Operand<i32>,
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000213 PatLeaf<(imm), [{
214 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
215 }]> {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216 let PrintMethod = "printSOImm2PartOperand";
217}
218
219def so_imm2part_1 : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000220 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
222}]>;
223
224def so_imm2part_2 : SDNodeXForm<imm, [{
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000225 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
227}]>;
228
229
230// Define ARM specific addressing modes.
231
232// addrmode2 := reg +/- reg shop imm
233// addrmode2 := reg +/- imm12
234//
235def addrmode2 : Operand<i32>,
236 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
237 let PrintMethod = "printAddrMode2Operand";
238 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
239}
240
241def am2offset : Operand<i32>,
242 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
243 let PrintMethod = "printAddrMode2OffsetOperand";
244 let MIOperandInfo = (ops GPR, i32imm);
245}
246
247// addrmode3 := reg +/- reg
248// addrmode3 := reg +/- imm8
249//
250def addrmode3 : Operand<i32>,
251 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
252 let PrintMethod = "printAddrMode3Operand";
253 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
254}
255
256def am3offset : Operand<i32>,
257 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
258 let PrintMethod = "printAddrMode3OffsetOperand";
259 let MIOperandInfo = (ops GPR, i32imm);
260}
261
262// addrmode4 := reg, <mode|W>
263//
264def addrmode4 : Operand<i32>,
265 ComplexPattern<i32, 2, "", []> {
266 let PrintMethod = "printAddrMode4Operand";
267 let MIOperandInfo = (ops GPR, i32imm);
268}
269
270// addrmode5 := reg +/- imm8*4
271//
272def addrmode5 : Operand<i32>,
273 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
274 let PrintMethod = "printAddrMode5Operand";
275 let MIOperandInfo = (ops GPR, i32imm);
276}
277
278// addrmodepc := pc + reg
279//
280def addrmodepc : Operand<i32>,
281 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
282 let PrintMethod = "printAddrModePCOperand";
283 let MIOperandInfo = (ops GPR, i32imm);
284}
285
286// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
287// register whose default is 0 (no register).
288def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
289 (ops (i32 14), (i32 zero_reg))> {
290 let PrintMethod = "printPredicateOperand";
291}
292
293// Conditional code result for instructions whose 's' bit is set, e.g. subs.
294//
295def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
296 let PrintMethod = "printSBitModifierOperand";
297}
298
299//===----------------------------------------------------------------------===//
300// ARM Instruction flags. These need to match ARMInstrInfo.h.
301//
302
303// Addressing mode.
304class AddrMode<bits<4> val> {
305 bits<4> Value = val;
306}
307def AddrModeNone : AddrMode<0>;
308def AddrMode1 : AddrMode<1>;
309def AddrMode2 : AddrMode<2>;
310def AddrMode3 : AddrMode<3>;
311def AddrMode4 : AddrMode<4>;
312def AddrMode5 : AddrMode<5>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000313def AddrModeT1 : AddrMode<6>;
314def AddrModeT2 : AddrMode<7>;
315def AddrModeT4 : AddrMode<8>;
316def AddrModeTs : AddrMode<9>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317
318// Instruction size.
319class SizeFlagVal<bits<3> val> {
320 bits<3> Value = val;
321}
322def SizeInvalid : SizeFlagVal<0>; // Unset.
323def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
324def Size8Bytes : SizeFlagVal<2>;
325def Size4Bytes : SizeFlagVal<3>;
326def Size2Bytes : SizeFlagVal<4>;
327
328// Load / store index mode.
329class IndexMode<bits<2> val> {
330 bits<2> Value = val;
331}
332def IndexModeNone : IndexMode<0>;
333def IndexModePre : IndexMode<1>;
334def IndexModePost : IndexMode<2>;
335
336//===----------------------------------------------------------------------===//
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000337
Evan Cheng7b0249b2008-08-28 23:39:26 +0000338include "ARMInstrFormats.td"
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000339
340//===----------------------------------------------------------------------===//
Evan Cheng7b0249b2008-08-28 23:39:26 +0000341// Multiclass helpers...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342//
343
Evan Cheng40d64532008-08-29 07:36:24 +0000344/// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345/// binop that produces a value.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000346multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000347 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348 opc, " $dst, $a, $b",
349 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000350 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 opc, " $dst, $a, $b",
352 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000353 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 opc, " $dst, $a, $b",
355 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
356}
357
358/// ASI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
359/// instruction modifies the CSPR register.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000360let Defs = [CPSR] in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000361multiclass ASI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000362 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 opc, "s $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000364 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000365 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366 opc, "s $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000367 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000368 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 opc, "s $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000370 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
371}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372}
373
374/// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
375/// patterns. Similar to AsI1_bin_irs except the instruction does not produce
376/// a explicit result, only implicitly set CPSR.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000377let Defs = [CPSR] in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000378multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode> {
Evan Cheng86a926a2008-11-05 18:35:52 +0000379 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380 opc, " $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000381 [(opnode GPR:$a, so_imm:$b)]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000382 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383 opc, " $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000384 [(opnode GPR:$a, GPR:$b)]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000385 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386 opc, " $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000387 [(opnode GPR:$a, so_reg:$b)]>;
388}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389}
390
391/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
392/// register and one whose operand is a register rotated by 8/16/24.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000393multiclass AI_unary_rrot<bits<4> opcod, string opc, PatFrag opnode> {
394 def r : AI<opcod, (outs GPR:$dst), (ins GPR:$Src), Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000395 opc, " $dst, $Src",
396 [(set GPR:$dst, (opnode GPR:$Src))]>, Requires<[IsARM, HasV6]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000397 def r_rot : AI<opcod, (outs GPR:$dst), (ins GPR:$Src, i32imm:$rot), Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398 opc, " $dst, $Src, ror $rot",
399 [(set GPR:$dst, (opnode (rotr GPR:$Src, rot_imm:$rot)))]>,
400 Requires<[IsARM, HasV6]>;
401}
402
403/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
404/// register and one whose operand is a register rotated by 8/16/24.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000405multiclass AI_bin_rrot<bits<4> opcod, string opc, PatFrag opnode> {
406 def rr : AI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
407 Pseudo, opc, " $dst, $LHS, $RHS",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
409 Requires<[IsARM, HasV6]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000410 def rr_rot : AI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot),
411 Pseudo, opc, " $dst, $LHS, $RHS, ror $rot",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 [(set GPR:$dst, (opnode GPR:$LHS,
413 (rotr GPR:$RHS, rot_imm:$rot)))]>,
414 Requires<[IsARM, HasV6]>;
415}
416
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417/// AsXI1_bin_c_irs - Same as AsI1_bin_irs but without the predicate operand and
418/// setting carry bit. But it can optionally set CPSR.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000419let Uses = [CPSR] in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000420multiclass AsXI1_bin_c_irs<bits<4> opcod, string opc, PatFrag opnode> {
421 def ri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b, cc_out:$s),
Evan Cheng86a926a2008-11-05 18:35:52 +0000422 DPFrm, !strconcat(opc, "${s} $dst, $a, $b"),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000423 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000424 def rr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, cc_out:$s),
Evan Cheng86a926a2008-11-05 18:35:52 +0000425 DPFrm, !strconcat(opc, "${s} $dst, $a, $b"),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000426 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000427 def rs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b, cc_out:$s),
Evan Cheng86a926a2008-11-05 18:35:52 +0000428 DPSoRegFrm, !strconcat(opc, "${s} $dst, $a, $b"),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000429 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
430}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431}
432
433//===----------------------------------------------------------------------===//
434// Instructions
435//===----------------------------------------------------------------------===//
436
437//===----------------------------------------------------------------------===//
438// Miscellaneous Instructions.
439//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440
441/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
442/// the function. The first operand is the ID# for this instruction, the second
443/// is the index into the MachineConstantPool that this is, the third is the
444/// size in bytes of this constant pool entry.
445let isNotDuplicable = 1 in
446def CONSTPOOL_ENTRY :
Evan Chengb783fa32007-07-19 01:14:50 +0000447PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
448 i32imm:$size),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449 "${instid:label} ${cpidx:cpentry}", []>;
450
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000451let Defs = [SP], Uses = [SP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452def ADJCALLSTACKUP :
Bill Wendling22f8deb2007-11-13 00:44:25 +0000453PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p),
454 "@ ADJCALLSTACKUP $amt1",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000455 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456
457def ADJCALLSTACKDOWN :
Evan Chengb783fa32007-07-19 01:14:50 +0000458PseudoInst<(outs), (ins i32imm:$amt, pred:$p),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459 "@ ADJCALLSTACKDOWN $amt",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000460 [(ARMcallseq_start timm:$amt)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000461}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462
463def DWARF_LOC :
Evan Chengb783fa32007-07-19 01:14:50 +0000464PseudoInst<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465 ".loc $file, $line, $col",
466 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
467
468let isNotDuplicable = 1 in {
Evan Cheng0d28b382008-10-31 19:11:09 +0000469def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000470 Pseudo, "$cp:\n\tadd$p $dst, pc, $a",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
472
Evan Cheng8610a3b2008-01-07 23:56:57 +0000473let AddedComplexity = 10 in {
474let isSimpleLoad = 1 in
Evan Chengae7b1d72008-09-01 07:34:13 +0000475def PICLD : AXI2ldw<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000476 Pseudo, "${addr:label}:\n\tldr$p $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477 [(set GPR:$dst, (load addrmodepc:$addr))]>;
478
Evan Chengae7b1d72008-09-01 07:34:13 +0000479def PICLDZH : AXI3ldh<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000480 Pseudo, "${addr:label}:\n\tldr${p}h $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
482
Evan Chengae7b1d72008-09-01 07:34:13 +0000483def PICLDZB : AXI2ldb<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000484 Pseudo, "${addr:label}:\n\tldr${p}b $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
486
Evan Chengae7b1d72008-09-01 07:34:13 +0000487def PICLDH : AXI3ldh<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000488 Pseudo, "${addr:label}:\n\tldr${p}h $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489 [(set GPR:$dst, (extloadi16 addrmodepc:$addr))]>;
490
Evan Chengae7b1d72008-09-01 07:34:13 +0000491def PICLDB : AXI2ldb<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000492 Pseudo, "${addr:label}:\n\tldr${p}b $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 [(set GPR:$dst, (extloadi8 addrmodepc:$addr))]>;
494
Evan Chengae7b1d72008-09-01 07:34:13 +0000495def PICLDSH : AXI3ldsh<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000496 Pseudo, "${addr:label}:\n\tldr${p}sh $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
498
Evan Chengae7b1d72008-09-01 07:34:13 +0000499def PICLDSB : AXI3ldsb<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000500 Pseudo, "${addr:label}:\n\tldr${p}sb $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
502}
Chris Lattnerf823faf2008-01-06 05:55:01 +0000503let AddedComplexity = 10 in {
Evan Chengae7b1d72008-09-01 07:34:13 +0000504def PICSTR : AXI2stw<0x0, (outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000505 Pseudo, "${addr:label}:\n\tstr$p $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506 [(store GPR:$src, addrmodepc:$addr)]>;
507
Evan Chengae7b1d72008-09-01 07:34:13 +0000508def PICSTRH : AXI3sth<0x0, (outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000509 Pseudo, "${addr:label}:\n\tstr${p}h $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
511
Evan Chengae7b1d72008-09-01 07:34:13 +0000512def PICSTRB : AXI2stb<0x0, (outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000513 Pseudo, "${addr:label}:\n\tstr${p}b $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
515}
516}
517
518//===----------------------------------------------------------------------===//
519// Control Flow Instructions.
520//
521
522let isReturn = 1, isTerminator = 1 in
Evan Cheng469bc762008-09-17 07:53:38 +0000523 def BX_RET : AI<0x0, (outs), (ins), BranchMisc, "bx", " lr", [(ARMretflag)]> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000524 let Inst{7-4} = 0b0001;
525 let Inst{19-8} = 0b111111111111;
526 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000527}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528
529// FIXME: remove when we have a way to marking a MI with these properties.
Evan Chengb783fa32007-07-19 01:14:50 +0000530// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
531// operand list.
Evan Cheng8610a3b2008-01-07 23:56:57 +0000532let isReturn = 1, isTerminator = 1 in
Evan Chengd36b01c2008-09-01 07:48:18 +0000533 def LDM_RET : AXI4ldpc<0x0, (outs),
Evan Chengb783fa32007-07-19 01:14:50 +0000534 (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
Evan Cheng86a926a2008-11-05 18:35:52 +0000535 LdMulFrm, "ldm${p}${addr:submode} $addr, $dst1",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 []>;
537
Evan Cheng37e7c752007-07-21 00:34:19 +0000538let isCall = 1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 Defs = [R0, R1, R2, R3, R12, LR,
540 D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in {
Evan Cheng10a9eb82008-09-01 08:25:56 +0000541 def BL : ABLI<0xB, (outs), (ins i32imm:$func, variable_ops), Branch,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 "bl ${func:call}",
543 [(ARMcall tglobaladdr:$func)]>;
544
Evan Cheng10a9eb82008-09-01 08:25:56 +0000545 def BL_pred : ABLpredI<0xB, (outs), (ins i32imm:$func, variable_ops), Branch,
546 "bl", " ${func:call}",
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000547 [(ARMcall_pred tglobaladdr:$func)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548
549 // ARMv5T and above
Evan Cheng469bc762008-09-17 07:53:38 +0000550 def BLX : AXI<0x0, (outs), (ins GPR:$func, variable_ops), BranchMisc,
Evan Chengb783fa32007-07-19 01:14:50 +0000551 "blx $func",
Evan Cheng469bc762008-09-17 07:53:38 +0000552 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T]> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000553 let Inst{7-4} = 0b0011;
554 let Inst{19-8} = 0b111111111111;
555 let Inst{27-20} = 0b00010010;
Evan Cheng469bc762008-09-17 07:53:38 +0000556 }
557
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 let Uses = [LR] in {
559 // ARMv4T
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000560 def BX : AXIx2<0x0, (outs), (ins GPR:$func, variable_ops),
561 BranchMisc, "mov lr, pc\n\tbx $func",
562 [(ARMcall_nolink GPR:$func)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 }
564}
565
Evan Cheng37e7c752007-07-21 00:34:19 +0000566let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567 // B is "predicable" since it can be xformed into a Bcc.
568 let isBarrier = 1 in {
569 let isPredicable = 1 in
Jim Grosbach88c246f2008-10-14 20:36:24 +0000570 def B : ABI<0xA, (outs), (ins brtarget:$target), Branch, "b $target",
Evan Chengb783fa32007-07-19 01:14:50 +0000571 [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572
Owen Andersonf8053082007-11-12 07:39:39 +0000573 let isNotDuplicable = 1, isIndirectBranch = 1 in {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000574 def BR_JTr : JTI<0b1101, (outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengb783fa32007-07-19 01:14:50 +0000575 "mov pc, $target \n$jt",
576 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000577 def BR_JTm : JTI2<0x0, (outs), (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengb783fa32007-07-19 01:14:50 +0000578 "ldr pc, $target \n$jt",
579 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 imm:$id)]>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000581 def BR_JTadd : JTI1<0b0100, (outs), (ins GPR:$target, GPR:$idx, jtblock_operand:$jt,
Evan Chengb783fa32007-07-19 01:14:50 +0000582 i32imm:$id),
583 "add pc, $target, $idx \n$jt",
584 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 imm:$id)]>;
586 }
587 }
588
589 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
590 // a two-value operand where a dag node expects two operands. :(
Evan Cheng10a9eb82008-09-01 08:25:56 +0000591 def Bcc : ABccI<0xA, (outs), (ins brtarget:$target), Branch,
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000592 "b", " $target",
593 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594}
595
596//===----------------------------------------------------------------------===//
597// Load / store Instructions.
598//
599
600// Load
Evan Cheng8610a3b2008-01-07 23:56:57 +0000601let isSimpleLoad = 1 in
Evan Chengda020022008-08-31 19:02:21 +0000602def LDR : AI2ldw<0x0, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 "ldr", " $dst, $addr",
604 [(set GPR:$dst, (load addrmode2:$addr))]>;
605
606// Special LDR for loads from non-pc-relative constpools.
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000607let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Evan Chengda020022008-08-31 19:02:21 +0000608def LDRcp : AI2ldw<0x0, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 "ldr", " $dst, $addr", []>;
610
611// Loads with zero extension
Evan Cheng86a926a2008-11-05 18:35:52 +0000612def LDRH : AI3ldh<0xB, (outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613 "ldr", "h $dst, $addr",
614 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
615
Evan Chengda020022008-08-31 19:02:21 +0000616def LDRB : AI2ldb<0x1, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617 "ldr", "b $dst, $addr",
618 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
619
620// Loads with sign extension
Evan Cheng86a926a2008-11-05 18:35:52 +0000621def LDRSH : AI3ldsh<0xE, (outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 "ldr", "sh $dst, $addr",
623 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
624
Evan Cheng86a926a2008-11-05 18:35:52 +0000625def LDRSB : AI3ldsb<0xD, (outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626 "ldr", "sb $dst, $addr",
627 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
628
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000629let mayLoad = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630// Load doubleword
Evan Cheng86a926a2008-11-05 18:35:52 +0000631def LDRD : AI3ldd<0xD, (outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 "ldr", "d $dst, $addr",
633 []>, Requires<[IsARM, HasV5T]>;
634
635// Indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000636def LDR_PRE : AI2ldwpr<0x0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000637 (ins addrmode2:$addr), LdFrm,
638 "ldr", " $dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000640def LDR_POST : AI2ldwpo<0x0, (outs GPR:$dst, GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000641 (ins GPR:$base, am2offset:$offset), LdFrm,
642 "ldr", " $dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643
Evan Chengac92c3f2008-09-01 07:00:14 +0000644def LDRH_PRE : AI3ldhpr<0xB, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000645 (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 "ldr", "h $dst, $addr!", "$addr.base = $base_wb", []>;
647
Evan Chengac92c3f2008-09-01 07:00:14 +0000648def LDRH_POST : AI3ldhpo<0xB, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000649 (ins GPR:$base,am3offset:$offset), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650 "ldr", "h $dst, [$base], $offset", "$base = $base_wb", []>;
651
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000652def LDRB_PRE : AI2ldbpr<0x1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000653 (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 "ldr", "b $dst, $addr!", "$addr.base = $base_wb", []>;
655
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000656def LDRB_POST : AI2ldbpo<0x1, (outs GPR:$dst, GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000657 (ins GPR:$base,am2offset:$offset), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 "ldr", "b $dst, [$base], $offset", "$base = $base_wb", []>;
659
Evan Chengac92c3f2008-09-01 07:00:14 +0000660def LDRSH_PRE : AI3ldshpr<0xE, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000661 (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 "ldr", "sh $dst, $addr!", "$addr.base = $base_wb", []>;
663
Evan Chengac92c3f2008-09-01 07:00:14 +0000664def LDRSH_POST: AI3ldshpo<0xE, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000665 (ins GPR:$base,am3offset:$offset), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 "ldr", "sh $dst, [$base], $offset", "$base = $base_wb", []>;
667
Evan Chengac92c3f2008-09-01 07:00:14 +0000668def LDRSB_PRE : AI3ldsbpr<0xD, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000669 (ins addrmode3:$addr), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 "ldr", "sb $dst, $addr!", "$addr.base = $base_wb", []>;
671
Evan Chengac92c3f2008-09-01 07:00:14 +0000672def LDRSB_POST: AI3ldsbpo<0xD, (outs GPR:$dst, GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000673 (ins GPR:$base,am3offset:$offset), LdMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 "ldr", "sb $dst, [$base], $offset", "$base = $base_wb", []>;
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000675}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676
677// Store
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000678def STR : AI2stw<0x0, (outs), (ins GPR:$src, addrmode2:$addr), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 "str", " $src, $addr",
680 [(store GPR:$src, addrmode2:$addr)]>;
681
682// Stores with truncate
Evan Cheng86a926a2008-11-05 18:35:52 +0000683def STRH : AI3sth<0xB, (outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 "str", "h $src, $addr",
685 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
686
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000687def STRB : AI2stb<0x1, (outs), (ins GPR:$src, addrmode2:$addr), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 "str", "b $src, $addr",
689 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
690
691// Store doubleword
Chris Lattner6887b142008-01-06 08:36:04 +0000692let mayStore = 1 in
Evan Cheng86a926a2008-11-05 18:35:52 +0000693def STRD : AI3std<0xF, (outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 "str", "d $src, $addr",
695 []>, Requires<[IsARM, HasV5T]>;
696
697// Indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000698def STR_PRE : AI2stwpr<0x0, (outs GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000699 (ins GPR:$src, GPR:$base, am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 "str", " $src, [$base, $offset]!", "$base = $base_wb",
701 [(set GPR:$base_wb,
702 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
703
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000704def STR_POST : AI2stwpo<0x0, (outs GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000705 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 "str", " $src, [$base], $offset", "$base = $base_wb",
707 [(set GPR:$base_wb,
708 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
709
Evan Chengac92c3f2008-09-01 07:00:14 +0000710def STRH_PRE : AI3sthpr<0xB, (outs GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000711 (ins GPR:$src, GPR:$base,am3offset:$offset), StMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 "str", "h $src, [$base, $offset]!", "$base = $base_wb",
713 [(set GPR:$base_wb,
714 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
715
Evan Chengac92c3f2008-09-01 07:00:14 +0000716def STRH_POST: AI3sthpo<0xB, (outs GPR:$base_wb),
Evan Cheng86a926a2008-11-05 18:35:52 +0000717 (ins GPR:$src, GPR:$base,am3offset:$offset), StMiscFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 "str", "h $src, [$base], $offset", "$base = $base_wb",
719 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
720 GPR:$base, am3offset:$offset))]>;
721
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000722def STRB_PRE : AI2stbpr<0x1, (outs GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000723 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 "str", "b $src, [$base, $offset]!", "$base = $base_wb",
725 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
726 GPR:$base, am2offset:$offset))]>;
727
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000728def STRB_POST: AI2stbpo<0x1, (outs GPR:$base_wb),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000729 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 "str", "b $src, [$base], $offset", "$base = $base_wb",
731 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
732 GPR:$base, am2offset:$offset))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733
734//===----------------------------------------------------------------------===//
735// Load / store multiple Instructions.
736//
737
Evan Chengb783fa32007-07-19 01:14:50 +0000738// FIXME: $dst1 should be a def.
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000739let mayLoad = 1 in
Evan Chengd36b01c2008-09-01 07:48:18 +0000740def LDM : AXI4ld<0x0, (outs),
Evan Chengb783fa32007-07-19 01:14:50 +0000741 (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
Evan Cheng86a926a2008-11-05 18:35:52 +0000742 LdMulFrm, "ldm${p}${addr:submode} $addr, $dst1",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 []>;
744
Chris Lattner6887b142008-01-06 08:36:04 +0000745let mayStore = 1 in
Evan Chengd36b01c2008-09-01 07:48:18 +0000746def STM : AXI4st<0x0, (outs),
Evan Chengb783fa32007-07-19 01:14:50 +0000747 (ins addrmode4:$addr, pred:$p, reglist:$src1, variable_ops),
Evan Cheng86a926a2008-11-05 18:35:52 +0000748 StMulFrm, "stm${p}${addr:submode} $addr, $src1",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 []>;
750
751//===----------------------------------------------------------------------===//
752// Move Instructions.
753//
754
Evan Cheng86a926a2008-11-05 18:35:52 +0000755def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm,
756 "mov", " $dst, $src", []>, UnaryDP;
757def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
758 "mov", " $dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759
760let isReMaterializable = 1 in
Evan Cheng86a926a2008-11-05 18:35:52 +0000761def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm,
762 "mov", " $dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763
Evan Cheng86a926a2008-11-05 18:35:52 +0000764def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000765 "mov", " $dst, $src, rrx",
Evan Cheng86a926a2008-11-05 18:35:52 +0000766 [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767
768// These aren't really mov instructions, but we have to define them this way
769// due to flag operands.
770
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771let Defs = [CPSR] in {
Evan Cheng86a926a2008-11-05 18:35:52 +0000772def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 "mov", "s $dst, $src, lsr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +0000774 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP;
775def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 "mov", "s $dst, $src, asr #1",
Evan Cheng86a926a2008-11-05 18:35:52 +0000777 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779
780//===----------------------------------------------------------------------===//
781// Extend Instructions.
782//
783
784// Sign extenders
785
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000786defm SXTB : AI_unary_rrot<0x0, "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
787defm SXTH : AI_unary_rrot<0x0, "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000789defm SXTAB : AI_bin_rrot<0x0, "sxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000791defm SXTAH : AI_bin_rrot<0x0, "sxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
793
794// TODO: SXT(A){B|H}16
795
796// Zero extenders
797
798let AddedComplexity = 16 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000799defm UXTB : AI_unary_rrot<0x0, "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
800defm UXTH : AI_unary_rrot<0x0, "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
801defm UXTB16 : AI_unary_rrot<0x0, "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802
803def : ARMV6Pat<(and (shl GPR:$Src, 8), 0xFF00FF),
804 (UXTB16r_rot GPR:$Src, 24)>;
805def : ARMV6Pat<(and (srl GPR:$Src, 8), 0xFF00FF),
806 (UXTB16r_rot GPR:$Src, 8)>;
807
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000808defm UXTAB : AI_bin_rrot<0x0, "uxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000810defm UXTAH : AI_bin_rrot<0x0, "uxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
812}
813
814// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
815//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
816
817// TODO: UXT(A){B|H}16
818
819//===----------------------------------------------------------------------===//
820// Arithmetic Instructions.
821//
822
Jim Grosbach88c246f2008-10-14 20:36:24 +0000823defm ADD : AsI1_bin_irs<0b0100, "add",
Evan Cheng469bc762008-09-17 07:53:38 +0000824 BinOpFrag<(add node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000825defm SUB : AsI1_bin_irs<0b0010, "sub",
Evan Cheng469bc762008-09-17 07:53:38 +0000826 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827
828// ADD and SUB with 's' bit set.
Jim Grosbach88c246f2008-10-14 20:36:24 +0000829defm ADDS : ASI1_bin_s_irs<0b0100, "add",
Evan Cheng469bc762008-09-17 07:53:38 +0000830 BinOpFrag<(addc node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000831defm SUBS : ASI1_bin_s_irs<0b0010, "sub",
Evan Cheng469bc762008-09-17 07:53:38 +0000832 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833
834// FIXME: Do not allow ADC / SBC to be predicated for now.
Jim Grosbach88c246f2008-10-14 20:36:24 +0000835defm ADC : AsXI1_bin_c_irs<0b0101, "adc",
Evan Cheng469bc762008-09-17 07:53:38 +0000836 BinOpFrag<(adde node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000837defm SBC : AsXI1_bin_c_irs<0b0110, "sbc",
Evan Cheng469bc762008-09-17 07:53:38 +0000838 BinOpFrag<(sube node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839
840// These don't define reg/reg forms, because they are handled above.
Evan Cheng86a926a2008-11-05 18:35:52 +0000841def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 "rsb", " $dst, $a, $b",
843 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]>;
844
Evan Cheng86a926a2008-11-05 18:35:52 +0000845def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 "rsb", " $dst, $a, $b",
847 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]>;
848
849// RSB with 's' bit set.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000850let Defs = [CPSR] in {
Evan Cheng86a926a2008-11-05 18:35:52 +0000851def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 "rsb", "s $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000853 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]>;
Evan Cheng86a926a2008-11-05 18:35:52 +0000854def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 "rsb", "s $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000856 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]>;
857}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858
859// FIXME: Do not allow RSC to be predicated for now. But they can set CPSR.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000860let Uses = [CPSR] in {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000861def RSCri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b, cc_out:$s),
Evan Cheng86a926a2008-11-05 18:35:52 +0000862 DPFrm, "rsc${s} $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000863 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000864def RSCrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b, cc_out:$s),
Evan Cheng86a926a2008-11-05 18:35:52 +0000865 DPSoRegFrm, "rsc${s} $dst, $a, $b",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000866 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>;
867}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868
869// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
870def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
871 (SUBri GPR:$src, so_imm_neg:$imm)>;
872
873//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
874// (SUBSri GPR:$src, so_imm_neg:$imm)>;
875//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
876// (SBCri GPR:$src, so_imm_neg:$imm)>;
877
878// Note: These are implemented in C++ code, because they have to generate
879// ADD/SUBrs instructions, which use a complex pattern that a xform function
880// cannot produce.
881// (mul X, 2^n+1) -> (add (X << n), X)
882// (mul X, 2^n-1) -> (rsb X, (X << n))
883
884
885//===----------------------------------------------------------------------===//
886// Bitwise Instructions.
887//
888
Jim Grosbach88c246f2008-10-14 20:36:24 +0000889defm AND : AsI1_bin_irs<0b0000, "and",
Evan Cheng469bc762008-09-17 07:53:38 +0000890 BinOpFrag<(and node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000891defm ORR : AsI1_bin_irs<0b1100, "orr",
Evan Cheng469bc762008-09-17 07:53:38 +0000892 BinOpFrag<(or node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000893defm EOR : AsI1_bin_irs<0b0001, "eor",
Evan Cheng469bc762008-09-17 07:53:38 +0000894 BinOpFrag<(xor node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +0000895defm BIC : AsI1_bin_irs<0b1110, "bic",
Evan Cheng469bc762008-09-17 07:53:38 +0000896 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897
Evan Cheng86a926a2008-11-05 18:35:52 +0000898def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm,
899 "mvn", " $dst, $src",
900 [(set GPR:$dst, (not GPR:$src))]>, UnaryDP;
901def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm,
902 "mvn", " $dst, $src",
903 [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904let isReMaterializable = 1 in
Evan Cheng86a926a2008-11-05 18:35:52 +0000905def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm,
906 "mvn", " $dst, $imm",
907 [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908
909def : ARMPat<(and GPR:$src, so_imm_not:$imm),
910 (BICri GPR:$src, so_imm_not:$imm)>;
911
912//===----------------------------------------------------------------------===//
913// Multiply Instructions.
914//
915
Evan Cheng86a926a2008-11-05 18:35:52 +0000916def MUL : AsMul1I<0b0000, (outs GPR:$dst), (ins GPR:$a, GPR:$b),
Jim Grosbach1feed042008-11-03 18:38:31 +0000917 "mul", " $dst, $a, $b",
918 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919
Evan Cheng86a926a2008-11-05 18:35:52 +0000920def MLA : AsMul1I<0b0010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
921 "mla", " $dst, $a, $b, $c",
Jim Grosbach1feed042008-11-03 18:38:31 +0000922 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923
924// Extra precision multiplies with low / high results
Evan Cheng86a926a2008-11-05 18:35:52 +0000925def SMULL : AsMul1I<0b1100, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
926 "smull", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927
Evan Cheng86a926a2008-11-05 18:35:52 +0000928def UMULL : AsMul1I<0b1000, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
929 "umull", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930
931// Multiply + accumulate
Evan Cheng86a926a2008-11-05 18:35:52 +0000932def SMLAL : AsMul1I<0b1110, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
933 "smlal", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934
Evan Cheng86a926a2008-11-05 18:35:52 +0000935def UMLAL : AsMul1I<0b1010, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
936 "umlal", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937
Evan Cheng86a926a2008-11-05 18:35:52 +0000938def UMAAL : AMul1I<0b0000, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
939 "umaal", " $ldst, $hdst, $a, $b", []>,
940 Requires<[IsARM, HasV6]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941
942// Most significant word multiply
Jim Grosbach1feed042008-11-03 18:38:31 +0000943// FIXME: encoding
Evan Cheng86a926a2008-11-05 18:35:52 +0000944def SMMUL : AI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm2,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 "smmul", " $dst, $a, $b",
946 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
947 Requires<[IsARM, HasV6]>;
948
Jim Grosbach1feed042008-11-03 18:38:31 +0000949// FIXME: encoding
Evan Cheng86a926a2008-11-05 18:35:52 +0000950def SMMLA : AI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), MulFrm2,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 "smmla", " $dst, $a, $b, $c",
952 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
953 Requires<[IsARM, HasV6]>;
954
955
Jim Grosbach1feed042008-11-03 18:38:31 +0000956// FIXME: encoding
Evan Cheng86a926a2008-11-05 18:35:52 +0000957def SMMLS : AI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), MulFrm2,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 "smmls", " $dst, $a, $b, $c",
959 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
960 Requires<[IsARM, HasV6]>;
961
Jim Grosbach1feed042008-11-03 18:38:31 +0000962// FIXME: encoding
Raul Herbster2e07e8d2007-08-30 23:25:47 +0000963multiclass AI_smul<string opc, PatFrag opnode> {
964 def BB : AI<0x8, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulSMUL,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 !strconcat(opc, "bb"), " $dst, $a, $b",
966 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
967 (sext_inreg GPR:$b, i16)))]>,
968 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +0000969
970 def BT : AI<0xC, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulSMUL,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 !strconcat(opc, "bt"), " $dst, $a, $b",
972 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
973 (sra GPR:$b, 16)))]>,
974 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +0000975
976 def TB : AI<0xA, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulSMUL,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 !strconcat(opc, "tb"), " $dst, $a, $b",
978 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
979 (sext_inreg GPR:$b, i16)))]>,
980 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +0000981
982 def TT : AI<0xE, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulSMUL,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 !strconcat(opc, "tt"), " $dst, $a, $b",
984 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
985 (sra GPR:$b, 16)))]>,
986 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +0000987
988 def WB : AI<0xA, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulSMULW,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 !strconcat(opc, "wb"), " $dst, $a, $b",
990 [(set GPR:$dst, (sra (opnode GPR:$a,
991 (sext_inreg GPR:$b, i16)), 16))]>,
992 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +0000993
994 def WT : AI<0xE, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulSMULW,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 !strconcat(opc, "wt"), " $dst, $a, $b",
996 [(set GPR:$dst, (sra (opnode GPR:$a,
997 (sra GPR:$b, 16)), 16))]>,
998 Requires<[IsARM, HasV5TE]>;
999}
1000
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001001
Jim Grosbach1feed042008-11-03 18:38:31 +00001002// FIXME: encoding
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001003multiclass AI_smla<string opc, PatFrag opnode> {
1004 def BB : AI<0x8, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulSMLA,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 !strconcat(opc, "bb"), " $dst, $a, $b, $acc",
1006 [(set GPR:$dst, (add GPR:$acc,
1007 (opnode (sext_inreg GPR:$a, i16),
1008 (sext_inreg GPR:$b, i16))))]>,
1009 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001010
1011 def BT : AI<0xC, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulSMLA,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 !strconcat(opc, "bt"), " $dst, $a, $b, $acc",
1013 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
1014 (sra GPR:$b, 16))))]>,
1015 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001016
1017 def TB : AI<0xA, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulSMLA,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 !strconcat(opc, "tb"), " $dst, $a, $b, $acc",
1019 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
1020 (sext_inreg GPR:$b, i16))))]>,
1021 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001022
1023 def TT : AI<0xE, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulSMLA,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 !strconcat(opc, "tt"), " $dst, $a, $b, $acc",
1025 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
1026 (sra GPR:$b, 16))))]>,
1027 Requires<[IsARM, HasV5TE]>;
1028
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001029 def WB : AI<0xA, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulSMLAW,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 !strconcat(opc, "wb"), " $dst, $a, $b, $acc",
1031 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1032 (sext_inreg GPR:$b, i16)), 16)))]>,
1033 Requires<[IsARM, HasV5TE]>;
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001034
1035 def WT : AI<0xE, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulSMLAW,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 !strconcat(opc, "wt"), " $dst, $a, $b, $acc",
1037 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1038 (sra GPR:$b, 16)), 16)))]>,
1039 Requires<[IsARM, HasV5TE]>;
1040}
1041
Jim Grosbach1feed042008-11-03 18:38:31 +00001042// FIXME: encoding
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001043defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Jim Grosbach1feed042008-11-03 18:38:31 +00001044// FIXME: encoding
Raul Herbster2e07e8d2007-08-30 23:25:47 +00001045defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046
1047// TODO: Halfword multiple accumulate long: SMLAL<x><y>
1048// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1049
1050//===----------------------------------------------------------------------===//
1051// Misc. Arithmetic Instructions.
1052//
1053
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001054def CLZ : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 "clz", " $dst, $src",
1056 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]>;
1057
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001058def REV : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 "rev", " $dst, $src",
1060 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]>;
1061
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001062def REV16 : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 "rev16", " $dst, $src",
1064 [(set GPR:$dst,
1065 (or (and (srl GPR:$src, 8), 0xFF),
1066 (or (and (shl GPR:$src, 8), 0xFF00),
1067 (or (and (srl GPR:$src, 8), 0xFF0000),
1068 (and (shl GPR:$src, 8), 0xFF000000)))))]>,
1069 Requires<[IsARM, HasV6]>;
1070
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001071def REVSH : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 "revsh", " $dst, $src",
1073 [(set GPR:$dst,
1074 (sext_inreg
1075 (or (srl (and GPR:$src, 0xFF00), 8),
1076 (shl GPR:$src, 8)), i16))]>,
1077 Requires<[IsARM, HasV6]>;
1078
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001079def PKHBT : AI<0x0, (outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1080 Pseudo, "pkhbt", " $dst, $src1, $src2, LSL $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1082 (and (shl GPR:$src2, (i32 imm:$shamt)),
1083 0xFFFF0000)))]>,
1084 Requires<[IsARM, HasV6]>;
1085
1086// Alternate cases for PKHBT where identities eliminate some nodes.
1087def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1088 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1089def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1090 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1091
1092
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001093def PKHTB : AI<0x0, (outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1094 Pseudo, "pkhtb", " $dst, $src1, $src2, ASR $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1096 (and (sra GPR:$src2, imm16_31:$shamt),
1097 0xFFFF)))]>, Requires<[IsARM, HasV6]>;
1098
1099// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1100// a shift amount of 0 is *not legal* here, it is PKHBT instead.
1101def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, 16)),
1102 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1103def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1104 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1105 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1106
1107
1108//===----------------------------------------------------------------------===//
1109// Comparison Instructions...
1110//
1111
Jim Grosbach88c246f2008-10-14 20:36:24 +00001112defm CMP : AI1_cmp_irs<0b1010, "cmp",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001113 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001114defm CMN : AI1_cmp_irs<0b1011, "cmn",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001115 BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116
1117// Note that TST/TEQ don't set all the same flags that CMP does!
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001118defm TST : AI1_cmp_irs<0x8, "tst",
1119 BinOpFrag<(ARMcmpNZ (and node:$LHS, node:$RHS), 0)>>;
1120defm TEQ : AI1_cmp_irs<0x9, "teq",
1121 BinOpFrag<(ARMcmpNZ (xor node:$LHS, node:$RHS), 0)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122
Jim Grosbach88c246f2008-10-14 20:36:24 +00001123defm CMPnz : AI1_cmp_irs<0b1010, "cmp",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001124 BinOpFrag<(ARMcmpNZ node:$LHS, node:$RHS)>>;
Jim Grosbach88c246f2008-10-14 20:36:24 +00001125defm CMNnz : AI1_cmp_irs<0b1011, "cmn",
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001126 BinOpFrag<(ARMcmpNZ node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127
1128def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1129 (CMNri GPR:$src, so_imm_neg:$imm)>;
1130
1131def : ARMPat<(ARMcmpNZ GPR:$src, so_imm_neg:$imm),
1132 (CMNri GPR:$src, so_imm_neg:$imm)>;
1133
1134
1135// Conditional moves
1136// FIXME: should be able to write a pattern for ARMcmov, but can't use
1137// a two-value operand where a dag node expects two operands. :(
Evan Cheng86a926a2008-11-05 18:35:52 +00001138def MOVCCr : AI<0xD, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm,
1139 "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
1141 RegConstraint<"$false = $dst">;
1142
Evan Cheng86a926a2008-11-05 18:35:52 +00001143def MOVCCs : AI<0xD, (outs GPR:$dst), (ins GPR:$false, so_reg:$true), DPSoRegFrm,
1144 "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Cheng86a926a2008-11-05 18:35:52 +00001146 RegConstraint<"$false = $dst">, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147
Evan Cheng86a926a2008-11-05 18:35:52 +00001148def MOVCCi : AI<0xD, (outs GPR:$dst), (ins GPR:$false, so_imm:$true), DPFrm,
1149 "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
Evan Cheng86a926a2008-11-05 18:35:52 +00001151 RegConstraint<"$false = $dst">, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152
1153
1154// LEApcrel - Load a pc-relative address into a register without offending the
1155// assembler.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001156def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p), Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
1158 "${:private}PCRELL${:uid}+8))\n"),
1159 !strconcat("${:private}PCRELL${:uid}:\n\t",
1160 "add$p $dst, pc, #PCRELV${:uid}")),
1161 []>;
1162
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001163def LEApcrelJT : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, i32imm:$id, pred:$p),
1164 Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
1166 "${:private}PCRELL${:uid}+8))\n"),
1167 !strconcat("${:private}PCRELL${:uid}:\n\t",
1168 "add$p $dst, pc, #PCRELV${:uid}")),
1169 []>;
1170
1171//===----------------------------------------------------------------------===//
1172// TLS Instructions
1173//
1174
1175// __aeabi_read_tp preserves the registers r1-r3.
1176let isCall = 1,
1177 Defs = [R0, R12, LR, CPSR] in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001178 def TPsoft : AXI<0x0, (outs), (ins), BranchMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 "bl __aeabi_read_tp",
1180 [(set R0, ARMthread_pointer)]>;
1181}
1182
1183//===----------------------------------------------------------------------===//
1184// Non-Instruction Patterns
1185//
1186
1187// ConstantPool, GlobalAddress, and JumpTable
1188def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1189def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1190def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
1191 (LEApcrelJT tjumptable:$dst, imm:$id)>;
1192
1193// Large immediate handling.
1194
1195// Two piece so_imms.
1196let isReMaterializable = 1 in
Evan Cheng86a926a2008-11-05 18:35:52 +00001197def MOVi2pieces : AI1x2<0x0, (outs GPR:$dst), (ins so_imm2part:$src), DPFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 "mov", " $dst, $src",
Evan Cheng86a926a2008-11-05 18:35:52 +00001199 [(set GPR:$dst, so_imm2part:$src)]>, UnaryDP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200
1201def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
1202 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1203 (so_imm2part_2 imm:$RHS))>;
1204def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
1205 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1206 (so_imm2part_2 imm:$RHS))>;
1207
1208// TODO: add,sub,and, 3-instr forms?
1209
1210
1211// Direct calls
1212def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
1213
1214// zextload i1 -> zextload i8
1215def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1216
1217// extload -> zextload
1218def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1219def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1220def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
1221
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222// smul* and smla*
1223def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra (shl GPR:$b, 16), 16)),
1224 (SMULBB GPR:$a, GPR:$b)>;
1225def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1226 (SMULBB GPR:$a, GPR:$b)>;
1227def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16)),
1228 (SMULBT GPR:$a, GPR:$b)>;
1229def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, 16)),
1230 (SMULBT GPR:$a, GPR:$b)>;
1231def : ARMV5TEPat<(mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16)),
1232 (SMULTB GPR:$a, GPR:$b)>;
1233def : ARMV5TEPat<(mul (sra GPR:$a, 16), sext_16_node:$b),
1234 (SMULTB GPR:$a, GPR:$b)>;
1235def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16),
1236 (SMULWB GPR:$a, GPR:$b)>;
1237def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), 16),
1238 (SMULWB GPR:$a, GPR:$b)>;
1239
1240def : ARMV5TEPat<(add GPR:$acc,
1241 (mul (sra (shl GPR:$a, 16), 16),
1242 (sra (shl GPR:$b, 16), 16))),
1243 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1244def : ARMV5TEPat<(add GPR:$acc,
1245 (mul sext_16_node:$a, sext_16_node:$b)),
1246 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1247def : ARMV5TEPat<(add GPR:$acc,
1248 (mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16))),
1249 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1250def : ARMV5TEPat<(add GPR:$acc,
1251 (mul sext_16_node:$a, (sra GPR:$b, 16))),
1252 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1253def : ARMV5TEPat<(add GPR:$acc,
1254 (mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16))),
1255 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1256def : ARMV5TEPat<(add GPR:$acc,
1257 (mul (sra GPR:$a, 16), sext_16_node:$b)),
1258 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1259def : ARMV5TEPat<(add GPR:$acc,
1260 (sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16)),
1261 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1262def : ARMV5TEPat<(add GPR:$acc,
1263 (sra (mul GPR:$a, sext_16_node:$b), 16)),
1264 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1265
1266//===----------------------------------------------------------------------===//
1267// Thumb Support
1268//
1269
1270include "ARMInstrThumb.td"
1271
1272//===----------------------------------------------------------------------===//
1273// Floating Point Support
1274//
1275
1276include "ARMInstrVFP.td"