blob: 24587cb6f69db8aaa6e8aee859d4fd8d835308ac [file] [log] [blame]
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson01135592010-03-23 17:23:59 +00002//
Evan Cheng37f25d92008-08-28 23:39:26 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilson01135592010-03-23 17:23:59 +00007//
Evan Cheng37f25d92008-08-28 23:39:26 +00008//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
Bob Wilson89ef7b72010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng37f25d92008-08-28 23:39:26 +000020}
21
Evan Chengffa6d962008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng37f25d92008-08-28 23:39:26 +000026
Evan Chengffa6d962008-11-13 23:36:57 +000027def DPFrm : Format<4>;
28def DPSoRegFrm : Format<5>;
Evan Cheng37f25d92008-08-28 23:39:26 +000029
Evan Chengffa6d962008-11-13 23:36:57 +000030def LdFrm : Format<6>;
31def StFrm : Format<7>;
32def LdMiscFrm : Format<8>;
33def StMiscFrm : Format<9>;
34def LdStMulFrm : Format<10>;
Evan Cheng37f25d92008-08-28 23:39:26 +000035
Johnny Chen81f04d52010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5278eb82009-12-11 01:42:04 +000037
Johnny Chen81f04d52010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson9a1c1892010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000041
Bob Wilson9a1c1892010-08-11 00:01:18 +000042def VFPUnaryFrm : Format<15>;
43def VFPBinaryFrm : Format<16>;
44def VFPConv1Frm : Format<17>;
45def VFPConv2Frm : Format<18>;
46def VFPConv3Frm : Format<19>;
47def VFPConv4Frm : Format<20>;
48def VFPConv5Frm : Format<21>;
49def VFPLdStFrm : Format<22>;
50def VFPLdStMulFrm : Format<23>;
51def VFPMiscFrm : Format<24>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000052
Bob Wilson9a1c1892010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng37f25d92008-08-28 23:39:26 +000055
Bob Wilson9a1c1892010-08-11 00:01:18 +000056def NGetLnFrm : Format<27>;
57def NSetLnFrm : Format<28>;
58def NDupFrm : Format<29>;
59def NLdStFrm : Format<30>;
60def N1RegModImmFrm: Format<31>;
61def N2RegFrm : Format<32>;
62def NVCVTFrm : Format<33>;
63def NVDupLnFrm : Format<34>;
64def N2RegVShLFrm : Format<35>;
65def N2RegVShRFrm : Format<36>;
66def N3RegFrm : Format<37>;
67def N3RegVShFrm : Format<38>;
68def NVExtFrm : Format<39>;
69def NVMulSLFrm : Format<40>;
70def NVTBLFrm : Format<41>;
Johnny Chencaa608e2010-03-20 00:17:00 +000071
Evan Cheng34a0fa32009-07-08 01:46:35 +000072// Misc flags.
73
Bill Wendling43f7b2d2010-12-01 02:42:55 +000074// The instruction has an Rn register operand.
Evan Cheng34a0fa32009-07-08 01:46:35 +000075// UnaryDP - Indicates this is a unary data processing instruction, i.e.
76// it doesn't have a Rn operand.
77class UnaryDP { bit isUnaryDataProc = 1; }
78
79// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80// a 16-bit Thumb instruction if certain conditions are met.
81class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng37f25d92008-08-28 23:39:26 +000082
Evan Cheng37f25d92008-08-28 23:39:26 +000083//===----------------------------------------------------------------------===//
Bob Wilson50622ce2010-03-18 23:57:57 +000084// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Cheng055b0312009-06-29 07:51:04 +000085//
86
Jim Grosbachff12a8b2011-01-18 19:59:19 +000087// FIXME: Once the JIT is MC-ized, these can go away.
Evan Cheng055b0312009-06-29 07:51:04 +000088// Addressing mode.
Jim Grosbachd86609f2010-10-05 18:14:55 +000089class AddrMode<bits<5> val> {
90 bits<5> Value = val;
Evan Cheng055b0312009-06-29 07:51:04 +000091}
Bill Wendlingda2ae632010-08-31 07:50:46 +000092def AddrModeNone : AddrMode<0>;
93def AddrMode1 : AddrMode<1>;
94def AddrMode2 : AddrMode<2>;
95def AddrMode3 : AddrMode<3>;
96def AddrMode4 : AddrMode<4>;
97def AddrMode5 : AddrMode<5>;
98def AddrMode6 : AddrMode<6>;
99def AddrModeT1_1 : AddrMode<7>;
100def AddrModeT1_2 : AddrMode<8>;
101def AddrModeT1_4 : AddrMode<9>;
102def AddrModeT1_s : AddrMode<10>;
103def AddrModeT2_i12 : AddrMode<11>;
104def AddrModeT2_i8 : AddrMode<12>;
105def AddrModeT2_so : AddrMode<13>;
106def AddrModeT2_pc : AddrMode<14>;
Bob Wilson8b024a52009-07-01 23:16:05 +0000107def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach3e556122010-10-26 22:37:02 +0000108def AddrMode_i12 : AddrMode<16>;
Evan Cheng055b0312009-06-29 07:51:04 +0000109
110// Instruction size.
111class SizeFlagVal<bits<3> val> {
112 bits<3> Value = val;
113}
114def SizeInvalid : SizeFlagVal<0>; // Unset.
115def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
116def Size8Bytes : SizeFlagVal<2>;
117def Size4Bytes : SizeFlagVal<3>;
118def Size2Bytes : SizeFlagVal<4>;
119
120// Load / store index mode.
121class IndexMode<bits<2> val> {
122 bits<2> Value = val;
123}
124def IndexModeNone : IndexMode<0>;
125def IndexModePre : IndexMode<1>;
126def IndexModePost : IndexMode<2>;
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000127def IndexModeUpd : IndexMode<3>;
Evan Cheng055b0312009-06-29 07:51:04 +0000128
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000129// Instruction execution domain.
130class Domain<bits<2> val> {
131 bits<2> Value = val;
132}
133def GenericDomain : Domain<0>;
134def VFPDomain : Domain<1>; // Instructions in VFP domain only
135def NeonDomain : Domain<2>; // Instructions in Neon domain only
136def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
137
Evan Cheng055b0312009-06-29 07:51:04 +0000138//===----------------------------------------------------------------------===//
Evan Cheng446c4282009-07-11 06:43:01 +0000139// ARM special operands.
140//
141
Daniel Dunbar8462b302010-08-11 06:36:53 +0000142def CondCodeOperand : AsmOperandClass {
143 let Name = "CondCode";
144 let SuperClasses = [];
145}
146
Jim Grosbachd67641b2010-12-06 18:21:12 +0000147def CCOutOperand : AsmOperandClass {
148 let Name = "CCOut";
149 let SuperClasses = [];
150}
151
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000152def MemBarrierOptOperand : AsmOperandClass {
153 let Name = "MemBarrierOpt";
154 let SuperClasses = [];
Jim Grosbachf922c472011-02-12 01:34:40 +0000155 let ParserMethod = "tryParseMemBarrierOptOperand";
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000156}
157
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000158def ProcIFlagsOperand : AsmOperandClass {
159 let Name = "ProcIFlags";
160 let SuperClasses = [];
161 let ParserMethod = "tryParseProcIFlagsOperand";
162}
163
164// ARM imod and iflag operands, used only by the CPS instruction.
165def imod_op : Operand<i32> {
166 let PrintMethod = "printCPSIMod";
167}
168
169def iflags_op : Operand<i32> {
170 let PrintMethod = "printCPSIFlag";
171 let ParserMatchClass = ProcIFlagsOperand;
172}
173
Evan Cheng446c4282009-07-11 06:43:01 +0000174// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
175// register whose default is 0 (no register).
176def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
177 (ops (i32 14), (i32 zero_reg))> {
178 let PrintMethod = "printPredicateOperand";
Daniel Dunbar8462b302010-08-11 06:36:53 +0000179 let ParserMatchClass = CondCodeOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000180}
181
182// Conditional code result for instructions whose 's' bit is set, e.g. subs.
183def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000184 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000185 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000186 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000187}
188
189// Same as cc_out except it defaults to setting CPSR.
190def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000191 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000192 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000193 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000194}
195
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000196// ARM special operands for disassembly only.
197//
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000198def setend_op : Operand<i32> {
199 let PrintMethod = "printSetendOperand";
200}
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000201
202def cps_opt : Operand<i32> {
203 let PrintMethod = "printCPSOptionOperand";
204}
205
206def msr_mask : Operand<i32> {
207 let PrintMethod = "printMSRMaskOperand";
208}
209
210// A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
211// The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
212def neg_zero : Operand<i32> {
213 let PrintMethod = "printNegZeroOperand";
214}
215
Evan Cheng446c4282009-07-11 06:43:01 +0000216//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000217// ARM Instruction templates.
218//
219
Johnny Chend68e1192009-12-15 17:24:14 +0000220class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
221 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000222 : Instruction {
223 let Namespace = "ARM";
224
Evan Cheng37f25d92008-08-28 23:39:26 +0000225 AddrMode AM = am;
Evan Cheng37f25d92008-08-28 23:39:26 +0000226 SizeFlagVal SZ = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000227 IndexMode IM = im;
228 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000229 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000230 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000231 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000232 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000233 bit canXformTo16Bit = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +0000234
Chris Lattner150d20e2010-10-31 19:22:57 +0000235 // If this is a pseudo instruction, mark it isCodeGenOnly.
236 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson01135592010-03-23 17:23:59 +0000237
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000238 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000239 let TSFlags{4-0} = AM.Value;
240 let TSFlags{7-5} = SZ.Value;
241 let TSFlags{9-8} = IndexModeBits;
242 let TSFlags{15-10} = Form;
243 let TSFlags{16} = isUnaryDataProc;
244 let TSFlags{17} = canXformTo16Bit;
245 let TSFlags{19-18} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000246
Evan Cheng37f25d92008-08-28 23:39:26 +0000247 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000248 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000249}
250
Johnny Chend68e1192009-12-15 17:24:14 +0000251class Encoding {
252 field bits<32> Inst;
253}
254
255class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
256 Format f, Domain d, string cstr, InstrItinClass itin>
257 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
258
259// This Encoding-less class is used by Thumb1 to specify the encoding bits later
260// on by adding flavors to specific instructions.
261class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
262 Format f, Domain d, string cstr, InstrItinClass itin>
263 : InstTemplate<am, sz, im, f, d, cstr, itin>;
264
Jim Grosbach99594eb2010-11-18 01:38:26 +0000265class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Jim Grosbachc6961f12010-11-18 01:20:48 +0000266 // FIXME: This really should derive from InstTemplate instead, as pseudos
267 // don't need encoding information. TableGen doesn't like that
268 // currently. Need to figure out why and fix it.
Bob Wilson01135592010-03-23 17:23:59 +0000269 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000270 "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000271 let OutOperandList = oops;
272 let InOperandList = iops;
Evan Cheng37f25d92008-08-28 23:39:26 +0000273 let Pattern = pattern;
274}
275
Jim Grosbach53694262010-11-18 01:15:56 +0000276// PseudoInst that's ARM-mode only.
Jim Grosbach6e422112010-11-29 23:48:41 +0000277class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
Jim Grosbach99594eb2010-11-18 01:38:26 +0000278 list<dag> pattern>
279 : PseudoInst<oops, iops, itin, pattern> {
Jim Grosbach6e422112010-11-29 23:48:41 +0000280 let SZ = sz;
Jim Grosbach53694262010-11-18 01:15:56 +0000281 list<Predicate> Predicates = [IsARM];
282}
283
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000284// PseudoInst that's Thumb-mode only.
285class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
286 list<dag> pattern>
287 : PseudoInst<oops, iops, itin, pattern> {
288 let SZ = sz;
289 list<Predicate> Predicates = [IsThumb];
290}
Jim Grosbach53694262010-11-18 01:15:56 +0000291
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000292// PseudoInst that's Thumb2-mode only.
293class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
294 list<dag> pattern>
295 : PseudoInst<oops, iops, itin, pattern> {
296 let SZ = sz;
297 list<Predicate> Predicates = [IsThumb2];
298}
Evan Cheng37f25d92008-08-28 23:39:26 +0000299// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000300class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000301 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000302 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000303 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000304 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000305 bits<4> p;
306 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000307 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000308 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000309 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000310 let Pattern = pattern;
311 list<Predicate> Predicates = [IsARM];
312}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000313
Jim Grosbachf6b28622009-12-14 18:31:20 +0000314// A few are not predicable
315class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000316 IndexMode im, Format f, InstrItinClass itin,
317 string opc, string asm, string cstr,
318 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000319 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
320 let OutOperandList = oops;
321 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000322 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000323 let Pattern = pattern;
324 let isPredicable = 0;
325 list<Predicate> Predicates = [IsARM];
326}
Evan Cheng37f25d92008-08-28 23:39:26 +0000327
Bill Wendling4822bce2010-08-30 01:47:35 +0000328// Same as I except it can optionally modify CPSR. Note it's modeled as an input
329// operand since by default it's a zero register. It will become an implicit def
330// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000331class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000332 IndexMode im, Format f, InstrItinClass itin,
333 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000334 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000335 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000336 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000337 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000338 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000339 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000340
Evan Cheng37f25d92008-08-28 23:39:26 +0000341 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000342 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000343 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000344 let Pattern = pattern;
345 list<Predicate> Predicates = [IsARM];
346}
347
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000348// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000349class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000350 IndexMode im, Format f, InstrItinClass itin,
351 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000352 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000353 let OutOperandList = oops;
354 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000355 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000356 let Pattern = pattern;
357 list<Predicate> Predicates = [IsARM];
358}
359
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000360class AI<dag oops, dag iops, Format f, InstrItinClass itin,
361 string opc, string asm, list<dag> pattern>
362 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
363 opc, asm, "", pattern>;
364class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
365 string opc, string asm, list<dag> pattern>
366 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
367 opc, asm, "", pattern>;
368class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000369 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000370 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000371 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000372class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000373 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000374 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000375 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000376
377// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000378class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
379 string opc, string asm, list<dag> pattern>
380 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
381 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000382 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000383}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000384class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
385 string asm, list<dag> pattern>
386 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
387 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000388 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000389}
Evan Cheng3aac7882008-09-01 08:25:56 +0000390
391// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000392class JTI<dag oops, dag iops, InstrItinClass itin,
393 string asm, list<dag> pattern>
394 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000395 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000396
Jim Grosbach5278eb82009-12-11 01:42:04 +0000397// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000398class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
399 string opc, string asm, list<dag> pattern>
400 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
401 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000402 bits<4> Rt;
403 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000404 let Inst{27-23} = 0b00011;
405 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000406 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000407 let Inst{19-16} = Rn;
408 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000409 let Inst{11-0} = 0b111110011111;
410}
411class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
412 string opc, string asm, list<dag> pattern>
413 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
414 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000415 bits<4> Rd;
416 bits<4> Rt;
417 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000418 let Inst{27-23} = 0b00011;
419 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000420 let Inst{20} = 0;
Jim Grosbach86875a22010-10-29 19:58:57 +0000421 let Inst{19-16} = Rn;
422 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000423 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000424 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000425}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000426class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
427 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
428 bits<4> Rt;
429 bits<4> Rt2;
430 bits<4> Rn;
431 let Inst{27-23} = 0b00010;
432 let Inst{22} = b;
433 let Inst{21-20} = 0b00;
434 let Inst{19-16} = Rn;
435 let Inst{15-12} = Rt;
436 let Inst{11-4} = 0b00001001;
437 let Inst{3-0} = Rt2;
438}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000439
Evan Cheng0d14fc82008-09-01 01:51:14 +0000440// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000441class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
442 string opc, string asm, list<dag> pattern>
443 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
444 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000445 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000446 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000447}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000448class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
449 string opc, string asm, list<dag> pattern>
450 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
451 opc, asm, "", pattern> {
452 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000453 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000454}
455class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000456 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000457 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000458 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000459 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000460 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000461}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000462
Evan Cheng93912732008-09-01 01:27:33 +0000463// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000464
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000465// LDR/LDRB/STR/STRB/...
466class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000467 Format f, InstrItinClass itin, string opc, string asm,
468 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000469 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
470 "", pattern> {
471 let Inst{27-25} = op;
472 let Inst{24} = 1; // 24 == P
473 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000474 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000475 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000476 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000477}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000478// Indexed load/stores
479class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000480 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000481 string asm, string cstr, list<dag> pattern>
482 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
483 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000484 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000485 let Inst{27-26} = 0b01;
486 let Inst{24} = isPre; // P bit
487 let Inst{22} = isByte; // B bit
488 let Inst{21} = isPre; // W bit
489 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000490 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000491}
Jim Grosbach953557f42010-11-19 21:35:06 +0000492class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
493 IndexMode im, Format f, InstrItinClass itin, string opc,
494 string asm, string cstr, list<dag> pattern>
495 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
496 pattern> {
497 // AM2 store w/ two operands: (GPR, am2offset)
498 // {13} 1 == Rm, 0 == imm12
499 // {12} isAdd
500 // {11-0} imm12/Rm
501 bits<14> offset;
502 bits<4> Rn;
503 let Inst{25} = offset{13};
504 let Inst{23} = offset{12};
505 let Inst{19-16} = Rn;
506 let Inst{11-0} = offset{11-0};
507}
Jim Grosbach3e556122010-10-26 22:37:02 +0000508
Evan Cheng0d14fc82008-09-01 01:51:14 +0000509// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000510class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
511 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach160f8f02010-11-18 00:46:58 +0000512 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
513 opc, asm, "", pattern> {
514 bits<14> addr;
515 bits<4> Rt;
516 let Inst{27-25} = 0b000;
517 let Inst{24} = 1; // P bit
518 let Inst{23} = addr{8}; // U bit
519 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
520 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000521 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000522 let Inst{19-16} = addr{12-9}; // Rn
523 let Inst{15-12} = Rt; // Rt
524 let Inst{11-8} = addr{7-4}; // imm7_4/zero
525 let Inst{7-4} = op;
526 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
527}
Evan Cheng840917b2008-09-01 07:00:14 +0000528
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000529class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
530 IndexMode im, Format f, InstrItinClass itin, string opc,
531 string asm, string cstr, list<dag> pattern>
532 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
533 opc, asm, cstr, pattern> {
534 bits<4> Rt;
535 let Inst{27-25} = 0b000;
536 let Inst{24} = isPre; // P bit
537 let Inst{21} = isPre; // W bit
538 let Inst{20} = op20; // L bit
539 let Inst{15-12} = Rt; // Rt
540 let Inst{7-4} = op;
541}
Jim Grosbach2dc77682010-11-29 18:37:44 +0000542class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
543 IndexMode im, Format f, InstrItinClass itin, string opc,
544 string asm, string cstr, list<dag> pattern>
545 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
546 pattern> {
547 // AM3 store w/ two operands: (GPR, am3offset)
548 bits<14> offset;
549 bits<4> Rt;
550 bits<4> Rn;
551 let Inst{27-25} = 0b000;
552 let Inst{23} = offset{8};
553 let Inst{22} = offset{9};
554 let Inst{19-16} = Rn;
555 let Inst{15-12} = Rt; // Rt
556 let Inst{11-8} = offset{7-4}; // imm7_4/zero
557 let Inst{7-4} = op;
558 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
559}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000560
Evan Cheng840917b2008-09-01 07:00:14 +0000561// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000562class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000563 string opc, string asm, list<dag> pattern>
564 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
565 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000566 bits<14> addr;
567 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000568 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000569 let Inst{24} = 1; // P bit
570 let Inst{23} = addr{8}; // U bit
571 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
572 let Inst{21} = 0; // W bit
573 let Inst{20} = 0; // L bit
574 let Inst{19-16} = addr{12-9}; // Rn
575 let Inst{15-12} = Rt; // Rt
576 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000577 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000578 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000579}
Evan Cheng840917b2008-09-01 07:00:14 +0000580
Evan Cheng840917b2008-09-01 07:00:14 +0000581// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000582class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
583 string opc, string asm, string cstr, list<dag> pattern>
584 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
585 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000586 let Inst{4} = 1;
587 let Inst{5} = 1; // H bit
588 let Inst{6} = 0; // S bit
589 let Inst{7} = 1;
590 let Inst{20} = 0; // L bit
591 let Inst{21} = 1; // W bit
592 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000593 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000594}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000595class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
596 string opc, string asm, string cstr, list<dag> pattern>
597 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
598 opc, asm, cstr, pattern> {
599 let Inst{4} = 1;
600 let Inst{5} = 1; // H bit
601 let Inst{6} = 1; // S bit
602 let Inst{7} = 1;
603 let Inst{20} = 0; // L bit
604 let Inst{21} = 1; // W bit
605 let Inst{24} = 1; // P bit
606 let Inst{27-25} = 0b000;
607}
Evan Cheng840917b2008-09-01 07:00:14 +0000608
Evan Cheng840917b2008-09-01 07:00:14 +0000609// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000610class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
611 string opc, string asm, string cstr, list<dag> pattern>
612 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
613 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000614 let Inst{4} = 1;
615 let Inst{5} = 1; // H bit
616 let Inst{6} = 0; // S bit
617 let Inst{7} = 1;
618 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000619 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000620 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000621 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000622}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000623class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
624 string opc, string asm, string cstr, list<dag> pattern>
625 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
626 opc, asm, cstr, pattern> {
627 let Inst{4} = 1;
628 let Inst{5} = 1; // H bit
629 let Inst{6} = 1; // S bit
630 let Inst{7} = 1;
631 let Inst{20} = 0; // L bit
632 let Inst{21} = 0; // W bit
633 let Inst{24} = 0; // P bit
634 let Inst{27-25} = 0b000;
635}
Evan Cheng840917b2008-09-01 07:00:14 +0000636
Evan Cheng0d14fc82008-09-01 01:51:14 +0000637// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000638class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
639 string asm, string cstr, list<dag> pattern>
640 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
641 bits<4> p;
642 bits<16> regs;
643 bits<4> Rn;
644 let Inst{31-28} = p;
645 let Inst{27-25} = 0b100;
646 let Inst{22} = 0; // S bit
647 let Inst{19-16} = Rn;
648 let Inst{15-0} = regs;
649}
Evan Cheng37f25d92008-08-28 23:39:26 +0000650
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000651// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000652class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
653 string opc, string asm, list<dag> pattern>
654 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
655 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000656 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000657 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000658 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000659}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000660class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
661 string opc, string asm, list<dag> pattern>
662 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
663 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000664 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000665 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000666}
667
668// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000669class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
670 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000671 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
672 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000673 bits<4> Rd;
674 bits<4> Rn;
675 bits<4> Rm;
676 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000677 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000678 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000679 let Inst{19-16} = Rd;
680 let Inst{11-8} = Rm;
681 let Inst{3-0} = Rn;
682}
683// MSW multiple w/ Ra operand
684class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
685 InstrItinClass itin, string opc, string asm, list<dag> pattern>
686 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
687 bits<4> Ra;
688 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000689}
Evan Cheng37f25d92008-08-28 23:39:26 +0000690
Evan Chengeb4f52e2008-11-06 03:35:07 +0000691// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000692class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000693 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000694 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
695 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000696 bits<4> Rn;
697 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000698 let Inst{4} = 0;
699 let Inst{7} = 1;
700 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000701 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000702 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000703 let Inst{11-8} = Rm;
704 let Inst{3-0} = Rn;
705}
706class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
707 InstrItinClass itin, string opc, string asm, list<dag> pattern>
708 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
709 bits<4> Rd;
710 let Inst{19-16} = Rd;
711}
712
713// AMulxyI with Ra operand
714class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
715 InstrItinClass itin, string opc, string asm, list<dag> pattern>
716 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
717 bits<4> Ra;
718 let Inst{15-12} = Ra;
719}
720// SMLAL*
721class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
722 InstrItinClass itin, string opc, string asm, list<dag> pattern>
723 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
724 bits<4> RdLo;
725 bits<4> RdHi;
726 let Inst{19-16} = RdHi;
727 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000728}
729
Evan Cheng97f48c32008-11-06 22:15:19 +0000730// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000731class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
732 string opc, string asm, list<dag> pattern>
733 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
734 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000735 // All AExtI instructions have Rd and Rm register operands.
736 bits<4> Rd;
737 bits<4> Rm;
738 let Inst{15-12} = Rd;
739 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000740 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000741 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000742 let Inst{27-20} = opcod;
743}
744
Evan Cheng8b59db32008-11-07 01:41:35 +0000745// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000746class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
747 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000748 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
749 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000750 bits<4> Rd;
751 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000752 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000753 let Inst{19-16} = 0b1111;
754 let Inst{15-12} = Rd;
755 let Inst{11-8} = 0b1111;
756 let Inst{7-4} = opc7_4;
757 let Inst{3-0} = Rm;
758}
759
760// PKH instructions
761class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
762 string opc, string asm, list<dag> pattern>
763 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
764 opc, asm, "", pattern> {
765 bits<4> Rd;
766 bits<4> Rn;
767 bits<4> Rm;
768 bits<8> sh;
769 let Inst{27-20} = opcod;
770 let Inst{19-16} = Rn;
771 let Inst{15-12} = Rd;
772 let Inst{11-7} = sh{7-3};
773 let Inst{6} = tb;
774 let Inst{5-4} = 0b01;
775 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000776}
777
Evan Cheng37f25d92008-08-28 23:39:26 +0000778//===----------------------------------------------------------------------===//
779
780// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
781class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
782 list<Predicate> Predicates = [IsARM];
783}
784class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
785 list<Predicate> Predicates = [IsARM, HasV5TE];
786}
787class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
788 list<Predicate> Predicates = [IsARM, HasV6];
789}
Evan Cheng13096642008-08-29 06:41:12 +0000790
791//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000792// Thumb Instruction Format Definitions.
793//
794
Evan Cheng446c4282009-07-11 06:43:01 +0000795class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000796 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000797 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000798 let OutOperandList = oops;
799 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000800 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000801 let Pattern = pattern;
802 list<Predicate> Predicates = [IsThumb];
803}
804
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000805// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000806class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
807 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000808
Evan Cheng35d6c412009-08-04 23:47:55 +0000809// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000810class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
811 list<dag> pattern>
812 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
813 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000814
Johnny Chend68e1192009-12-15 17:24:14 +0000815// tBL, tBX 32-bit instructions
816class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000817 dag oops, dag iops, InstrItinClass itin, string asm,
818 list<dag> pattern>
819 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
820 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000821 let Inst{31-27} = opcod1;
822 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000823 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000824}
Evan Cheng13096642008-08-29 06:41:12 +0000825
Bruno Cardoso Lopesfa5bd272011-01-20 16:35:57 +0000826// Move to/from coprocessor instructions
827class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
828 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
829 Encoding, Requires<[IsThumb, HasV6]> {
830 let Inst{31-28} = 0b1110;
831}
832
Evan Cheng13096642008-08-29 06:41:12 +0000833// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000834class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
835 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000836 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000837
Evan Cheng09c39fc2009-06-23 19:38:13 +0000838// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +0000839class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000840 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000841 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000842 let OutOperandList = oops;
843 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000844 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000845 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000846 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000847}
848
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000849class T1I<dag oops, dag iops, InstrItinClass itin,
850 string asm, list<dag> pattern>
851 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
852class T1Ix2<dag oops, dag iops, InstrItinClass itin,
853 string asm, list<dag> pattern>
854 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000855
856// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000857class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000858 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000859 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000860 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000861
862// Thumb1 instruction that can either be predicated or set CPSR.
863class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000864 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000865 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000866 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000867 let OutOperandList = !con(oops, (outs s_cc_out:$s));
868 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000869 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000870 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000871 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000872}
873
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000874class T1sI<dag oops, dag iops, InstrItinClass itin,
875 string opc, string asm, list<dag> pattern>
876 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000877
878// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000879class T1sIt<dag oops, dag iops, InstrItinClass itin,
880 string opc, string asm, list<dag> pattern>
881 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000882 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000883
884// Thumb1 instruction that can be predicated.
885class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000886 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000887 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000888 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000889 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000890 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000891 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000892 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000893 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000894}
895
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000896class T1pI<dag oops, dag iops, InstrItinClass itin,
897 string opc, string asm, list<dag> pattern>
898 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000899
900// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000901class T1pIt<dag oops, dag iops, InstrItinClass itin,
902 string opc, string asm, list<dag> pattern>
903 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000904 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000905
Bob Wilson01135592010-03-23 17:23:59 +0000906class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000907 InstrItinClass itin, string opc, string asm, list<dag> pattern>
908 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000909
Johnny Chenbbc71b22009-12-16 02:32:54 +0000910class Encoding16 : Encoding {
911 let Inst{31-16} = 0x0000;
912}
913
Johnny Chend68e1192009-12-15 17:24:14 +0000914// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +0000915class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000916 let Inst{15-10} = opcode;
917}
918
919// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000920class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000921 let Inst{15-14} = 0b00;
922 let Inst{13-9} = opcode;
923}
924
925// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000926class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000927 let Inst{15-10} = 0b010000;
928 let Inst{9-6} = opcode;
929}
930
931// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000932class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000933 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +0000934 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +0000935}
936
937// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000938class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000939 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000940 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +0000941}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000942class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +0000943
Bill Wendling1fd374e2010-11-30 22:57:21 +0000944// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +0000945// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +0000946//
Bill Wendling1fd374e2010-11-30 22:57:21 +0000947// 0b0110 => Immediate, 4 bytes
948// 0b1000 => Immediate, 2 bytes
949// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +0000950class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
951 InstrItinClass itin, string opc, string asm,
952 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000953 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000954 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000955 bits<3> Rt;
956 bits<8> addr;
957 let Inst{8-6} = addr{5-3}; // Rm
958 let Inst{5-3} = addr{2-0}; // Rn
959 let Inst{2-0} = Rt;
960}
Bill Wendling40062fb2010-12-01 01:38:08 +0000961class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
962 InstrItinClass itin, string opc, string asm,
963 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000964 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000965 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000966 bits<3> Rt;
967 bits<8> addr;
968 let Inst{10-6} = addr{7-3}; // imm5
969 let Inst{5-3} = addr{2-0}; // Rn
970 let Inst{2-0} = Rt;
971}
972
Johnny Chend68e1192009-12-15 17:24:14 +0000973// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000974class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000975 let Inst{15-12} = 0b1011;
976 let Inst{11-5} = opcode;
977}
978
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000979// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
980class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000981 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000982 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000983 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000984 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000985 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000986 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000987 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +0000988 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000989}
990
Bill Wendlingda2ae632010-08-31 07:50:46 +0000991// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
992// input operand since by default it's a zero register. It will become an
993// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +0000994//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000995// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
996// more consistent.
997class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000998 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +0000999 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001000 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001001 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1002 let Inst{20} = s;
1003
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001004 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001005 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001006 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001007 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001008 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001009}
1010
1011// Special cases
1012class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001013 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001014 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001015 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001016 let OutOperandList = oops;
1017 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001018 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001019 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001020 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001021}
1022
Jim Grosbachd1228742009-12-01 18:10:36 +00001023class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001024 InstrItinClass itin,
1025 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001026 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1027 let OutOperandList = oops;
1028 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001029 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001030 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001031 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001032}
1033
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001034class T2I<dag oops, dag iops, InstrItinClass itin,
1035 string opc, string asm, list<dag> pattern>
1036 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1037class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1038 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001039 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001040class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1041 string opc, string asm, list<dag> pattern>
1042 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1043class T2Iso<dag oops, dag iops, InstrItinClass itin,
1044 string opc, string asm, list<dag> pattern>
1045 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1046class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1047 string opc, string asm, list<dag> pattern>
1048 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001049class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001050 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001051 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1052 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001053 bits<4> Rt;
1054 bits<4> Rt2;
1055 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001056 let Inst{31-25} = 0b1110100;
1057 let Inst{24} = P;
1058 let Inst{23} = addr{8};
1059 let Inst{22} = 1;
1060 let Inst{21} = W;
1061 let Inst{20} = isLoad;
1062 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001063 let Inst{15-12} = Rt{3-0};
1064 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001065 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001066}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001067
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001068class T2sI<dag oops, dag iops, InstrItinClass itin,
1069 string opc, string asm, list<dag> pattern>
1070 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001071
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001072class T2XI<dag oops, dag iops, InstrItinClass itin,
1073 string asm, list<dag> pattern>
1074 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1075class T2JTI<dag oops, dag iops, InstrItinClass itin,
1076 string asm, list<dag> pattern>
1077 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001078
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001079// Move to/from coprocessor instructions
1080class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1081 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1082 let Inst{31-28} = 0b1111;
1083}
1084
Bob Wilson815baeb2010-03-13 01:08:20 +00001085// Two-address instructions
1086class T2XIt<dag oops, dag iops, InstrItinClass itin,
1087 string asm, string cstr, list<dag> pattern>
1088 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001089
Evan Chenge88d5ce2009-07-02 07:28:31 +00001090// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001091class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1092 dag oops, dag iops,
1093 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001094 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001095 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001096 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001097 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001098 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001099 let Pattern = pattern;
1100 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001101 let Inst{31-27} = 0b11111;
1102 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001103 let Inst{24} = signed;
1104 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001105 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001106 let Inst{20} = load;
1107 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001108 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001109 let Inst{10} = pre; // The P bit.
1110 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001111
Owen Anderson6af50f72010-11-30 00:14:31 +00001112 bits<9> addr;
1113 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001114 let Inst{9} = addr{8}; // Sign bit
1115
Owen Anderson6af50f72010-11-30 00:14:31 +00001116 bits<4> Rt;
1117 bits<4> Rn;
1118 let Inst{15-12} = Rt{3-0};
1119 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001120}
1121
David Goodwinc9d138f2009-07-27 19:59:26 +00001122// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1123class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001124 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001125}
1126
1127// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1128class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001129 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001130}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001131
Evan Cheng9cb9e672009-06-27 02:26:13 +00001132// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1133class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001134 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001135}
1136
Evan Cheng13096642008-08-29 06:41:12 +00001137//===----------------------------------------------------------------------===//
1138
Evan Cheng96581d32008-11-11 02:11:05 +00001139//===----------------------------------------------------------------------===//
1140// ARM VFP Instruction templates.
1141//
1142
David Goodwin3ca524e2009-07-10 17:03:29 +00001143// Almost all VFP instructions are predicable.
1144class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001145 IndexMode im, Format f, InstrItinClass itin,
1146 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001147 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001148 bits<4> p;
1149 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001150 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001151 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001152 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001153 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001154 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001155 list<Predicate> Predicates = [HasVFP2];
1156}
1157
1158// Special cases
1159class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001160 IndexMode im, Format f, InstrItinClass itin,
1161 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001162 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001163 bits<4> p;
1164 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001165 let OutOperandList = oops;
1166 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001167 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001168 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001169 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001170 list<Predicate> Predicates = [HasVFP2];
1171}
1172
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001173class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1174 string opc, string asm, list<dag> pattern>
1175 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001176 opc, asm, "", pattern> {
1177 let PostEncoderMethod = "VFPThumb2PostEncoder";
1178}
David Goodwin3ca524e2009-07-10 17:03:29 +00001179
Evan Chengcd8e66a2008-11-11 21:48:44 +00001180// ARM VFP addrmode5 loads and stores
1181class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001182 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001183 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001184 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001185 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001186 // Instruction operands.
1187 bits<5> Dd;
1188 bits<13> addr;
1189
1190 // Encode instruction operands.
1191 let Inst{23} = addr{8}; // U (add = (U == '1'))
1192 let Inst{22} = Dd{4};
1193 let Inst{19-16} = addr{12-9}; // Rn
1194 let Inst{15-12} = Dd{3-0};
1195 let Inst{7-0} = addr{7-0}; // imm8
1196
Evan Cheng96581d32008-11-11 02:11:05 +00001197 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001198 let Inst{27-24} = opcod1;
1199 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001200 let Inst{11-9} = 0b101;
1201 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001202
Evan Cheng5eda2822011-02-16 00:35:02 +00001203 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001204 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001205}
1206
Evan Chengcd8e66a2008-11-11 21:48:44 +00001207class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001208 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001209 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001210 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001211 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001212 // Instruction operands.
1213 bits<5> Sd;
1214 bits<13> addr;
1215
1216 // Encode instruction operands.
1217 let Inst{23} = addr{8}; // U (add = (U == '1'))
1218 let Inst{22} = Sd{0};
1219 let Inst{19-16} = addr{12-9}; // Rn
1220 let Inst{15-12} = Sd{4-1};
1221 let Inst{7-0} = addr{7-0}; // imm8
1222
Evan Cheng96581d32008-11-11 02:11:05 +00001223 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001224 let Inst{27-24} = opcod1;
1225 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001226 let Inst{11-9} = 0b101;
1227 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001228
1229 // Loads & stores operate on both NEON and VFP pipelines.
1230 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001231}
1232
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001233// VFP Load / store multiple pseudo instructions.
1234class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1235 list<dag> pattern>
1236 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1237 cstr, itin> {
1238 let OutOperandList = oops;
1239 let InOperandList = !con(iops, (ins pred:$p));
1240 let Pattern = pattern;
1241 list<Predicate> Predicates = [HasVFP2];
1242}
1243
Evan Chengcd8e66a2008-11-11 21:48:44 +00001244// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001245class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001246 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001247 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001248 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001249 // Instruction operands.
1250 bits<4> Rn;
1251 bits<13> regs;
1252
1253 // Encode instruction operands.
1254 let Inst{19-16} = Rn;
1255 let Inst{22} = regs{12};
1256 let Inst{15-12} = regs{11-8};
1257 let Inst{7-0} = regs{7-0};
1258
Evan Chengcd8e66a2008-11-11 21:48:44 +00001259 // TODO: Mark the instructions with the appropriate subtarget info.
1260 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001261 let Inst{11-9} = 0b101;
1262 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001263}
1264
Jim Grosbach72db1822010-09-08 00:25:50 +00001265class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001266 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001267 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001268 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001269 // Instruction operands.
1270 bits<4> Rn;
1271 bits<13> regs;
1272
1273 // Encode instruction operands.
1274 let Inst{19-16} = Rn;
1275 let Inst{22} = regs{8};
1276 let Inst{15-12} = regs{12-9};
1277 let Inst{7-0} = regs{7-0};
1278
Evan Chengcd8e66a2008-11-11 21:48:44 +00001279 // TODO: Mark the instructions with the appropriate subtarget info.
1280 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001281 let Inst{11-9} = 0b101;
1282 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001283}
1284
Evan Cheng96581d32008-11-11 02:11:05 +00001285// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001286class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1287 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1288 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001289 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001290 // Instruction operands.
1291 bits<5> Dd;
1292 bits<5> Dm;
1293
1294 // Encode instruction operands.
1295 let Inst{3-0} = Dm{3-0};
1296 let Inst{5} = Dm{4};
1297 let Inst{15-12} = Dd{3-0};
1298 let Inst{22} = Dd{4};
1299
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001300 let Inst{27-23} = opcod1;
1301 let Inst{21-20} = opcod2;
1302 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001303 let Inst{11-9} = 0b101;
1304 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001305 let Inst{7-6} = opcod4;
1306 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001307}
1308
1309// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001310class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001311 dag iops, InstrItinClass itin, string opc, string asm,
1312 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001313 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001314 // Instruction operands.
1315 bits<5> Dd;
1316 bits<5> Dn;
1317 bits<5> Dm;
1318
1319 // Encode instruction operands.
1320 let Inst{3-0} = Dm{3-0};
1321 let Inst{5} = Dm{4};
1322 let Inst{19-16} = Dn{3-0};
1323 let Inst{7} = Dn{4};
1324 let Inst{15-12} = Dd{3-0};
1325 let Inst{22} = Dd{4};
1326
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001327 let Inst{27-23} = opcod1;
1328 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001329 let Inst{11-9} = 0b101;
1330 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001331 let Inst{6} = op6;
1332 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001333}
1334
1335// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001336class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1337 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1338 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001339 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001340 // Instruction operands.
1341 bits<5> Sd;
1342 bits<5> Sm;
1343
1344 // Encode instruction operands.
1345 let Inst{3-0} = Sm{4-1};
1346 let Inst{5} = Sm{0};
1347 let Inst{15-12} = Sd{4-1};
1348 let Inst{22} = Sd{0};
1349
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001350 let Inst{27-23} = opcod1;
1351 let Inst{21-20} = opcod2;
1352 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001353 let Inst{11-9} = 0b101;
1354 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001355 let Inst{7-6} = opcod4;
1356 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001357}
1358
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001359// Single precision unary, if no NEON. Same as ASuI except not available if
1360// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001361class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1362 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1363 string asm, list<dag> pattern>
1364 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1365 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001366 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1367}
1368
Evan Cheng96581d32008-11-11 02:11:05 +00001369// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001370class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1371 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001372 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001373 // Instruction operands.
1374 bits<5> Sd;
1375 bits<5> Sn;
1376 bits<5> Sm;
1377
1378 // Encode instruction operands.
1379 let Inst{3-0} = Sm{4-1};
1380 let Inst{5} = Sm{0};
1381 let Inst{19-16} = Sn{4-1};
1382 let Inst{7} = Sn{0};
1383 let Inst{15-12} = Sd{4-1};
1384 let Inst{22} = Sd{0};
1385
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001386 let Inst{27-23} = opcod1;
1387 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001388 let Inst{11-9} = 0b101;
1389 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001390 let Inst{6} = op6;
1391 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001392}
1393
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001394// Single precision binary, if no NEON. Same as ASbI except not available if
1395// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001396class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001397 dag iops, InstrItinClass itin, string opc, string asm,
1398 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001399 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001400 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001401
1402 // Instruction operands.
1403 bits<5> Sd;
1404 bits<5> Sn;
1405 bits<5> Sm;
1406
1407 // Encode instruction operands.
1408 let Inst{3-0} = Sm{4-1};
1409 let Inst{5} = Sm{0};
1410 let Inst{19-16} = Sn{4-1};
1411 let Inst{7} = Sn{0};
1412 let Inst{15-12} = Sd{4-1};
1413 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001414}
1415
Evan Cheng80a11982008-11-12 06:41:41 +00001416// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001417class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1418 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1419 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001420 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001421 let Inst{27-23} = opcod1;
1422 let Inst{21-20} = opcod2;
1423 let Inst{19-16} = opcod3;
1424 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001425 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001426 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001427}
1428
Johnny Chen811663f2010-02-11 18:47:03 +00001429// VFP conversion between floating-point and fixed-point
1430class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001431 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1432 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001433 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1434 // size (fixed-point number): sx == 0 ? 16 : 32
1435 let Inst{7} = op5; // sx
1436}
1437
David Goodwin338268c2009-08-10 22:17:39 +00001438// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001439class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001440 dag oops, dag iops, InstrItinClass itin,
1441 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001442 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1443 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001444 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1445}
1446
Evan Cheng80a11982008-11-12 06:41:41 +00001447class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001448 InstrItinClass itin,
1449 string opc, string asm, list<dag> pattern>
1450 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001451 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001452 let Inst{11-8} = opcod2;
1453 let Inst{4} = 1;
1454}
1455
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001456class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1457 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1458 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001459
Bob Wilson01135592010-03-23 17:23:59 +00001460class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001461 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1462 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001463
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001464class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1465 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1466 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001467
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001468class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1469 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1470 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001471
Evan Cheng96581d32008-11-11 02:11:05 +00001472//===----------------------------------------------------------------------===//
1473
Bob Wilson5bafff32009-06-22 23:27:02 +00001474//===----------------------------------------------------------------------===//
1475// ARM NEON Instruction templates.
1476//
Evan Cheng13096642008-08-29 06:41:12 +00001477
Johnny Chencaa608e2010-03-20 00:17:00 +00001478class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1479 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1480 list<dag> pattern>
1481 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001482 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001483 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001484 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001485 let Pattern = pattern;
1486 list<Predicate> Predicates = [HasNEON];
1487}
1488
1489// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001490class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1491 InstrItinClass itin, string opc, string asm, string cstr,
1492 list<dag> pattern>
1493 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001494 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001495 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001496 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001497 let Pattern = pattern;
1498 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001499}
1500
Bob Wilsonb07c1712009-10-07 21:53:04 +00001501class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1502 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001503 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001504 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1505 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001506 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001507 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001508 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001509 let Inst{11-8} = op11_8;
1510 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001511
Chris Lattner2ac19022010-11-15 05:19:05 +00001512 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001513
Owen Andersond9aa7d32010-11-02 00:05:05 +00001514 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001515 bits<6> Rn;
1516 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001517
Owen Andersond9aa7d32010-11-02 00:05:05 +00001518 let Inst{22} = Vd{4};
1519 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001520 let Inst{19-16} = Rn{3-0};
1521 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001522}
1523
Owen Andersond138d702010-11-02 20:47:39 +00001524class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1525 dag oops, dag iops, InstrItinClass itin,
1526 string opc, string dt, string asm, string cstr, list<dag> pattern>
1527 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1528 dt, asm, cstr, pattern> {
1529 bits<3> lane;
1530}
1531
Bob Wilson709d5922010-08-25 23:27:42 +00001532class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1533 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1534 itin> {
1535 let OutOperandList = oops;
1536 let InOperandList = !con(iops, (ins pred:$p));
1537 list<Predicate> Predicates = [HasNEON];
1538}
1539
Jim Grosbach7cd27292010-10-06 20:36:55 +00001540class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1541 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001542 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1543 itin> {
1544 let OutOperandList = oops;
1545 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001546 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001547 list<Predicate> Predicates = [HasNEON];
1548}
1549
Johnny Chen785516a2010-03-23 16:43:47 +00001550class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001551 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001552 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1553 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001554 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001555 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001556}
1557
Johnny Chen927b88f2010-03-23 20:40:44 +00001558class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001559 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001560 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001561 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001562 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001563 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001564}
1565
1566// NEON "one register and a modified immediate" format.
1567class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1568 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001569 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001570 string opc, string dt, string asm, string cstr,
1571 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001572 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001573 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001574 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001575 let Inst{11-8} = op11_8;
1576 let Inst{7} = op7;
1577 let Inst{6} = op6;
1578 let Inst{5} = op5;
1579 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001580
Owen Andersona88ea032010-10-26 17:40:54 +00001581 // Instruction operands.
1582 bits<5> Vd;
1583 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001584
Owen Andersona88ea032010-10-26 17:40:54 +00001585 let Inst{15-12} = Vd{3-0};
1586 let Inst{22} = Vd{4};
1587 let Inst{24} = SIMM{7};
1588 let Inst{18-16} = SIMM{6-4};
1589 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001590}
1591
1592// NEON 2 vector register format.
1593class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1594 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001595 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001596 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001597 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001598 let Inst{24-23} = op24_23;
1599 let Inst{21-20} = op21_20;
1600 let Inst{19-18} = op19_18;
1601 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001602 let Inst{11-7} = op11_7;
1603 let Inst{6} = op6;
1604 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001605
Owen Anderson162875a2010-10-25 18:43:52 +00001606 // Instruction operands.
1607 bits<5> Vd;
1608 bits<5> Vm;
1609
1610 let Inst{15-12} = Vd{3-0};
1611 let Inst{22} = Vd{4};
1612 let Inst{3-0} = Vm{3-0};
1613 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001614}
1615
1616// Same as N2V except it doesn't have a datatype suffix.
1617class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001618 bits<5> op11_7, bit op6, bit op4,
1619 dag oops, dag iops, InstrItinClass itin,
1620 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001621 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001622 let Inst{24-23} = op24_23;
1623 let Inst{21-20} = op21_20;
1624 let Inst{19-18} = op19_18;
1625 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001626 let Inst{11-7} = op11_7;
1627 let Inst{6} = op6;
1628 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001629
Owen Anderson162875a2010-10-25 18:43:52 +00001630 // Instruction operands.
1631 bits<5> Vd;
1632 bits<5> Vm;
1633
1634 let Inst{15-12} = Vd{3-0};
1635 let Inst{22} = Vd{4};
1636 let Inst{3-0} = Vm{3-0};
1637 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001638}
1639
1640// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001641class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001642 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001643 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001644 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001645 let Inst{24} = op24;
1646 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001647 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001648 let Inst{7} = op7;
1649 let Inst{6} = op6;
1650 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001651
Owen Anderson3557d002010-10-26 20:56:57 +00001652 // Instruction operands.
1653 bits<5> Vd;
1654 bits<5> Vm;
1655 bits<6> SIMM;
1656
1657 let Inst{15-12} = Vd{3-0};
1658 let Inst{22} = Vd{4};
1659 let Inst{3-0} = Vm{3-0};
1660 let Inst{5} = Vm{4};
1661 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001662}
1663
Bob Wilson10bc69c2010-03-27 03:56:52 +00001664// NEON 3 vector register format.
1665class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1666 dag oops, dag iops, Format f, InstrItinClass itin,
1667 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001668 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001669 let Inst{24} = op24;
1670 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001671 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001672 let Inst{11-8} = op11_8;
1673 let Inst{6} = op6;
1674 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001675
Owen Andersond451f882010-10-21 20:21:49 +00001676 // Instruction operands.
1677 bits<5> Vd;
1678 bits<5> Vn;
1679 bits<5> Vm;
1680
1681 let Inst{15-12} = Vd{3-0};
1682 let Inst{22} = Vd{4};
1683 let Inst{19-16} = Vn{3-0};
1684 let Inst{7} = Vn{4};
1685 let Inst{3-0} = Vm{3-0};
1686 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001687}
1688
Johnny Chen841e8282010-03-23 21:35:03 +00001689// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001690class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1691 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001692 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001693 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001694 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001695 let Inst{24} = op24;
1696 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001697 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001698 let Inst{11-8} = op11_8;
1699 let Inst{6} = op6;
1700 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001701
Owen Anderson8c71eff2010-10-25 18:28:30 +00001702 // Instruction operands.
1703 bits<5> Vd;
1704 bits<5> Vn;
1705 bits<5> Vm;
1706
1707 let Inst{15-12} = Vd{3-0};
1708 let Inst{22} = Vd{4};
1709 let Inst{19-16} = Vn{3-0};
1710 let Inst{7} = Vn{4};
1711 let Inst{3-0} = Vm{3-0};
1712 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001713}
1714
1715// NEON VMOVs between scalar and core registers.
1716class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001717 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001718 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001719 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001720 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001721 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001722 let Inst{11-8} = opcod2;
1723 let Inst{6-5} = opcod3;
1724 let Inst{4} = 1;
Evan Chengf81bf152009-11-23 21:57:23 +00001725
1726 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001727 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001728 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001729 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001730 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001731
Chris Lattner2ac19022010-11-15 05:19:05 +00001732 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001733
Owen Andersond2fbdb72010-10-27 21:28:09 +00001734 bits<5> V;
1735 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001736 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001737 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001738
Owen Andersonf587a9352010-10-27 19:25:54 +00001739 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001740 let Inst{7} = V{4};
1741 let Inst{19-16} = V{3-0};
1742 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001743}
1744class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001745 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001746 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001747 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001748 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001749class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001750 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001751 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001752 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001753 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001754class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001755 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001756 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001757 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001758 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001759
Johnny Chene4614f72010-03-25 17:01:27 +00001760// Vector Duplicate Lane (from scalar to all elements)
1761class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1762 InstrItinClass itin, string opc, string dt, string asm,
1763 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001764 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001765 let Inst{24-23} = 0b11;
1766 let Inst{21-20} = 0b11;
1767 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001768 let Inst{11-7} = 0b11000;
1769 let Inst{6} = op6;
1770 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001771
Owen Andersonf587a9352010-10-27 19:25:54 +00001772 bits<5> Vd;
1773 bits<5> Vm;
1774 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001775
Owen Andersonf587a9352010-10-27 19:25:54 +00001776 let Inst{22} = Vd{4};
1777 let Inst{15-12} = Vd{3-0};
1778 let Inst{5} = Vm{4};
1779 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001780}
1781
David Goodwin42a83f22009-08-04 17:53:06 +00001782// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1783// for single-precision FP.
1784class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1785 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1786}