blob: 0a10eb197a36495750cef4f764f10c095a9e2643 [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//
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
15//===----------------------------------------------------------------------===//
16// ARM specific DAG Nodes.
17//
18
19// Type profiles.
20def SDT_ARMCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
21
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
48def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeq,
49 [SDNPHasChain, SDNPOutFlag]>;
50def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeq,
51 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
52
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
60def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTRet,
61 [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, [{
111 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(N->getValue()),
112 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, [{
118 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(-(int)N->getValue()),
119 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, [{
125 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(~(int)N->getValue()),
126 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), [{
131 int32_t v = (int32_t)N->getValue();
132 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), [{
137 return (int32_t)N->getValue() >= 1 && (int32_t)N->getValue() < 16;
138}]>;
139
140/// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
141def imm16_31 : PatLeaf<(i32 imm), [{
142 return (int32_t)N->getValue() >= 16 && (int32_t)N->getValue() < 32;
143}]>;
144
145def so_imm_neg :
146 PatLeaf<(imm), [{ return ARM_AM::getSOImmVal(-(int)N->getValue()) != -1; }],
147 so_imm_neg_XFORM>;
148
149def so_imm_not :
150 PatLeaf<(imm), [{ return ARM_AM::getSOImmVal(~(int)N->getValue()) != -1; }],
151 so_imm_not_XFORM>;
152
153// sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
154def sext_16_node : PatLeaf<(i32 GPR:$a), [{
155 return CurDAG->ComputeNumSignBits(SDOperand(N,0)) >= 17;
156}]>;
157
158
159
160//===----------------------------------------------------------------------===//
161// Operand Definitions.
162//
163
164// Branch target.
165def brtarget : Operand<OtherVT>;
166
167// A list of registers separated by comma. Used by load/store multiple.
168def reglist : Operand<i32> {
169 let PrintMethod = "printRegisterList";
170}
171
172// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
173def cpinst_operand : Operand<i32> {
174 let PrintMethod = "printCPInstOperand";
175}
176
177def jtblock_operand : Operand<i32> {
178 let PrintMethod = "printJTBlockOperand";
179}
180
181// Local PC labels.
182def pclabel : Operand<i32> {
183 let PrintMethod = "printPCLabel";
184}
185
186// shifter_operand operands: so_reg and so_imm.
187def so_reg : Operand<i32>, // reg reg imm
188 ComplexPattern<i32, 3, "SelectShifterOperandReg",
189 [shl,srl,sra,rotr]> {
190 let PrintMethod = "printSORegOperand";
191 let MIOperandInfo = (ops GPR, GPR, i32imm);
192}
193
194// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
195// 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
196// represented in the imm field in the same 12-bit form that they are encoded
197// into so_imm instructions: the 8-bit immediate is the least significant bits
198// [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
199def so_imm : Operand<i32>,
200 PatLeaf<(imm),
201 [{ return ARM_AM::getSOImmVal(N->getValue()) != -1; }],
202 so_imm_XFORM> {
203 let PrintMethod = "printSOImmOperand";
204}
205
206// Break so_imm's up into two pieces. This handles immediates with up to 16
207// bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
208// get the first/second pieces.
209def so_imm2part : Operand<i32>,
210 PatLeaf<(imm),
211 [{ return ARM_AM::isSOImmTwoPartVal((unsigned)N->getValue()); }]> {
212 let PrintMethod = "printSOImm2PartOperand";
213}
214
215def so_imm2part_1 : SDNodeXForm<imm, [{
216 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getValue());
217 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
218}]>;
219
220def so_imm2part_2 : SDNodeXForm<imm, [{
221 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getValue());
222 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
223}]>;
224
225
226// Define ARM specific addressing modes.
227
228// addrmode2 := reg +/- reg shop imm
229// addrmode2 := reg +/- imm12
230//
231def addrmode2 : Operand<i32>,
232 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
233 let PrintMethod = "printAddrMode2Operand";
234 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
235}
236
237def am2offset : Operand<i32>,
238 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
239 let PrintMethod = "printAddrMode2OffsetOperand";
240 let MIOperandInfo = (ops GPR, i32imm);
241}
242
243// addrmode3 := reg +/- reg
244// addrmode3 := reg +/- imm8
245//
246def addrmode3 : Operand<i32>,
247 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
248 let PrintMethod = "printAddrMode3Operand";
249 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
250}
251
252def am3offset : Operand<i32>,
253 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
254 let PrintMethod = "printAddrMode3OffsetOperand";
255 let MIOperandInfo = (ops GPR, i32imm);
256}
257
258// addrmode4 := reg, <mode|W>
259//
260def addrmode4 : Operand<i32>,
261 ComplexPattern<i32, 2, "", []> {
262 let PrintMethod = "printAddrMode4Operand";
263 let MIOperandInfo = (ops GPR, i32imm);
264}
265
266// addrmode5 := reg +/- imm8*4
267//
268def addrmode5 : Operand<i32>,
269 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
270 let PrintMethod = "printAddrMode5Operand";
271 let MIOperandInfo = (ops GPR, i32imm);
272}
273
274// addrmodepc := pc + reg
275//
276def addrmodepc : Operand<i32>,
277 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
278 let PrintMethod = "printAddrModePCOperand";
279 let MIOperandInfo = (ops GPR, i32imm);
280}
281
282// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
283// register whose default is 0 (no register).
284def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
285 (ops (i32 14), (i32 zero_reg))> {
286 let PrintMethod = "printPredicateOperand";
287}
288
289// Conditional code result for instructions whose 's' bit is set, e.g. subs.
290//
291def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
292 let PrintMethod = "printSBitModifierOperand";
293}
294
295//===----------------------------------------------------------------------===//
296// ARM Instruction flags. These need to match ARMInstrInfo.h.
297//
298
299// Addressing mode.
300class AddrMode<bits<4> val> {
301 bits<4> Value = val;
302}
303def AddrModeNone : AddrMode<0>;
304def AddrMode1 : AddrMode<1>;
305def AddrMode2 : AddrMode<2>;
306def AddrMode3 : AddrMode<3>;
307def AddrMode4 : AddrMode<4>;
308def AddrMode5 : AddrMode<5>;
309def AddrModeT1 : AddrMode<6>;
310def AddrModeT2 : AddrMode<7>;
311def AddrModeT4 : AddrMode<8>;
312def AddrModeTs : AddrMode<9>;
313
314// Instruction size.
315class SizeFlagVal<bits<3> val> {
316 bits<3> Value = val;
317}
318def SizeInvalid : SizeFlagVal<0>; // Unset.
319def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
320def Size8Bytes : SizeFlagVal<2>;
321def Size4Bytes : SizeFlagVal<3>;
322def Size2Bytes : SizeFlagVal<4>;
323
324// Load / store index mode.
325class IndexMode<bits<2> val> {
326 bits<2> Value = val;
327}
328def IndexModeNone : IndexMode<0>;
329def IndexModePre : IndexMode<1>;
330def IndexModePost : IndexMode<2>;
331
332//===----------------------------------------------------------------------===//
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000333// ARM Instruction Format Definitions.
334//
335
336// Format specifies the encoding used by the instruction. This is part of the
337// ad-hoc solution used to emit machine instruction encodings by our machine
338// code emitter.
339class Format<bits<5> val> {
340 bits<5> Value = val;
341}
342
343def Pseudo : Format<1>;
344def MulFrm : Format<2>;
345def Branch : Format<3>;
346def BranchMisc : Format<4>;
347
348def DPRdIm : Format<5>;
349def DPRdReg : Format<6>;
350def DPRdSoReg : Format<7>;
351def DPRdMisc : Format<8>;
352def DPRnIm : Format<9>;
353def DPRnReg : Format<10>;
354def DPRnSoReg : Format<11>;
355def DPRIm : Format<12>;
356def DPRReg : Format<13>;
357def DPRSoReg : Format<14>;
358def DPRImS : Format<15>;
359def DPRRegS : Format<16>;
360def DPRSoRegS : Format<17>;
361
362def LdFrm : Format<18>;
363def StFrm : Format<19>;
364
365def ArithMisc : Format<20>;
366def ThumbFrm : Format<21>;
367def VFPFrm : Format<22>;
368
369
370
371//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372// ARM Instruction templates.
373//
374
375// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
376class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
377 list<Predicate> Predicates = [IsARM];
378}
379class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
380 list<Predicate> Predicates = [IsARM, HasV5TE];
381}
382class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
383 list<Predicate> Predicates = [IsARM, HasV6];
384}
385
386class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000387 Format f, string cstr>
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 : Instruction {
389 let Namespace = "ARM";
390
391 bits<4> Opcode = opcod;
392 AddrMode AM = am;
393 bits<4> AddrModeBits = AM.Value;
394
395 SizeFlagVal SZ = sz;
396 bits<3> SizeFlag = SZ.Value;
397
398 IndexMode IM = im;
399 bits<2> IndexModeBits = IM.Value;
400
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000401 Format F = f;
402 bits<5> Form = F.Value;
403
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404 let Constraints = cstr;
405}
406
Evan Chengb783fa32007-07-19 01:14:50 +0000407class PseudoInst<dag oops, dag iops, string asm, list<dag> pattern>
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000408 : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, ""> {
Evan Chengb783fa32007-07-19 01:14:50 +0000409 let OutOperandList = oops;
410 let InOperandList = iops;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411 let AsmString = asm;
412 let Pattern = pattern;
413}
414
415// Almost all ARM instructions are predicable.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000416class I<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, IndexMode im,
417 Format f, string opc, string asm, string cstr, list<dag> pattern>
418 : InstARM<opcod, am, sz, im, f, cstr> {
Evan Chengb783fa32007-07-19 01:14:50 +0000419 let OutOperandList = oops;
420 let InOperandList = !con(iops, (ops pred:$p));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421 let AsmString = !strconcat(opc, !strconcat("${p}", asm));
422 let Pattern = pattern;
423 list<Predicate> Predicates = [IsARM];
424}
425
Evan Chengb783fa32007-07-19 01:14:50 +0000426// Same as I except it can optionally modify CPSR. Note it's modeled as
427// an input operand since by default it's a zero register. It will
428// become an implicit def once it's "flipped".
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000429class sI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, IndexMode im,
430 Format f, string opc, string asm, string cstr, list<dag> pattern>
431 : InstARM<opcod, am, sz, im, f, cstr> {
Evan Chengb783fa32007-07-19 01:14:50 +0000432 let OutOperandList = oops;
433 let InOperandList = !con(iops, (ops pred:$p, cc_out:$s));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 let AsmString = !strconcat(opc, !strconcat("${p}${s}", asm));
435 let Pattern = pattern;
436 list<Predicate> Predicates = [IsARM];
437}
438
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000439class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
440 string asm, list<dag> pattern>
441 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
442 asm,"",pattern>;
443class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
444 string asm, list<dag> pattern>
445 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
446 asm,"",pattern>;
447class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
448 string asm, list<dag> pattern>
449 : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
450 asm, "", pattern>;
451class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
452 string asm, list<dag> pattern>
453 : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
454 asm, "", pattern>;
455class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
456 string asm, list<dag> pattern>
457 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
458 asm, "", pattern>;
459class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
460 string asm, list<dag> pattern>
461 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
462 asm, "", pattern>;
463class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
464 string asm, list<dag> pattern>
465 : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
466 asm, "", pattern>;
467class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
468 string asm, list<dag> pattern>
469 : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
470 asm, "", pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471
472// Pre-indexed ops
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000473class AI2pr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
474 string asm, string cstr, list<dag> pattern>
475 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
476 asm, cstr, pattern>;
477class AI3pr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
478 string asm, string cstr, list<dag> pattern>
479 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
480 asm, cstr, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
482// Post-indexed ops
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000483class AI2po<bits<4> opcod, dag oops, dag iops, Format f, string opc,
484 string asm, string cstr, list<dag> pattern>
485 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
486 asm, cstr,pattern>;
487class AI3po<bits<4> opcod, dag oops, dag iops, Format f, string opc,
488 string asm, string cstr, list<dag> pattern>
489 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
490 asm, cstr,pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491
492
493class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
494class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
495
496
497/// AI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
498/// binop that produces a value.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000499multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode> {
500 def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPRIm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 opc, " $dst, $a, $b",
502 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000503 def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPRReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 opc, " $dst, $a, $b",
505 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000506 def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPRSoReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 opc, " $dst, $a, $b",
508 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
509}
510
511/// ASI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
512/// instruction modifies the CSPR register.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000513multiclass ASI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode> {
514 def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPRImS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 opc, "s $dst, $a, $b",
516 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>, Imp<[], [CPSR]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000517 def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPRRegS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518 opc, "s $dst, $a, $b",
519 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Imp<[], [CPSR]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000520 def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPRSoRegS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000521 opc, "s $dst, $a, $b",
522 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>, Imp<[], [CPSR]>;
523}
524
525/// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
526/// patterns. Similar to AsI1_bin_irs except the instruction does not produce
527/// a explicit result, only implicitly set CPSR.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000528multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode> {
529 def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPRnIm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 opc, " $a, $b",
531 [(opnode GPR:$a, so_imm:$b)]>, Imp<[], [CPSR]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000532 def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPRnReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 opc, " $a, $b",
534 [(opnode GPR:$a, GPR:$b)]>, Imp<[], [CPSR]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000535 def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPRnSoReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 opc, " $a, $b",
537 [(opnode GPR:$a, so_reg:$b)]>, Imp<[], [CPSR]>;
538}
539
540/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
541/// register and one whose operand is a register rotated by 8/16/24.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000542multiclass AI_unary_rrot<bits<4> opcod, string opc, PatFrag opnode> {
543 def r : AI<opcod, (outs GPR:$dst), (ins GPR:$Src), Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 opc, " $dst, $Src",
545 [(set GPR:$dst, (opnode GPR:$Src))]>, Requires<[IsARM, HasV6]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000546 def r_rot : AI<opcod, (outs GPR:$dst), (ins GPR:$Src, i32imm:$rot), Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547 opc, " $dst, $Src, ror $rot",
548 [(set GPR:$dst, (opnode (rotr GPR:$Src, rot_imm:$rot)))]>,
549 Requires<[IsARM, HasV6]>;
550}
551
552/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
553/// register and one whose operand is a register rotated by 8/16/24.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000554multiclass AI_bin_rrot<bits<4> opcod, string opc, PatFrag opnode> {
555 def rr : AI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS),
556 Pseudo, opc, " $dst, $LHS, $RHS",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
558 Requires<[IsARM, HasV6]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000559 def rr_rot : AI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot),
560 Pseudo, opc, " $dst, $LHS, $RHS, ror $rot",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(set GPR:$dst, (opnode GPR:$LHS,
562 (rotr GPR:$RHS, rot_imm:$rot)))]>,
563 Requires<[IsARM, HasV6]>;
564}
565
566// Special cases.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000567class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
568 IndexMode im, Format f, string asm, string cstr, list<dag> pattern>
569 : InstARM<opcod, am, sz, im, f, cstr> {
Evan Chengb783fa32007-07-19 01:14:50 +0000570 let OutOperandList = oops;
571 let InOperandList = iops;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572 let AsmString = asm;
573 let Pattern = pattern;
574 list<Predicate> Predicates = [IsARM];
575}
576
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000577class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
578 list<dag> pattern>
579 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
580 "", pattern>;
581class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
582 list<dag> pattern>
583 : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
584 "", pattern>;
585class AXI2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
586 list<dag> pattern>
587 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
588 "", pattern>;
589class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
590 list<dag> pattern>
591 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
592 "", pattern>;
593class AXI4<bits<4> opcod, dag oops, dag iops, Format f, string asm,
594 list<dag> pattern>
595 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
596 "", pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000598class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
599 list<dag> pattern>
600 : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
601 "", pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602
603// BR_JT instructions
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000604class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
605 : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
606 asm, "", pattern>;
607class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
608 : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
609 asm, "", pattern>;
610class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
611 : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
612 asm, "", pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
614/// AsXI1_bin_c_irs - Same as AsI1_bin_irs but without the predicate operand and
615/// setting carry bit. But it can optionally set CPSR.
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000616multiclass AsXI1_bin_c_irs<bits<4> opcod, string opc, PatFrag opnode> {
617 def ri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b, cc_out:$s),
618 DPRIm, !strconcat(opc, "${s} $dst, $a, $b"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>, Imp<[CPSR], []>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000620 def rr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, cc_out:$s),
621 DPRReg, !strconcat(opc, "${s} $dst, $a, $b"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Imp<[CPSR], []>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000623 def rs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b, cc_out:$s),
624 DPRSoReg, !strconcat(opc, "${s} $dst, $a, $b"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>, Imp<[CPSR], []>;
626}
627
628//===----------------------------------------------------------------------===//
629// Instructions
630//===----------------------------------------------------------------------===//
631
632//===----------------------------------------------------------------------===//
633// Miscellaneous Instructions.
634//
635def IMPLICIT_DEF_GPR :
Evan Chengb783fa32007-07-19 01:14:50 +0000636PseudoInst<(outs GPR:$rD), (ins pred:$p),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637 "@ IMPLICIT_DEF_GPR $rD",
638 [(set GPR:$rD, (undef))]>;
639
640
641/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
642/// the function. The first operand is the ID# for this instruction, the second
643/// is the index into the MachineConstantPool that this is, the third is the
644/// size in bytes of this constant pool entry.
645let isNotDuplicable = 1 in
646def CONSTPOOL_ENTRY :
Evan Chengb783fa32007-07-19 01:14:50 +0000647PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
648 i32imm:$size),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000649 "${instid:label} ${cpidx:cpentry}", []>;
650
651def ADJCALLSTACKUP :
Evan Chengb783fa32007-07-19 01:14:50 +0000652PseudoInst<(outs), (ins i32imm:$amt, pred:$p),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 "@ ADJCALLSTACKUP $amt",
654 [(ARMcallseq_end imm:$amt)]>, Imp<[SP],[SP]>;
655
656def ADJCALLSTACKDOWN :
Evan Chengb783fa32007-07-19 01:14:50 +0000657PseudoInst<(outs), (ins i32imm:$amt, pred:$p),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 "@ ADJCALLSTACKDOWN $amt",
659 [(ARMcallseq_start imm:$amt)]>, Imp<[SP],[SP]>;
660
661def DWARF_LOC :
Evan Chengb783fa32007-07-19 01:14:50 +0000662PseudoInst<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663 ".loc $file, $line, $col",
664 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
665
666let isNotDuplicable = 1 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000667def PICADD : AXI1<0x0, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
668 Pseudo, "$cp:\n\tadd$p $dst, pc, $a",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
670
671let isLoad = 1, AddedComplexity = 10 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000672def PICLD : AXI2<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
673 Pseudo, "${addr:label}:\n\tldr$p $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 [(set GPR:$dst, (load addrmodepc:$addr))]>;
675
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000676def PICLDZH : AXI3<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
677 Pseudo, "${addr:label}:\n\tldr${p}h $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678 [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>;
679
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000680def PICLDZB : AXI2<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
681 Pseudo, "${addr:label}:\n\tldr${p}b $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>;
683
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000684def PICLDH : AXI3<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
685 Pseudo, "${addr:label}:\n\tldr${p}h $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 [(set GPR:$dst, (extloadi16 addrmodepc:$addr))]>;
687
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000688def PICLDB : AXI2<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
689 Pseudo, "${addr:label}:\n\tldr${p}b $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 [(set GPR:$dst, (extloadi8 addrmodepc:$addr))]>;
691
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000692def PICLDSH : AXI3<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
693 Pseudo, "${addr:label}:\n\tldr${p}sh $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>;
695
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000696def PICLDSB : AXI3<0x0, (outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
697 Pseudo, "${addr:label}:\n\tldr${p}sb $dst, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>;
699}
700let isStore = 1, AddedComplexity = 10 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000701def PICSTR : AXI2<0x0, (outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
702 Pseudo, "${addr:label}:\n\tstr$p $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(store GPR:$src, addrmodepc:$addr)]>;
704
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000705def PICSTRH : AXI3<0x0, (outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
706 Pseudo, "${addr:label}:\n\tstr${p}h $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707 [(truncstorei16 GPR:$src, addrmodepc:$addr)]>;
708
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000709def PICSTRB : AXI2<0x0, (outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
710 Pseudo, "${addr:label}:\n\tstr${p}b $src, $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
712}
713}
714
715//===----------------------------------------------------------------------===//
716// Control Flow Instructions.
717//
718
719let isReturn = 1, isTerminator = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000720 def BX_RET : AI<0x1, (outs), (ins), BranchMisc, "bx", " lr", [(ARMretflag)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721
722// FIXME: remove when we have a way to marking a MI with these properties.
Evan Chengb783fa32007-07-19 01:14:50 +0000723// FIXME: $dst1 should be a def. But the extra ops must be in the end of the
724// operand list.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725let isLoad = 1, isReturn = 1, isTerminator = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000726 def LDM_RET : AXI4<0x0, (outs),
Evan Chengb783fa32007-07-19 01:14:50 +0000727 (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000728 LdFrm, "ldm${p}${addr:submode} $addr, $dst1",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 []>;
730
Evan Cheng37e7c752007-07-21 00:34:19 +0000731let isCall = 1,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 Defs = [R0, R1, R2, R3, R12, LR,
733 D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000734 def BL : AXI<0xB, (outs), (ins i32imm:$func, variable_ops), Branch,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 "bl ${func:call}",
736 [(ARMcall tglobaladdr:$func)]>;
737
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000738 def BL_pred : AI<0xB, (outs), (ins i32imm:$func, variable_ops),
739 Branch, "bl", " ${func:call}",
740 [(ARMcall_pred tglobaladdr:$func)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741
742 // ARMv5T and above
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000743 def BLX : AXI<0x2, (outs), (ins GPR:$func, variable_ops), BranchMisc,
Evan Chengb783fa32007-07-19 01:14:50 +0000744 "blx $func",
745 [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 let Uses = [LR] in {
747 // ARMv4T
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000748 def BX : AXIx2<0x0, (outs), (ins GPR:$func, variable_ops),
749 BranchMisc, "mov lr, pc\n\tbx $func",
750 [(ARMcall_nolink GPR:$func)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 }
752}
753
Evan Cheng37e7c752007-07-21 00:34:19 +0000754let isBranch = 1, isTerminator = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755 // B is "predicable" since it can be xformed into a Bcc.
756 let isBarrier = 1 in {
757 let isPredicable = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000758 def B : AXI<0xA, (outs), (ins brtarget:$target), Branch, "b $target",
Evan Chengb783fa32007-07-19 01:14:50 +0000759 [(br bb:$target)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760
761 let isNotDuplicable = 1 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000762 def BR_JTr : JTI<0x0, (outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengb783fa32007-07-19 01:14:50 +0000763 "mov pc, $target \n$jt",
764 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000765 def BR_JTm : JTI2<0x0, (outs), (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id),
Evan Chengb783fa32007-07-19 01:14:50 +0000766 "ldr pc, $target \n$jt",
767 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 imm:$id)]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000769 def BR_JTadd : JTI1<0x0, (outs), (ins GPR:$target, GPR:$idx, jtblock_operand:$jt,
Evan Chengb783fa32007-07-19 01:14:50 +0000770 i32imm:$id),
771 "add pc, $target, $idx \n$jt",
772 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 imm:$id)]>;
774 }
775 }
776
777 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
778 // a two-value operand where a dag node expects two operands. :(
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000779 def Bcc : AI<0x0, (outs), (ins brtarget:$target), Branch,
780 "b", " $target",
781 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782}
783
784//===----------------------------------------------------------------------===//
785// Load / store Instructions.
786//
787
788// Load
789let isLoad = 1 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000790def LDR : AI2<0x0, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 "ldr", " $dst, $addr",
792 [(set GPR:$dst, (load addrmode2:$addr))]>;
793
794// Special LDR for loads from non-pc-relative constpools.
795let isReMaterializable = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000796def LDRcp : AI2<0x0, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 "ldr", " $dst, $addr", []>;
798
799// Loads with zero extension
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000800def LDRH : AI3<0xB, (outs GPR:$dst), (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 "ldr", "h $dst, $addr",
802 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
803
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000804def LDRB : AI2<0x1, (outs GPR:$dst), (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 "ldr", "b $dst, $addr",
806 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
807
808// Loads with sign extension
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000809def LDRSH : AI3<0xE, (outs GPR:$dst), (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 "ldr", "sh $dst, $addr",
811 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
812
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000813def LDRSB : AI3<0xD, (outs GPR:$dst), (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 "ldr", "sb $dst, $addr",
815 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
816
817// Load doubleword
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000818def LDRD : AI3<0x0, (outs GPR:$dst), (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 "ldr", "d $dst, $addr",
820 []>, Requires<[IsARM, HasV5T]>;
821
822// Indexed loads
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000823def LDR_PRE : AI2pr<0x0, (outs GPR:$dst, GPR:$base_wb),
824 (ins addrmode2:$addr), LdFrm,
825 "ldr", " $dst, $addr!", "$addr.base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000827def LDR_POST : AI2po<0x0, (outs GPR:$dst, GPR:$base_wb),
828 (ins GPR:$base, am2offset:$offset), LdFrm,
829 "ldr", " $dst, [$base], $offset", "$base = $base_wb", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000831def LDRH_PRE : AI3pr<0xB, (outs GPR:$dst, GPR:$base_wb),
832 (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 "ldr", "h $dst, $addr!", "$addr.base = $base_wb", []>;
834
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000835def LDRH_POST : AI3po<0xB, (outs GPR:$dst, GPR:$base_wb),
836 (ins GPR:$base,am3offset:$offset), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 "ldr", "h $dst, [$base], $offset", "$base = $base_wb", []>;
838
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000839def LDRB_PRE : AI2pr<0x1, (outs GPR:$dst, GPR:$base_wb),
840 (ins addrmode2:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 "ldr", "b $dst, $addr!", "$addr.base = $base_wb", []>;
842
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000843def LDRB_POST : AI2po<0x1, (outs GPR:$dst, GPR:$base_wb),
844 (ins GPR:$base,am2offset:$offset), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 "ldr", "b $dst, [$base], $offset", "$base = $base_wb", []>;
846
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000847def LDRSH_PRE : AI3pr<0xE, (outs GPR:$dst, GPR:$base_wb),
848 (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 "ldr", "sh $dst, $addr!", "$addr.base = $base_wb", []>;
850
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000851def LDRSH_POST: AI3po<0xE, (outs GPR:$dst, GPR:$base_wb),
852 (ins GPR:$base,am3offset:$offset), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 "ldr", "sh $dst, [$base], $offset", "$base = $base_wb", []>;
854
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000855def LDRSB_PRE : AI3pr<0xD, (outs GPR:$dst, GPR:$base_wb),
856 (ins addrmode3:$addr), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 "ldr", "sb $dst, $addr!", "$addr.base = $base_wb", []>;
858
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000859def LDRSB_POST: AI3po<0xD, (outs GPR:$dst, GPR:$base_wb),
860 (ins GPR:$base,am3offset:$offset), LdFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 "ldr", "sb $dst, [$base], $offset", "$base = $base_wb", []>;
862} // isLoad
863
864// Store
865let isStore = 1 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000866def STR : AI2<0x0, (outs), (ins GPR:$src, addrmode2:$addr), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 "str", " $src, $addr",
868 [(store GPR:$src, addrmode2:$addr)]>;
869
870// Stores with truncate
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000871def STRH : AI3<0xB, (outs), (ins GPR:$src, addrmode3:$addr), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 "str", "h $src, $addr",
873 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
874
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000875def STRB : AI2<0x1, (outs), (ins GPR:$src, addrmode2:$addr), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 "str", "b $src, $addr",
877 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
878
879// Store doubleword
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000880def STRD : AI3<0x0, (outs), (ins GPR:$src, addrmode3:$addr), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 "str", "d $src, $addr",
882 []>, Requires<[IsARM, HasV5T]>;
883
884// Indexed stores
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000885def STR_PRE : AI2pr<0x0, (outs GPR:$base_wb),
886 (ins GPR:$src, GPR:$base, am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 "str", " $src, [$base, $offset]!", "$base = $base_wb",
888 [(set GPR:$base_wb,
889 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
890
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000891def STR_POST : AI2po<0x0, (outs GPR:$base_wb),
892 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 "str", " $src, [$base], $offset", "$base = $base_wb",
894 [(set GPR:$base_wb,
895 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
896
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000897def STRH_PRE : AI3pr<0xB, (outs GPR:$base_wb),
898 (ins GPR:$src, GPR:$base,am3offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 "str", "h $src, [$base, $offset]!", "$base = $base_wb",
900 [(set GPR:$base_wb,
901 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
902
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000903def STRH_POST: AI3po<0xB, (outs GPR:$base_wb),
904 (ins GPR:$src, GPR:$base,am3offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 "str", "h $src, [$base], $offset", "$base = $base_wb",
906 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
907 GPR:$base, am3offset:$offset))]>;
908
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000909def STRB_PRE : AI2pr<0x1, (outs GPR:$base_wb),
910 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 "str", "b $src, [$base, $offset]!", "$base = $base_wb",
912 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
913 GPR:$base, am2offset:$offset))]>;
914
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000915def STRB_POST: AI2po<0x1, (outs GPR:$base_wb),
916 (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 "str", "b $src, [$base], $offset", "$base = $base_wb",
918 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
919 GPR:$base, am2offset:$offset))]>;
920} // isStore
921
922//===----------------------------------------------------------------------===//
923// Load / store multiple Instructions.
924//
925
Evan Chengb783fa32007-07-19 01:14:50 +0000926// FIXME: $dst1 should be a def.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927let isLoad = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000928def LDM : AXI4<0x0, (outs),
Evan Chengb783fa32007-07-19 01:14:50 +0000929 (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000930 LdFrm, "ldm${p}${addr:submode} $addr, $dst1",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 []>;
932
933let isStore = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000934def STM : AXI4<0x0, (outs),
Evan Chengb783fa32007-07-19 01:14:50 +0000935 (ins addrmode4:$addr, pred:$p, reglist:$src1, variable_ops),
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000936 StFrm, "stm${p}${addr:submode} $addr, $src1",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 []>;
938
939//===----------------------------------------------------------------------===//
940// Move Instructions.
941//
942
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000943def MOVr : AsI1<0xD, (outs GPR:$dst), (ins GPR:$src), DPRdReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 "mov", " $dst, $src", []>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000945def MOVs : AsI1<0xD, (outs GPR:$dst), (ins so_reg:$src), DPRdSoReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 "mov", " $dst, $src", [(set GPR:$dst, so_reg:$src)]>;
947
948let isReMaterializable = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000949def MOVi : AsI1<0xD, (outs GPR:$dst), (ins so_imm:$src), DPRdIm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 "mov", " $dst, $src", [(set GPR:$dst, so_imm:$src)]>;
951
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000952def MOVrx : AsI1<0xD, (outs GPR:$dst), (ins GPR:$src), DPRdMisc,
Evan Chengb783fa32007-07-19 01:14:50 +0000953 "mov", " $dst, $src, rrx",
954 [(set GPR:$dst, (ARMrrx GPR:$src))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955
956// These aren't really mov instructions, but we have to define them this way
957// due to flag operands.
958
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000959def MOVsrl_flag : AI1<0xD, (outs GPR:$dst), (ins GPR:$src), DPRdMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 "mov", "s $dst, $src, lsr #1",
961 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, Imp<[], [CPSR]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000962def MOVsra_flag : AI1<0xD, (outs GPR:$dst), (ins GPR:$src), DPRdMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 "mov", "s $dst, $src, asr #1",
964 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, Imp<[], [CPSR]>;
965
966//===----------------------------------------------------------------------===//
967// Extend Instructions.
968//
969
970// Sign extenders
971
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000972defm SXTB : AI_unary_rrot<0x0, "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
973defm SXTH : AI_unary_rrot<0x0, "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000975defm SXTAB : AI_bin_rrot<0x0, "sxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000977defm SXTAH : AI_bin_rrot<0x0, "sxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
979
980// TODO: SXT(A){B|H}16
981
982// Zero extenders
983
984let AddedComplexity = 16 in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000985defm UXTB : AI_unary_rrot<0x0, "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
986defm UXTH : AI_unary_rrot<0x0, "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
987defm UXTB16 : AI_unary_rrot<0x0, "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988
989def : ARMV6Pat<(and (shl GPR:$Src, 8), 0xFF00FF),
990 (UXTB16r_rot GPR:$Src, 24)>;
991def : ARMV6Pat<(and (srl GPR:$Src, 8), 0xFF00FF),
992 (UXTB16r_rot GPR:$Src, 8)>;
993
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000994defm UXTAB : AI_bin_rrot<0x0, "uxtab",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +0000996defm UXTAH : AI_bin_rrot<0x0, "uxtah",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
998}
999
1000// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
1001//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
1002
1003// TODO: UXT(A){B|H}16
1004
1005//===----------------------------------------------------------------------===//
1006// Arithmetic Instructions.
1007//
1008
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001009defm ADD : AsI1_bin_irs<0x4, "add", BinOpFrag<(add node:$LHS, node:$RHS)>>;
1010defm SUB : AsI1_bin_irs<0x2, "sub", BinOpFrag<(sub node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011
1012// ADD and SUB with 's' bit set.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001013defm ADDS : ASI1_bin_s_irs<0x4, "add", BinOpFrag<(addc node:$LHS, node:$RHS)>>;
1014defm SUBS : ASI1_bin_s_irs<0x2, "sub", BinOpFrag<(subc node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015
1016// FIXME: Do not allow ADC / SBC to be predicated for now.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001017defm ADC : AsXI1_bin_c_irs<0x5, "adc", BinOpFrag<(adde node:$LHS, node:$RHS)>>;
1018defm SBC : AsXI1_bin_c_irs<0x6, "sbc", BinOpFrag<(sube node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019
1020// These don't define reg/reg forms, because they are handled above.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001021def RSBri : AsI1<0x3, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPRIm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 "rsb", " $dst, $a, $b",
1023 [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]>;
1024
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001025def RSBrs : AsI1<0x3, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPRSoReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 "rsb", " $dst, $a, $b",
1027 [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]>;
1028
1029// RSB with 's' bit set.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001030def RSBSri : AI1<0x3, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPRIm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 "rsb", "s $dst, $a, $b",
1032 [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]>, Imp<[], [CPSR]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001033def RSBSrs : AI1<0x3, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPRSoReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 "rsb", "s $dst, $a, $b",
1035 [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]>, Imp<[], [CPSR]>;
1036
1037// FIXME: Do not allow RSC to be predicated for now. But they can set CPSR.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001038def RSCri : AXI1<0x7, (outs GPR:$dst), (ins GPR:$a, so_imm:$b, cc_out:$s),
1039 DPRIm, "rsc${s} $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>, Imp<[CPSR], []>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001041def RSCrs : AXI1<0x7, (outs GPR:$dst), (ins GPR:$a, so_reg:$b, cc_out:$s),
1042 DPRSoReg, "rsc${s} $dst, $a, $b",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, Imp<[CPSR], []>;
1044
1045// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
1046def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
1047 (SUBri GPR:$src, so_imm_neg:$imm)>;
1048
1049//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
1050// (SUBSri GPR:$src, so_imm_neg:$imm)>;
1051//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
1052// (SBCri GPR:$src, so_imm_neg:$imm)>;
1053
1054// Note: These are implemented in C++ code, because they have to generate
1055// ADD/SUBrs instructions, which use a complex pattern that a xform function
1056// cannot produce.
1057// (mul X, 2^n+1) -> (add (X << n), X)
1058// (mul X, 2^n-1) -> (rsb X, (X << n))
1059
1060
1061//===----------------------------------------------------------------------===//
1062// Bitwise Instructions.
1063//
1064
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001065defm AND : AsI1_bin_irs<0x0, "and", BinOpFrag<(and node:$LHS, node:$RHS)>>;
1066defm ORR : AsI1_bin_irs<0xC, "orr", BinOpFrag<(or node:$LHS, node:$RHS)>>;
1067defm EOR : AsI1_bin_irs<0x1, "eor", BinOpFrag<(xor node:$LHS, node:$RHS)>>;
1068defm BIC : AsI1_bin_irs<0xE, "bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001070def MVNr : AsI<0xE, (outs GPR:$dst), (ins GPR:$src), DPRdReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 "mvn", " $dst, $src", [(set GPR:$dst, (not GPR:$src))]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001072def MVNs : AsI<0xE, (outs GPR:$dst), (ins so_reg:$src), DPRdSoReg,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 "mvn", " $dst, $src", [(set GPR:$dst, (not so_reg:$src))]>;
1074let isReMaterializable = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001075def MVNi : AsI<0xE, (outs GPR:$dst), (ins so_imm:$imm), DPRdIm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 "mvn", " $dst, $imm", [(set GPR:$dst, so_imm_not:$imm)]>;
1077
1078def : ARMPat<(and GPR:$src, so_imm_not:$imm),
1079 (BICri GPR:$src, so_imm_not:$imm)>;
1080
1081//===----------------------------------------------------------------------===//
1082// Multiply Instructions.
1083//
1084
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001085def MUL : AsI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
1086 "mul", " $dst, $a, $b",
1087 [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001089def MLA : AsI<0x2, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c),
1090 MulFrm, "mla", " $dst, $a, $b, $c",
1091 [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092
1093// Extra precision multiplies with low / high results
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001094def SMULL : AsI<0xC, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
1095 MulFrm, "smull", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001097def UMULL : AsI<0x8, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
1098 MulFrm, "umull", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099
1100// Multiply + accumulate
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001101def SMLAL : AsI<0xE, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
1102 MulFrm, "smlal", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001104def UMLAL : AsI<0xA, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b),
1105 MulFrm, "umlal", " $ldst, $hdst, $a, $b", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001107def UMAAL : AI<0x0, (outs GPR:$ldst, GPR:$hdst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 "umaal", " $ldst, $hdst, $a, $b", []>,
1109 Requires<[IsARM, HasV6]>;
1110
1111// Most significant word multiply
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001112def SMMUL : AI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 "smmul", " $dst, $a, $b",
1114 [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>,
1115 Requires<[IsARM, HasV6]>;
1116
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001117def SMMLA : AI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 "smmla", " $dst, $a, $b, $c",
1119 [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>,
1120 Requires<[IsARM, HasV6]>;
1121
1122
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001123def SMMLS : AI<0x0, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 "smmls", " $dst, $a, $b, $c",
1125 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
1126 Requires<[IsARM, HasV6]>;
1127
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001128multiclass AI_smul<bits<4> opcod, string opc, PatFrag opnode> {
1129 def BB : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 !strconcat(opc, "bb"), " $dst, $a, $b",
1131 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1132 (sext_inreg GPR:$b, i16)))]>,
1133 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001134 def BT : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 !strconcat(opc, "bt"), " $dst, $a, $b",
1136 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
1137 (sra GPR:$b, 16)))]>,
1138 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001139 def TB : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 !strconcat(opc, "tb"), " $dst, $a, $b",
1141 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
1142 (sext_inreg GPR:$b, i16)))]>,
1143 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001144 def TT : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 !strconcat(opc, "tt"), " $dst, $a, $b",
1146 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
1147 (sra GPR:$b, 16)))]>,
1148 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001149 def WB : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 !strconcat(opc, "wb"), " $dst, $a, $b",
1151 [(set GPR:$dst, (sra (opnode GPR:$a,
1152 (sext_inreg GPR:$b, i16)), 16))]>,
1153 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001154 def WT : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 !strconcat(opc, "wt"), " $dst, $a, $b",
1156 [(set GPR:$dst, (sra (opnode GPR:$a,
1157 (sra GPR:$b, 16)), 16))]>,
1158 Requires<[IsARM, HasV5TE]>;
1159}
1160
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001161multiclass AI_smla<bits<4> opcod, string opc, PatFrag opnode> {
1162 def BB : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 !strconcat(opc, "bb"), " $dst, $a, $b, $acc",
1164 [(set GPR:$dst, (add GPR:$acc,
1165 (opnode (sext_inreg GPR:$a, i16),
1166 (sext_inreg GPR:$b, i16))))]>,
1167 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001168 def BT : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 !strconcat(opc, "bt"), " $dst, $a, $b, $acc",
1170 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
1171 (sra GPR:$b, 16))))]>,
1172 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001173 def TB : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 !strconcat(opc, "tb"), " $dst, $a, $b, $acc",
1175 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
1176 (sext_inreg GPR:$b, i16))))]>,
1177 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001178 def TT : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 !strconcat(opc, "tt"), " $dst, $a, $b, $acc",
1180 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
1181 (sra GPR:$b, 16))))]>,
1182 Requires<[IsARM, HasV5TE]>;
1183
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001184 def WB : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 !strconcat(opc, "wb"), " $dst, $a, $b, $acc",
1186 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1187 (sext_inreg GPR:$b, i16)), 16)))]>,
1188 Requires<[IsARM, HasV5TE]>;
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001189 def WT : AI<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), MulFrm,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 !strconcat(opc, "wt"), " $dst, $a, $b, $acc",
1191 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
1192 (sra GPR:$b, 16)), 16)))]>,
1193 Requires<[IsARM, HasV5TE]>;
1194}
1195
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001196defm SMUL : AI_smul<0x0, "smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
1197defm SMLA : AI_smla<0x0, "smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198
1199// TODO: Halfword multiple accumulate long: SMLAL<x><y>
1200// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
1201
1202//===----------------------------------------------------------------------===//
1203// Misc. Arithmetic Instructions.
1204//
1205
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001206def CLZ : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 "clz", " $dst, $src",
1208 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]>;
1209
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001210def REV : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 "rev", " $dst, $src",
1212 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]>;
1213
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001214def REV16 : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 "rev16", " $dst, $src",
1216 [(set GPR:$dst,
1217 (or (and (srl GPR:$src, 8), 0xFF),
1218 (or (and (shl GPR:$src, 8), 0xFF00),
1219 (or (and (srl GPR:$src, 8), 0xFF0000),
1220 (and (shl GPR:$src, 8), 0xFF000000)))))]>,
1221 Requires<[IsARM, HasV6]>;
1222
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001223def REVSH : AI<0x0, (outs GPR:$dst), (ins GPR:$src), ArithMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 "revsh", " $dst, $src",
1225 [(set GPR:$dst,
1226 (sext_inreg
1227 (or (srl (and GPR:$src, 0xFF00), 8),
1228 (shl GPR:$src, 8)), i16))]>,
1229 Requires<[IsARM, HasV6]>;
1230
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001231def PKHBT : AI<0x0, (outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1232 Pseudo, "pkhbt", " $dst, $src1, $src2, LSL $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
1234 (and (shl GPR:$src2, (i32 imm:$shamt)),
1235 0xFFFF0000)))]>,
1236 Requires<[IsARM, HasV6]>;
1237
1238// Alternate cases for PKHBT where identities eliminate some nodes.
1239def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1240 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1241def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1242 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
1243
1244
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001245def PKHTB : AI<0x0, (outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
1246 Pseudo, "pkhtb", " $dst, $src1, $src2, ASR $shamt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1248 (and (sra GPR:$src2, imm16_31:$shamt),
1249 0xFFFF)))]>, Requires<[IsARM, HasV6]>;
1250
1251// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1252// a shift amount of 0 is *not legal* here, it is PKHBT instead.
1253def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, 16)),
1254 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1255def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1256 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1257 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
1258
1259
1260//===----------------------------------------------------------------------===//
1261// Comparison Instructions...
1262//
1263
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001264defm CMP : AI1_cmp_irs<0xA, "cmp",
1265 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
1266defm CMN : AI1_cmp_irs<0xB, "cmn",
1267 BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268
1269// Note that TST/TEQ don't set all the same flags that CMP does!
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001270defm TST : AI1_cmp_irs<0x8, "tst",
1271 BinOpFrag<(ARMcmpNZ (and node:$LHS, node:$RHS), 0)>>;
1272defm TEQ : AI1_cmp_irs<0x9, "teq",
1273 BinOpFrag<(ARMcmpNZ (xor node:$LHS, node:$RHS), 0)>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001275defm CMPnz : AI1_cmp_irs<0xA, "cmp",
1276 BinOpFrag<(ARMcmpNZ node:$LHS, node:$RHS)>>;
1277defm CMNnz : AI1_cmp_irs<0xA, "cmn",
1278 BinOpFrag<(ARMcmpNZ node:$LHS,(ineg node:$RHS))>>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279
1280def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1281 (CMNri GPR:$src, so_imm_neg:$imm)>;
1282
1283def : ARMPat<(ARMcmpNZ GPR:$src, so_imm_neg:$imm),
1284 (CMNri GPR:$src, so_imm_neg:$imm)>;
1285
1286
1287// Conditional moves
1288// FIXME: should be able to write a pattern for ARMcmov, but can't use
1289// a two-value operand where a dag node expects two operands. :(
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001290def MOVCCr : AI<0xD, (outs GPR:$dst), (ins GPR:$false, GPR:$true),
1291 DPRdReg, "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>,
1293 RegConstraint<"$false = $dst">;
1294
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001295def MOVCCs : AI<0xD, (outs GPR:$dst), (ins GPR:$false, so_reg:$true),
1296 DPRdSoReg, "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>,
1298 RegConstraint<"$false = $dst">;
1299
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001300def MOVCCi : AI<0xD, (outs GPR:$dst), (ins GPR:$false, so_imm:$true),
1301 DPRdIm, "mov", " $dst, $true",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>,
1303 RegConstraint<"$false = $dst">;
1304
1305
1306// LEApcrel - Load a pc-relative address into a register without offending the
1307// assembler.
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001308def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p), Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
1310 "${:private}PCRELL${:uid}+8))\n"),
1311 !strconcat("${:private}PCRELL${:uid}:\n\t",
1312 "add$p $dst, pc, #PCRELV${:uid}")),
1313 []>;
1314
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001315def LEApcrelJT : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, i32imm:$id, pred:$p),
1316 Pseudo,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
1318 "${:private}PCRELL${:uid}+8))\n"),
1319 !strconcat("${:private}PCRELL${:uid}:\n\t",
1320 "add$p $dst, pc, #PCRELV${:uid}")),
1321 []>;
1322
1323//===----------------------------------------------------------------------===//
1324// TLS Instructions
1325//
1326
1327// __aeabi_read_tp preserves the registers r1-r3.
1328let isCall = 1,
1329 Defs = [R0, R12, LR, CPSR] in {
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001330 def TPsoft : AXI<0x0, (outs), (ins), BranchMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 "bl __aeabi_read_tp",
1332 [(set R0, ARMthread_pointer)]>;
1333}
1334
1335//===----------------------------------------------------------------------===//
1336// Non-Instruction Patterns
1337//
1338
1339// ConstantPool, GlobalAddress, and JumpTable
1340def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1341def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1342def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
1343 (LEApcrelJT tjumptable:$dst, imm:$id)>;
1344
1345// Large immediate handling.
1346
1347// Two piece so_imms.
1348let isReMaterializable = 1 in
Evan Chenga7b3e7c2007-08-07 01:37:15 +00001349def MOVi2pieces : AI1x2<0x0, (outs GPR:$dst), (ins so_imm2part:$src), DPRdMisc,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 "mov", " $dst, $src",
1351 [(set GPR:$dst, so_imm2part:$src)]>;
1352
1353def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
1354 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1355 (so_imm2part_2 imm:$RHS))>;
1356def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
1357 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1358 (so_imm2part_2 imm:$RHS))>;
1359
1360// TODO: add,sub,and, 3-instr forms?
1361
1362
1363// Direct calls
1364def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
1365
1366// zextload i1 -> zextload i8
1367def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1368
1369// extload -> zextload
1370def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1371def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1372def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
1373
1374// truncstore i1 -> truncstore i8
1375def : ARMPat<(truncstorei1 GPR:$src, addrmode2:$dst),
1376 (STRB GPR:$src, addrmode2:$dst)>;
1377def : ARMPat<(pre_truncsti1 GPR:$src, GPR:$base, am2offset:$offset),
1378 (STRB_PRE GPR:$src, GPR:$base, am2offset:$offset)>;
1379def : ARMPat<(post_truncsti1 GPR:$src, GPR:$base, am2offset:$offset),
1380 (STRB_POST GPR:$src, GPR:$base, am2offset:$offset)>;
1381
1382// smul* and smla*
1383def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra (shl GPR:$b, 16), 16)),
1384 (SMULBB GPR:$a, GPR:$b)>;
1385def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1386 (SMULBB GPR:$a, GPR:$b)>;
1387def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16)),
1388 (SMULBT GPR:$a, GPR:$b)>;
1389def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, 16)),
1390 (SMULBT GPR:$a, GPR:$b)>;
1391def : ARMV5TEPat<(mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16)),
1392 (SMULTB GPR:$a, GPR:$b)>;
1393def : ARMV5TEPat<(mul (sra GPR:$a, 16), sext_16_node:$b),
1394 (SMULTB GPR:$a, GPR:$b)>;
1395def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16),
1396 (SMULWB GPR:$a, GPR:$b)>;
1397def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), 16),
1398 (SMULWB GPR:$a, GPR:$b)>;
1399
1400def : ARMV5TEPat<(add GPR:$acc,
1401 (mul (sra (shl GPR:$a, 16), 16),
1402 (sra (shl GPR:$b, 16), 16))),
1403 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1404def : ARMV5TEPat<(add GPR:$acc,
1405 (mul sext_16_node:$a, sext_16_node:$b)),
1406 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1407def : ARMV5TEPat<(add GPR:$acc,
1408 (mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16))),
1409 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1410def : ARMV5TEPat<(add GPR:$acc,
1411 (mul sext_16_node:$a, (sra GPR:$b, 16))),
1412 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1413def : ARMV5TEPat<(add GPR:$acc,
1414 (mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16))),
1415 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1416def : ARMV5TEPat<(add GPR:$acc,
1417 (mul (sra GPR:$a, 16), sext_16_node:$b)),
1418 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1419def : ARMV5TEPat<(add GPR:$acc,
1420 (sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16)),
1421 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1422def : ARMV5TEPat<(add GPR:$acc,
1423 (sra (mul GPR:$a, sext_16_node:$b), 16)),
1424 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1425
1426//===----------------------------------------------------------------------===//
1427// Thumb Support
1428//
1429
1430include "ARMInstrThumb.td"
1431
1432//===----------------------------------------------------------------------===//
1433// Floating Point Support
1434//
1435
1436include "ARMInstrVFP.td"