blob: cf8c4724c59d6cd637ff954de5c9a69876d0a50f [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.
Evan Cheng6557bce2011-02-22 19:53:14 +0000130class Domain<bits<3> val> {
131 bits<3> Value = val;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000132}
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
Evan Cheng2b943562011-02-23 02:35:33 +0000137def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000138
Evan Cheng055b0312009-06-29 07:51:04 +0000139//===----------------------------------------------------------------------===//
Evan Cheng446c4282009-07-11 06:43:01 +0000140// ARM special operands.
141//
142
Daniel Dunbar8462b302010-08-11 06:36:53 +0000143def CondCodeOperand : AsmOperandClass {
144 let Name = "CondCode";
145 let SuperClasses = [];
146}
147
Jim Grosbachd67641b2010-12-06 18:21:12 +0000148def CCOutOperand : AsmOperandClass {
149 let Name = "CCOut";
150 let SuperClasses = [];
151}
152
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000153def MemBarrierOptOperand : AsmOperandClass {
154 let Name = "MemBarrierOpt";
155 let SuperClasses = [];
Jim Grosbachf922c472011-02-12 01:34:40 +0000156 let ParserMethod = "tryParseMemBarrierOptOperand";
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000157}
158
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000159def ProcIFlagsOperand : AsmOperandClass {
160 let Name = "ProcIFlags";
161 let SuperClasses = [];
162 let ParserMethod = "tryParseProcIFlagsOperand";
163}
164
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000165def MSRMaskOperand : AsmOperandClass {
166 let Name = "MSRMask";
167 let SuperClasses = [];
168 let ParserMethod = "tryParseMSRMaskOperand";
169}
170
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000171// ARM imod and iflag operands, used only by the CPS instruction.
172def imod_op : Operand<i32> {
173 let PrintMethod = "printCPSIMod";
174}
175
176def iflags_op : Operand<i32> {
177 let PrintMethod = "printCPSIFlag";
178 let ParserMatchClass = ProcIFlagsOperand;
179}
180
Evan Cheng446c4282009-07-11 06:43:01 +0000181// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
182// register whose default is 0 (no register).
183def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
184 (ops (i32 14), (i32 zero_reg))> {
185 let PrintMethod = "printPredicateOperand";
Daniel Dunbar8462b302010-08-11 06:36:53 +0000186 let ParserMatchClass = CondCodeOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000187}
188
189// Conditional code result for instructions whose 's' bit is set, e.g. subs.
190def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
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
196// Same as cc_out except it defaults to setting CPSR.
197def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000198 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000199 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000200 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000201}
202
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000203// ARM special operands for disassembly only.
204//
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000205def setend_op : Operand<i32> {
206 let PrintMethod = "printSetendOperand";
207}
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000208
209def cps_opt : Operand<i32> {
210 let PrintMethod = "printCPSOptionOperand";
211}
212
213def msr_mask : Operand<i32> {
214 let PrintMethod = "printMSRMaskOperand";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000215 let ParserMatchClass = MSRMaskOperand;
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000216}
217
218// A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
219// The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
220def neg_zero : Operand<i32> {
221 let PrintMethod = "printNegZeroOperand";
222}
223
Bill Wendlinga656b632011-03-01 01:00:59 +0000224// Narrow Shift Right Immediate - A narrow shift right immediate is encoded
225// differently from other shift immediates. The imm6 field is encoded like so:
226//
227// 16-bit: imm6<5:3> = '001', 8 - <imm> is encded in imm6<2:0>
228// 32-bit: imm6<5:4> = '01',16 - <imm> is encded in imm6<3:0>
229// 64-bit: imm6<5> = '1', 32 - <imm> is encded in imm6<4:0>
230def nsr16_imm : Operand<i32> {
231 let EncoderMethod = "getNarrowShiftRight16Imm";
232}
233def nsr32_imm : Operand<i32> {
234 let EncoderMethod = "getNarrowShiftRight32Imm";
235}
236def nsr64_imm : Operand<i32> {
237 let EncoderMethod = "getNarrowShiftRight64Imm";
238}
239
Evan Cheng446c4282009-07-11 06:43:01 +0000240//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000241// ARM Instruction templates.
242//
243
Johnny Chend68e1192009-12-15 17:24:14 +0000244class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
245 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000246 : Instruction {
247 let Namespace = "ARM";
248
Evan Cheng37f25d92008-08-28 23:39:26 +0000249 AddrMode AM = am;
Evan Cheng37f25d92008-08-28 23:39:26 +0000250 SizeFlagVal SZ = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000251 IndexMode IM = im;
252 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000253 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000254 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000255 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000256 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000257 bit canXformTo16Bit = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +0000258
Chris Lattner150d20e2010-10-31 19:22:57 +0000259 // If this is a pseudo instruction, mark it isCodeGenOnly.
260 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson01135592010-03-23 17:23:59 +0000261
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000262 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000263 let TSFlags{4-0} = AM.Value;
264 let TSFlags{7-5} = SZ.Value;
265 let TSFlags{9-8} = IndexModeBits;
266 let TSFlags{15-10} = Form;
267 let TSFlags{16} = isUnaryDataProc;
268 let TSFlags{17} = canXformTo16Bit;
Evan Cheng6557bce2011-02-22 19:53:14 +0000269 let TSFlags{20-18} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000270
Evan Cheng37f25d92008-08-28 23:39:26 +0000271 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000272 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000273}
274
Johnny Chend68e1192009-12-15 17:24:14 +0000275class Encoding {
276 field bits<32> Inst;
277}
278
279class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
280 Format f, Domain d, string cstr, InstrItinClass itin>
281 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
282
283// This Encoding-less class is used by Thumb1 to specify the encoding bits later
284// on by adding flavors to specific instructions.
285class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
286 Format f, Domain d, string cstr, InstrItinClass itin>
287 : InstTemplate<am, sz, im, f, d, cstr, itin>;
288
Jim Grosbach99594eb2010-11-18 01:38:26 +0000289class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Jim Grosbachc6961f12010-11-18 01:20:48 +0000290 // FIXME: This really should derive from InstTemplate instead, as pseudos
291 // don't need encoding information. TableGen doesn't like that
292 // currently. Need to figure out why and fix it.
Bob Wilson01135592010-03-23 17:23:59 +0000293 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000294 "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000295 let OutOperandList = oops;
296 let InOperandList = iops;
Evan Cheng37f25d92008-08-28 23:39:26 +0000297 let Pattern = pattern;
298}
299
Jim Grosbach53694262010-11-18 01:15:56 +0000300// PseudoInst that's ARM-mode only.
Jim Grosbach6e422112010-11-29 23:48:41 +0000301class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
Jim Grosbach99594eb2010-11-18 01:38:26 +0000302 list<dag> pattern>
303 : PseudoInst<oops, iops, itin, pattern> {
Jim Grosbach6e422112010-11-29 23:48:41 +0000304 let SZ = sz;
Jim Grosbach53694262010-11-18 01:15:56 +0000305 list<Predicate> Predicates = [IsARM];
306}
307
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000308// PseudoInst that's Thumb-mode only.
309class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
310 list<dag> pattern>
311 : PseudoInst<oops, iops, itin, pattern> {
312 let SZ = sz;
313 list<Predicate> Predicates = [IsThumb];
314}
Jim Grosbach53694262010-11-18 01:15:56 +0000315
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000316// PseudoInst that's Thumb2-mode only.
317class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
318 list<dag> pattern>
319 : PseudoInst<oops, iops, itin, pattern> {
320 let SZ = sz;
321 list<Predicate> Predicates = [IsThumb2];
322}
Evan Cheng37f25d92008-08-28 23:39:26 +0000323// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000324class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000325 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000326 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000327 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000328 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000329 bits<4> p;
330 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000331 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000332 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000333 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000334 let Pattern = pattern;
335 list<Predicate> Predicates = [IsARM];
336}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000337
Jim Grosbachf6b28622009-12-14 18:31:20 +0000338// A few are not predicable
339class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000340 IndexMode im, Format f, InstrItinClass itin,
341 string opc, string asm, string cstr,
342 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000343 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
344 let OutOperandList = oops;
345 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000346 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000347 let Pattern = pattern;
348 let isPredicable = 0;
349 list<Predicate> Predicates = [IsARM];
350}
Evan Cheng37f25d92008-08-28 23:39:26 +0000351
Bill Wendling4822bce2010-08-30 01:47:35 +0000352// Same as I except it can optionally modify CPSR. Note it's modeled as an input
353// operand since by default it's a zero register. It will become an implicit def
354// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000355class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000356 IndexMode im, Format f, InstrItinClass itin,
357 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000358 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000359 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000360 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000361 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000362 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000363 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000364
Evan Cheng37f25d92008-08-28 23:39:26 +0000365 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000366 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000367 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000368 let Pattern = pattern;
369 list<Predicate> Predicates = [IsARM];
370}
371
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000372// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000373class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000374 IndexMode im, Format f, InstrItinClass itin,
375 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000376 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000377 let OutOperandList = oops;
378 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000379 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000380 let Pattern = pattern;
381 list<Predicate> Predicates = [IsARM];
382}
383
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000384class AI<dag oops, dag iops, Format f, InstrItinClass itin,
385 string opc, string asm, list<dag> pattern>
386 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
387 opc, asm, "", pattern>;
388class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
389 string opc, string asm, list<dag> pattern>
390 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
391 opc, asm, "", pattern>;
392class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000393 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000394 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000395 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000396class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000397 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000398 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000399 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000400
401// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000402class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
403 string opc, string asm, list<dag> pattern>
404 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
405 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000406 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000407}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000408class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
409 string asm, list<dag> pattern>
410 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
411 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000412 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000413}
Evan Cheng3aac7882008-09-01 08:25:56 +0000414
415// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000416class JTI<dag oops, dag iops, InstrItinClass itin,
417 string asm, list<dag> pattern>
418 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000419 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000420
Jim Grosbach5278eb82009-12-11 01:42:04 +0000421// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000422class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
423 string opc, string asm, list<dag> pattern>
424 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
425 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000426 bits<4> Rt;
427 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000428 let Inst{27-23} = 0b00011;
429 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000430 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000431 let Inst{19-16} = Rn;
432 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000433 let Inst{11-0} = 0b111110011111;
434}
435class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
436 string opc, string asm, list<dag> pattern>
437 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
438 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000439 bits<4> Rd;
440 bits<4> Rt;
441 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000442 let Inst{27-23} = 0b00011;
443 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000444 let Inst{20} = 0;
Jim Grosbach86875a22010-10-29 19:58:57 +0000445 let Inst{19-16} = Rn;
446 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000447 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000448 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000449}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000450class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
451 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
452 bits<4> Rt;
453 bits<4> Rt2;
454 bits<4> Rn;
455 let Inst{27-23} = 0b00010;
456 let Inst{22} = b;
457 let Inst{21-20} = 0b00;
458 let Inst{19-16} = Rn;
459 let Inst{15-12} = Rt;
460 let Inst{11-4} = 0b00001001;
461 let Inst{3-0} = Rt2;
462}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000463
Evan Cheng0d14fc82008-09-01 01:51:14 +0000464// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000465class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
466 string opc, string asm, list<dag> pattern>
467 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
468 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000469 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000470 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000471}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000472class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
473 string opc, string asm, list<dag> pattern>
474 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
475 opc, asm, "", pattern> {
476 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000477 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000478}
479class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000480 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000481 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000482 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000483 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000484 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000485}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000486
Evan Cheng93912732008-09-01 01:27:33 +0000487// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000488
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000489// LDR/LDRB/STR/STRB/...
490class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000491 Format f, InstrItinClass itin, string opc, string asm,
492 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000493 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
494 "", pattern> {
495 let Inst{27-25} = op;
496 let Inst{24} = 1; // 24 == P
497 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000498 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000499 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000500 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000501}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000502// Indexed load/stores
503class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000504 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000505 string asm, string cstr, list<dag> pattern>
506 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
507 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000508 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000509 let Inst{27-26} = 0b01;
510 let Inst{24} = isPre; // P bit
511 let Inst{22} = isByte; // B bit
512 let Inst{21} = isPre; // W bit
513 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000514 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000515}
Jim Grosbach953557f42010-11-19 21:35:06 +0000516class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
517 IndexMode im, Format f, InstrItinClass itin, string opc,
518 string asm, string cstr, list<dag> pattern>
519 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
520 pattern> {
521 // AM2 store w/ two operands: (GPR, am2offset)
522 // {13} 1 == Rm, 0 == imm12
523 // {12} isAdd
524 // {11-0} imm12/Rm
525 bits<14> offset;
526 bits<4> Rn;
527 let Inst{25} = offset{13};
528 let Inst{23} = offset{12};
529 let Inst{19-16} = Rn;
530 let Inst{11-0} = offset{11-0};
531}
Jim Grosbach3e556122010-10-26 22:37:02 +0000532
Evan Cheng0d14fc82008-09-01 01:51:14 +0000533// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000534class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
535 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach160f8f02010-11-18 00:46:58 +0000536 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
537 opc, asm, "", pattern> {
538 bits<14> addr;
539 bits<4> Rt;
540 let Inst{27-25} = 0b000;
541 let Inst{24} = 1; // P bit
542 let Inst{23} = addr{8}; // U bit
543 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
544 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000545 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000546 let Inst{19-16} = addr{12-9}; // Rn
547 let Inst{15-12} = Rt; // Rt
548 let Inst{11-8} = addr{7-4}; // imm7_4/zero
549 let Inst{7-4} = op;
550 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
551}
Evan Cheng840917b2008-09-01 07:00:14 +0000552
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000553class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
554 IndexMode im, Format f, InstrItinClass itin, string opc,
555 string asm, string cstr, list<dag> pattern>
556 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
557 opc, asm, cstr, pattern> {
558 bits<4> Rt;
559 let Inst{27-25} = 0b000;
560 let Inst{24} = isPre; // P bit
561 let Inst{21} = isPre; // W bit
562 let Inst{20} = op20; // L bit
563 let Inst{15-12} = Rt; // Rt
564 let Inst{7-4} = op;
565}
Jim Grosbach2dc77682010-11-29 18:37:44 +0000566class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
567 IndexMode im, Format f, InstrItinClass itin, string opc,
568 string asm, string cstr, list<dag> pattern>
569 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
570 pattern> {
571 // AM3 store w/ two operands: (GPR, am3offset)
572 bits<14> offset;
573 bits<4> Rt;
574 bits<4> Rn;
575 let Inst{27-25} = 0b000;
576 let Inst{23} = offset{8};
577 let Inst{22} = offset{9};
578 let Inst{19-16} = Rn;
579 let Inst{15-12} = Rt; // Rt
580 let Inst{11-8} = offset{7-4}; // imm7_4/zero
581 let Inst{7-4} = op;
582 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
583}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000584
Evan Cheng840917b2008-09-01 07:00:14 +0000585// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000586class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000587 string opc, string asm, list<dag> pattern>
588 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
589 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000590 bits<14> addr;
591 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000592 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000593 let Inst{24} = 1; // P bit
594 let Inst{23} = addr{8}; // U bit
595 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
596 let Inst{21} = 0; // W bit
597 let Inst{20} = 0; // L bit
598 let Inst{19-16} = addr{12-9}; // Rn
599 let Inst{15-12} = Rt; // Rt
600 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000601 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000602 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000603}
Evan Cheng840917b2008-09-01 07:00:14 +0000604
Evan Cheng840917b2008-09-01 07:00:14 +0000605// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000606class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, string cstr, list<dag> pattern>
608 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
609 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000610 let Inst{4} = 1;
611 let Inst{5} = 1; // H bit
612 let Inst{6} = 0; // S bit
613 let Inst{7} = 1;
614 let Inst{20} = 0; // L bit
615 let Inst{21} = 1; // W bit
616 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000617 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000618}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000619class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
620 string opc, string asm, string cstr, list<dag> pattern>
621 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
622 opc, asm, cstr, pattern> {
623 let Inst{4} = 1;
624 let Inst{5} = 1; // H bit
625 let Inst{6} = 1; // S bit
626 let Inst{7} = 1;
627 let Inst{20} = 0; // L bit
628 let Inst{21} = 1; // W bit
629 let Inst{24} = 1; // P bit
630 let Inst{27-25} = 0b000;
631}
Evan Cheng840917b2008-09-01 07:00:14 +0000632
Evan Cheng840917b2008-09-01 07:00:14 +0000633// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000634class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
635 string opc, string asm, string cstr, list<dag> pattern>
636 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
637 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000638 let Inst{4} = 1;
639 let Inst{5} = 1; // H bit
640 let Inst{6} = 0; // S bit
641 let Inst{7} = 1;
642 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000643 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000644 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000645 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000646}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000647class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
648 string opc, string asm, string cstr, list<dag> pattern>
649 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
650 opc, asm, cstr, pattern> {
651 let Inst{4} = 1;
652 let Inst{5} = 1; // H bit
653 let Inst{6} = 1; // S bit
654 let Inst{7} = 1;
655 let Inst{20} = 0; // L bit
656 let Inst{21} = 0; // W bit
657 let Inst{24} = 0; // P bit
658 let Inst{27-25} = 0b000;
659}
Evan Cheng840917b2008-09-01 07:00:14 +0000660
Evan Cheng0d14fc82008-09-01 01:51:14 +0000661// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000662class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
663 string asm, string cstr, list<dag> pattern>
664 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
665 bits<4> p;
666 bits<16> regs;
667 bits<4> Rn;
668 let Inst{31-28} = p;
669 let Inst{27-25} = 0b100;
670 let Inst{22} = 0; // S bit
671 let Inst{19-16} = Rn;
672 let Inst{15-0} = regs;
673}
Evan Cheng37f25d92008-08-28 23:39:26 +0000674
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000675// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000676class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
677 string opc, string asm, list<dag> pattern>
678 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
679 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000680 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000681 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000682 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000683}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000684class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
685 string opc, string asm, list<dag> pattern>
686 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
687 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000688 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000689 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000690}
691
692// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000693class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
694 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000695 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
696 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000697 bits<4> Rd;
698 bits<4> Rn;
699 bits<4> Rm;
700 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000701 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000702 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000703 let Inst{19-16} = Rd;
704 let Inst{11-8} = Rm;
705 let Inst{3-0} = Rn;
706}
707// MSW multiple w/ Ra operand
708class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
709 InstrItinClass itin, string opc, string asm, list<dag> pattern>
710 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
711 bits<4> Ra;
712 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000713}
Evan Cheng37f25d92008-08-28 23:39:26 +0000714
Evan Chengeb4f52e2008-11-06 03:35:07 +0000715// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000716class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000717 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000718 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
719 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000720 bits<4> Rn;
721 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000722 let Inst{4} = 0;
723 let Inst{7} = 1;
724 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000725 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000726 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000727 let Inst{11-8} = Rm;
728 let Inst{3-0} = Rn;
729}
730class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
731 InstrItinClass itin, string opc, string asm, list<dag> pattern>
732 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
733 bits<4> Rd;
734 let Inst{19-16} = Rd;
735}
736
737// AMulxyI with Ra operand
738class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
739 InstrItinClass itin, string opc, string asm, list<dag> pattern>
740 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
741 bits<4> Ra;
742 let Inst{15-12} = Ra;
743}
744// SMLAL*
745class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
746 InstrItinClass itin, string opc, string asm, list<dag> pattern>
747 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
748 bits<4> RdLo;
749 bits<4> RdHi;
750 let Inst{19-16} = RdHi;
751 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000752}
753
Evan Cheng97f48c32008-11-06 22:15:19 +0000754// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000755class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
756 string opc, string asm, list<dag> pattern>
757 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
758 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000759 // All AExtI instructions have Rd and Rm register operands.
760 bits<4> Rd;
761 bits<4> Rm;
762 let Inst{15-12} = Rd;
763 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000764 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000765 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000766 let Inst{27-20} = opcod;
767}
768
Evan Cheng8b59db32008-11-07 01:41:35 +0000769// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000770class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
771 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000772 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
773 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000774 bits<4> Rd;
775 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000776 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000777 let Inst{19-16} = 0b1111;
778 let Inst{15-12} = Rd;
779 let Inst{11-8} = 0b1111;
780 let Inst{7-4} = opc7_4;
781 let Inst{3-0} = Rm;
782}
783
784// PKH instructions
785class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
786 string opc, string asm, list<dag> pattern>
787 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
788 opc, asm, "", pattern> {
789 bits<4> Rd;
790 bits<4> Rn;
791 bits<4> Rm;
792 bits<8> sh;
793 let Inst{27-20} = opcod;
794 let Inst{19-16} = Rn;
795 let Inst{15-12} = Rd;
796 let Inst{11-7} = sh{7-3};
797 let Inst{6} = tb;
798 let Inst{5-4} = 0b01;
799 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000800}
801
Evan Cheng37f25d92008-08-28 23:39:26 +0000802//===----------------------------------------------------------------------===//
803
804// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
805class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
806 list<Predicate> Predicates = [IsARM];
807}
808class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
809 list<Predicate> Predicates = [IsARM, HasV5TE];
810}
811class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
812 list<Predicate> Predicates = [IsARM, HasV6];
813}
Evan Cheng13096642008-08-29 06:41:12 +0000814
815//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000816// Thumb Instruction Format Definitions.
817//
818
Evan Cheng446c4282009-07-11 06:43:01 +0000819class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000820 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000821 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000822 let OutOperandList = oops;
823 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000824 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000825 let Pattern = pattern;
826 list<Predicate> Predicates = [IsThumb];
827}
828
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000829// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000830class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
831 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000832
Evan Cheng35d6c412009-08-04 23:47:55 +0000833// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000834class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
835 list<dag> pattern>
836 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
837 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000838
Johnny Chend68e1192009-12-15 17:24:14 +0000839// tBL, tBX 32-bit instructions
840class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000841 dag oops, dag iops, InstrItinClass itin, string asm,
842 list<dag> pattern>
843 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
844 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000845 let Inst{31-27} = opcod1;
846 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000847 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000848}
Evan Cheng13096642008-08-29 06:41:12 +0000849
Bruno Cardoso Lopesfa5bd272011-01-20 16:35:57 +0000850// Move to/from coprocessor instructions
851class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
852 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
853 Encoding, Requires<[IsThumb, HasV6]> {
854 let Inst{31-28} = 0b1110;
855}
856
Evan Cheng13096642008-08-29 06:41:12 +0000857// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000858class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
859 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000860 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000861
Evan Cheng09c39fc2009-06-23 19:38:13 +0000862// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +0000863class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000864 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000865 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000866 let OutOperandList = oops;
867 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000868 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000869 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000870 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000871}
872
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000873class T1I<dag oops, dag iops, InstrItinClass itin,
874 string asm, list<dag> pattern>
875 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
876class T1Ix2<dag oops, dag iops, InstrItinClass itin,
877 string asm, list<dag> pattern>
878 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000879
880// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000881class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000882 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000883 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000884 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000885
886// Thumb1 instruction that can either be predicated or set CPSR.
887class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000888 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000889 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000890 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000891 let OutOperandList = !con(oops, (outs s_cc_out:$s));
892 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000893 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000894 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000895 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000896}
897
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000898class T1sI<dag oops, dag iops, InstrItinClass itin,
899 string opc, string asm, list<dag> pattern>
900 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000901
902// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000903class T1sIt<dag oops, dag iops, InstrItinClass itin,
904 string opc, string asm, list<dag> pattern>
905 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000906 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000907
908// Thumb1 instruction that can be predicated.
909class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000910 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000911 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000912 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000913 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000914 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000915 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000916 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000917 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000918}
919
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000920class T1pI<dag oops, dag iops, InstrItinClass itin,
921 string opc, string asm, list<dag> pattern>
922 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000923
924// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000925class T1pIt<dag oops, dag iops, InstrItinClass itin,
926 string opc, string asm, list<dag> pattern>
927 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000928 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000929
Bob Wilson01135592010-03-23 17:23:59 +0000930class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000931 InstrItinClass itin, string opc, string asm, list<dag> pattern>
932 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000933
Johnny Chenbbc71b22009-12-16 02:32:54 +0000934class Encoding16 : Encoding {
935 let Inst{31-16} = 0x0000;
936}
937
Johnny Chend68e1192009-12-15 17:24:14 +0000938// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +0000939class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000940 let Inst{15-10} = opcode;
941}
942
943// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000944class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000945 let Inst{15-14} = 0b00;
946 let Inst{13-9} = opcode;
947}
948
949// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000950class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000951 let Inst{15-10} = 0b010000;
952 let Inst{9-6} = opcode;
953}
954
955// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000956class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000957 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +0000958 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +0000959}
960
961// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000962class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000963 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000964 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +0000965}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000966class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +0000967
Bill Wendling1fd374e2010-11-30 22:57:21 +0000968// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +0000969// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +0000970//
Bill Wendling1fd374e2010-11-30 22:57:21 +0000971// 0b0110 => Immediate, 4 bytes
972// 0b1000 => Immediate, 2 bytes
973// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +0000974class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
975 InstrItinClass itin, string opc, string asm,
976 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000977 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000978 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000979 bits<3> Rt;
980 bits<8> addr;
981 let Inst{8-6} = addr{5-3}; // Rm
982 let Inst{5-3} = addr{2-0}; // Rn
983 let Inst{2-0} = Rt;
984}
Bill Wendling40062fb2010-12-01 01:38:08 +0000985class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
986 InstrItinClass itin, string opc, string asm,
987 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000988 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000989 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000990 bits<3> Rt;
991 bits<8> addr;
992 let Inst{10-6} = addr{7-3}; // imm5
993 let Inst{5-3} = addr{2-0}; // Rn
994 let Inst{2-0} = Rt;
995}
996
Johnny Chend68e1192009-12-15 17:24:14 +0000997// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000998class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000999 let Inst{15-12} = 0b1011;
1000 let Inst{11-5} = opcode;
1001}
1002
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001003// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1004class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001005 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001006 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001007 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001008 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001009 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001010 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001011 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001012 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001013}
1014
Bill Wendlingda2ae632010-08-31 07:50:46 +00001015// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1016// input operand since by default it's a zero register. It will become an
1017// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001018//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001019// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1020// more consistent.
1021class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001022 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001023 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001024 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001025 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1026 let Inst{20} = s;
1027
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001028 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001029 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001030 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001031 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001032 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001033}
1034
1035// Special cases
1036class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001037 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001038 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001039 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001040 let OutOperandList = oops;
1041 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001042 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001043 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001044 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001045}
1046
Jim Grosbachd1228742009-12-01 18:10:36 +00001047class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001048 InstrItinClass itin,
1049 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001050 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1051 let OutOperandList = oops;
1052 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001053 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001054 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001055 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001056}
1057
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001058class T2I<dag oops, dag iops, InstrItinClass itin,
1059 string opc, string asm, list<dag> pattern>
1060 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1061class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1062 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001063 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001064class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1065 string opc, string asm, list<dag> pattern>
1066 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1067class T2Iso<dag oops, dag iops, InstrItinClass itin,
1068 string opc, string asm, list<dag> pattern>
1069 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1070class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1071 string opc, string asm, list<dag> pattern>
1072 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001073class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001074 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001075 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1076 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001077 bits<4> Rt;
1078 bits<4> Rt2;
1079 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001080 let Inst{31-25} = 0b1110100;
1081 let Inst{24} = P;
1082 let Inst{23} = addr{8};
1083 let Inst{22} = 1;
1084 let Inst{21} = W;
1085 let Inst{20} = isLoad;
1086 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001087 let Inst{15-12} = Rt{3-0};
1088 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001089 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001090}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001091
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001092class T2sI<dag oops, dag iops, InstrItinClass itin,
1093 string opc, string asm, list<dag> pattern>
1094 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001095
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001096class T2XI<dag oops, dag iops, InstrItinClass itin,
1097 string asm, list<dag> pattern>
1098 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1099class T2JTI<dag oops, dag iops, InstrItinClass itin,
1100 string asm, list<dag> pattern>
1101 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001102
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001103// Move to/from coprocessor instructions
1104class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1105 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1106 let Inst{31-28} = 0b1111;
1107}
1108
Bob Wilson815baeb2010-03-13 01:08:20 +00001109// Two-address instructions
1110class T2XIt<dag oops, dag iops, InstrItinClass itin,
1111 string asm, string cstr, list<dag> pattern>
1112 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001113
Evan Chenge88d5ce2009-07-02 07:28:31 +00001114// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001115class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1116 dag oops, dag iops,
1117 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001118 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001119 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001120 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001121 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001122 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001123 let Pattern = pattern;
1124 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001125 let Inst{31-27} = 0b11111;
1126 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001127 let Inst{24} = signed;
1128 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001129 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001130 let Inst{20} = load;
1131 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001132 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001133 let Inst{10} = pre; // The P bit.
1134 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001135
Owen Anderson6af50f72010-11-30 00:14:31 +00001136 bits<9> addr;
1137 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001138 let Inst{9} = addr{8}; // Sign bit
1139
Owen Anderson6af50f72010-11-30 00:14:31 +00001140 bits<4> Rt;
1141 bits<4> Rn;
1142 let Inst{15-12} = Rt{3-0};
1143 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001144}
1145
David Goodwinc9d138f2009-07-27 19:59:26 +00001146// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1147class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001148 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001149}
1150
1151// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1152class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001153 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001154}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001155
Evan Cheng9cb9e672009-06-27 02:26:13 +00001156// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1157class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001158 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001159}
1160
Evan Cheng13096642008-08-29 06:41:12 +00001161//===----------------------------------------------------------------------===//
1162
Evan Cheng96581d32008-11-11 02:11:05 +00001163//===----------------------------------------------------------------------===//
1164// ARM VFP Instruction templates.
1165//
1166
David Goodwin3ca524e2009-07-10 17:03:29 +00001167// Almost all VFP instructions are predicable.
1168class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001169 IndexMode im, Format f, InstrItinClass itin,
1170 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001171 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001172 bits<4> p;
1173 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001174 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001175 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001176 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001177 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001178 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001179 list<Predicate> Predicates = [HasVFP2];
1180}
1181
1182// Special cases
1183class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001184 IndexMode im, Format f, InstrItinClass itin,
1185 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001186 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001187 bits<4> p;
1188 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001189 let OutOperandList = oops;
1190 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001191 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001192 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001193 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001194 list<Predicate> Predicates = [HasVFP2];
1195}
1196
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001197class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1198 string opc, string asm, list<dag> pattern>
1199 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001200 opc, asm, "", pattern> {
1201 let PostEncoderMethod = "VFPThumb2PostEncoder";
1202}
David Goodwin3ca524e2009-07-10 17:03:29 +00001203
Evan Chengcd8e66a2008-11-11 21:48:44 +00001204// ARM VFP addrmode5 loads and stores
1205class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001206 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001207 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001208 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001209 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001210 // Instruction operands.
1211 bits<5> Dd;
1212 bits<13> addr;
1213
1214 // Encode instruction operands.
1215 let Inst{23} = addr{8}; // U (add = (U == '1'))
1216 let Inst{22} = Dd{4};
1217 let Inst{19-16} = addr{12-9}; // Rn
1218 let Inst{15-12} = Dd{3-0};
1219 let Inst{7-0} = addr{7-0}; // imm8
1220
Evan Cheng96581d32008-11-11 02:11:05 +00001221 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001222 let Inst{27-24} = opcod1;
1223 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001224 let Inst{11-9} = 0b101;
1225 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001226
Evan Cheng5eda2822011-02-16 00:35:02 +00001227 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001228 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001229}
1230
Evan Chengcd8e66a2008-11-11 21:48:44 +00001231class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001232 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001233 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001234 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001235 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001236 // Instruction operands.
1237 bits<5> Sd;
1238 bits<13> addr;
1239
1240 // Encode instruction operands.
1241 let Inst{23} = addr{8}; // U (add = (U == '1'))
1242 let Inst{22} = Sd{0};
1243 let Inst{19-16} = addr{12-9}; // Rn
1244 let Inst{15-12} = Sd{4-1};
1245 let Inst{7-0} = addr{7-0}; // imm8
1246
Evan Cheng96581d32008-11-11 02:11:05 +00001247 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001248 let Inst{27-24} = opcod1;
1249 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001250 let Inst{11-9} = 0b101;
1251 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001252
1253 // Loads & stores operate on both NEON and VFP pipelines.
1254 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001255}
1256
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001257// VFP Load / store multiple pseudo instructions.
1258class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1259 list<dag> pattern>
1260 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1261 cstr, itin> {
1262 let OutOperandList = oops;
1263 let InOperandList = !con(iops, (ins pred:$p));
1264 let Pattern = pattern;
1265 list<Predicate> Predicates = [HasVFP2];
1266}
1267
Evan Chengcd8e66a2008-11-11 21:48:44 +00001268// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001269class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001270 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001271 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001272 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001273 // Instruction operands.
1274 bits<4> Rn;
1275 bits<13> regs;
1276
1277 // Encode instruction operands.
1278 let Inst{19-16} = Rn;
1279 let Inst{22} = regs{12};
1280 let Inst{15-12} = regs{11-8};
1281 let Inst{7-0} = regs{7-0};
1282
Evan Chengcd8e66a2008-11-11 21:48:44 +00001283 // TODO: Mark the instructions with the appropriate subtarget info.
1284 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001285 let Inst{11-9} = 0b101;
1286 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001287}
1288
Jim Grosbach72db1822010-09-08 00:25:50 +00001289class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001290 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001291 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001292 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001293 // Instruction operands.
1294 bits<4> Rn;
1295 bits<13> regs;
1296
1297 // Encode instruction operands.
1298 let Inst{19-16} = Rn;
1299 let Inst{22} = regs{8};
1300 let Inst{15-12} = regs{12-9};
1301 let Inst{7-0} = regs{7-0};
1302
Evan Chengcd8e66a2008-11-11 21:48:44 +00001303 // TODO: Mark the instructions with the appropriate subtarget info.
1304 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001305 let Inst{11-9} = 0b101;
1306 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001307}
1308
Evan Cheng96581d32008-11-11 02:11:05 +00001309// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001310class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1311 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1312 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001313 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001314 // Instruction operands.
1315 bits<5> Dd;
1316 bits<5> Dm;
1317
1318 // Encode instruction operands.
1319 let Inst{3-0} = Dm{3-0};
1320 let Inst{5} = Dm{4};
1321 let Inst{15-12} = Dd{3-0};
1322 let Inst{22} = Dd{4};
1323
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001324 let Inst{27-23} = opcod1;
1325 let Inst{21-20} = opcod2;
1326 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001327 let Inst{11-9} = 0b101;
1328 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001329 let Inst{7-6} = opcod4;
1330 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001331}
1332
1333// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001334class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001335 dag iops, InstrItinClass itin, string opc, string asm,
1336 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001337 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001338 // Instruction operands.
1339 bits<5> Dd;
1340 bits<5> Dn;
1341 bits<5> Dm;
1342
1343 // Encode instruction operands.
1344 let Inst{3-0} = Dm{3-0};
1345 let Inst{5} = Dm{4};
1346 let Inst{19-16} = Dn{3-0};
1347 let Inst{7} = Dn{4};
1348 let Inst{15-12} = Dd{3-0};
1349 let Inst{22} = Dd{4};
1350
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001351 let Inst{27-23} = opcod1;
1352 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001353 let Inst{11-9} = 0b101;
1354 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001355 let Inst{6} = op6;
1356 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001357}
1358
1359// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001360class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1361 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1362 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001363 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001364 // Instruction operands.
1365 bits<5> Sd;
1366 bits<5> Sm;
1367
1368 // Encode instruction operands.
1369 let Inst{3-0} = Sm{4-1};
1370 let Inst{5} = Sm{0};
1371 let Inst{15-12} = Sd{4-1};
1372 let Inst{22} = Sd{0};
1373
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001374 let Inst{27-23} = opcod1;
1375 let Inst{21-20} = opcod2;
1376 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001377 let Inst{11-9} = 0b101;
1378 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001379 let Inst{7-6} = opcod4;
1380 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001381}
1382
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001383// Single precision unary, if no NEON. Same as ASuI except not available if
1384// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001385class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1386 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1387 string asm, list<dag> pattern>
1388 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1389 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001390 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1391}
1392
Evan Cheng96581d32008-11-11 02:11:05 +00001393// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001394class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1395 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001396 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001397 // Instruction operands.
1398 bits<5> Sd;
1399 bits<5> Sn;
1400 bits<5> Sm;
1401
1402 // Encode instruction operands.
1403 let Inst{3-0} = Sm{4-1};
1404 let Inst{5} = Sm{0};
1405 let Inst{19-16} = Sn{4-1};
1406 let Inst{7} = Sn{0};
1407 let Inst{15-12} = Sd{4-1};
1408 let Inst{22} = Sd{0};
1409
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001410 let Inst{27-23} = opcod1;
1411 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001412 let Inst{11-9} = 0b101;
1413 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001414 let Inst{6} = op6;
1415 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001416}
1417
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001418// Single precision binary, if no NEON. Same as ASbI except not available if
1419// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001420class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001421 dag iops, InstrItinClass itin, string opc, string asm,
1422 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001423 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001424 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001425
1426 // Instruction operands.
1427 bits<5> Sd;
1428 bits<5> Sn;
1429 bits<5> Sm;
1430
1431 // Encode instruction operands.
1432 let Inst{3-0} = Sm{4-1};
1433 let Inst{5} = Sm{0};
1434 let Inst{19-16} = Sn{4-1};
1435 let Inst{7} = Sn{0};
1436 let Inst{15-12} = Sd{4-1};
1437 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001438}
1439
Evan Cheng80a11982008-11-12 06:41:41 +00001440// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001441class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1442 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1443 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001444 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001445 let Inst{27-23} = opcod1;
1446 let Inst{21-20} = opcod2;
1447 let Inst{19-16} = opcod3;
1448 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001449 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001450 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001451}
1452
Johnny Chen811663f2010-02-11 18:47:03 +00001453// VFP conversion between floating-point and fixed-point
1454class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001455 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1456 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001457 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1458 // size (fixed-point number): sx == 0 ? 16 : 32
1459 let Inst{7} = op5; // sx
1460}
1461
David Goodwin338268c2009-08-10 22:17:39 +00001462// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001463class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001464 dag oops, dag iops, InstrItinClass itin,
1465 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001466 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1467 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001468 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1469}
1470
Evan Cheng80a11982008-11-12 06:41:41 +00001471class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001472 InstrItinClass itin,
1473 string opc, string asm, list<dag> pattern>
1474 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001475 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001476 let Inst{11-8} = opcod2;
1477 let Inst{4} = 1;
1478}
1479
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001480class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1481 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1482 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001483
Bob Wilson01135592010-03-23 17:23:59 +00001484class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001485 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1486 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001487
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001488class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1489 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1490 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001491
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001492class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1493 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1494 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001495
Evan Cheng96581d32008-11-11 02:11:05 +00001496//===----------------------------------------------------------------------===//
1497
Bob Wilson5bafff32009-06-22 23:27:02 +00001498//===----------------------------------------------------------------------===//
1499// ARM NEON Instruction templates.
1500//
Evan Cheng13096642008-08-29 06:41:12 +00001501
Johnny Chencaa608e2010-03-20 00:17:00 +00001502class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1503 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1504 list<dag> pattern>
1505 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001506 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001507 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001508 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001509 let Pattern = pattern;
1510 list<Predicate> Predicates = [HasNEON];
1511}
1512
1513// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001514class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1515 InstrItinClass itin, string opc, string asm, string cstr,
1516 list<dag> pattern>
1517 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001518 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001519 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001520 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001521 let Pattern = pattern;
1522 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001523}
1524
Bob Wilsonb07c1712009-10-07 21:53:04 +00001525class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1526 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001527 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001528 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1529 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001530 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001531 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001532 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001533 let Inst{11-8} = op11_8;
1534 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001535
Chris Lattner2ac19022010-11-15 05:19:05 +00001536 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001537
Owen Andersond9aa7d32010-11-02 00:05:05 +00001538 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001539 bits<6> Rn;
1540 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001541
Owen Andersond9aa7d32010-11-02 00:05:05 +00001542 let Inst{22} = Vd{4};
1543 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001544 let Inst{19-16} = Rn{3-0};
1545 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001546}
1547
Owen Andersond138d702010-11-02 20:47:39 +00001548class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1549 dag oops, dag iops, InstrItinClass itin,
1550 string opc, string dt, string asm, string cstr, list<dag> pattern>
1551 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1552 dt, asm, cstr, pattern> {
1553 bits<3> lane;
1554}
1555
Bob Wilson709d5922010-08-25 23:27:42 +00001556class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1557 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1558 itin> {
1559 let OutOperandList = oops;
1560 let InOperandList = !con(iops, (ins pred:$p));
1561 list<Predicate> Predicates = [HasNEON];
1562}
1563
Jim Grosbach7cd27292010-10-06 20:36:55 +00001564class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1565 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001566 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1567 itin> {
1568 let OutOperandList = oops;
1569 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001570 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001571 list<Predicate> Predicates = [HasNEON];
1572}
1573
Johnny Chen785516a2010-03-23 16:43:47 +00001574class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001575 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001576 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1577 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001578 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001579 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001580}
1581
Johnny Chen927b88f2010-03-23 20:40:44 +00001582class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001583 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001584 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001585 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001586 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001587 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001588}
1589
1590// NEON "one register and a modified immediate" format.
1591class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1592 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001593 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001594 string opc, string dt, string asm, string cstr,
1595 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001596 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001597 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001598 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001599 let Inst{11-8} = op11_8;
1600 let Inst{7} = op7;
1601 let Inst{6} = op6;
1602 let Inst{5} = op5;
1603 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001604
Owen Andersona88ea032010-10-26 17:40:54 +00001605 // Instruction operands.
1606 bits<5> Vd;
1607 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001608
Owen Andersona88ea032010-10-26 17:40:54 +00001609 let Inst{15-12} = Vd{3-0};
1610 let Inst{22} = Vd{4};
1611 let Inst{24} = SIMM{7};
1612 let Inst{18-16} = SIMM{6-4};
1613 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001614}
1615
1616// NEON 2 vector register format.
1617class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1618 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001619 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001620 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001621 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +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};
Evan Chengf81bf152009-11-23 21:57:23 +00001638}
1639
1640// Same as N2V except it doesn't have a datatype suffix.
1641class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001642 bits<5> op11_7, bit op6, bit op4,
1643 dag oops, dag iops, InstrItinClass itin,
1644 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001645 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001646 let Inst{24-23} = op24_23;
1647 let Inst{21-20} = op21_20;
1648 let Inst{19-18} = op19_18;
1649 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001650 let Inst{11-7} = op11_7;
1651 let Inst{6} = op6;
1652 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001653
Owen Anderson162875a2010-10-25 18:43:52 +00001654 // Instruction operands.
1655 bits<5> Vd;
1656 bits<5> Vm;
1657
1658 let Inst{15-12} = Vd{3-0};
1659 let Inst{22} = Vd{4};
1660 let Inst{3-0} = Vm{3-0};
1661 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001662}
1663
1664// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001665class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001666 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001667 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +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;
Bob Wilson5bafff32009-06-22 23:27:02 +00001671 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001672 let Inst{7} = op7;
1673 let Inst{6} = op6;
1674 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001675
Owen Anderson3557d002010-10-26 20:56:57 +00001676 // Instruction operands.
1677 bits<5> Vd;
1678 bits<5> Vm;
1679 bits<6> SIMM;
1680
1681 let Inst{15-12} = Vd{3-0};
1682 let Inst{22} = Vd{4};
1683 let Inst{3-0} = Vm{3-0};
1684 let Inst{5} = Vm{4};
1685 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001686}
1687
Bob Wilson10bc69c2010-03-27 03:56:52 +00001688// NEON 3 vector register format.
1689class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1690 dag oops, dag iops, Format f, InstrItinClass itin,
1691 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001692 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001693 let Inst{24} = op24;
1694 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001695 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001696 let Inst{11-8} = op11_8;
1697 let Inst{6} = op6;
1698 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001699
Owen Andersond451f882010-10-21 20:21:49 +00001700 // Instruction operands.
1701 bits<5> Vd;
1702 bits<5> Vn;
1703 bits<5> Vm;
1704
1705 let Inst{15-12} = Vd{3-0};
1706 let Inst{22} = Vd{4};
1707 let Inst{19-16} = Vn{3-0};
1708 let Inst{7} = Vn{4};
1709 let Inst{3-0} = Vm{3-0};
1710 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001711}
1712
Johnny Chen841e8282010-03-23 21:35:03 +00001713// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001714class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1715 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001716 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001717 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001718 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001719 let Inst{24} = op24;
1720 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001721 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001722 let Inst{11-8} = op11_8;
1723 let Inst{6} = op6;
1724 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001725
Owen Anderson8c71eff2010-10-25 18:28:30 +00001726 // Instruction operands.
1727 bits<5> Vd;
1728 bits<5> Vn;
1729 bits<5> Vm;
1730
1731 let Inst{15-12} = Vd{3-0};
1732 let Inst{22} = Vd{4};
1733 let Inst{19-16} = Vn{3-0};
1734 let Inst{7} = Vn{4};
1735 let Inst{3-0} = Vm{3-0};
1736 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001737}
1738
1739// NEON VMOVs between scalar and core registers.
1740class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001741 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001742 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001743 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001744 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001745 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001746 let Inst{11-8} = opcod2;
1747 let Inst{6-5} = opcod3;
1748 let Inst{4} = 1;
Evan Chengf81bf152009-11-23 21:57:23 +00001749
1750 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001751 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001752 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001753 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001754 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001755
Chris Lattner2ac19022010-11-15 05:19:05 +00001756 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001757
Owen Andersond2fbdb72010-10-27 21:28:09 +00001758 bits<5> V;
1759 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001760 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001761 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001762
Owen Andersonf587a9352010-10-27 19:25:54 +00001763 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001764 let Inst{7} = V{4};
1765 let Inst{19-16} = V{3-0};
1766 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001767}
1768class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001769 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001770 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001771 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001772 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001773class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001774 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001775 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001776 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001777 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001778class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001779 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001780 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001781 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001782 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001783
Johnny Chene4614f72010-03-25 17:01:27 +00001784// Vector Duplicate Lane (from scalar to all elements)
1785class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1786 InstrItinClass itin, string opc, string dt, string asm,
1787 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001788 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001789 let Inst{24-23} = 0b11;
1790 let Inst{21-20} = 0b11;
1791 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001792 let Inst{11-7} = 0b11000;
1793 let Inst{6} = op6;
1794 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001795
Owen Andersonf587a9352010-10-27 19:25:54 +00001796 bits<5> Vd;
1797 bits<5> Vm;
1798 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001799
Owen Andersonf587a9352010-10-27 19:25:54 +00001800 let Inst{22} = Vd{4};
1801 let Inst{15-12} = Vd{3-0};
1802 let Inst{5} = Vm{4};
1803 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001804}
1805
David Goodwin42a83f22009-08-04 17:53:06 +00001806// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1807// for single-precision FP.
1808class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1809 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1810}