blob: 5441212b865129c647dfb1dfe65eefa66a219305 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
Rafael Espindola7bc59bc2006-05-14 22:18:28 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the "Instituto Nokia de Tecnologia" and
6// is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10//
11// This file describes the ARM instructions in TableGen format.
12//
13//===----------------------------------------------------------------------===//
14
Evan Chenga8e29892007-01-19 07:51:42 +000015//===----------------------------------------------------------------------===//
16// ARM specific DAG Nodes.
17//
Rafael Espindola7cca7c52006-09-11 17:25:40 +000018
Evan Chenga8e29892007-01-19 07:51:42 +000019// Type profiles.
20def SDT_ARMCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
Rafael Espindola6e8c6492006-11-08 17:07:32 +000021
Evan Chenga8e29892007-01-19 07:51:42 +000022def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
Rafael Espindola32bd5f42006-10-17 18:04:53 +000023
Evan Chenga8e29892007-01-19 07:51:42 +000024def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
Rafael Espindola7cca7c52006-09-11 17:25:40 +000025
Evan Chenga8e29892007-01-19 07:51:42 +000026def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
28 SDTCisVT<3, i32>]>;
Rafael Espindola6e8c6492006-11-08 17:07:32 +000029
Evan Chenga8e29892007-01-19 07:51:42 +000030def 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
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000042def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
43
Evan Chenga8e29892007-01-19 07:51:42 +000044// Node definitions.
45def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
Evan Chenga8e29892007-01-19 07:51:42 +000046def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
47
48def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeq,
49 [SDNPHasChain, SDNPOutFlag]>;
50def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeq,
Evan Chengb38cba92007-02-03 09:11:58 +000051 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chenga8e29892007-01-19 07:51:42 +000052
53def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
54 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
55def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
56 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
57
58def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTRet,
59 [SDNPHasChain, SDNPOptInFlag]>;
60
61def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
62 [SDNPInFlag]>;
63def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov,
64 [SDNPInFlag]>;
65
66def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
67 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
68
69def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
70 [SDNPHasChain]>;
71
72def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
73 [SDNPOutFlag]>;
74
Lauro Ramos Venancio99966632007-04-02 01:30:03 +000075def ARMcmpNZ : SDNode<"ARMISD::CMPNZ", SDT_ARMCmp,
76 [SDNPOutFlag]>;
77
Evan Chenga8e29892007-01-19 07:51:42 +000078def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
79
80def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
81def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>;
82def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>;
Rafael Espindola32bd5f42006-10-17 18:04:53 +000083
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +000084def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
85
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000086//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +000087// ARM Instruction Predicate Definitions.
88//
89def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
90def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">;
91def HasV6 : Predicate<"Subtarget->hasV6Ops()">;
92def IsThumb : Predicate<"Subtarget->isThumb()">;
93def IsARM : Predicate<"!Subtarget->isThumb()">;
94
Rafael Espindola7bc59bc2006-05-14 22:18:28 +000095//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +000096// ARM Flag Definitions.
97
98class RegConstraint<string C> {
99 string Constraints = C;
100}
101
102//===----------------------------------------------------------------------===//
103// ARM specific transformation functions and pattern fragments.
104//
105
106// so_imm_XFORM - Return a so_imm value packed into the format described for
107// so_imm def below.
108def so_imm_XFORM : SDNodeXForm<imm, [{
109 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(N->getValue()),
110 MVT::i32);
111}]>;
112
113// so_imm_neg_XFORM - Return a so_imm value packed into the format described for
114// so_imm_neg def below.
115def so_imm_neg_XFORM : SDNodeXForm<imm, [{
116 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(-(int)N->getValue()),
117 MVT::i32);
118}]>;
119
120// so_imm_not_XFORM - Return a so_imm value packed into the format described for
121// so_imm_not def below.
122def so_imm_not_XFORM : SDNodeXForm<imm, [{
123 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(~(int)N->getValue()),
124 MVT::i32);
125}]>;
126
127// rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24.
128def rot_imm : PatLeaf<(i32 imm), [{
129 int32_t v = (int32_t)N->getValue();
130 return v == 8 || v == 16 || v == 24;
131}]>;
132
133/// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
134def imm1_15 : PatLeaf<(i32 imm), [{
135 return (int32_t)N->getValue() >= 1 && (int32_t)N->getValue() < 16;
136}]>;
137
138/// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
139def imm16_31 : PatLeaf<(i32 imm), [{
140 return (int32_t)N->getValue() >= 16 && (int32_t)N->getValue() < 32;
141}]>;
142
143def so_imm_neg :
144 PatLeaf<(imm), [{ return ARM_AM::getSOImmVal(-(int)N->getValue()) != -1; }],
145 so_imm_neg_XFORM>;
146
Evan Chenga2515702007-03-19 07:09:02 +0000147def so_imm_not :
Evan Chenga8e29892007-01-19 07:51:42 +0000148 PatLeaf<(imm), [{ return ARM_AM::getSOImmVal(~(int)N->getValue()) != -1; }],
149 so_imm_not_XFORM>;
150
151// sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
152def sext_16_node : PatLeaf<(i32 GPR:$a), [{
153 return TLI.ComputeNumSignBits(SDOperand(N,0)) >= 17;
154}]>;
155
156
Evan Chenga8e29892007-01-19 07:51:42 +0000157
158//===----------------------------------------------------------------------===//
159// Operand Definitions.
160//
161
162// Branch target.
163def brtarget : Operand<OtherVT>;
164
Evan Chenga8e29892007-01-19 07:51:42 +0000165// A list of registers separated by comma. Used by load/store multiple.
166def reglist : Operand<i32> {
167 let PrintMethod = "printRegisterList";
168}
169
170// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
171def cpinst_operand : Operand<i32> {
172 let PrintMethod = "printCPInstOperand";
173}
174
175def jtblock_operand : Operand<i32> {
176 let PrintMethod = "printJTBlockOperand";
177}
178
179// Local PC labels.
180def pclabel : Operand<i32> {
181 let PrintMethod = "printPCLabel";
182}
183
184// shifter_operand operands: so_reg and so_imm.
185def so_reg : Operand<i32>, // reg reg imm
186 ComplexPattern<i32, 3, "SelectShifterOperandReg",
187 [shl,srl,sra,rotr]> {
188 let PrintMethod = "printSORegOperand";
189 let MIOperandInfo = (ops GPR, GPR, i32imm);
190}
191
192// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
193// 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
194// represented in the imm field in the same 12-bit form that they are encoded
195// into so_imm instructions: the 8-bit immediate is the least significant bits
196// [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
197def so_imm : Operand<i32>,
198 PatLeaf<(imm),
199 [{ return ARM_AM::getSOImmVal(N->getValue()) != -1; }],
200 so_imm_XFORM> {
201 let PrintMethod = "printSOImmOperand";
202}
203
Evan Chengc70d1842007-03-20 08:11:30 +0000204// Break so_imm's up into two pieces. This handles immediates with up to 16
205// bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
206// get the first/second pieces.
207def so_imm2part : Operand<i32>,
208 PatLeaf<(imm),
209 [{ return ARM_AM::isSOImmTwoPartVal((unsigned)N->getValue()); }]> {
210 let PrintMethod = "printSOImm2PartOperand";
211}
212
213def so_imm2part_1 : SDNodeXForm<imm, [{
214 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getValue());
215 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
216}]>;
217
218def so_imm2part_2 : SDNodeXForm<imm, [{
219 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getValue());
220 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
221}]>;
222
Evan Chenga8e29892007-01-19 07:51:42 +0000223
224// Define ARM specific addressing modes.
225
226// addrmode2 := reg +/- reg shop imm
227// addrmode2 := reg +/- imm12
228//
229def addrmode2 : Operand<i32>,
230 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
231 let PrintMethod = "printAddrMode2Operand";
232 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
233}
234
235def am2offset : Operand<i32>,
236 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
237 let PrintMethod = "printAddrMode2OffsetOperand";
238 let MIOperandInfo = (ops GPR, i32imm);
239}
240
241// addrmode3 := reg +/- reg
242// addrmode3 := reg +/- imm8
243//
244def addrmode3 : Operand<i32>,
245 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
246 let PrintMethod = "printAddrMode3Operand";
247 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
248}
249
250def am3offset : Operand<i32>,
251 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
252 let PrintMethod = "printAddrMode3OffsetOperand";
253 let MIOperandInfo = (ops GPR, i32imm);
254}
255
256// addrmode4 := reg, <mode|W>
257//
258def addrmode4 : Operand<i32>,
259 ComplexPattern<i32, 2, "", []> {
260 let PrintMethod = "printAddrMode4Operand";
261 let MIOperandInfo = (ops GPR, i32imm);
262}
263
264// addrmode5 := reg +/- imm8*4
265//
266def addrmode5 : Operand<i32>,
267 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
268 let PrintMethod = "printAddrMode5Operand";
269 let MIOperandInfo = (ops GPR, i32imm);
270}
271
272// addrmodepc := pc + reg
273//
274def addrmodepc : Operand<i32>,
275 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
276 let PrintMethod = "printAddrModePCOperand";
277 let MIOperandInfo = (ops GPR, i32imm);
278}
279
Evan Cheng42d712b2007-05-08 21:08:43 +0000280// ARM branch / cmov condition code operand.
281def ccop : PredicateOperand<i32, (ops i32imm), (ops)> {
282 let PrintMethod = "printPredicateOperand";
283}
284
285// ARM Predicate operand. Default to 14 = always (AL).
286def pred : PredicateOperand<i32, (ops i32imm), (ops (i32 14))> {
287 let PrintMethod = "printPredicateOperand";
288}
289
Evan Chenga8e29892007-01-19 07:51:42 +0000290//===----------------------------------------------------------------------===//
291// ARM Instruction flags. These need to match ARMInstrInfo.h.
292//
293
294// Addressing mode.
295class AddrMode<bits<4> val> {
296 bits<4> Value = val;
297}
298def AddrModeNone : AddrMode<0>;
299def AddrMode1 : AddrMode<1>;
300def AddrMode2 : AddrMode<2>;
301def AddrMode3 : AddrMode<3>;
302def AddrMode4 : AddrMode<4>;
303def AddrMode5 : AddrMode<5>;
304def AddrModeT1 : AddrMode<6>;
305def AddrModeT2 : AddrMode<7>;
306def AddrModeT4 : AddrMode<8>;
307def AddrModeTs : AddrMode<9>;
308
309// Instruction size.
310class SizeFlagVal<bits<3> val> {
311 bits<3> Value = val;
312}
313def SizeInvalid : SizeFlagVal<0>; // Unset.
314def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
315def Size8Bytes : SizeFlagVal<2>;
316def Size4Bytes : SizeFlagVal<3>;
317def Size2Bytes : SizeFlagVal<4>;
318
319// Load / store index mode.
320class IndexMode<bits<2> val> {
321 bits<2> Value = val;
322}
323def IndexModeNone : IndexMode<0>;
324def IndexModePre : IndexMode<1>;
325def IndexModePost : IndexMode<2>;
326
327//===----------------------------------------------------------------------===//
328// ARM Instruction templates.
329//
330
331// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
332class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
333 list<Predicate> Predicates = [IsARM];
334}
Evan Cheng34b12d22007-01-19 20:27:35 +0000335class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
336 list<Predicate> Predicates = [IsARM, HasV5TE];
337}
Evan Chenga8e29892007-01-19 07:51:42 +0000338class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
339 list<Predicate> Predicates = [IsARM, HasV6];
340}
341
Evan Chenga8e29892007-01-19 07:51:42 +0000342class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
343 dag ops, string asmstr, string cstr>
344 : Instruction {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000345 let Namespace = "ARM";
346
Evan Chenga8e29892007-01-19 07:51:42 +0000347 bits<4> Opcode = opcod;
348 AddrMode AM = am;
349 bits<4> AddrModeBits = AM.Value;
350
351 SizeFlagVal SZ = sz;
352 bits<3> SizeFlag = SZ.Value;
353
354 IndexMode IM = im;
355 bits<2> IndexModeBits = IM.Value;
356
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000357 dag OperandList = ops;
358 let AsmString = asmstr;
Evan Chenga8e29892007-01-19 07:51:42 +0000359 let Constraints = cstr;
360}
361
362class PseudoInst<dag ops, string asm, list<dag> pattern>
363 : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, ops, asm, ""> {
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000364 let Pattern = pattern;
365}
366
Evan Chenga8e29892007-01-19 07:51:42 +0000367class I<dag ops, AddrMode am, SizeFlagVal sz, IndexMode im,
368 string asm, string cstr, list<dag> pattern>
369 // FIXME: Set all opcodes to 0 for now.
370 : InstARM<0, am, sz, im, ops, asm, cstr> {
371 let Pattern = pattern;
372 list<Predicate> Predicates = [IsARM];
373}
Rafael Espindola15a6c3e2006-10-16 17:57:20 +0000374
Evan Chenga8e29892007-01-19 07:51:42 +0000375class AI<dag ops, string asm, list<dag> pattern>
376 : I<ops, AddrModeNone, Size4Bytes, IndexModeNone, asm, "", pattern>;
377class AI1<dag ops, string asm, list<dag> pattern>
378 : I<ops, AddrMode1, Size4Bytes, IndexModeNone, asm, "", pattern>;
379class AI2<dag ops, string asm, list<dag> pattern>
380 : I<ops, AddrMode2, Size4Bytes, IndexModeNone, asm, "", pattern>;
381class AI3<dag ops, string asm, list<dag> pattern>
382 : I<ops, AddrMode3, Size4Bytes, IndexModeNone, asm, "", pattern>;
383class AI4<dag ops, string asm, list<dag> pattern>
384 : I<ops, AddrMode4, Size4Bytes, IndexModeNone, asm, "", pattern>;
Lauro Ramos Venanciob8a93a42007-03-27 16:19:21 +0000385class AIx2<dag ops, string asm, list<dag> pattern>
386 : I<ops, AddrModeNone, Size8Bytes, IndexModeNone, asm, "", pattern>;
Evan Chengc70d1842007-03-20 08:11:30 +0000387class AI1x2<dag ops, string asm, list<dag> pattern>
388 : I<ops, AddrMode1, Size8Bytes, IndexModeNone, asm, "", pattern>;
Rafael Espindolaa6f149d2006-10-16 18:32:36 +0000389
Evan Chenga8e29892007-01-19 07:51:42 +0000390// Pre-indexed ops
391class AI2pr<dag ops, string asm, string cstr, list<dag> pattern>
392 : I<ops, AddrMode2, Size4Bytes, IndexModePre, asm, cstr, pattern>;
393class AI3pr<dag ops, string asm, string cstr, list<dag> pattern>
394 : I<ops, AddrMode3, Size4Bytes, IndexModePre, asm, cstr, pattern>;
Rafael Espindola27e469e2006-10-16 18:39:22 +0000395
Evan Chenga8e29892007-01-19 07:51:42 +0000396// Post-indexed ops
397class AI2po<dag ops, string asm, string cstr, list<dag> pattern>
398 : I<ops, AddrMode2, Size4Bytes, IndexModePost, asm, cstr, pattern>;
399class AI3po<dag ops, string asm, string cstr, list<dag> pattern>
400 : I<ops, AddrMode3, Size4Bytes, IndexModePost, asm, cstr, pattern>;
Rafael Espindola04d88ff2006-10-17 20:45:22 +0000401
Evan Chenga8e29892007-01-19 07:51:42 +0000402// BR_JT instructions
403class JTI<dag ops, string asm, list<dag> pattern>
404 : I<ops, AddrModeNone, SizeSpecial, IndexModeNone, asm, "", pattern>;
405class JTI1<dag ops, string asm, list<dag> pattern>
406 : I<ops, AddrMode1, SizeSpecial, IndexModeNone, asm, "", pattern>;
407class JTI2<dag ops, string asm, list<dag> pattern>
408 : I<ops, AddrMode2, SizeSpecial, IndexModeNone, asm, "", pattern>;
Rafael Espindola04d88ff2006-10-17 20:45:22 +0000409
Evan Chenga8e29892007-01-19 07:51:42 +0000410
411class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
412class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
413
414
415/// AI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
416/// binop that produces a value.
417multiclass AI1_bin_irs<string opc, PatFrag opnode> {
418 def ri : AI1<(ops GPR:$dst, GPR:$a, so_imm:$b),
419 !strconcat(opc, " $dst, $a, $b"),
420 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
421 def rr : AI1<(ops GPR:$dst, GPR:$a, GPR:$b),
422 !strconcat(opc, " $dst, $a, $b"),
423 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
424 def rs : AI1<(ops GPR:$dst, GPR:$a, so_reg:$b),
425 !strconcat(opc, " $dst, $a, $b"),
426 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
427}
428
429/// AI1_bin0_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns.
430/// Similar to AI1_bin_irs except the instruction does not produce a result.
431multiclass AI1_bin0_irs<string opc, PatFrag opnode> {
432 def ri : AI1<(ops GPR:$a, so_imm:$b),
433 !strconcat(opc, " $a, $b"),
434 [(opnode GPR:$a, so_imm:$b)]>;
435 def rr : AI1<(ops GPR:$a, GPR:$b),
436 !strconcat(opc, " $a, $b"),
437 [(opnode GPR:$a, GPR:$b)]>;
438 def rs : AI1<(ops GPR:$a, so_reg:$b),
439 !strconcat(opc, " $a, $b"),
440 [(opnode GPR:$a, so_reg:$b)]>;
441}
442
443/// AI1_bin_is - Defines a set of (op r, {so_imm|so_reg}) patterns for a binop.
444multiclass AI1_bin_is<string opc, PatFrag opnode> {
445 def ri : AI1<(ops GPR:$dst, GPR:$a, so_imm:$b),
446 !strconcat(opc, " $dst, $a, $b"),
447 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
448 def rs : AI1<(ops GPR:$dst, GPR:$a, so_reg:$b),
449 !strconcat(opc, " $dst, $a, $b"),
450 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
451}
452
453/// AI1_unary_irs - Defines a set of (op {so_imm|r|so_reg}) patterns for unary
454/// ops.
455multiclass AI1_unary_irs<string opc, PatFrag opnode> {
456 def i : AI1<(ops GPR:$dst, so_imm:$a),
457 !strconcat(opc, " $dst, $a"),
458 [(set GPR:$dst, (opnode so_imm:$a))]>;
459 def r : AI1<(ops GPR:$dst, GPR:$a),
460 !strconcat(opc, " $dst, $a"),
461 [(set GPR:$dst, (opnode GPR:$a))]>;
462 def s : AI1<(ops GPR:$dst, so_reg:$a),
463 !strconcat(opc, " $dst, $a"),
464 [(set GPR:$dst, (opnode so_reg:$a))]>;
465}
466
467/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
468/// register and one whose operand is a register rotated by 8/16/24.
469multiclass AI_unary_rrot<string opc, PatFrag opnode> {
470 def r : AI<(ops GPR:$dst, GPR:$Src),
471 !strconcat(opc, " $dst, $Src"),
472 [(set GPR:$dst, (opnode GPR:$Src))]>, Requires<[IsARM, HasV6]>;
473 def r_rot : AI<(ops GPR:$dst, GPR:$Src, i32imm:$rot),
474 !strconcat(opc, " $dst, $Src, ror $rot"),
475 [(set GPR:$dst, (opnode (rotr GPR:$Src, rot_imm:$rot)))]>,
476 Requires<[IsARM, HasV6]>;
477}
478
479/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
480/// register and one whose operand is a register rotated by 8/16/24.
481multiclass AI_bin_rrot<string opc, PatFrag opnode> {
482 def rr : AI<(ops GPR:$dst, GPR:$LHS, GPR:$RHS),
483 !strconcat(opc, " $dst, $LHS, $RHS"),
484 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
485 Requires<[IsARM, HasV6]>;
486 def rr_rot : AI<(ops GPR:$dst, GPR:$LHS, GPR:$RHS, i32imm:$rot),
487 !strconcat(opc, " $dst, $LHS, $RHS, ror $rot"),
488 [(set GPR:$dst, (opnode GPR:$LHS,
489 (rotr GPR:$RHS, rot_imm:$rot)))]>,
490 Requires<[IsARM, HasV6]>;
491}
492
Rafael Espindola90057aa2006-10-16 18:18:14 +0000493
Rafael Espindola15a6c3e2006-10-16 17:57:20 +0000494//===----------------------------------------------------------------------===//
495// Instructions
496//===----------------------------------------------------------------------===//
497
Evan Chenga8e29892007-01-19 07:51:42 +0000498//===----------------------------------------------------------------------===//
499// Miscellaneous Instructions.
500//
501def IMPLICIT_DEF_GPR :
502PseudoInst<(ops GPR:$rD),
503 "@ IMPLICIT_DEF_GPR $rD",
504 [(set GPR:$rD, (undef))]>;
Rafael Espindola687bc492006-08-24 13:45:55 +0000505
Rafael Espindola6f602de2006-08-24 16:13:15 +0000506
Evan Chenga8e29892007-01-19 07:51:42 +0000507/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
508/// the function. The first operand is the ID# for this instruction, the second
509/// is the index into the MachineConstantPool that this is, the third is the
510/// size in bytes of this constant pool entry.
511def CONSTPOOL_ENTRY :
512PseudoInst<(ops cpinst_operand:$instid, cpinst_operand:$cpidx, i32imm:$size),
513 "${instid:label} ${cpidx:cpentry}", []>;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000514
Evan Chenga8e29892007-01-19 07:51:42 +0000515def ADJCALLSTACKUP :
516PseudoInst<(ops i32imm:$amt),
517 "@ ADJCALLSTACKUP $amt",
518 [(ARMcallseq_end imm:$amt)]>, Imp<[SP],[SP]>;
Rafael Espindolacdda88c2006-08-24 17:19:08 +0000519
Evan Chenga8e29892007-01-19 07:51:42 +0000520def ADJCALLSTACKDOWN :
521PseudoInst<(ops i32imm:$amt),
522 "@ ADJCALLSTACKDOWN $amt",
523 [(ARMcallseq_start imm:$amt)]>, Imp<[SP],[SP]>;
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000524
Evan Chenga8e29892007-01-19 07:51:42 +0000525def DWARF_LOC :
526PseudoInst<(ops i32imm:$line, i32imm:$col, i32imm:$file),
527 ".loc $file, $line, $col",
528 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
Rafael Espindola4b20fbc2006-10-10 12:56:00 +0000529
Evan Chenga8e29892007-01-19 07:51:42 +0000530def PICADD : AI1<(ops GPR:$dst, GPR:$a, pclabel:$cp),
Evan Chengc60e76d2007-01-30 20:37:08 +0000531 "$cp:\n\tadd $dst, pc, $a",
Evan Chenga8e29892007-01-19 07:51:42 +0000532 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
533let AddedComplexity = 10 in
534def PICLD : AI2<(ops GPR:$dst, addrmodepc:$addr),
Evan Chengc60e76d2007-01-30 20:37:08 +0000535 "${addr:label}:\n\tldr $dst, $addr",
Evan Chenga8e29892007-01-19 07:51:42 +0000536 [(set GPR:$dst, (load addrmodepc:$addr))]>;
Rafael Espindola84b19be2006-07-16 01:02:57 +0000537
Evan Chenga8e29892007-01-19 07:51:42 +0000538//===----------------------------------------------------------------------===//
539// Control Flow Instructions.
540//
Rafael Espindola9e071f02006-10-02 19:30:56 +0000541
Evan Chenga8e29892007-01-19 07:51:42 +0000542let isReturn = 1, isTerminator = 1 in
543 def BX_RET : AI<(ops), "bx lr", [(ARMretflag)]>;
Rafael Espindola27185192006-09-29 21:20:16 +0000544
Evan Chenga8e29892007-01-19 07:51:42 +0000545// FIXME: remove when we have a way to marking a MI with these properties.
546let isLoad = 1, isReturn = 1, isTerminator = 1 in
547 def LDM_RET : AI4<(ops addrmode4:$addr, reglist:$dst1, variable_ops),
548 "ldm${addr:submode} $addr, $dst1",
549 []>;
Rafael Espindolaa2845842006-10-05 16:48:49 +0000550
Evan Chenga8e29892007-01-19 07:51:42 +0000551let isCall = 1, noResults = 1,
552 Defs = [R0, R1, R2, R3, R12, LR,
553 D0, D1, D2, D3, D4, D5, D6, D7] in {
554 def BL : AI<(ops i32imm:$func, variable_ops),
555 "bl ${func:call}",
556 [(ARMcall tglobaladdr:$func)]>;
557 // ARMv5T and above
558 def BLX : AI<(ops GPR:$dst, variable_ops),
559 "blx $dst",
560 [(ARMcall GPR:$dst)]>, Requires<[IsARM, HasV5T]>;
Lauro Ramos Venancio64c88d72007-03-20 17:57:23 +0000561 let Uses = [LR] in {
562 // ARMv4T
Lauro Ramos Venanciob8a93a42007-03-27 16:19:21 +0000563 def BX : AIx2<(ops GPR:$dst, variable_ops),
564 "mov lr, pc\n\tbx $dst",
565 [(ARMcall_nolink GPR:$dst)]>;
Lauro Ramos Venancio64c88d72007-03-20 17:57:23 +0000566 }
Rafael Espindola35574632006-07-18 17:00:30 +0000567}
Rafael Espindoladc124a22006-05-18 21:45:49 +0000568
Evan Chenga8e29892007-01-19 07:51:42 +0000569let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
570 def B : AI<(ops brtarget:$dst), "b $dst",
571 [(br bb:$dst)]>;
572
573 def BR_JTr : JTI<(ops GPR:$dst, jtblock_operand:$jt, i32imm:$id),
574 "mov pc, $dst \n$jt",
575 [(ARMbrjt GPR:$dst, tjumptable:$jt, imm:$id)]>;
576 def BR_JTm : JTI2<(ops addrmode2:$dst, jtblock_operand:$jt, i32imm:$id),
577 "ldr pc, $dst \n$jt",
578 [(ARMbrjt (i32 (load addrmode2:$dst)), tjumptable:$jt,
579 imm:$id)]>;
580 def BR_JTadd : JTI1<(ops GPR:$dst, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
581 "add pc, $dst, $idx \n$jt",
582 [(ARMbrjt (add GPR:$dst, GPR:$idx), tjumptable:$jt,
583 imm:$id)]>;
Rafael Espindola1ed3af12006-08-01 18:53:10 +0000584}
Rafael Espindola84b19be2006-07-16 01:02:57 +0000585
Evan Chenga8e29892007-01-19 07:51:42 +0000586let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in
Evan Cheng42d712b2007-05-08 21:08:43 +0000587 def Bcc : AI<(ops brtarget:$dst, ccop:$cc), "b$cc $dst",
Evan Chenga8e29892007-01-19 07:51:42 +0000588 [(ARMbrcond bb:$dst, imm:$cc)]>;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000589
Evan Chenga8e29892007-01-19 07:51:42 +0000590//===----------------------------------------------------------------------===//
591// Load / store Instructions.
592//
Rafael Espindola82c678b2006-10-16 17:17:22 +0000593
Evan Chenga8e29892007-01-19 07:51:42 +0000594// Load
595let isLoad = 1 in {
596def LDR : AI2<(ops GPR:$dst, addrmode2:$addr),
597 "ldr $dst, $addr",
598 [(set GPR:$dst, (load addrmode2:$addr))]>;
Rafael Espindola82c678b2006-10-16 17:17:22 +0000599
Evan Chengfa775d02007-03-19 07:20:03 +0000600// Special LDR for loads from non-pc-relative constpools.
601let isReMaterializable = 1 in
602def LDRcp : AI2<(ops GPR:$dst, addrmode2:$addr),
603 "ldr $dst, $addr", []>;
604
Evan Chenga8e29892007-01-19 07:51:42 +0000605// Loads with zero extension
606def LDRH : AI3<(ops GPR:$dst, addrmode3:$addr),
607 "ldrh $dst, $addr",
608 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
Rafael Espindola82c678b2006-10-16 17:17:22 +0000609
Evan Chenga8e29892007-01-19 07:51:42 +0000610def LDRB : AI2<(ops GPR:$dst, addrmode2:$addr),
611 "ldrb $dst, $addr",
612 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
Rafael Espindola82c678b2006-10-16 17:17:22 +0000613
Evan Chenga8e29892007-01-19 07:51:42 +0000614// Loads with sign extension
615def LDRSH : AI3<(ops GPR:$dst, addrmode3:$addr),
616 "ldrsh $dst, $addr",
617 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
Rafael Espindola7bc59bc2006-05-14 22:18:28 +0000618
Evan Chenga8e29892007-01-19 07:51:42 +0000619def LDRSB : AI3<(ops GPR:$dst, addrmode3:$addr),
620 "ldrsb $dst, $addr",
621 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
Rafael Espindolac391d162006-10-23 20:34:27 +0000622
Evan Chenga8e29892007-01-19 07:51:42 +0000623// Load doubleword
624def LDRD : AI3<(ops GPR:$dst, addrmode3:$addr),
625 "ldrd $dst, $addr",
626 []>, Requires<[IsARM, HasV5T]>;
Rafael Espindolac391d162006-10-23 20:34:27 +0000627
Evan Chenga8e29892007-01-19 07:51:42 +0000628// Indexed loads
629def LDR_PRE : AI2pr<(ops GPR:$dst, GPR:$base_wb, addrmode2:$addr),
630 "ldr $dst, $addr!", "$addr.base = $base_wb", []>;
Rafael Espindoladc124a22006-05-18 21:45:49 +0000631
Evan Chenga8e29892007-01-19 07:51:42 +0000632def LDR_POST : AI2po<(ops GPR:$dst, GPR:$base_wb, GPR:$base, am2offset:$offset),
633 "ldr $dst, [$base], $offset", "$base = $base_wb", []>;
Rafael Espindola450856d2006-12-12 00:37:38 +0000634
Evan Chenga8e29892007-01-19 07:51:42 +0000635def LDRH_PRE : AI3pr<(ops GPR:$dst, GPR:$base_wb, addrmode3:$addr),
636 "ldrh $dst, $addr!", "$addr.base = $base_wb", []>;
Rafael Espindola4e307642006-09-08 16:59:47 +0000637
Evan Chenga8e29892007-01-19 07:51:42 +0000638def LDRH_POST : AI3po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am3offset:$offset),
639 "ldrh $dst, [$base], $offset", "$base = $base_wb", []>;
Lauro Ramos Venancio301009a2006-12-28 13:11:14 +0000640
Evan Chenga8e29892007-01-19 07:51:42 +0000641def LDRB_PRE : AI2pr<(ops GPR:$dst, GPR:$base_wb, addrmode2:$addr),
642 "ldrb $dst, $addr!", "$addr.base = $base_wb", []>;
Lauro Ramos Venancio301009a2006-12-28 13:11:14 +0000643
Evan Chenga8e29892007-01-19 07:51:42 +0000644def LDRB_POST : AI2po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am2offset:$offset),
645 "ldrb $dst, [$base], $offset", "$base = $base_wb", []>;
646
647def LDRSH_PRE : AI3pr<(ops GPR:$dst, GPR:$base_wb, addrmode3:$addr),
648 "ldrsh $dst, $addr!", "$addr.base = $base_wb", []>;
649
650def LDRSH_POST: AI3po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am3offset:$offset),
651 "ldrsh $dst, [$base], $offset", "$base = $base_wb", []>;
652
653def LDRSB_PRE : AI3pr<(ops GPR:$dst, GPR:$base_wb, addrmode3:$addr),
654 "ldrsb $dst, $addr!", "$addr.base = $base_wb", []>;
655
656def LDRSB_POST: AI3po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am3offset:$offset),
657 "ldrsb $dst, [$base], $offset", "$base = $base_wb", []>;
658} // isLoad
659
660// Store
661let isStore = 1 in {
662def STR : AI2<(ops GPR:$src, addrmode2:$addr),
663 "str $src, $addr",
664 [(store GPR:$src, addrmode2:$addr)]>;
665
666// Stores with truncate
667def STRH : AI3<(ops GPR:$src, addrmode3:$addr),
668 "strh $src, $addr",
669 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
670
671def STRB : AI2<(ops GPR:$src, addrmode2:$addr),
672 "strb $src, $addr",
673 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
674
675// Store doubleword
676def STRD : AI3<(ops GPR:$src, addrmode3:$addr),
677 "strd $src, $addr",
678 []>, Requires<[IsARM, HasV5T]>;
679
680// Indexed stores
681def STR_PRE : AI2pr<(ops GPR:$base_wb, GPR:$src, GPR:$base, am2offset:$offset),
682 "str $src, [$base, $offset]!", "$base = $base_wb",
683 [(set GPR:$base_wb,
684 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
685
686def STR_POST : AI2po<(ops GPR:$base_wb, GPR:$src, GPR:$base,am2offset:$offset),
687 "str $src, [$base], $offset", "$base = $base_wb",
688 [(set GPR:$base_wb,
689 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
690
691def STRH_PRE : AI3pr<(ops GPR:$base_wb, GPR:$src, GPR:$base,am3offset:$offset),
692 "strh $src, [$base, $offset]!", "$base = $base_wb",
693 [(set GPR:$base_wb,
694 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
695
696def STRH_POST: AI3po<(ops GPR:$base_wb, GPR:$src, GPR:$base,am3offset:$offset),
697 "strh $src, [$base], $offset", "$base = $base_wb",
698 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
699 GPR:$base, am3offset:$offset))]>;
700
701def STRB_PRE : AI2pr<(ops GPR:$base_wb, GPR:$src, GPR:$base,am2offset:$offset),
702 "strb $src, [$base, $offset]!", "$base = $base_wb",
703 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
704 GPR:$base, am2offset:$offset))]>;
705
706def STRB_POST: AI2po<(ops GPR:$base_wb, GPR:$src, GPR:$base,am2offset:$offset),
707 "strb $src, [$base], $offset", "$base = $base_wb",
708 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
709 GPR:$base, am2offset:$offset))]>;
710} // isStore
711
712//===----------------------------------------------------------------------===//
713// Load / store multiple Instructions.
714//
715
716let isLoad = 1 in
717def LDM : AI4<(ops addrmode4:$addr, reglist:$dst1, variable_ops),
718 "ldm${addr:submode} $addr, $dst1",
719 []>;
720
721let isStore = 1 in
722def STM : AI4<(ops addrmode4:$addr, reglist:$src1, variable_ops),
723 "stm${addr:submode} $addr, $src1",
724 []>;
725
726//===----------------------------------------------------------------------===//
727// Move Instructions.
728//
729
Evan Cheng9f6636f2007-03-19 07:48:02 +0000730def MOVr : AI1<(ops GPR:$dst, GPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000731 "mov $dst, $src", []>;
Evan Cheng9f6636f2007-03-19 07:48:02 +0000732def MOVs : AI1<(ops GPR:$dst, so_reg:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000733 "mov $dst, $src", [(set GPR:$dst, so_reg:$src)]>;
Evan Chenga2515702007-03-19 07:09:02 +0000734
735let isReMaterializable = 1 in
Evan Cheng9f6636f2007-03-19 07:48:02 +0000736def MOVi : AI1<(ops GPR:$dst, so_imm:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000737 "mov $dst, $src", [(set GPR:$dst, so_imm:$src)]>;
738
739// These aren't really mov instructions, but we have to define them this way
740// due to flag operands.
741
742def MOVsrl_flag : AI1<(ops GPR:$dst, GPR:$src),
743 "movs $dst, $src, lsr #1",
744 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>;
745def MOVsra_flag : AI1<(ops GPR:$dst, GPR:$src),
746 "movs $dst, $src, asr #1",
747 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>;
Evan Cheng9f6636f2007-03-19 07:48:02 +0000748def MOVrx : AI1<(ops GPR:$dst, GPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000749 "mov $dst, $src, rrx",
750 [(set GPR:$dst, (ARMrrx GPR:$src))]>;
751
752
753//===----------------------------------------------------------------------===//
754// Extend Instructions.
755//
756
757// Sign extenders
758
759defm SXTB : AI_unary_rrot<"sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
760defm SXTH : AI_unary_rrot<"sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
761
762defm SXTAB : AI_bin_rrot<"sxtab",
763 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
764defm SXTAH : AI_bin_rrot<"sxtah",
765 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
766
767// TODO: SXT(A){B|H}16
768
769// Zero extenders
770
771let AddedComplexity = 16 in {
772defm UXTB : AI_unary_rrot<"uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
773defm UXTH : AI_unary_rrot<"uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
774defm UXTB16 : AI_unary_rrot<"uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
775
776def : ARMV6Pat<(and (shl GPR:$Src, 8), 0xFF00FF),
777 (UXTB16r_rot GPR:$Src, 24)>;
778def : ARMV6Pat<(and (srl GPR:$Src, 8), 0xFF00FF),
779 (UXTB16r_rot GPR:$Src, 8)>;
780
781defm UXTAB : AI_bin_rrot<"uxtab",
782 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
783defm UXTAH : AI_bin_rrot<"uxtah",
784 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Rafael Espindola3c000bf2006-08-21 22:00:32 +0000785}
786
Evan Chenga8e29892007-01-19 07:51:42 +0000787// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
788//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
Rafael Espindola817e7fd2006-09-11 19:24:19 +0000789
Evan Chenga8e29892007-01-19 07:51:42 +0000790// TODO: UXT(A){B|H}16
791
792//===----------------------------------------------------------------------===//
793// Arithmetic Instructions.
794//
795
796defm ADD : AI1_bin_irs<"add" , BinOpFrag<(add node:$LHS, node:$RHS)>>;
797defm ADDS : AI1_bin_irs<"adds", BinOpFrag<(addc node:$LHS, node:$RHS)>>;
798defm ADC : AI1_bin_irs<"adc" , BinOpFrag<(adde node:$LHS, node:$RHS)>>;
799defm SUB : AI1_bin_irs<"sub" , BinOpFrag<(sub node:$LHS, node:$RHS)>>;
800defm SUBS : AI1_bin_irs<"subs", BinOpFrag<(subc node:$LHS, node:$RHS)>>;
801defm SBC : AI1_bin_irs<"sbc" , BinOpFrag<(sube node:$LHS, node:$RHS)>>;
802
803// These don't define reg/reg forms, because they are handled above.
804defm RSB : AI1_bin_is <"rsb" , BinOpFrag<(sub node:$RHS, node:$LHS)>>;
805defm RSBS : AI1_bin_is <"rsbs", BinOpFrag<(subc node:$RHS, node:$LHS)>>;
806defm RSC : AI1_bin_is <"rsc" , BinOpFrag<(sube node:$RHS, node:$LHS)>>;
807
808// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
809def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
810 (SUBri GPR:$src, so_imm_neg:$imm)>;
811
812//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
813// (SUBSri GPR:$src, so_imm_neg:$imm)>;
814//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
815// (SBCri GPR:$src, so_imm_neg:$imm)>;
816
817// Note: These are implemented in C++ code, because they have to generate
818// ADD/SUBrs instructions, which use a complex pattern that a xform function
819// cannot produce.
820// (mul X, 2^n+1) -> (add (X << n), X)
821// (mul X, 2^n-1) -> (rsb X, (X << n))
822
823
824//===----------------------------------------------------------------------===//
825// Bitwise Instructions.
826//
827
828defm AND : AI1_bin_irs<"and", BinOpFrag<(and node:$LHS, node:$RHS)>>;
829defm ORR : AI1_bin_irs<"orr", BinOpFrag<(or node:$LHS, node:$RHS)>>;
830defm EOR : AI1_bin_irs<"eor", BinOpFrag<(xor node:$LHS, node:$RHS)>>;
831defm BIC : AI1_bin_irs<"bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
832
Evan Chenga2515702007-03-19 07:09:02 +0000833def MVNr : AI<(ops GPR:$dst, GPR:$src),
834 "mvn $dst, $src", [(set GPR:$dst, (not GPR:$src))]>;
835def MVNs : AI<(ops GPR:$dst, so_reg:$src),
836 "mvn $dst, $src", [(set GPR:$dst, (not so_reg:$src))]>;
837let isReMaterializable = 1 in
838def MVNi : AI<(ops GPR:$dst, so_imm:$imm),
839 "mvn $dst, $imm", [(set GPR:$dst, so_imm_not:$imm)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000840
841def : ARMPat<(and GPR:$src, so_imm_not:$imm),
842 (BICri GPR:$src, so_imm_not:$imm)>;
843
844//===----------------------------------------------------------------------===//
845// Multiply Instructions.
846//
847
848// AI_orr - Defines a (op r, r) pattern.
849class AI_orr<string opc, SDNode opnode>
850 : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
851 !strconcat(opc, " $dst, $a, $b"),
852 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
853
854// AI_oorr - Defines a (op (op r, r), r) pattern.
855class AI_oorr<string opc, SDNode opnode1, SDNode opnode2>
856 : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$c),
857 !strconcat(opc, " $dst, $a, $b, $c"),
858 [(set GPR:$dst, (opnode1 (opnode2 GPR:$a, GPR:$b), GPR:$c))]>;
859
860def MUL : AI_orr<"mul", mul>;
861def MLA : AI_oorr<"mla", add, mul>;
862
863// Extra precision multiplies with low / high results
864def SMULL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
865 "smull $ldst, $hdst, $a, $b",
866 []>;
867
868def UMULL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
869 "umull $ldst, $hdst, $a, $b",
870 []>;
871
872// Multiply + accumulate
873def SMLAL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
874 "smlal $ldst, $hdst, $a, $b",
875 []>;
876
877def UMLAL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
878 "umlal $ldst, $hdst, $a, $b",
879 []>;
880
881def UMAAL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
882 "umaal $ldst, $hdst, $a, $b",
883 []>, Requires<[IsARM, HasV6]>;
884
885// Most significant word multiply
886def SMMUL : AI_orr<"smmul", mulhs>, Requires<[IsARM, HasV6]>;
887def SMMLA : AI_oorr<"smmla", add, mulhs>, Requires<[IsARM, HasV6]>;
888
889
890def SMMLS : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$c),
891 "smmls $dst, $a, $b, $c",
892 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
893 Requires<[IsARM, HasV6]>;
894
895multiclass AI_smul<string opc, PatFrag opnode> {
Evan Cheng34b12d22007-01-19 20:27:35 +0000896 def BB : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
897 !strconcat(opc, "bb $dst, $a, $b"),
898 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
899 (sext_inreg GPR:$b, i16)))]>,
900 Requires<[IsARM, HasV5TE]>;
901 def BT : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
902 !strconcat(opc, "bt $dst, $a, $b"),
903 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
904 (sra GPR:$b, 16)))]>,
905 Requires<[IsARM, HasV5TE]>;
906 def TB : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
907 !strconcat(opc, "tb $dst, $a, $b"),
908 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
909 (sext_inreg GPR:$b, i16)))]>,
910 Requires<[IsARM, HasV5TE]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000911 def TT : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
912 !strconcat(opc, "tt $dst, $a, $b"),
913 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
914 (sra GPR:$b, 16)))]>,
915 Requires<[IsARM, HasV5TE]>;
Evan Cheng34b12d22007-01-19 20:27:35 +0000916 def WB : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
917 !strconcat(opc, "wb $dst, $a, $b"),
918 [(set GPR:$dst, (sra (opnode GPR:$a,
919 (sext_inreg GPR:$b, i16)), 16))]>,
920 Requires<[IsARM, HasV5TE]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000921 def WT : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
922 !strconcat(opc, "wt $dst, $a, $b"),
923 [(set GPR:$dst, (sra (opnode GPR:$a,
924 (sra GPR:$b, 16)), 16))]>,
925 Requires<[IsARM, HasV5TE]>;
Rafael Espindolabec2e382006-10-16 16:33:29 +0000926}
927
Evan Chenga8e29892007-01-19 07:51:42 +0000928multiclass AI_smla<string opc, PatFrag opnode> {
Evan Cheng34b12d22007-01-19 20:27:35 +0000929 def BB : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
930 !strconcat(opc, "bb $dst, $a, $b, $acc"),
931 [(set GPR:$dst, (add GPR:$acc,
932 (opnode (sext_inreg GPR:$a, i16),
933 (sext_inreg GPR:$b, i16))))]>,
934 Requires<[IsARM, HasV5TE]>;
935 def BT : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
936 !strconcat(opc, "bt $dst, $a, $b, $acc"),
937 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
Evan Chenga8e29892007-01-19 07:51:42 +0000938 (sra GPR:$b, 16))))]>,
Evan Cheng34b12d22007-01-19 20:27:35 +0000939 Requires<[IsARM, HasV5TE]>;
940 def TB : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
941 !strconcat(opc, "tb $dst, $a, $b, $acc"),
942 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
943 (sext_inreg GPR:$b, i16))))]>,
944 Requires<[IsARM, HasV5TE]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000945 def TT : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
946 !strconcat(opc, "tt $dst, $a, $b, $acc"),
947 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
948 (sra GPR:$b, 16))))]>,
949 Requires<[IsARM, HasV5TE]>;
950
Evan Cheng34b12d22007-01-19 20:27:35 +0000951 def WB : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
952 !strconcat(opc, "wb $dst, $a, $b, $acc"),
953 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
954 (sext_inreg GPR:$b, i16)), 16)))]>,
955 Requires<[IsARM, HasV5TE]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000956 def WT : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
957 !strconcat(opc, "wt $dst, $a, $b, $acc"),
958 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
959 (sra GPR:$b, 16)), 16)))]>,
960 Requires<[IsARM, HasV5TE]>;
Rafael Espindola70673a12006-10-18 16:20:57 +0000961}
Rafael Espindola5c2aa0a2006-09-08 12:47:03 +0000962
Evan Chenga8e29892007-01-19 07:51:42 +0000963defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
964defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Rafael Espindola27185192006-09-29 21:20:16 +0000965
Evan Chenga8e29892007-01-19 07:51:42 +0000966// TODO: Halfword multiple accumulate long: SMLAL<x><y>
967// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
Rafael Espindola42b62f32006-10-13 13:14:59 +0000968
Evan Chenga8e29892007-01-19 07:51:42 +0000969//===----------------------------------------------------------------------===//
970// Misc. Arithmetic Instructions.
971//
Rafael Espindola0d9fe762006-10-10 16:33:47 +0000972
Evan Chenga8e29892007-01-19 07:51:42 +0000973def CLZ : AI<(ops GPR:$dst, GPR:$src),
974 "clz $dst, $src",
975 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]>;
Rafael Espindola199dd672006-10-17 13:13:23 +0000976
Evan Chenga8e29892007-01-19 07:51:42 +0000977def REV : AI<(ops GPR:$dst, GPR:$src),
978 "rev $dst, $src",
979 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]>;
Rafael Espindola199dd672006-10-17 13:13:23 +0000980
Evan Chenga8e29892007-01-19 07:51:42 +0000981def REV16 : AI<(ops GPR:$dst, GPR:$src),
982 "rev16 $dst, $src",
983 [(set GPR:$dst,
984 (or (and (srl GPR:$src, 8), 0xFF),
985 (or (and (shl GPR:$src, 8), 0xFF00),
986 (or (and (srl GPR:$src, 8), 0xFF0000),
987 (and (shl GPR:$src, 8), 0xFF000000)))))]>,
988 Requires<[IsARM, HasV6]>;
Rafael Espindola27185192006-09-29 21:20:16 +0000989
Evan Chenga8e29892007-01-19 07:51:42 +0000990def REVSH : AI<(ops GPR:$dst, GPR:$src),
991 "revsh $dst, $src",
992 [(set GPR:$dst,
993 (sext_inreg
Chris Lattner120fba92007-04-17 22:39:58 +0000994 (or (srl (and GPR:$src, 0xFF00), 8),
Evan Chenga8e29892007-01-19 07:51:42 +0000995 (shl GPR:$src, 8)), i16))]>,
996 Requires<[IsARM, HasV6]>;
Rafael Espindola27185192006-09-29 21:20:16 +0000997
Evan Chenga8e29892007-01-19 07:51:42 +0000998def PKHBT : AI<(ops GPR:$dst, GPR:$src1, GPR:$src2, i32imm:$shamt),
999 "pkhbt $dst, $src1, $src2, LSL $shamt",
1000 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1001 (and (shl GPR:$src2, (i32 imm:$shamt)),
1002 0xFFFF0000)))]>,
1003 Requires<[IsARM, HasV6]>;
Rafael Espindola27185192006-09-29 21:20:16 +00001004
Evan Chenga8e29892007-01-19 07:51:42 +00001005// Alternate cases for PKHBT where identities eliminate some nodes.
1006def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1007 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1008def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1009 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
Rafael Espindola9e071f02006-10-02 19:30:56 +00001010
Rafael Espindolaa2845842006-10-05 16:48:49 +00001011
Evan Chenga8e29892007-01-19 07:51:42 +00001012def PKHTB : AI<(ops GPR:$dst, GPR:$src1, GPR:$src2, i32imm:$shamt),
1013 "pkhtb $dst, $src1, $src2, ASR $shamt",
1014 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1015 (and (sra GPR:$src2, imm16_31:$shamt),
1016 0xFFFF)))]>, Requires<[IsARM, HasV6]>;
Rafael Espindola9e071f02006-10-02 19:30:56 +00001017
Evan Chenga8e29892007-01-19 07:51:42 +00001018// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1019// a shift amount of 0 is *not legal* here, it is PKHBT instead.
1020def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, 16)),
1021 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1022def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1023 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1024 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
Rafael Espindolab47e1d02006-10-10 18:55:14 +00001025
Rafael Espindolad9ae7782006-10-07 13:46:42 +00001026
Evan Chenga8e29892007-01-19 07:51:42 +00001027//===----------------------------------------------------------------------===//
1028// Comparison Instructions...
1029//
Rafael Espindolab47e1d02006-10-10 18:55:14 +00001030
Evan Chenga8e29892007-01-19 07:51:42 +00001031defm CMP : AI1_bin0_irs<"cmp", BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
1032defm CMN : AI1_bin0_irs<"cmn", BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +00001033
Evan Chenga8e29892007-01-19 07:51:42 +00001034def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1035 (CMNri GPR:$src, so_imm_neg:$imm)>;
Rafael Espindola493a7fc2006-10-10 20:38:57 +00001036
Evan Chenga8e29892007-01-19 07:51:42 +00001037// Note that TST/TEQ don't set all the same flags that CMP does!
Lauro Ramos Venancio99966632007-04-02 01:30:03 +00001038defm TST : AI1_bin0_irs<"tst", BinOpFrag<(ARMcmpNZ (and node:$LHS, node:$RHS), 0)>>;
1039defm TEQ : AI1_bin0_irs<"teq", BinOpFrag<(ARMcmpNZ (xor node:$LHS, node:$RHS), 0)>>;
1040
1041defm CMPnz : AI1_bin0_irs<"cmp", BinOpFrag<(ARMcmpNZ node:$LHS, node:$RHS)>>;
1042defm CMNnz : AI1_bin0_irs<"cmn", BinOpFrag<(ARMcmpNZ node:$LHS,(ineg node:$RHS))>>;
1043
1044def : ARMPat<(ARMcmpNZ GPR:$src, so_imm_neg:$imm),
1045 (CMNri GPR:$src, so_imm_neg:$imm)>;
1046
Rafael Espindolae5bbd6d2006-10-07 14:24:52 +00001047
Evan Chenga8e29892007-01-19 07:51:42 +00001048// Conditional moves
Evan Cheng42d712b2007-05-08 21:08:43 +00001049def MOVCCr : AI<(ops GPR:$dst, GPR:$false, GPR:$true, ccop:$cc),
Evan Chenga8e29892007-01-19 07:51:42 +00001050 "mov$cc $dst, $true",
1051 [(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc))]>,
1052 RegConstraint<"$false = $dst">;
Rafael Espindola493a7fc2006-10-10 20:38:57 +00001053
Evan Cheng42d712b2007-05-08 21:08:43 +00001054def MOVCCs : AI<(ops GPR:$dst, GPR:$false, so_reg:$true, ccop:$cc),
Evan Chenga8e29892007-01-19 07:51:42 +00001055 "mov$cc $dst, $true",
1056 [(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true,imm:$cc))]>,
1057 RegConstraint<"$false = $dst">;
Rafael Espindola2dc0f2b2006-10-09 17:50:29 +00001058
Evan Cheng42d712b2007-05-08 21:08:43 +00001059def MOVCCi : AI<(ops GPR:$dst, GPR:$false, so_imm:$true, ccop:$cc),
Evan Chenga8e29892007-01-19 07:51:42 +00001060 "mov$cc $dst, $true",
1061 [(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true,imm:$cc))]>,
1062 RegConstraint<"$false = $dst">;
Rafael Espindolad9ae7782006-10-07 13:46:42 +00001063
Rafael Espindola4b20fbc2006-10-10 12:56:00 +00001064
Evan Chenga8e29892007-01-19 07:51:42 +00001065// LEApcrel - Load a pc-relative address into a register without offending the
1066// assembler.
1067def LEApcrel : AI1<(ops GPR:$dst, i32imm:$label),
1068 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
1069 "${:private}PCRELL${:uid}+8))\n"),
1070 !strconcat("${:private}PCRELL${:uid}:\n\t",
1071 "add $dst, pc, #PCRELV${:uid}")),
1072 []>;
Rafael Espindola667c3492006-10-10 19:35:01 +00001073
Evan Chenga8e29892007-01-19 07:51:42 +00001074def LEApcrelJT : AI1<(ops GPR:$dst, i32imm:$label, i32imm:$id),
1075 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
1076 "${:private}PCRELL${:uid}+8))\n"),
1077 !strconcat("${:private}PCRELL${:uid}:\n\t",
1078 "add $dst, pc, #PCRELV${:uid}")),
1079 []>;
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +00001080//===----------------------------------------------------------------------===//
1081// TLS Instructions
1082//
1083
1084// __aeabi_read_tp preserves the registers r1-r3.
1085let isCall = 1,
1086 Defs = [R0, R12, LR] in {
1087 def TPsoft : AI<(ops),
1088 "bl __aeabi_read_tp",
1089 [(set R0, ARMthread_pointer)]>;
1090}
Rafael Espindolac01c87c2006-10-17 20:33:13 +00001091
Evan Chenga8e29892007-01-19 07:51:42 +00001092//===----------------------------------------------------------------------===//
1093// Non-Instruction Patterns
1094//
Rafael Espindola5aca9272006-10-07 14:03:39 +00001095
Evan Chenga8e29892007-01-19 07:51:42 +00001096// ConstantPool, GlobalAddress, and JumpTable
1097def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1098def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1099def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
Evan Chengc70d1842007-03-20 08:11:30 +00001100 (LEApcrelJT tjumptable:$dst, imm:$id)>;
Rafael Espindola5aca9272006-10-07 14:03:39 +00001101
Evan Chenga8e29892007-01-19 07:51:42 +00001102// Large immediate handling.
Rafael Espindola0505be02006-10-16 21:10:32 +00001103
Evan Chenga8e29892007-01-19 07:51:42 +00001104// Two piece so_imms.
Evan Chengc70d1842007-03-20 08:11:30 +00001105let isReMaterializable = 1 in
1106def MOVi2pieces : AI1x2<(ops GPR:$dst, so_imm2part:$src),
1107 "mov $dst, $src",
1108 [(set GPR:$dst, so_imm2part:$src)]>;
Rafael Espindolaf621abc2006-10-17 13:36:07 +00001109
Evan Chenga8e29892007-01-19 07:51:42 +00001110def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
1111 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1112 (so_imm2part_2 imm:$RHS))>;
1113def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
1114 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1115 (so_imm2part_2 imm:$RHS))>;
Rafael Espindolaf621abc2006-10-17 13:36:07 +00001116
Evan Chenga8e29892007-01-19 07:51:42 +00001117// TODO: add,sub,and, 3-instr forms?
Rafael Espindola0505be02006-10-16 21:10:32 +00001118
Rafael Espindola24357862006-10-19 17:05:03 +00001119
Evan Chenga8e29892007-01-19 07:51:42 +00001120// Direct calls
1121def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
Rafael Espindola9dca7ad2006-11-01 14:13:27 +00001122
Evan Chenga8e29892007-01-19 07:51:42 +00001123// zextload i1 -> zextload i8
1124def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
Lauro Ramos Venancioa8f9f4a2006-12-26 19:30:42 +00001125
Evan Chenga8e29892007-01-19 07:51:42 +00001126// extload -> zextload
1127def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1128def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1129def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
Rafael Espindola9dca7ad2006-11-01 14:13:27 +00001130
Evan Chenga8e29892007-01-19 07:51:42 +00001131// truncstore i1 -> truncstore i8
Dale Johannesen25c1f9e2007-04-27 22:17:18 +00001132def : ARMPat<(truncstorei1 GPR:$src, addrmode2:$dst),
Dale Johannesencaa80552007-04-28 00:36:37 +00001133 (STRB GPR:$src, addrmode2:$dst)>;
Dale Johannesen25c1f9e2007-04-27 22:17:18 +00001134def : ARMPat<(pre_truncsti1 GPR:$src, GPR:$base, am2offset:$offset),
Dale Johannesencaa80552007-04-28 00:36:37 +00001135 (STRB_PRE GPR:$src, GPR:$base, am2offset:$offset)>;
Dale Johannesen25c1f9e2007-04-27 22:17:18 +00001136def : ARMPat<(post_truncsti1 GPR:$src, GPR:$base, am2offset:$offset),
Dale Johannesencaa80552007-04-28 00:36:37 +00001137 (STRB_POST GPR:$src, GPR:$base, am2offset:$offset)>;
Evan Chenga8e29892007-01-19 07:51:42 +00001138
Evan Cheng34b12d22007-01-19 20:27:35 +00001139// smul* and smla*
1140def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra (shl GPR:$b, 16), 16)),
1141 (SMULBB GPR:$a, GPR:$b)>;
1142def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1143 (SMULBB GPR:$a, GPR:$b)>;
1144def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16)),
1145 (SMULBT GPR:$a, GPR:$b)>;
1146def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, 16)),
1147 (SMULBT GPR:$a, GPR:$b)>;
1148def : ARMV5TEPat<(mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16)),
1149 (SMULTB GPR:$a, GPR:$b)>;
1150def : ARMV5TEPat<(mul (sra GPR:$a, 16), sext_16_node:$b),
1151 (SMULTB GPR:$a, GPR:$b)>;
1152def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16),
1153 (SMULWB GPR:$a, GPR:$b)>;
1154def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), 16),
1155 (SMULWB GPR:$a, GPR:$b)>;
1156
1157def : ARMV5TEPat<(add GPR:$acc,
1158 (mul (sra (shl GPR:$a, 16), 16),
1159 (sra (shl GPR:$b, 16), 16))),
1160 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1161def : ARMV5TEPat<(add GPR:$acc,
1162 (mul sext_16_node:$a, sext_16_node:$b)),
1163 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1164def : ARMV5TEPat<(add GPR:$acc,
1165 (mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16))),
1166 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1167def : ARMV5TEPat<(add GPR:$acc,
1168 (mul sext_16_node:$a, (sra GPR:$b, 16))),
1169 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1170def : ARMV5TEPat<(add GPR:$acc,
1171 (mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16))),
1172 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1173def : ARMV5TEPat<(add GPR:$acc,
1174 (mul (sra GPR:$a, 16), sext_16_node:$b)),
1175 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1176def : ARMV5TEPat<(add GPR:$acc,
1177 (sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16)),
1178 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1179def : ARMV5TEPat<(add GPR:$acc,
1180 (sra (mul GPR:$a, sext_16_node:$b), 16)),
1181 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1182
Evan Chenga8e29892007-01-19 07:51:42 +00001183//===----------------------------------------------------------------------===//
1184// Thumb Support
1185//
1186
1187include "ARMInstrThumb.td"
1188
1189//===----------------------------------------------------------------------===//
1190// Floating Point Support
1191//
1192
1193include "ARMInstrVFP.td"