blob: 4293d1a4be70f899fe550cccbc2ffe7fd3b69969 [file] [log] [blame]
Evan Cheng10043e22007-01-19 07:51:42 +00001//===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
Rafael Espindolaffdc24b2006-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 Cheng10043e22007-01-19 07:51:42 +000015//===----------------------------------------------------------------------===//
16// ARM specific DAG Nodes.
17//
Rafael Espindolae45a79a2006-09-11 17:25:40 +000018
Evan Cheng10043e22007-01-19 07:51:42 +000019// Type profiles.
20def SDT_ARMCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
Rafael Espindola708cb602006-11-08 17:07:32 +000021
Evan Cheng10043e22007-01-19 07:51:42 +000022def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
Rafael Espindola19398ec2006-10-17 18:04:53 +000023
Evan Cheng10043e22007-01-19 07:51:42 +000024def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
Rafael Espindolae45a79a2006-09-11 17:25:40 +000025
Evan Cheng10043e22007-01-19 07:51:42 +000026def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
28 SDTCisVT<3, i32>]>;
Rafael Espindola708cb602006-11-08 17:07:32 +000029
Evan Cheng10043e22007-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 Venancioc39c12a2007-04-27 13:54:47 +000042def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
43
Evan Cheng10043e22007-01-19 07:51:42 +000044// Node definitions.
45def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
Evan Cheng10043e22007-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 Cheng456db392007-02-03 09:11:58 +000051 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng10043e22007-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 Venancio6be85332007-04-02 01:30:03 +000075def ARMcmpNZ : SDNode<"ARMISD::CMPNZ", SDT_ARMCmp,
76 [SDNPOutFlag]>;
77
Evan Cheng10043e22007-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 Espindola19398ec2006-10-17 18:04:53 +000083
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +000084def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
85
Rafael Espindolaffdc24b2006-05-14 22:18:28 +000086//===----------------------------------------------------------------------===//
Evan Cheng10043e22007-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 Espindolaffdc24b2006-05-14 22:18:28 +000095//===----------------------------------------------------------------------===//
Evan Cheng10043e22007-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 Cheng5be3e092007-03-19 07:09:02 +0000147def so_imm_not :
Evan Cheng10043e22007-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 Cheng10043e22007-01-19 07:51:42 +0000157
158//===----------------------------------------------------------------------===//
159// Operand Definitions.
160//
161
162// Branch target.
163def brtarget : Operand<OtherVT>;
164
165// Operand for printing out a condition code.
166def CCOp : Operand<i32> {
167 let PrintMethod = "printCCOperand";
168}
169
170// A list of registers separated by comma. Used by load/store multiple.
171def reglist : Operand<i32> {
172 let PrintMethod = "printRegisterList";
173}
174
175// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
176def cpinst_operand : Operand<i32> {
177 let PrintMethod = "printCPInstOperand";
178}
179
180def jtblock_operand : Operand<i32> {
181 let PrintMethod = "printJTBlockOperand";
182}
183
184// Local PC labels.
185def pclabel : Operand<i32> {
186 let PrintMethod = "printPCLabel";
187}
188
189// shifter_operand operands: so_reg and so_imm.
190def so_reg : Operand<i32>, // reg reg imm
191 ComplexPattern<i32, 3, "SelectShifterOperandReg",
192 [shl,srl,sra,rotr]> {
193 let PrintMethod = "printSORegOperand";
194 let MIOperandInfo = (ops GPR, GPR, i32imm);
195}
196
197// so_imm - Match a 32-bit shifter_operand immediate operand, which is an
198// 8-bit immediate rotated by an arbitrary number of bits. so_imm values are
199// represented in the imm field in the same 12-bit form that they are encoded
200// into so_imm instructions: the 8-bit immediate is the least significant bits
201// [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11].
202def so_imm : Operand<i32>,
203 PatLeaf<(imm),
204 [{ return ARM_AM::getSOImmVal(N->getValue()) != -1; }],
205 so_imm_XFORM> {
206 let PrintMethod = "printSOImmOperand";
207}
208
Evan Cheng9e7b8382007-03-20 08:11:30 +0000209// Break so_imm's up into two pieces. This handles immediates with up to 16
210// bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
211// get the first/second pieces.
212def so_imm2part : Operand<i32>,
213 PatLeaf<(imm),
214 [{ return ARM_AM::isSOImmTwoPartVal((unsigned)N->getValue()); }]> {
215 let PrintMethod = "printSOImm2PartOperand";
216}
217
218def so_imm2part_1 : SDNodeXForm<imm, [{
219 unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getValue());
220 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
221}]>;
222
223def so_imm2part_2 : SDNodeXForm<imm, [{
224 unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getValue());
225 return CurDAG->getTargetConstant(ARM_AM::getSOImmVal(V), MVT::i32);
226}]>;
227
Evan Cheng10043e22007-01-19 07:51:42 +0000228
229// Define ARM specific addressing modes.
230
231// addrmode2 := reg +/- reg shop imm
232// addrmode2 := reg +/- imm12
233//
234def addrmode2 : Operand<i32>,
235 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
236 let PrintMethod = "printAddrMode2Operand";
237 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
238}
239
240def am2offset : Operand<i32>,
241 ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> {
242 let PrintMethod = "printAddrMode2OffsetOperand";
243 let MIOperandInfo = (ops GPR, i32imm);
244}
245
246// addrmode3 := reg +/- reg
247// addrmode3 := reg +/- imm8
248//
249def addrmode3 : Operand<i32>,
250 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
251 let PrintMethod = "printAddrMode3Operand";
252 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
253}
254
255def am3offset : Operand<i32>,
256 ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> {
257 let PrintMethod = "printAddrMode3OffsetOperand";
258 let MIOperandInfo = (ops GPR, i32imm);
259}
260
261// addrmode4 := reg, <mode|W>
262//
263def addrmode4 : Operand<i32>,
264 ComplexPattern<i32, 2, "", []> {
265 let PrintMethod = "printAddrMode4Operand";
266 let MIOperandInfo = (ops GPR, i32imm);
267}
268
269// addrmode5 := reg +/- imm8*4
270//
271def addrmode5 : Operand<i32>,
272 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
273 let PrintMethod = "printAddrMode5Operand";
274 let MIOperandInfo = (ops GPR, i32imm);
275}
276
277// addrmodepc := pc + reg
278//
279def addrmodepc : Operand<i32>,
280 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
281 let PrintMethod = "printAddrModePCOperand";
282 let MIOperandInfo = (ops GPR, i32imm);
283}
284
285//===----------------------------------------------------------------------===//
286// ARM Instruction flags. These need to match ARMInstrInfo.h.
287//
288
289// Addressing mode.
290class AddrMode<bits<4> val> {
291 bits<4> Value = val;
292}
293def AddrModeNone : AddrMode<0>;
294def AddrMode1 : AddrMode<1>;
295def AddrMode2 : AddrMode<2>;
296def AddrMode3 : AddrMode<3>;
297def AddrMode4 : AddrMode<4>;
298def AddrMode5 : AddrMode<5>;
299def AddrModeT1 : AddrMode<6>;
300def AddrModeT2 : AddrMode<7>;
301def AddrModeT4 : AddrMode<8>;
302def AddrModeTs : AddrMode<9>;
303
304// Instruction size.
305class SizeFlagVal<bits<3> val> {
306 bits<3> Value = val;
307}
308def SizeInvalid : SizeFlagVal<0>; // Unset.
309def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
310def Size8Bytes : SizeFlagVal<2>;
311def Size4Bytes : SizeFlagVal<3>;
312def Size2Bytes : SizeFlagVal<4>;
313
314// Load / store index mode.
315class IndexMode<bits<2> val> {
316 bits<2> Value = val;
317}
318def IndexModeNone : IndexMode<0>;
319def IndexModePre : IndexMode<1>;
320def IndexModePost : IndexMode<2>;
321
322//===----------------------------------------------------------------------===//
323// ARM Instruction templates.
324//
325
326// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
327class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
328 list<Predicate> Predicates = [IsARM];
329}
Evan Cheng77c15de2007-01-19 20:27:35 +0000330class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
331 list<Predicate> Predicates = [IsARM, HasV5TE];
332}
Evan Cheng10043e22007-01-19 07:51:42 +0000333class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
334 list<Predicate> Predicates = [IsARM, HasV6];
335}
336
Evan Cheng10043e22007-01-19 07:51:42 +0000337class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
338 dag ops, string asmstr, string cstr>
339 : Instruction {
Rafael Espindolaffdc24b2006-05-14 22:18:28 +0000340 let Namespace = "ARM";
341
Evan Cheng10043e22007-01-19 07:51:42 +0000342 bits<4> Opcode = opcod;
343 AddrMode AM = am;
344 bits<4> AddrModeBits = AM.Value;
345
346 SizeFlagVal SZ = sz;
347 bits<3> SizeFlag = SZ.Value;
348
349 IndexMode IM = im;
350 bits<2> IndexModeBits = IM.Value;
351
Rafael Espindolaffdc24b2006-05-14 22:18:28 +0000352 dag OperandList = ops;
353 let AsmString = asmstr;
Evan Cheng10043e22007-01-19 07:51:42 +0000354 let Constraints = cstr;
355}
356
357class PseudoInst<dag ops, string asm, list<dag> pattern>
358 : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, ops, asm, ""> {
Rafael Espindolaffdc24b2006-05-14 22:18:28 +0000359 let Pattern = pattern;
360}
361
Evan Cheng10043e22007-01-19 07:51:42 +0000362class I<dag ops, AddrMode am, SizeFlagVal sz, IndexMode im,
363 string asm, string cstr, list<dag> pattern>
364 // FIXME: Set all opcodes to 0 for now.
365 : InstARM<0, am, sz, im, ops, asm, cstr> {
366 let Pattern = pattern;
367 list<Predicate> Predicates = [IsARM];
368}
Rafael Espindola203922d2006-10-16 17:57:20 +0000369
Evan Cheng10043e22007-01-19 07:51:42 +0000370class AI<dag ops, string asm, list<dag> pattern>
371 : I<ops, AddrModeNone, Size4Bytes, IndexModeNone, asm, "", pattern>;
372class AI1<dag ops, string asm, list<dag> pattern>
373 : I<ops, AddrMode1, Size4Bytes, IndexModeNone, asm, "", pattern>;
374class AI2<dag ops, string asm, list<dag> pattern>
375 : I<ops, AddrMode2, Size4Bytes, IndexModeNone, asm, "", pattern>;
376class AI3<dag ops, string asm, list<dag> pattern>
377 : I<ops, AddrMode3, Size4Bytes, IndexModeNone, asm, "", pattern>;
378class AI4<dag ops, string asm, list<dag> pattern>
379 : I<ops, AddrMode4, Size4Bytes, IndexModeNone, asm, "", pattern>;
Lauro Ramos Venancio143b0df2007-03-27 16:19:21 +0000380class AIx2<dag ops, string asm, list<dag> pattern>
381 : I<ops, AddrModeNone, Size8Bytes, IndexModeNone, asm, "", pattern>;
Evan Cheng9e7b8382007-03-20 08:11:30 +0000382class AI1x2<dag ops, string asm, list<dag> pattern>
383 : I<ops, AddrMode1, Size8Bytes, IndexModeNone, asm, "", pattern>;
Rafael Espindolaf63752f2006-10-16 18:32:36 +0000384
Evan Cheng10043e22007-01-19 07:51:42 +0000385// Pre-indexed ops
386class AI2pr<dag ops, string asm, string cstr, list<dag> pattern>
387 : I<ops, AddrMode2, Size4Bytes, IndexModePre, asm, cstr, pattern>;
388class AI3pr<dag ops, string asm, string cstr, list<dag> pattern>
389 : I<ops, AddrMode3, Size4Bytes, IndexModePre, asm, cstr, pattern>;
Rafael Espindolae341d602006-10-16 18:39:22 +0000390
Evan Cheng10043e22007-01-19 07:51:42 +0000391// Post-indexed ops
392class AI2po<dag ops, string asm, string cstr, list<dag> pattern>
393 : I<ops, AddrMode2, Size4Bytes, IndexModePost, asm, cstr, pattern>;
394class AI3po<dag ops, string asm, string cstr, list<dag> pattern>
395 : I<ops, AddrMode3, Size4Bytes, IndexModePost, asm, cstr, pattern>;
Rafael Espindola39682632006-10-17 20:45:22 +0000396
Evan Cheng10043e22007-01-19 07:51:42 +0000397// BR_JT instructions
398class JTI<dag ops, string asm, list<dag> pattern>
399 : I<ops, AddrModeNone, SizeSpecial, IndexModeNone, asm, "", pattern>;
400class JTI1<dag ops, string asm, list<dag> pattern>
401 : I<ops, AddrMode1, SizeSpecial, IndexModeNone, asm, "", pattern>;
402class JTI2<dag ops, string asm, list<dag> pattern>
403 : I<ops, AddrMode2, SizeSpecial, IndexModeNone, asm, "", pattern>;
Rafael Espindola39682632006-10-17 20:45:22 +0000404
Evan Cheng10043e22007-01-19 07:51:42 +0000405
406class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
407class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
408
409
410/// AI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
411/// binop that produces a value.
412multiclass AI1_bin_irs<string opc, PatFrag opnode> {
413 def ri : AI1<(ops GPR:$dst, GPR:$a, so_imm:$b),
414 !strconcat(opc, " $dst, $a, $b"),
415 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
416 def rr : AI1<(ops GPR:$dst, GPR:$a, GPR:$b),
417 !strconcat(opc, " $dst, $a, $b"),
418 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
419 def rs : AI1<(ops GPR:$dst, GPR:$a, so_reg:$b),
420 !strconcat(opc, " $dst, $a, $b"),
421 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
422}
423
424/// AI1_bin0_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns.
425/// Similar to AI1_bin_irs except the instruction does not produce a result.
426multiclass AI1_bin0_irs<string opc, PatFrag opnode> {
427 def ri : AI1<(ops GPR:$a, so_imm:$b),
428 !strconcat(opc, " $a, $b"),
429 [(opnode GPR:$a, so_imm:$b)]>;
430 def rr : AI1<(ops GPR:$a, GPR:$b),
431 !strconcat(opc, " $a, $b"),
432 [(opnode GPR:$a, GPR:$b)]>;
433 def rs : AI1<(ops GPR:$a, so_reg:$b),
434 !strconcat(opc, " $a, $b"),
435 [(opnode GPR:$a, so_reg:$b)]>;
436}
437
438/// AI1_bin_is - Defines a set of (op r, {so_imm|so_reg}) patterns for a binop.
439multiclass AI1_bin_is<string opc, PatFrag opnode> {
440 def ri : AI1<(ops GPR:$dst, GPR:$a, so_imm:$b),
441 !strconcat(opc, " $dst, $a, $b"),
442 [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>;
443 def rs : AI1<(ops GPR:$dst, GPR:$a, so_reg:$b),
444 !strconcat(opc, " $dst, $a, $b"),
445 [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>;
446}
447
448/// AI1_unary_irs - Defines a set of (op {so_imm|r|so_reg}) patterns for unary
449/// ops.
450multiclass AI1_unary_irs<string opc, PatFrag opnode> {
451 def i : AI1<(ops GPR:$dst, so_imm:$a),
452 !strconcat(opc, " $dst, $a"),
453 [(set GPR:$dst, (opnode so_imm:$a))]>;
454 def r : AI1<(ops GPR:$dst, GPR:$a),
455 !strconcat(opc, " $dst, $a"),
456 [(set GPR:$dst, (opnode GPR:$a))]>;
457 def s : AI1<(ops GPR:$dst, so_reg:$a),
458 !strconcat(opc, " $dst, $a"),
459 [(set GPR:$dst, (opnode so_reg:$a))]>;
460}
461
462/// AI_unary_rrot - A unary operation with two forms: one whose operand is a
463/// register and one whose operand is a register rotated by 8/16/24.
464multiclass AI_unary_rrot<string opc, PatFrag opnode> {
465 def r : AI<(ops GPR:$dst, GPR:$Src),
466 !strconcat(opc, " $dst, $Src"),
467 [(set GPR:$dst, (opnode GPR:$Src))]>, Requires<[IsARM, HasV6]>;
468 def r_rot : AI<(ops GPR:$dst, GPR:$Src, i32imm:$rot),
469 !strconcat(opc, " $dst, $Src, ror $rot"),
470 [(set GPR:$dst, (opnode (rotr GPR:$Src, rot_imm:$rot)))]>,
471 Requires<[IsARM, HasV6]>;
472}
473
474/// AI_bin_rrot - A binary operation with two forms: one whose operand is a
475/// register and one whose operand is a register rotated by 8/16/24.
476multiclass AI_bin_rrot<string opc, PatFrag opnode> {
477 def rr : AI<(ops GPR:$dst, GPR:$LHS, GPR:$RHS),
478 !strconcat(opc, " $dst, $LHS, $RHS"),
479 [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>,
480 Requires<[IsARM, HasV6]>;
481 def rr_rot : AI<(ops GPR:$dst, GPR:$LHS, GPR:$RHS, i32imm:$rot),
482 !strconcat(opc, " $dst, $LHS, $RHS, ror $rot"),
483 [(set GPR:$dst, (opnode GPR:$LHS,
484 (rotr GPR:$RHS, rot_imm:$rot)))]>,
485 Requires<[IsARM, HasV6]>;
486}
487
Rafael Espindolab23dc142006-10-16 18:18:14 +0000488
Rafael Espindola203922d2006-10-16 17:57:20 +0000489//===----------------------------------------------------------------------===//
490// Instructions
491//===----------------------------------------------------------------------===//
492
Evan Cheng10043e22007-01-19 07:51:42 +0000493//===----------------------------------------------------------------------===//
494// Miscellaneous Instructions.
495//
496def IMPLICIT_DEF_GPR :
497PseudoInst<(ops GPR:$rD),
498 "@ IMPLICIT_DEF_GPR $rD",
499 [(set GPR:$rD, (undef))]>;
Rafael Espindolae08b9852006-08-24 13:45:55 +0000500
Rafael Espindolafe03fe92006-08-24 16:13:15 +0000501
Evan Cheng10043e22007-01-19 07:51:42 +0000502/// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
503/// the function. The first operand is the ID# for this instruction, the second
504/// is the index into the MachineConstantPool that this is, the third is the
505/// size in bytes of this constant pool entry.
506def CONSTPOOL_ENTRY :
507PseudoInst<(ops cpinst_operand:$instid, cpinst_operand:$cpidx, i32imm:$size),
508 "${instid:label} ${cpidx:cpentry}", []>;
Rafael Espindolaffdc24b2006-05-14 22:18:28 +0000509
Evan Cheng10043e22007-01-19 07:51:42 +0000510def ADJCALLSTACKUP :
511PseudoInst<(ops i32imm:$amt),
512 "@ ADJCALLSTACKUP $amt",
513 [(ARMcallseq_end imm:$amt)]>, Imp<[SP],[SP]>;
Rafael Espindola29e48752006-08-24 17:19:08 +0000514
Evan Cheng10043e22007-01-19 07:51:42 +0000515def ADJCALLSTACKDOWN :
516PseudoInst<(ops i32imm:$amt),
517 "@ ADJCALLSTACKDOWN $amt",
518 [(ARMcallseq_start imm:$amt)]>, Imp<[SP],[SP]>;
Rafael Espindolad0dee772006-08-21 22:00:32 +0000519
Evan Cheng10043e22007-01-19 07:51:42 +0000520def DWARF_LOC :
521PseudoInst<(ops i32imm:$line, i32imm:$col, i32imm:$file),
522 ".loc $file, $line, $col",
523 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
Rafael Espindolad15c8922006-10-10 12:56:00 +0000524
Evan Cheng10043e22007-01-19 07:51:42 +0000525def PICADD : AI1<(ops GPR:$dst, GPR:$a, pclabel:$cp),
Evan Cheng83f35172007-01-30 20:37:08 +0000526 "$cp:\n\tadd $dst, pc, $a",
Evan Cheng10043e22007-01-19 07:51:42 +0000527 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
528let AddedComplexity = 10 in
529def PICLD : AI2<(ops GPR:$dst, addrmodepc:$addr),
Evan Cheng83f35172007-01-30 20:37:08 +0000530 "${addr:label}:\n\tldr $dst, $addr",
Evan Cheng10043e22007-01-19 07:51:42 +0000531 [(set GPR:$dst, (load addrmodepc:$addr))]>;
Rafael Espindola75269be2006-07-16 01:02:57 +0000532
Evan Cheng10043e22007-01-19 07:51:42 +0000533//===----------------------------------------------------------------------===//
534// Control Flow Instructions.
535//
Rafael Espindolad55c0a42006-10-02 19:30:56 +0000536
Evan Cheng10043e22007-01-19 07:51:42 +0000537let isReturn = 1, isTerminator = 1 in
538 def BX_RET : AI<(ops), "bx lr", [(ARMretflag)]>;
Rafael Espindola53f78be2006-09-29 21:20:16 +0000539
Evan Cheng10043e22007-01-19 07:51:42 +0000540// FIXME: remove when we have a way to marking a MI with these properties.
541let isLoad = 1, isReturn = 1, isTerminator = 1 in
542 def LDM_RET : AI4<(ops addrmode4:$addr, reglist:$dst1, variable_ops),
543 "ldm${addr:submode} $addr, $dst1",
544 []>;
Rafael Espindolae04df412006-10-05 16:48:49 +0000545
Evan Cheng10043e22007-01-19 07:51:42 +0000546let isCall = 1, noResults = 1,
547 Defs = [R0, R1, R2, R3, R12, LR,
548 D0, D1, D2, D3, D4, D5, D6, D7] in {
549 def BL : AI<(ops i32imm:$func, variable_ops),
550 "bl ${func:call}",
551 [(ARMcall tglobaladdr:$func)]>;
552 // ARMv5T and above
553 def BLX : AI<(ops GPR:$dst, variable_ops),
554 "blx $dst",
555 [(ARMcall GPR:$dst)]>, Requires<[IsARM, HasV5T]>;
Lauro Ramos Venancioa88c4a72007-03-20 17:57:23 +0000556 let Uses = [LR] in {
557 // ARMv4T
Lauro Ramos Venancio143b0df2007-03-27 16:19:21 +0000558 def BX : AIx2<(ops GPR:$dst, variable_ops),
559 "mov lr, pc\n\tbx $dst",
560 [(ARMcall_nolink GPR:$dst)]>;
Lauro Ramos Venancioa88c4a72007-03-20 17:57:23 +0000561 }
Rafael Espindolabf3a17c2006-07-18 17:00:30 +0000562}
Rafael Espindolab15597b2006-05-18 21:45:49 +0000563
Evan Cheng10043e22007-01-19 07:51:42 +0000564let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
565 def B : AI<(ops brtarget:$dst), "b $dst",
566 [(br bb:$dst)]>;
567
568 def BR_JTr : JTI<(ops GPR:$dst, jtblock_operand:$jt, i32imm:$id),
569 "mov pc, $dst \n$jt",
570 [(ARMbrjt GPR:$dst, tjumptable:$jt, imm:$id)]>;
571 def BR_JTm : JTI2<(ops addrmode2:$dst, jtblock_operand:$jt, i32imm:$id),
572 "ldr pc, $dst \n$jt",
573 [(ARMbrjt (i32 (load addrmode2:$dst)), tjumptable:$jt,
574 imm:$id)]>;
575 def BR_JTadd : JTI1<(ops GPR:$dst, GPR:$idx, jtblock_operand:$jt, i32imm:$id),
576 "add pc, $dst, $idx \n$jt",
577 [(ARMbrjt (add GPR:$dst, GPR:$idx), tjumptable:$jt,
578 imm:$id)]>;
Rafael Espindola8b7bd822006-08-01 18:53:10 +0000579}
Rafael Espindola75269be2006-07-16 01:02:57 +0000580
Evan Cheng10043e22007-01-19 07:51:42 +0000581let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in
582 def Bcc : AI<(ops brtarget:$dst, CCOp:$cc), "b$cc $dst",
583 [(ARMbrcond bb:$dst, imm:$cc)]>;
Rafael Espindolaffdc24b2006-05-14 22:18:28 +0000584
Evan Cheng10043e22007-01-19 07:51:42 +0000585//===----------------------------------------------------------------------===//
586// Load / store Instructions.
587//
Rafael Espindola677ee832006-10-16 17:17:22 +0000588
Evan Cheng10043e22007-01-19 07:51:42 +0000589// Load
590let isLoad = 1 in {
591def LDR : AI2<(ops GPR:$dst, addrmode2:$addr),
592 "ldr $dst, $addr",
593 [(set GPR:$dst, (load addrmode2:$addr))]>;
Rafael Espindola677ee832006-10-16 17:17:22 +0000594
Evan Chengee2763f2007-03-19 07:20:03 +0000595// Special LDR for loads from non-pc-relative constpools.
596let isReMaterializable = 1 in
597def LDRcp : AI2<(ops GPR:$dst, addrmode2:$addr),
598 "ldr $dst, $addr", []>;
599
Evan Cheng10043e22007-01-19 07:51:42 +0000600// Loads with zero extension
601def LDRH : AI3<(ops GPR:$dst, addrmode3:$addr),
602 "ldrh $dst, $addr",
603 [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>;
Rafael Espindola677ee832006-10-16 17:17:22 +0000604
Evan Cheng10043e22007-01-19 07:51:42 +0000605def LDRB : AI2<(ops GPR:$dst, addrmode2:$addr),
606 "ldrb $dst, $addr",
607 [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>;
Rafael Espindola677ee832006-10-16 17:17:22 +0000608
Evan Cheng10043e22007-01-19 07:51:42 +0000609// Loads with sign extension
610def LDRSH : AI3<(ops GPR:$dst, addrmode3:$addr),
611 "ldrsh $dst, $addr",
612 [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>;
Rafael Espindolaffdc24b2006-05-14 22:18:28 +0000613
Evan Cheng10043e22007-01-19 07:51:42 +0000614def LDRSB : AI3<(ops GPR:$dst, addrmode3:$addr),
615 "ldrsb $dst, $addr",
616 [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>;
Rafael Espindolab43efe82006-10-23 20:34:27 +0000617
Evan Cheng10043e22007-01-19 07:51:42 +0000618// Load doubleword
619def LDRD : AI3<(ops GPR:$dst, addrmode3:$addr),
620 "ldrd $dst, $addr",
621 []>, Requires<[IsARM, HasV5T]>;
Rafael Espindolab43efe82006-10-23 20:34:27 +0000622
Evan Cheng10043e22007-01-19 07:51:42 +0000623// Indexed loads
624def LDR_PRE : AI2pr<(ops GPR:$dst, GPR:$base_wb, addrmode2:$addr),
625 "ldr $dst, $addr!", "$addr.base = $base_wb", []>;
Rafael Espindolab15597b2006-05-18 21:45:49 +0000626
Evan Cheng10043e22007-01-19 07:51:42 +0000627def LDR_POST : AI2po<(ops GPR:$dst, GPR:$base_wb, GPR:$base, am2offset:$offset),
628 "ldr $dst, [$base], $offset", "$base = $base_wb", []>;
Rafael Espindola1bbe5812006-12-12 00:37:38 +0000629
Evan Cheng10043e22007-01-19 07:51:42 +0000630def LDRH_PRE : AI3pr<(ops GPR:$dst, GPR:$base_wb, addrmode3:$addr),
631 "ldrh $dst, $addr!", "$addr.base = $base_wb", []>;
Rafael Espindola4443c7d2006-09-08 16:59:47 +0000632
Evan Cheng10043e22007-01-19 07:51:42 +0000633def LDRH_POST : AI3po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am3offset:$offset),
634 "ldrh $dst, [$base], $offset", "$base = $base_wb", []>;
Lauro Ramos Venancio7251e572006-12-28 13:11:14 +0000635
Evan Cheng10043e22007-01-19 07:51:42 +0000636def LDRB_PRE : AI2pr<(ops GPR:$dst, GPR:$base_wb, addrmode2:$addr),
637 "ldrb $dst, $addr!", "$addr.base = $base_wb", []>;
Lauro Ramos Venancio7251e572006-12-28 13:11:14 +0000638
Evan Cheng10043e22007-01-19 07:51:42 +0000639def LDRB_POST : AI2po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am2offset:$offset),
640 "ldrb $dst, [$base], $offset", "$base = $base_wb", []>;
641
642def LDRSH_PRE : AI3pr<(ops GPR:$dst, GPR:$base_wb, addrmode3:$addr),
643 "ldrsh $dst, $addr!", "$addr.base = $base_wb", []>;
644
645def LDRSH_POST: AI3po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am3offset:$offset),
646 "ldrsh $dst, [$base], $offset", "$base = $base_wb", []>;
647
648def LDRSB_PRE : AI3pr<(ops GPR:$dst, GPR:$base_wb, addrmode3:$addr),
649 "ldrsb $dst, $addr!", "$addr.base = $base_wb", []>;
650
651def LDRSB_POST: AI3po<(ops GPR:$dst, GPR:$base_wb, GPR:$base,am3offset:$offset),
652 "ldrsb $dst, [$base], $offset", "$base = $base_wb", []>;
653} // isLoad
654
655// Store
656let isStore = 1 in {
657def STR : AI2<(ops GPR:$src, addrmode2:$addr),
658 "str $src, $addr",
659 [(store GPR:$src, addrmode2:$addr)]>;
660
661// Stores with truncate
662def STRH : AI3<(ops GPR:$src, addrmode3:$addr),
663 "strh $src, $addr",
664 [(truncstorei16 GPR:$src, addrmode3:$addr)]>;
665
666def STRB : AI2<(ops GPR:$src, addrmode2:$addr),
667 "strb $src, $addr",
668 [(truncstorei8 GPR:$src, addrmode2:$addr)]>;
669
670// Store doubleword
671def STRD : AI3<(ops GPR:$src, addrmode3:$addr),
672 "strd $src, $addr",
673 []>, Requires<[IsARM, HasV5T]>;
674
675// Indexed stores
676def STR_PRE : AI2pr<(ops GPR:$base_wb, GPR:$src, GPR:$base, am2offset:$offset),
677 "str $src, [$base, $offset]!", "$base = $base_wb",
678 [(set GPR:$base_wb,
679 (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>;
680
681def STR_POST : AI2po<(ops GPR:$base_wb, GPR:$src, GPR:$base,am2offset:$offset),
682 "str $src, [$base], $offset", "$base = $base_wb",
683 [(set GPR:$base_wb,
684 (post_store GPR:$src, GPR:$base, am2offset:$offset))]>;
685
686def STRH_PRE : AI3pr<(ops GPR:$base_wb, GPR:$src, GPR:$base,am3offset:$offset),
687 "strh $src, [$base, $offset]!", "$base = $base_wb",
688 [(set GPR:$base_wb,
689 (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>;
690
691def STRH_POST: AI3po<(ops GPR:$base_wb, GPR:$src, GPR:$base,am3offset:$offset),
692 "strh $src, [$base], $offset", "$base = $base_wb",
693 [(set GPR:$base_wb, (post_truncsti16 GPR:$src,
694 GPR:$base, am3offset:$offset))]>;
695
696def STRB_PRE : AI2pr<(ops GPR:$base_wb, GPR:$src, GPR:$base,am2offset:$offset),
697 "strb $src, [$base, $offset]!", "$base = $base_wb",
698 [(set GPR:$base_wb, (pre_truncsti8 GPR:$src,
699 GPR:$base, am2offset:$offset))]>;
700
701def STRB_POST: AI2po<(ops GPR:$base_wb, GPR:$src, GPR:$base,am2offset:$offset),
702 "strb $src, [$base], $offset", "$base = $base_wb",
703 [(set GPR:$base_wb, (post_truncsti8 GPR:$src,
704 GPR:$base, am2offset:$offset))]>;
705} // isStore
706
707//===----------------------------------------------------------------------===//
708// Load / store multiple Instructions.
709//
710
711let isLoad = 1 in
712def LDM : AI4<(ops addrmode4:$addr, reglist:$dst1, variable_ops),
713 "ldm${addr:submode} $addr, $dst1",
714 []>;
715
716let isStore = 1 in
717def STM : AI4<(ops addrmode4:$addr, reglist:$src1, variable_ops),
718 "stm${addr:submode} $addr, $src1",
719 []>;
720
721//===----------------------------------------------------------------------===//
722// Move Instructions.
723//
724
Evan Cheng9bb01c92007-03-19 07:48:02 +0000725def MOVr : AI1<(ops GPR:$dst, GPR:$src),
Evan Cheng10043e22007-01-19 07:51:42 +0000726 "mov $dst, $src", []>;
Evan Cheng9bb01c92007-03-19 07:48:02 +0000727def MOVs : AI1<(ops GPR:$dst, so_reg:$src),
Evan Cheng10043e22007-01-19 07:51:42 +0000728 "mov $dst, $src", [(set GPR:$dst, so_reg:$src)]>;
Evan Cheng5be3e092007-03-19 07:09:02 +0000729
730let isReMaterializable = 1 in
Evan Cheng9bb01c92007-03-19 07:48:02 +0000731def MOVi : AI1<(ops GPR:$dst, so_imm:$src),
Evan Cheng10043e22007-01-19 07:51:42 +0000732 "mov $dst, $src", [(set GPR:$dst, so_imm:$src)]>;
733
734// These aren't really mov instructions, but we have to define them this way
735// due to flag operands.
736
737def MOVsrl_flag : AI1<(ops GPR:$dst, GPR:$src),
738 "movs $dst, $src, lsr #1",
739 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>;
740def MOVsra_flag : AI1<(ops GPR:$dst, GPR:$src),
741 "movs $dst, $src, asr #1",
742 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>;
Evan Cheng9bb01c92007-03-19 07:48:02 +0000743def MOVrx : AI1<(ops GPR:$dst, GPR:$src),
Evan Cheng10043e22007-01-19 07:51:42 +0000744 "mov $dst, $src, rrx",
745 [(set GPR:$dst, (ARMrrx GPR:$src))]>;
746
747
748//===----------------------------------------------------------------------===//
749// Extend Instructions.
750//
751
752// Sign extenders
753
754defm SXTB : AI_unary_rrot<"sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
755defm SXTH : AI_unary_rrot<"sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
756
757defm SXTAB : AI_bin_rrot<"sxtab",
758 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
759defm SXTAH : AI_bin_rrot<"sxtah",
760 BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
761
762// TODO: SXT(A){B|H}16
763
764// Zero extenders
765
766let AddedComplexity = 16 in {
767defm UXTB : AI_unary_rrot<"uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
768defm UXTH : AI_unary_rrot<"uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
769defm UXTB16 : AI_unary_rrot<"uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
770
771def : ARMV6Pat<(and (shl GPR:$Src, 8), 0xFF00FF),
772 (UXTB16r_rot GPR:$Src, 24)>;
773def : ARMV6Pat<(and (srl GPR:$Src, 8), 0xFF00FF),
774 (UXTB16r_rot GPR:$Src, 8)>;
775
776defm UXTAB : AI_bin_rrot<"uxtab",
777 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
778defm UXTAH : AI_bin_rrot<"uxtah",
779 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
Rafael Espindolad0dee772006-08-21 22:00:32 +0000780}
781
Evan Cheng10043e22007-01-19 07:51:42 +0000782// This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
783//defm UXTAB16 : xxx<"uxtab16", 0xff00ff>;
Rafael Espindolac7829d62006-09-11 19:24:19 +0000784
Evan Cheng10043e22007-01-19 07:51:42 +0000785// TODO: UXT(A){B|H}16
786
787//===----------------------------------------------------------------------===//
788// Arithmetic Instructions.
789//
790
791defm ADD : AI1_bin_irs<"add" , BinOpFrag<(add node:$LHS, node:$RHS)>>;
792defm ADDS : AI1_bin_irs<"adds", BinOpFrag<(addc node:$LHS, node:$RHS)>>;
793defm ADC : AI1_bin_irs<"adc" , BinOpFrag<(adde node:$LHS, node:$RHS)>>;
794defm SUB : AI1_bin_irs<"sub" , BinOpFrag<(sub node:$LHS, node:$RHS)>>;
795defm SUBS : AI1_bin_irs<"subs", BinOpFrag<(subc node:$LHS, node:$RHS)>>;
796defm SBC : AI1_bin_irs<"sbc" , BinOpFrag<(sube node:$LHS, node:$RHS)>>;
797
798// These don't define reg/reg forms, because they are handled above.
799defm RSB : AI1_bin_is <"rsb" , BinOpFrag<(sub node:$RHS, node:$LHS)>>;
800defm RSBS : AI1_bin_is <"rsbs", BinOpFrag<(subc node:$RHS, node:$LHS)>>;
801defm RSC : AI1_bin_is <"rsc" , BinOpFrag<(sube node:$RHS, node:$LHS)>>;
802
803// (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
804def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
805 (SUBri GPR:$src, so_imm_neg:$imm)>;
806
807//def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
808// (SUBSri GPR:$src, so_imm_neg:$imm)>;
809//def : ARMPat<(adde GPR:$src, so_imm_neg:$imm),
810// (SBCri GPR:$src, so_imm_neg:$imm)>;
811
812// Note: These are implemented in C++ code, because they have to generate
813// ADD/SUBrs instructions, which use a complex pattern that a xform function
814// cannot produce.
815// (mul X, 2^n+1) -> (add (X << n), X)
816// (mul X, 2^n-1) -> (rsb X, (X << n))
817
818
819//===----------------------------------------------------------------------===//
820// Bitwise Instructions.
821//
822
823defm AND : AI1_bin_irs<"and", BinOpFrag<(and node:$LHS, node:$RHS)>>;
824defm ORR : AI1_bin_irs<"orr", BinOpFrag<(or node:$LHS, node:$RHS)>>;
825defm EOR : AI1_bin_irs<"eor", BinOpFrag<(xor node:$LHS, node:$RHS)>>;
826defm BIC : AI1_bin_irs<"bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
827
Evan Cheng5be3e092007-03-19 07:09:02 +0000828def MVNr : AI<(ops GPR:$dst, GPR:$src),
829 "mvn $dst, $src", [(set GPR:$dst, (not GPR:$src))]>;
830def MVNs : AI<(ops GPR:$dst, so_reg:$src),
831 "mvn $dst, $src", [(set GPR:$dst, (not so_reg:$src))]>;
832let isReMaterializable = 1 in
833def MVNi : AI<(ops GPR:$dst, so_imm:$imm),
834 "mvn $dst, $imm", [(set GPR:$dst, so_imm_not:$imm)]>;
Evan Cheng10043e22007-01-19 07:51:42 +0000835
836def : ARMPat<(and GPR:$src, so_imm_not:$imm),
837 (BICri GPR:$src, so_imm_not:$imm)>;
838
839//===----------------------------------------------------------------------===//
840// Multiply Instructions.
841//
842
843// AI_orr - Defines a (op r, r) pattern.
844class AI_orr<string opc, SDNode opnode>
845 : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
846 !strconcat(opc, " $dst, $a, $b"),
847 [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>;
848
849// AI_oorr - Defines a (op (op r, r), r) pattern.
850class AI_oorr<string opc, SDNode opnode1, SDNode opnode2>
851 : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$c),
852 !strconcat(opc, " $dst, $a, $b, $c"),
853 [(set GPR:$dst, (opnode1 (opnode2 GPR:$a, GPR:$b), GPR:$c))]>;
854
855def MUL : AI_orr<"mul", mul>;
856def MLA : AI_oorr<"mla", add, mul>;
857
858// Extra precision multiplies with low / high results
859def SMULL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
860 "smull $ldst, $hdst, $a, $b",
861 []>;
862
863def UMULL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
864 "umull $ldst, $hdst, $a, $b",
865 []>;
866
867// Multiply + accumulate
868def SMLAL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
869 "smlal $ldst, $hdst, $a, $b",
870 []>;
871
872def UMLAL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
873 "umlal $ldst, $hdst, $a, $b",
874 []>;
875
876def UMAAL : AI<(ops GPR:$ldst, GPR:$hdst, GPR:$a, GPR:$b),
877 "umaal $ldst, $hdst, $a, $b",
878 []>, Requires<[IsARM, HasV6]>;
879
880// Most significant word multiply
881def SMMUL : AI_orr<"smmul", mulhs>, Requires<[IsARM, HasV6]>;
882def SMMLA : AI_oorr<"smmla", add, mulhs>, Requires<[IsARM, HasV6]>;
883
884
885def SMMLS : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$c),
886 "smmls $dst, $a, $b, $c",
887 [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>,
888 Requires<[IsARM, HasV6]>;
889
890multiclass AI_smul<string opc, PatFrag opnode> {
Evan Cheng77c15de2007-01-19 20:27:35 +0000891 def BB : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
892 !strconcat(opc, "bb $dst, $a, $b"),
893 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
894 (sext_inreg GPR:$b, i16)))]>,
895 Requires<[IsARM, HasV5TE]>;
896 def BT : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
897 !strconcat(opc, "bt $dst, $a, $b"),
898 [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16),
899 (sra GPR:$b, 16)))]>,
900 Requires<[IsARM, HasV5TE]>;
901 def TB : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
902 !strconcat(opc, "tb $dst, $a, $b"),
903 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
904 (sext_inreg GPR:$b, i16)))]>,
905 Requires<[IsARM, HasV5TE]>;
Evan Cheng10043e22007-01-19 07:51:42 +0000906 def TT : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
907 !strconcat(opc, "tt $dst, $a, $b"),
908 [(set GPR:$dst, (opnode (sra GPR:$a, 16),
909 (sra GPR:$b, 16)))]>,
910 Requires<[IsARM, HasV5TE]>;
Evan Cheng77c15de2007-01-19 20:27:35 +0000911 def WB : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
912 !strconcat(opc, "wb $dst, $a, $b"),
913 [(set GPR:$dst, (sra (opnode GPR:$a,
914 (sext_inreg GPR:$b, i16)), 16))]>,
915 Requires<[IsARM, HasV5TE]>;
Evan Cheng10043e22007-01-19 07:51:42 +0000916 def WT : AI<(ops GPR:$dst, GPR:$a, GPR:$b),
917 !strconcat(opc, "wt $dst, $a, $b"),
918 [(set GPR:$dst, (sra (opnode GPR:$a,
919 (sra GPR:$b, 16)), 16))]>,
920 Requires<[IsARM, HasV5TE]>;
Rafael Espindola595dc4c2006-10-16 16:33:29 +0000921}
922
Evan Cheng10043e22007-01-19 07:51:42 +0000923multiclass AI_smla<string opc, PatFrag opnode> {
Evan Cheng77c15de2007-01-19 20:27:35 +0000924 def BB : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
925 !strconcat(opc, "bb $dst, $a, $b, $acc"),
926 [(set GPR:$dst, (add GPR:$acc,
927 (opnode (sext_inreg GPR:$a, i16),
928 (sext_inreg GPR:$b, i16))))]>,
929 Requires<[IsARM, HasV5TE]>;
930 def BT : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
931 !strconcat(opc, "bt $dst, $a, $b, $acc"),
932 [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16),
Evan Cheng10043e22007-01-19 07:51:42 +0000933 (sra GPR:$b, 16))))]>,
Evan Cheng77c15de2007-01-19 20:27:35 +0000934 Requires<[IsARM, HasV5TE]>;
935 def TB : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
936 !strconcat(opc, "tb $dst, $a, $b, $acc"),
937 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
938 (sext_inreg GPR:$b, i16))))]>,
939 Requires<[IsARM, HasV5TE]>;
Evan Cheng10043e22007-01-19 07:51:42 +0000940 def TT : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
941 !strconcat(opc, "tt $dst, $a, $b, $acc"),
942 [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, 16),
943 (sra GPR:$b, 16))))]>,
944 Requires<[IsARM, HasV5TE]>;
945
Evan Cheng77c15de2007-01-19 20:27:35 +0000946 def WB : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
947 !strconcat(opc, "wb $dst, $a, $b, $acc"),
948 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
949 (sext_inreg GPR:$b, i16)), 16)))]>,
950 Requires<[IsARM, HasV5TE]>;
Evan Cheng10043e22007-01-19 07:51:42 +0000951 def WT : AI<(ops GPR:$dst, GPR:$a, GPR:$b, GPR:$acc),
952 !strconcat(opc, "wt $dst, $a, $b, $acc"),
953 [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a,
954 (sra GPR:$b, 16)), 16)))]>,
955 Requires<[IsARM, HasV5TE]>;
Rafael Espindola01dd97a2006-10-18 16:20:57 +0000956}
Rafael Espindola778769a2006-09-08 12:47:03 +0000957
Evan Cheng10043e22007-01-19 07:51:42 +0000958defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
959defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
Rafael Espindola53f78be2006-09-29 21:20:16 +0000960
Evan Cheng10043e22007-01-19 07:51:42 +0000961// TODO: Halfword multiple accumulate long: SMLAL<x><y>
962// TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD
Rafael Espindola3874a162006-10-13 13:14:59 +0000963
Evan Cheng10043e22007-01-19 07:51:42 +0000964//===----------------------------------------------------------------------===//
965// Misc. Arithmetic Instructions.
966//
Rafael Espindolad1a4ea42006-10-10 16:33:47 +0000967
Evan Cheng10043e22007-01-19 07:51:42 +0000968def CLZ : AI<(ops GPR:$dst, GPR:$src),
969 "clz $dst, $src",
970 [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]>;
Rafael Espindolac31ee942006-10-17 13:13:23 +0000971
Evan Cheng10043e22007-01-19 07:51:42 +0000972def REV : AI<(ops GPR:$dst, GPR:$src),
973 "rev $dst, $src",
974 [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]>;
Rafael Espindolac31ee942006-10-17 13:13:23 +0000975
Evan Cheng10043e22007-01-19 07:51:42 +0000976def REV16 : AI<(ops GPR:$dst, GPR:$src),
977 "rev16 $dst, $src",
978 [(set GPR:$dst,
979 (or (and (srl GPR:$src, 8), 0xFF),
980 (or (and (shl GPR:$src, 8), 0xFF00),
981 (or (and (srl GPR:$src, 8), 0xFF0000),
982 (and (shl GPR:$src, 8), 0xFF000000)))))]>,
983 Requires<[IsARM, HasV6]>;
Rafael Espindola53f78be2006-09-29 21:20:16 +0000984
Evan Cheng10043e22007-01-19 07:51:42 +0000985def REVSH : AI<(ops GPR:$dst, GPR:$src),
986 "revsh $dst, $src",
987 [(set GPR:$dst,
988 (sext_inreg
Chris Lattner598bc0d2007-04-17 22:39:58 +0000989 (or (srl (and GPR:$src, 0xFF00), 8),
Evan Cheng10043e22007-01-19 07:51:42 +0000990 (shl GPR:$src, 8)), i16))]>,
991 Requires<[IsARM, HasV6]>;
Rafael Espindola53f78be2006-09-29 21:20:16 +0000992
Evan Cheng10043e22007-01-19 07:51:42 +0000993def PKHBT : AI<(ops GPR:$dst, GPR:$src1, GPR:$src2, i32imm:$shamt),
994 "pkhbt $dst, $src1, $src2, LSL $shamt",
995 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF),
996 (and (shl GPR:$src2, (i32 imm:$shamt)),
997 0xFFFF0000)))]>,
998 Requires<[IsARM, HasV6]>;
Rafael Espindola53f78be2006-09-29 21:20:16 +0000999
Evan Cheng10043e22007-01-19 07:51:42 +00001000// Alternate cases for PKHBT where identities eliminate some nodes.
1001def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)),
1002 (PKHBT GPR:$src1, GPR:$src2, 0)>;
1003def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)),
1004 (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>;
Rafael Espindolad55c0a42006-10-02 19:30:56 +00001005
Rafael Espindolae04df412006-10-05 16:48:49 +00001006
Evan Cheng10043e22007-01-19 07:51:42 +00001007def PKHTB : AI<(ops GPR:$dst, GPR:$src1, GPR:$src2, i32imm:$shamt),
1008 "pkhtb $dst, $src1, $src2, ASR $shamt",
1009 [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000),
1010 (and (sra GPR:$src2, imm16_31:$shamt),
1011 0xFFFF)))]>, Requires<[IsARM, HasV6]>;
Rafael Espindolad55c0a42006-10-02 19:30:56 +00001012
Evan Cheng10043e22007-01-19 07:51:42 +00001013// Alternate cases for PKHTB where identities eliminate some nodes. Note that
1014// a shift amount of 0 is *not legal* here, it is PKHBT instead.
1015def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, 16)),
1016 (PKHTB GPR:$src1, GPR:$src2, 16)>;
1017def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
1018 (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)),
1019 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>;
Rafael Espindola57d109f2006-10-10 18:55:14 +00001020
Rafael Espindola40f5dd22006-10-07 13:46:42 +00001021
Evan Cheng10043e22007-01-19 07:51:42 +00001022//===----------------------------------------------------------------------===//
1023// Comparison Instructions...
1024//
Rafael Espindola57d109f2006-10-10 18:55:14 +00001025
Evan Cheng10043e22007-01-19 07:51:42 +00001026defm CMP : AI1_bin0_irs<"cmp", BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
1027defm CMN : AI1_bin0_irs<"cmn", BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
Rafael Espindolab5093882006-10-07 14:24:52 +00001028
Evan Cheng10043e22007-01-19 07:51:42 +00001029def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
1030 (CMNri GPR:$src, so_imm_neg:$imm)>;
Rafael Espindola8429e1f2006-10-10 20:38:57 +00001031
Evan Cheng10043e22007-01-19 07:51:42 +00001032// Note that TST/TEQ don't set all the same flags that CMP does!
Lauro Ramos Venancio6be85332007-04-02 01:30:03 +00001033defm TST : AI1_bin0_irs<"tst", BinOpFrag<(ARMcmpNZ (and node:$LHS, node:$RHS), 0)>>;
1034defm TEQ : AI1_bin0_irs<"teq", BinOpFrag<(ARMcmpNZ (xor node:$LHS, node:$RHS), 0)>>;
1035
1036defm CMPnz : AI1_bin0_irs<"cmp", BinOpFrag<(ARMcmpNZ node:$LHS, node:$RHS)>>;
1037defm CMNnz : AI1_bin0_irs<"cmn", BinOpFrag<(ARMcmpNZ node:$LHS,(ineg node:$RHS))>>;
1038
1039def : ARMPat<(ARMcmpNZ GPR:$src, so_imm_neg:$imm),
1040 (CMNri GPR:$src, so_imm_neg:$imm)>;
1041
Rafael Espindolab5093882006-10-07 14:24:52 +00001042
Evan Cheng10043e22007-01-19 07:51:42 +00001043// Conditional moves
1044def MOVCCr : AI<(ops GPR:$dst, GPR:$false, GPR:$true, CCOp:$cc),
1045 "mov$cc $dst, $true",
1046 [(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc))]>,
1047 RegConstraint<"$false = $dst">;
Rafael Espindola8429e1f2006-10-10 20:38:57 +00001048
Evan Cheng10043e22007-01-19 07:51:42 +00001049def MOVCCs : AI<(ops GPR:$dst, GPR:$false, so_reg:$true, CCOp:$cc),
1050 "mov$cc $dst, $true",
1051 [(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true,imm:$cc))]>,
1052 RegConstraint<"$false = $dst">;
Rafael Espindola9e29ec32006-10-09 17:50:29 +00001053
Evan Cheng10043e22007-01-19 07:51:42 +00001054def MOVCCi : AI<(ops GPR:$dst, GPR:$false, so_imm:$true, CCOp:$cc),
1055 "mov$cc $dst, $true",
1056 [(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true,imm:$cc))]>,
1057 RegConstraint<"$false = $dst">;
Rafael Espindola40f5dd22006-10-07 13:46:42 +00001058
Rafael Espindolad15c8922006-10-10 12:56:00 +00001059
Evan Cheng10043e22007-01-19 07:51:42 +00001060// LEApcrel - Load a pc-relative address into a register without offending the
1061// assembler.
1062def LEApcrel : AI1<(ops GPR:$dst, i32imm:$label),
1063 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
1064 "${:private}PCRELL${:uid}+8))\n"),
1065 !strconcat("${:private}PCRELL${:uid}:\n\t",
1066 "add $dst, pc, #PCRELV${:uid}")),
1067 []>;
Rafael Espindolab5f1ff332006-10-10 19:35:01 +00001068
Evan Cheng10043e22007-01-19 07:51:42 +00001069def LEApcrelJT : AI1<(ops GPR:$dst, i32imm:$label, i32imm:$id),
1070 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
1071 "${:private}PCRELL${:uid}+8))\n"),
1072 !strconcat("${:private}PCRELL${:uid}:\n\t",
1073 "add $dst, pc, #PCRELV${:uid}")),
1074 []>;
Lauro Ramos Venancioc39c12a2007-04-27 13:54:47 +00001075//===----------------------------------------------------------------------===//
1076// TLS Instructions
1077//
1078
1079// __aeabi_read_tp preserves the registers r1-r3.
1080let isCall = 1,
1081 Defs = [R0, R12, LR] in {
1082 def TPsoft : AI<(ops),
1083 "bl __aeabi_read_tp",
1084 [(set R0, ARMthread_pointer)]>;
1085}
Rafael Espindola99bf1332006-10-17 20:33:13 +00001086
Evan Cheng10043e22007-01-19 07:51:42 +00001087//===----------------------------------------------------------------------===//
1088// Non-Instruction Patterns
1089//
Rafael Espindola58c368b2006-10-07 14:03:39 +00001090
Evan Cheng10043e22007-01-19 07:51:42 +00001091// ConstantPool, GlobalAddress, and JumpTable
1092def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>;
1093def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
1094def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
Evan Cheng9e7b8382007-03-20 08:11:30 +00001095 (LEApcrelJT tjumptable:$dst, imm:$id)>;
Rafael Espindola58c368b2006-10-07 14:03:39 +00001096
Evan Cheng10043e22007-01-19 07:51:42 +00001097// Large immediate handling.
Rafael Espindolaf719c5f2006-10-16 21:10:32 +00001098
Evan Cheng10043e22007-01-19 07:51:42 +00001099// Two piece so_imms.
Evan Cheng9e7b8382007-03-20 08:11:30 +00001100let isReMaterializable = 1 in
1101def MOVi2pieces : AI1x2<(ops GPR:$dst, so_imm2part:$src),
1102 "mov $dst, $src",
1103 [(set GPR:$dst, so_imm2part:$src)]>;
Rafael Espindola418c8e62006-10-17 13:36:07 +00001104
Evan Cheng10043e22007-01-19 07:51:42 +00001105def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS),
1106 (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1107 (so_imm2part_2 imm:$RHS))>;
1108def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS),
1109 (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)),
1110 (so_imm2part_2 imm:$RHS))>;
Rafael Espindola418c8e62006-10-17 13:36:07 +00001111
Evan Cheng10043e22007-01-19 07:51:42 +00001112// TODO: add,sub,and, 3-instr forms?
Rafael Espindolaf719c5f2006-10-16 21:10:32 +00001113
Rafael Espindola336d62e2006-10-19 17:05:03 +00001114
Evan Cheng10043e22007-01-19 07:51:42 +00001115// Direct calls
1116def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
Rafael Espindola0cd8d142006-11-01 14:13:27 +00001117
Evan Cheng10043e22007-01-19 07:51:42 +00001118// zextload i1 -> zextload i8
1119def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
Lauro Ramos Venanciod0ced3f2006-12-26 19:30:42 +00001120
Evan Cheng10043e22007-01-19 07:51:42 +00001121// extload -> zextload
1122def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1123def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>;
1124def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
Rafael Espindola0cd8d142006-11-01 14:13:27 +00001125
Evan Cheng10043e22007-01-19 07:51:42 +00001126// truncstore i1 -> truncstore i8
Dale Johannesen29c05752007-04-27 22:17:18 +00001127def : ARMPat<(truncstorei1 GPR:$src, addrmode2:$dst),
Evan Cheng10043e22007-01-19 07:51:42 +00001128 (STRB GPR:$src, addrmode2:$dst)>;
Dale Johannesen29c05752007-04-27 22:17:18 +00001129def : ARMPat<(pre_truncsti1 GPR:$src, GPR:$base, am2offset:$offset),
Evan Cheng10043e22007-01-19 07:51:42 +00001130 (STRB_PRE GPR:$src, GPR:$base, am2offset:$offset)>;
Dale Johannesen29c05752007-04-27 22:17:18 +00001131def : ARMPat<(post_truncsti1 GPR:$src, GPR:$base, am2offset:$offset),
Evan Cheng10043e22007-01-19 07:51:42 +00001132 (STRB_POST GPR:$src, GPR:$base, am2offset:$offset)>;
1133
Evan Cheng77c15de2007-01-19 20:27:35 +00001134// smul* and smla*
1135def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra (shl GPR:$b, 16), 16)),
1136 (SMULBB GPR:$a, GPR:$b)>;
1137def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
1138 (SMULBB GPR:$a, GPR:$b)>;
1139def : ARMV5TEPat<(mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16)),
1140 (SMULBT GPR:$a, GPR:$b)>;
1141def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, 16)),
1142 (SMULBT GPR:$a, GPR:$b)>;
1143def : ARMV5TEPat<(mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16)),
1144 (SMULTB GPR:$a, GPR:$b)>;
1145def : ARMV5TEPat<(mul (sra GPR:$a, 16), sext_16_node:$b),
1146 (SMULTB GPR:$a, GPR:$b)>;
1147def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16),
1148 (SMULWB GPR:$a, GPR:$b)>;
1149def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), 16),
1150 (SMULWB GPR:$a, GPR:$b)>;
1151
1152def : ARMV5TEPat<(add GPR:$acc,
1153 (mul (sra (shl GPR:$a, 16), 16),
1154 (sra (shl GPR:$b, 16), 16))),
1155 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1156def : ARMV5TEPat<(add GPR:$acc,
1157 (mul sext_16_node:$a, sext_16_node:$b)),
1158 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
1159def : ARMV5TEPat<(add GPR:$acc,
1160 (mul (sra (shl GPR:$a, 16), 16), (sra GPR:$b, 16))),
1161 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1162def : ARMV5TEPat<(add GPR:$acc,
1163 (mul sext_16_node:$a, (sra GPR:$b, 16))),
1164 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
1165def : ARMV5TEPat<(add GPR:$acc,
1166 (mul (sra GPR:$a, 16), (sra (shl GPR:$b, 16), 16))),
1167 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1168def : ARMV5TEPat<(add GPR:$acc,
1169 (mul (sra GPR:$a, 16), sext_16_node:$b)),
1170 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
1171def : ARMV5TEPat<(add GPR:$acc,
1172 (sra (mul GPR:$a, (sra (shl GPR:$b, 16), 16)), 16)),
1173 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1174def : ARMV5TEPat<(add GPR:$acc,
1175 (sra (mul GPR:$a, sext_16_node:$b), 16)),
1176 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
1177
Evan Cheng10043e22007-01-19 07:51:42 +00001178//===----------------------------------------------------------------------===//
1179// Thumb Support
1180//
1181
1182include "ARMInstrThumb.td"
1183
1184//===----------------------------------------------------------------------===//
1185// Floating Point Support
1186//
1187
1188include "ARMInstrVFP.td"