blob: e73ba6893f391783a8a6867e841b80e978f416fd [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
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000209def msr_mask : Operand<i32> {
210 let PrintMethod = "printMSRMaskOperand";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000211 let ParserMatchClass = MSRMaskOperand;
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000212}
213
Bill Wendling3116dce2011-03-07 23:38:41 +0000214// Shift Right Immediate - A shift right immediate is encoded differently from
215// other shift immediates. The imm6 field is encoded like so:
Bill Wendlinga656b632011-03-01 01:00:59 +0000216//
Bill Wendling3116dce2011-03-07 23:38:41 +0000217// Offset Encoding
218// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
219// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
220// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
221// 64 64 - <imm> is encoded in imm6<5:0>
222def shr_imm8 : Operand<i32> {
223 let EncoderMethod = "getShiftRight8Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000224}
Bill Wendling3116dce2011-03-07 23:38:41 +0000225def shr_imm16 : Operand<i32> {
226 let EncoderMethod = "getShiftRight16Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000227}
Bill Wendling3116dce2011-03-07 23:38:41 +0000228def shr_imm32 : Operand<i32> {
229 let EncoderMethod = "getShiftRight32Imm";
230}
231def shr_imm64 : Operand<i32> {
232 let EncoderMethod = "getShiftRight64Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000233}
234
Evan Cheng446c4282009-07-11 06:43:01 +0000235//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000236// ARM Instruction templates.
237//
238
Johnny Chend68e1192009-12-15 17:24:14 +0000239class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
240 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000241 : Instruction {
242 let Namespace = "ARM";
243
Evan Cheng37f25d92008-08-28 23:39:26 +0000244 AddrMode AM = am;
Evan Cheng37f25d92008-08-28 23:39:26 +0000245 SizeFlagVal SZ = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000246 IndexMode IM = im;
247 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000248 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000249 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000250 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000251 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000252 bit canXformTo16Bit = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +0000253
Chris Lattner150d20e2010-10-31 19:22:57 +0000254 // If this is a pseudo instruction, mark it isCodeGenOnly.
255 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson01135592010-03-23 17:23:59 +0000256
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000257 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000258 let TSFlags{4-0} = AM.Value;
259 let TSFlags{7-5} = SZ.Value;
260 let TSFlags{9-8} = IndexModeBits;
261 let TSFlags{15-10} = Form;
262 let TSFlags{16} = isUnaryDataProc;
263 let TSFlags{17} = canXformTo16Bit;
Evan Cheng6557bce2011-02-22 19:53:14 +0000264 let TSFlags{20-18} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000265
Evan Cheng37f25d92008-08-28 23:39:26 +0000266 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000267 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000268}
269
Johnny Chend68e1192009-12-15 17:24:14 +0000270class Encoding {
271 field bits<32> Inst;
272}
273
274class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
275 Format f, Domain d, string cstr, InstrItinClass itin>
276 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
277
278// This Encoding-less class is used by Thumb1 to specify the encoding bits later
279// on by adding flavors to specific instructions.
280class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
281 Format f, Domain d, string cstr, InstrItinClass itin>
282 : InstTemplate<am, sz, im, f, d, cstr, itin>;
283
Jim Grosbach99594eb2010-11-18 01:38:26 +0000284class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Jim Grosbachc6961f12010-11-18 01:20:48 +0000285 // FIXME: This really should derive from InstTemplate instead, as pseudos
286 // don't need encoding information. TableGen doesn't like that
287 // currently. Need to figure out why and fix it.
Bob Wilson01135592010-03-23 17:23:59 +0000288 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000289 "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000290 let OutOperandList = oops;
291 let InOperandList = iops;
Evan Cheng37f25d92008-08-28 23:39:26 +0000292 let Pattern = pattern;
Jim Grosbacha768c3d2011-03-10 19:06:39 +0000293 let isCodeGenOnly = 1;
Evan Cheng37f25d92008-08-28 23:39:26 +0000294}
295
Jim Grosbach53694262010-11-18 01:15:56 +0000296// PseudoInst that's ARM-mode only.
Jim Grosbach6e422112010-11-29 23:48:41 +0000297class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
Jim Grosbach99594eb2010-11-18 01:38:26 +0000298 list<dag> pattern>
299 : PseudoInst<oops, iops, itin, pattern> {
Jim Grosbach6e422112010-11-29 23:48:41 +0000300 let SZ = sz;
Jim Grosbach53694262010-11-18 01:15:56 +0000301 list<Predicate> Predicates = [IsARM];
302}
303
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000304// PseudoInst that's Thumb-mode only.
305class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
306 list<dag> pattern>
307 : PseudoInst<oops, iops, itin, pattern> {
308 let SZ = sz;
309 list<Predicate> Predicates = [IsThumb];
310}
Jim Grosbach53694262010-11-18 01:15:56 +0000311
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000312// PseudoInst that's Thumb2-mode only.
313class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
314 list<dag> pattern>
315 : PseudoInst<oops, iops, itin, pattern> {
316 let SZ = sz;
317 list<Predicate> Predicates = [IsThumb2];
318}
Evan Cheng37f25d92008-08-28 23:39:26 +0000319// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000320class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000321 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000322 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000323 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000324 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000325 bits<4> p;
326 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000327 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000328 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000329 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000330 let Pattern = pattern;
331 list<Predicate> Predicates = [IsARM];
332}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000333
Jim Grosbachf6b28622009-12-14 18:31:20 +0000334// A few are not predicable
335class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000336 IndexMode im, Format f, InstrItinClass itin,
337 string opc, string asm, string cstr,
338 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000339 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
340 let OutOperandList = oops;
341 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000342 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000343 let Pattern = pattern;
344 let isPredicable = 0;
345 list<Predicate> Predicates = [IsARM];
346}
Evan Cheng37f25d92008-08-28 23:39:26 +0000347
Bill Wendling4822bce2010-08-30 01:47:35 +0000348// Same as I except it can optionally modify CPSR. Note it's modeled as an input
349// operand since by default it's a zero register. It will become an implicit def
350// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000351class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000352 IndexMode im, Format f, InstrItinClass itin,
353 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000354 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000355 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000356 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000357 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000358 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000359 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000360
Evan Cheng37f25d92008-08-28 23:39:26 +0000361 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000362 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000363 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000364 let Pattern = pattern;
365 list<Predicate> Predicates = [IsARM];
366}
367
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000368// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000369class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000370 IndexMode im, Format f, InstrItinClass itin,
371 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000372 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000373 let OutOperandList = oops;
374 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000375 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000376 let Pattern = pattern;
377 list<Predicate> Predicates = [IsARM];
378}
379
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000380class AI<dag oops, dag iops, Format f, InstrItinClass itin,
381 string opc, string asm, list<dag> pattern>
382 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
383 opc, asm, "", pattern>;
384class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
385 string opc, string asm, list<dag> pattern>
386 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
387 opc, asm, "", pattern>;
388class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000389 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000390 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000391 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000392class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000393 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000394 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000395 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000396
397// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000398class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
399 string opc, string asm, list<dag> pattern>
400 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
401 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000402 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000403}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000404class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
405 string asm, list<dag> pattern>
406 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
407 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000408 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000409}
Evan Cheng3aac7882008-09-01 08:25:56 +0000410
411// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000412class JTI<dag oops, dag iops, InstrItinClass itin,
413 string asm, list<dag> pattern>
414 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000415 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000416
Jim Grosbach5278eb82009-12-11 01:42:04 +0000417// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000418class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
419 string opc, string asm, list<dag> pattern>
420 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
421 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000422 bits<4> Rt;
423 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000424 let Inst{27-23} = 0b00011;
425 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000426 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000427 let Inst{19-16} = Rn;
428 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000429 let Inst{11-0} = 0b111110011111;
430}
431class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
432 string opc, string asm, list<dag> pattern>
433 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
434 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000435 bits<4> Rd;
436 bits<4> Rt;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000437 bits<4> addr;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000438 let Inst{27-23} = 0b00011;
439 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000440 let Inst{20} = 0;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000441 let Inst{19-16} = addr;
Jim Grosbach86875a22010-10-29 19:58:57 +0000442 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000443 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000444 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000445}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000446class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
447 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
448 bits<4> Rt;
449 bits<4> Rt2;
450 bits<4> Rn;
451 let Inst{27-23} = 0b00010;
452 let Inst{22} = b;
453 let Inst{21-20} = 0b00;
454 let Inst{19-16} = Rn;
455 let Inst{15-12} = Rt;
456 let Inst{11-4} = 0b00001001;
457 let Inst{3-0} = Rt2;
458}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000459
Evan Cheng0d14fc82008-09-01 01:51:14 +0000460// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000461class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
462 string opc, string asm, list<dag> pattern>
463 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
464 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000465 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000466 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000467}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000468class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
469 string opc, string asm, list<dag> pattern>
470 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
471 opc, asm, "", pattern> {
472 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000473 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000474}
475class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000476 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000477 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000478 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000479 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000480 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000481}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000482
Evan Cheng93912732008-09-01 01:27:33 +0000483// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000484
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000485// LDR/LDRB/STR/STRB/...
486class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000487 Format f, InstrItinClass itin, string opc, string asm,
488 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000489 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
490 "", pattern> {
491 let Inst{27-25} = op;
492 let Inst{24} = 1; // 24 == P
493 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000494 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000495 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000496 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000497}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000498// Indexed load/stores
499class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000500 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000501 string asm, string cstr, list<dag> pattern>
502 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
503 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000504 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000505 let Inst{27-26} = 0b01;
506 let Inst{24} = isPre; // P bit
507 let Inst{22} = isByte; // B bit
508 let Inst{21} = isPre; // W bit
509 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000510 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000511}
Jim Grosbach953557f42010-11-19 21:35:06 +0000512class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
513 IndexMode im, Format f, InstrItinClass itin, string opc,
514 string asm, string cstr, list<dag> pattern>
515 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
516 pattern> {
517 // AM2 store w/ two operands: (GPR, am2offset)
518 // {13} 1 == Rm, 0 == imm12
519 // {12} isAdd
520 // {11-0} imm12/Rm
Bruno Cardoso Lopesb41aaab2011-03-31 15:54:36 +0000521 bits<14> offset;
522 bits<4> Rn;
523 let Inst{25} = offset{13};
524 let Inst{23} = offset{12};
525 let Inst{19-16} = Rn;
526 let Inst{11-0} = offset{11-0};
Jim Grosbach953557f42010-11-19 21:35:06 +0000527}
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000528// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
529// but for now use this class for STRT and STRBT.
530class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
531 IndexMode im, Format f, InstrItinClass itin, string opc,
532 string asm, string cstr, list<dag> pattern>
533 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
534 pattern> {
535 // AM2 store w/ two operands: (GPR, am2offset)
536 // {17-14} Rn
537 // {13} 1 == Rm, 0 == imm12
538 // {12} isAdd
539 // {11-0} imm12/Rm
540 bits<18> addr;
541 let Inst{25} = addr{13};
542 let Inst{23} = addr{12};
543 let Inst{19-16} = addr{17-14};
544 let Inst{11-0} = addr{11-0};
545}
Jim Grosbach3e556122010-10-26 22:37:02 +0000546
Evan Cheng0d14fc82008-09-01 01:51:14 +0000547// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000548class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
549 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach160f8f02010-11-18 00:46:58 +0000550 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
551 opc, asm, "", pattern> {
552 bits<14> addr;
553 bits<4> Rt;
554 let Inst{27-25} = 0b000;
555 let Inst{24} = 1; // P bit
556 let Inst{23} = addr{8}; // U bit
557 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
558 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000559 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000560 let Inst{19-16} = addr{12-9}; // Rn
561 let Inst{15-12} = Rt; // Rt
562 let Inst{11-8} = addr{7-4}; // imm7_4/zero
563 let Inst{7-4} = op;
564 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
565}
Evan Cheng840917b2008-09-01 07:00:14 +0000566
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000567class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
568 IndexMode im, Format f, InstrItinClass itin, string opc,
569 string asm, string cstr, list<dag> pattern>
570 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
571 opc, asm, cstr, pattern> {
572 bits<4> Rt;
573 let Inst{27-25} = 0b000;
574 let Inst{24} = isPre; // P bit
575 let Inst{21} = isPre; // W bit
576 let Inst{20} = op20; // L bit
577 let Inst{15-12} = Rt; // Rt
578 let Inst{7-4} = op;
579}
Jim Grosbach2dc77682010-11-29 18:37:44 +0000580class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
581 IndexMode im, Format f, InstrItinClass itin, string opc,
582 string asm, string cstr, list<dag> pattern>
583 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
584 pattern> {
585 // AM3 store w/ two operands: (GPR, am3offset)
586 bits<14> offset;
587 bits<4> Rt;
588 bits<4> Rn;
589 let Inst{27-25} = 0b000;
590 let Inst{23} = offset{8};
591 let Inst{22} = offset{9};
592 let Inst{19-16} = Rn;
593 let Inst{15-12} = Rt; // Rt
594 let Inst{11-8} = offset{7-4}; // imm7_4/zero
595 let Inst{7-4} = op;
596 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
597}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000598
Evan Cheng840917b2008-09-01 07:00:14 +0000599// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000600class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000601 string opc, string asm, list<dag> pattern>
602 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
603 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000604 bits<14> addr;
605 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000606 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000607 let Inst{24} = 1; // P bit
608 let Inst{23} = addr{8}; // U bit
609 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
610 let Inst{21} = 0; // W bit
611 let Inst{20} = 0; // L bit
612 let Inst{19-16} = addr{12-9}; // Rn
613 let Inst{15-12} = Rt; // Rt
614 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000615 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000616 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000617}
Evan Cheng840917b2008-09-01 07:00:14 +0000618
Evan Cheng840917b2008-09-01 07:00:14 +0000619// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000620class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
621 string opc, string asm, string cstr, list<dag> pattern>
622 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
623 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000624 let Inst{4} = 1;
625 let Inst{5} = 1; // H bit
626 let Inst{6} = 0; // S bit
627 let Inst{7} = 1;
628 let Inst{20} = 0; // L bit
629 let Inst{21} = 1; // W bit
630 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000631 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000632}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000633class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
634 string opc, string asm, string cstr, list<dag> pattern>
635 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
636 opc, asm, cstr, pattern> {
637 let Inst{4} = 1;
638 let Inst{5} = 1; // H bit
639 let Inst{6} = 1; // S bit
640 let Inst{7} = 1;
641 let Inst{20} = 0; // L bit
642 let Inst{21} = 1; // W bit
643 let Inst{24} = 1; // P bit
644 let Inst{27-25} = 0b000;
645}
Evan Cheng840917b2008-09-01 07:00:14 +0000646
Evan Cheng840917b2008-09-01 07:00:14 +0000647// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000648class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
649 string opc, string asm, string cstr, list<dag> pattern>
650 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
651 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000652 let Inst{4} = 1;
653 let Inst{5} = 1; // H bit
654 let Inst{6} = 0; // S bit
655 let Inst{7} = 1;
656 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000657 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000658 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000659 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000660}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000661class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
662 string opc, string asm, string cstr, list<dag> pattern>
663 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
664 opc, asm, cstr, pattern> {
665 let Inst{4} = 1;
666 let Inst{5} = 1; // H bit
667 let Inst{6} = 1; // S bit
668 let Inst{7} = 1;
669 let Inst{20} = 0; // L bit
670 let Inst{21} = 0; // W bit
671 let Inst{24} = 0; // P bit
672 let Inst{27-25} = 0b000;
673}
Evan Cheng840917b2008-09-01 07:00:14 +0000674
Evan Cheng0d14fc82008-09-01 01:51:14 +0000675// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000676class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
677 string asm, string cstr, list<dag> pattern>
678 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
679 bits<4> p;
680 bits<16> regs;
681 bits<4> Rn;
682 let Inst{31-28} = p;
683 let Inst{27-25} = 0b100;
684 let Inst{22} = 0; // S bit
685 let Inst{19-16} = Rn;
686 let Inst{15-0} = regs;
687}
Evan Cheng37f25d92008-08-28 23:39:26 +0000688
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000689// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000690class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
691 string opc, string asm, list<dag> pattern>
692 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
693 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000694 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000695 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000696 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000697}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000698class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
699 string opc, string asm, list<dag> pattern>
700 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
701 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000702 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000703 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000704}
705
706// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000707class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
708 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000709 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
710 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000711 bits<4> Rd;
712 bits<4> Rn;
713 bits<4> Rm;
714 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000715 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000716 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000717 let Inst{19-16} = Rd;
718 let Inst{11-8} = Rm;
719 let Inst{3-0} = Rn;
720}
721// MSW multiple w/ Ra operand
722class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
723 InstrItinClass itin, string opc, string asm, list<dag> pattern>
724 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
725 bits<4> Ra;
726 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000727}
Evan Cheng37f25d92008-08-28 23:39:26 +0000728
Evan Chengeb4f52e2008-11-06 03:35:07 +0000729// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000730class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000731 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000732 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
733 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000734 bits<4> Rn;
735 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000736 let Inst{4} = 0;
737 let Inst{7} = 1;
738 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000739 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000740 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000741 let Inst{11-8} = Rm;
742 let Inst{3-0} = Rn;
743}
744class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
745 InstrItinClass itin, string opc, string asm, list<dag> pattern>
746 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
747 bits<4> Rd;
748 let Inst{19-16} = Rd;
749}
750
751// AMulxyI with Ra operand
752class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
753 InstrItinClass itin, string opc, string asm, list<dag> pattern>
754 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
755 bits<4> Ra;
756 let Inst{15-12} = Ra;
757}
758// SMLAL*
759class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
760 InstrItinClass itin, string opc, string asm, list<dag> pattern>
761 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
762 bits<4> RdLo;
763 bits<4> RdHi;
764 let Inst{19-16} = RdHi;
765 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000766}
767
Evan Cheng97f48c32008-11-06 22:15:19 +0000768// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000769class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
770 string opc, string asm, list<dag> pattern>
771 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
772 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000773 // All AExtI instructions have Rd and Rm register operands.
774 bits<4> Rd;
775 bits<4> Rm;
776 let Inst{15-12} = Rd;
777 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000778 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000779 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000780 let Inst{27-20} = opcod;
781}
782
Evan Cheng8b59db32008-11-07 01:41:35 +0000783// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000784class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
785 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000786 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
787 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000788 bits<4> Rd;
789 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000790 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000791 let Inst{19-16} = 0b1111;
792 let Inst{15-12} = Rd;
793 let Inst{11-8} = 0b1111;
794 let Inst{7-4} = opc7_4;
795 let Inst{3-0} = Rm;
796}
797
798// PKH instructions
799class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
800 string opc, string asm, list<dag> pattern>
801 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
802 opc, asm, "", pattern> {
803 bits<4> Rd;
804 bits<4> Rn;
805 bits<4> Rm;
806 bits<8> sh;
807 let Inst{27-20} = opcod;
808 let Inst{19-16} = Rn;
809 let Inst{15-12} = Rd;
810 let Inst{11-7} = sh{7-3};
811 let Inst{6} = tb;
812 let Inst{5-4} = 0b01;
813 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000814}
815
Evan Cheng37f25d92008-08-28 23:39:26 +0000816//===----------------------------------------------------------------------===//
817
818// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
819class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
820 list<Predicate> Predicates = [IsARM];
821}
822class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
823 list<Predicate> Predicates = [IsARM, HasV5TE];
824}
825class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
826 list<Predicate> Predicates = [IsARM, HasV6];
827}
Evan Cheng13096642008-08-29 06:41:12 +0000828
829//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000830// Thumb Instruction Format Definitions.
831//
832
Evan Cheng446c4282009-07-11 06:43:01 +0000833class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000834 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000835 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000836 let OutOperandList = oops;
837 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000838 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000839 let Pattern = pattern;
840 list<Predicate> Predicates = [IsThumb];
841}
842
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000843// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000844class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
845 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000846
Evan Cheng35d6c412009-08-04 23:47:55 +0000847// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000848class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
849 list<dag> pattern>
850 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
851 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000852
Johnny Chend68e1192009-12-15 17:24:14 +0000853// tBL, tBX 32-bit instructions
854class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000855 dag oops, dag iops, InstrItinClass itin, string asm,
856 list<dag> pattern>
857 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
858 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000859 let Inst{31-27} = opcod1;
860 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000861 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000862}
Evan Cheng13096642008-08-29 06:41:12 +0000863
Bruno Cardoso Lopesfa5bd272011-01-20 16:35:57 +0000864// Move to/from coprocessor instructions
865class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
866 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
867 Encoding, Requires<[IsThumb, HasV6]> {
868 let Inst{31-28} = 0b1110;
869}
870
Evan Cheng13096642008-08-29 06:41:12 +0000871// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000872class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
873 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000874 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000875
Evan Cheng09c39fc2009-06-23 19:38:13 +0000876// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +0000877class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000878 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000879 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000880 let OutOperandList = oops;
881 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000882 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000883 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000884 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000885}
886
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000887class T1I<dag oops, dag iops, InstrItinClass itin,
888 string asm, list<dag> pattern>
889 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
890class T1Ix2<dag oops, dag iops, InstrItinClass itin,
891 string asm, list<dag> pattern>
892 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000893
894// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000895class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000896 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000897 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000898 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000899
900// Thumb1 instruction that can either be predicated or set CPSR.
901class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000902 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000903 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000904 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000905 let OutOperandList = !con(oops, (outs s_cc_out:$s));
906 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000907 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000908 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000909 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000910}
911
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000912class T1sI<dag oops, dag iops, InstrItinClass itin,
913 string opc, string asm, list<dag> pattern>
914 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000915
916// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000917class T1sIt<dag oops, dag iops, InstrItinClass itin,
918 string opc, string asm, list<dag> pattern>
919 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000920 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000921
922// Thumb1 instruction that can be predicated.
923class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000924 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000925 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000926 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000927 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000928 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000929 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000930 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000931 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000932}
933
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000934class T1pI<dag oops, dag iops, InstrItinClass itin,
935 string opc, string asm, list<dag> pattern>
936 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000937
938// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000939class T1pIt<dag oops, dag iops, InstrItinClass itin,
940 string opc, string asm, list<dag> pattern>
941 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000942 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000943
Bob Wilson01135592010-03-23 17:23:59 +0000944class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000945 InstrItinClass itin, string opc, string asm, list<dag> pattern>
946 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000947
Johnny Chenbbc71b22009-12-16 02:32:54 +0000948class Encoding16 : Encoding {
949 let Inst{31-16} = 0x0000;
950}
951
Johnny Chend68e1192009-12-15 17:24:14 +0000952// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +0000953class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000954 let Inst{15-10} = opcode;
955}
956
957// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000958class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000959 let Inst{15-14} = 0b00;
960 let Inst{13-9} = opcode;
961}
962
963// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000964class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000965 let Inst{15-10} = 0b010000;
966 let Inst{9-6} = opcode;
967}
968
969// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000970class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000971 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +0000972 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +0000973}
974
975// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000976class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000977 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000978 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +0000979}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000980class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +0000981
Bill Wendling1fd374e2010-11-30 22:57:21 +0000982// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +0000983// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +0000984//
Bill Wendling1fd374e2010-11-30 22:57:21 +0000985// 0b0110 => Immediate, 4 bytes
986// 0b1000 => Immediate, 2 bytes
987// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +0000988class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
989 InstrItinClass itin, string opc, string asm,
990 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000991 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000992 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000993 bits<3> Rt;
994 bits<8> addr;
995 let Inst{8-6} = addr{5-3}; // Rm
996 let Inst{5-3} = addr{2-0}; // Rn
997 let Inst{2-0} = Rt;
998}
Bill Wendling40062fb2010-12-01 01:38:08 +0000999class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1000 InstrItinClass itin, string opc, string asm,
1001 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +00001002 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001003 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001004 bits<3> Rt;
1005 bits<8> addr;
1006 let Inst{10-6} = addr{7-3}; // imm5
1007 let Inst{5-3} = addr{2-0}; // Rn
1008 let Inst{2-0} = Rt;
1009}
1010
Johnny Chend68e1192009-12-15 17:24:14 +00001011// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001012class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001013 let Inst{15-12} = 0b1011;
1014 let Inst{11-5} = opcode;
1015}
1016
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001017// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1018class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001019 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001020 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001021 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001022 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001023 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001024 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001025 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001026 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001027}
1028
Bill Wendlingda2ae632010-08-31 07:50:46 +00001029// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1030// input operand since by default it's a zero register. It will become an
1031// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001032//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001033// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1034// more consistent.
1035class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001036 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001037 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001038 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001039 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1040 let Inst{20} = s;
1041
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001042 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001043 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001044 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001045 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001046 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001047}
1048
1049// Special cases
1050class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001051 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001052 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001053 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001054 let OutOperandList = oops;
1055 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001056 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001057 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001058 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001059}
1060
Jim Grosbachd1228742009-12-01 18:10:36 +00001061class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001062 InstrItinClass itin,
1063 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001064 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1065 let OutOperandList = oops;
1066 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001067 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001068 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001069 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001070}
1071
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001072class T2I<dag oops, dag iops, InstrItinClass itin,
1073 string opc, string asm, list<dag> pattern>
1074 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1075class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1076 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001077 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001078class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1079 string opc, string asm, list<dag> pattern>
1080 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1081class T2Iso<dag oops, dag iops, InstrItinClass itin,
1082 string opc, string asm, list<dag> pattern>
1083 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1084class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1085 string opc, string asm, list<dag> pattern>
1086 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001087class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001088 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001089 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1090 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001091 bits<4> Rt;
1092 bits<4> Rt2;
1093 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001094 let Inst{31-25} = 0b1110100;
1095 let Inst{24} = P;
1096 let Inst{23} = addr{8};
1097 let Inst{22} = 1;
1098 let Inst{21} = W;
1099 let Inst{20} = isLoad;
1100 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001101 let Inst{15-12} = Rt{3-0};
1102 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001103 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001104}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001105
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001106class T2sI<dag oops, dag iops, InstrItinClass itin,
1107 string opc, string asm, list<dag> pattern>
1108 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001109
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001110class T2XI<dag oops, dag iops, InstrItinClass itin,
1111 string asm, list<dag> pattern>
1112 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1113class T2JTI<dag oops, dag iops, InstrItinClass itin,
1114 string asm, list<dag> pattern>
1115 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001116
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001117// Move to/from coprocessor instructions
1118class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1119 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1120 let Inst{31-28} = 0b1111;
1121}
1122
Bob Wilson815baeb2010-03-13 01:08:20 +00001123// Two-address instructions
1124class T2XIt<dag oops, dag iops, InstrItinClass itin,
1125 string asm, string cstr, list<dag> pattern>
1126 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001127
Evan Chenge88d5ce2009-07-02 07:28:31 +00001128// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001129class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1130 dag oops, dag iops,
1131 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001132 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001133 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001134 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001135 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001136 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001137 let Pattern = pattern;
1138 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001139 let Inst{31-27} = 0b11111;
1140 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001141 let Inst{24} = signed;
1142 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001143 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001144 let Inst{20} = load;
1145 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001146 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001147 let Inst{10} = pre; // The P bit.
1148 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001149
Owen Anderson6af50f72010-11-30 00:14:31 +00001150 bits<9> addr;
1151 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001152 let Inst{9} = addr{8}; // Sign bit
1153
Owen Anderson6af50f72010-11-30 00:14:31 +00001154 bits<4> Rt;
1155 bits<4> Rn;
1156 let Inst{15-12} = Rt{3-0};
1157 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001158}
1159
David Goodwinc9d138f2009-07-27 19:59:26 +00001160// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1161class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001162 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001163}
1164
1165// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1166class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001167 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001168}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001169
Evan Cheng9cb9e672009-06-27 02:26:13 +00001170// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1171class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001172 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001173}
1174
Evan Cheng13096642008-08-29 06:41:12 +00001175//===----------------------------------------------------------------------===//
1176
Evan Cheng96581d32008-11-11 02:11:05 +00001177//===----------------------------------------------------------------------===//
1178// ARM VFP Instruction templates.
1179//
1180
David Goodwin3ca524e2009-07-10 17:03:29 +00001181// Almost all VFP instructions are predicable.
1182class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001183 IndexMode im, Format f, InstrItinClass itin,
1184 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001185 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001186 bits<4> p;
1187 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001188 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001189 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001190 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001191 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001192 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001193 list<Predicate> Predicates = [HasVFP2];
1194}
1195
1196// Special cases
1197class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001198 IndexMode im, Format f, InstrItinClass itin,
1199 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001200 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001201 bits<4> p;
1202 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001203 let OutOperandList = oops;
1204 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001205 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001206 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001207 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001208 list<Predicate> Predicates = [HasVFP2];
1209}
1210
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001211class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1212 string opc, string asm, list<dag> pattern>
1213 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001214 opc, asm, "", pattern> {
1215 let PostEncoderMethod = "VFPThumb2PostEncoder";
1216}
David Goodwin3ca524e2009-07-10 17:03:29 +00001217
Evan Chengcd8e66a2008-11-11 21:48:44 +00001218// ARM VFP addrmode5 loads and stores
1219class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001220 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001221 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001222 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001223 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001224 // Instruction operands.
1225 bits<5> Dd;
1226 bits<13> addr;
1227
1228 // Encode instruction operands.
1229 let Inst{23} = addr{8}; // U (add = (U == '1'))
1230 let Inst{22} = Dd{4};
1231 let Inst{19-16} = addr{12-9}; // Rn
1232 let Inst{15-12} = Dd{3-0};
1233 let Inst{7-0} = addr{7-0}; // imm8
1234
Evan Cheng96581d32008-11-11 02:11:05 +00001235 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001236 let Inst{27-24} = opcod1;
1237 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001238 let Inst{11-9} = 0b101;
1239 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001240
Evan Cheng5eda2822011-02-16 00:35:02 +00001241 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001242 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001243}
1244
Evan Chengcd8e66a2008-11-11 21:48:44 +00001245class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001246 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001247 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001248 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001249 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001250 // Instruction operands.
1251 bits<5> Sd;
1252 bits<13> addr;
1253
1254 // Encode instruction operands.
1255 let Inst{23} = addr{8}; // U (add = (U == '1'))
1256 let Inst{22} = Sd{0};
1257 let Inst{19-16} = addr{12-9}; // Rn
1258 let Inst{15-12} = Sd{4-1};
1259 let Inst{7-0} = addr{7-0}; // imm8
1260
Evan Cheng96581d32008-11-11 02:11:05 +00001261 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001262 let Inst{27-24} = opcod1;
1263 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001264 let Inst{11-9} = 0b101;
1265 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001266
1267 // Loads & stores operate on both NEON and VFP pipelines.
1268 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001269}
1270
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001271// VFP Load / store multiple pseudo instructions.
1272class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1273 list<dag> pattern>
1274 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1275 cstr, itin> {
1276 let OutOperandList = oops;
1277 let InOperandList = !con(iops, (ins pred:$p));
1278 let Pattern = pattern;
1279 list<Predicate> Predicates = [HasVFP2];
1280}
1281
Evan Chengcd8e66a2008-11-11 21:48:44 +00001282// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001283class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001284 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001285 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001286 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001287 // Instruction operands.
1288 bits<4> Rn;
1289 bits<13> regs;
1290
1291 // Encode instruction operands.
1292 let Inst{19-16} = Rn;
1293 let Inst{22} = regs{12};
1294 let Inst{15-12} = regs{11-8};
1295 let Inst{7-0} = regs{7-0};
1296
Evan Chengcd8e66a2008-11-11 21:48:44 +00001297 // TODO: Mark the instructions with the appropriate subtarget info.
1298 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001299 let Inst{11-9} = 0b101;
1300 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001301}
1302
Jim Grosbach72db1822010-09-08 00:25:50 +00001303class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001304 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001305 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001306 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001307 // Instruction operands.
1308 bits<4> Rn;
1309 bits<13> regs;
1310
1311 // Encode instruction operands.
1312 let Inst{19-16} = Rn;
1313 let Inst{22} = regs{8};
1314 let Inst{15-12} = regs{12-9};
1315 let Inst{7-0} = regs{7-0};
1316
Evan Chengcd8e66a2008-11-11 21:48:44 +00001317 // TODO: Mark the instructions with the appropriate subtarget info.
1318 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001319 let Inst{11-9} = 0b101;
1320 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001321}
1322
Evan Cheng96581d32008-11-11 02:11:05 +00001323// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001324class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1325 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1326 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001327 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001328 // Instruction operands.
1329 bits<5> Dd;
1330 bits<5> Dm;
1331
1332 // Encode instruction operands.
1333 let Inst{3-0} = Dm{3-0};
1334 let Inst{5} = Dm{4};
1335 let Inst{15-12} = Dd{3-0};
1336 let Inst{22} = Dd{4};
1337
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001338 let Inst{27-23} = opcod1;
1339 let Inst{21-20} = opcod2;
1340 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001341 let Inst{11-9} = 0b101;
1342 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001343 let Inst{7-6} = opcod4;
1344 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001345}
1346
1347// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001348class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001349 dag iops, InstrItinClass itin, string opc, string asm,
1350 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001351 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001352 // Instruction operands.
1353 bits<5> Dd;
1354 bits<5> Dn;
1355 bits<5> Dm;
1356
1357 // Encode instruction operands.
1358 let Inst{3-0} = Dm{3-0};
1359 let Inst{5} = Dm{4};
1360 let Inst{19-16} = Dn{3-0};
1361 let Inst{7} = Dn{4};
1362 let Inst{15-12} = Dd{3-0};
1363 let Inst{22} = Dd{4};
1364
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001365 let Inst{27-23} = opcod1;
1366 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001367 let Inst{11-9} = 0b101;
1368 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001369 let Inst{6} = op6;
1370 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001371}
1372
1373// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001374class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1375 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1376 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001377 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001378 // Instruction operands.
1379 bits<5> Sd;
1380 bits<5> Sm;
1381
1382 // Encode instruction operands.
1383 let Inst{3-0} = Sm{4-1};
1384 let Inst{5} = Sm{0};
1385 let Inst{15-12} = Sd{4-1};
1386 let Inst{22} = Sd{0};
1387
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001388 let Inst{27-23} = opcod1;
1389 let Inst{21-20} = opcod2;
1390 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001391 let Inst{11-9} = 0b101;
1392 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001393 let Inst{7-6} = opcod4;
1394 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001395}
1396
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001397// Single precision unary, if no NEON. Same as ASuI except not available if
1398// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001399class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1400 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1401 string asm, list<dag> pattern>
1402 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1403 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001404 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1405}
1406
Evan Cheng96581d32008-11-11 02:11:05 +00001407// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001408class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1409 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001410 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001411 // Instruction operands.
1412 bits<5> Sd;
1413 bits<5> Sn;
1414 bits<5> Sm;
1415
1416 // Encode instruction operands.
1417 let Inst{3-0} = Sm{4-1};
1418 let Inst{5} = Sm{0};
1419 let Inst{19-16} = Sn{4-1};
1420 let Inst{7} = Sn{0};
1421 let Inst{15-12} = Sd{4-1};
1422 let Inst{22} = Sd{0};
1423
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001424 let Inst{27-23} = opcod1;
1425 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001426 let Inst{11-9} = 0b101;
1427 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001428 let Inst{6} = op6;
1429 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001430}
1431
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001432// Single precision binary, if no NEON. Same as ASbI except not available if
1433// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001434class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001435 dag iops, InstrItinClass itin, string opc, string asm,
1436 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001437 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001438 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001439
1440 // Instruction operands.
1441 bits<5> Sd;
1442 bits<5> Sn;
1443 bits<5> Sm;
1444
1445 // Encode instruction operands.
1446 let Inst{3-0} = Sm{4-1};
1447 let Inst{5} = Sm{0};
1448 let Inst{19-16} = Sn{4-1};
1449 let Inst{7} = Sn{0};
1450 let Inst{15-12} = Sd{4-1};
1451 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001452}
1453
Evan Cheng80a11982008-11-12 06:41:41 +00001454// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001455class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1456 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1457 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001458 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001459 let Inst{27-23} = opcod1;
1460 let Inst{21-20} = opcod2;
1461 let Inst{19-16} = opcod3;
1462 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001463 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001464 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001465}
1466
Johnny Chen811663f2010-02-11 18:47:03 +00001467// VFP conversion between floating-point and fixed-point
1468class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001469 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1470 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001471 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1472 // size (fixed-point number): sx == 0 ? 16 : 32
1473 let Inst{7} = op5; // sx
1474}
1475
David Goodwin338268c2009-08-10 22:17:39 +00001476// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001477class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001478 dag oops, dag iops, InstrItinClass itin,
1479 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001480 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1481 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001482 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1483}
1484
Evan Cheng80a11982008-11-12 06:41:41 +00001485class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001486 InstrItinClass itin,
1487 string opc, string asm, list<dag> pattern>
1488 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001489 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001490 let Inst{11-8} = opcod2;
1491 let Inst{4} = 1;
1492}
1493
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001494class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1495 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1496 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001497
Bob Wilson01135592010-03-23 17:23:59 +00001498class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001499 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1500 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001501
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001502class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1503 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1504 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001505
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001506class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1507 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1508 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001509
Evan Cheng96581d32008-11-11 02:11:05 +00001510//===----------------------------------------------------------------------===//
1511
Bob Wilson5bafff32009-06-22 23:27:02 +00001512//===----------------------------------------------------------------------===//
1513// ARM NEON Instruction templates.
1514//
Evan Cheng13096642008-08-29 06:41:12 +00001515
Johnny Chencaa608e2010-03-20 00:17:00 +00001516class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1517 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1518 list<dag> pattern>
1519 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001520 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001521 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001522 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001523 let Pattern = pattern;
1524 list<Predicate> Predicates = [HasNEON];
1525}
1526
1527// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001528class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1529 InstrItinClass itin, string opc, string asm, string cstr,
1530 list<dag> pattern>
1531 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001532 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001533 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001534 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001535 let Pattern = pattern;
1536 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001537}
1538
Bob Wilsonb07c1712009-10-07 21:53:04 +00001539class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1540 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001541 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001542 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1543 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001544 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001545 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001546 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001547 let Inst{11-8} = op11_8;
1548 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001549
Chris Lattner2ac19022010-11-15 05:19:05 +00001550 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001551
Owen Andersond9aa7d32010-11-02 00:05:05 +00001552 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001553 bits<6> Rn;
1554 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001555
Owen Andersond9aa7d32010-11-02 00:05:05 +00001556 let Inst{22} = Vd{4};
1557 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001558 let Inst{19-16} = Rn{3-0};
1559 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001560}
1561
Owen Andersond138d702010-11-02 20:47:39 +00001562class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1563 dag oops, dag iops, InstrItinClass itin,
1564 string opc, string dt, string asm, string cstr, list<dag> pattern>
1565 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1566 dt, asm, cstr, pattern> {
1567 bits<3> lane;
1568}
1569
Bob Wilson709d5922010-08-25 23:27:42 +00001570class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1571 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1572 itin> {
1573 let OutOperandList = oops;
1574 let InOperandList = !con(iops, (ins pred:$p));
1575 list<Predicate> Predicates = [HasNEON];
1576}
1577
Jim Grosbach7cd27292010-10-06 20:36:55 +00001578class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1579 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001580 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1581 itin> {
1582 let OutOperandList = oops;
1583 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001584 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001585 list<Predicate> Predicates = [HasNEON];
1586}
1587
Johnny Chen785516a2010-03-23 16:43:47 +00001588class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001589 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001590 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1591 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001592 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001593 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001594}
1595
Johnny Chen927b88f2010-03-23 20:40:44 +00001596class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001597 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001598 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001599 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001600 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001601 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001602}
1603
1604// NEON "one register and a modified immediate" format.
1605class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1606 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001607 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001608 string opc, string dt, string asm, string cstr,
1609 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001610 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001611 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001612 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001613 let Inst{11-8} = op11_8;
1614 let Inst{7} = op7;
1615 let Inst{6} = op6;
1616 let Inst{5} = op5;
1617 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001618
Owen Andersona88ea032010-10-26 17:40:54 +00001619 // Instruction operands.
1620 bits<5> Vd;
1621 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001622
Owen Andersona88ea032010-10-26 17:40:54 +00001623 let Inst{15-12} = Vd{3-0};
1624 let Inst{22} = Vd{4};
1625 let Inst{24} = SIMM{7};
1626 let Inst{18-16} = SIMM{6-4};
1627 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001628}
1629
1630// NEON 2 vector register format.
1631class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1632 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001633 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001634 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001635 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001636 let Inst{24-23} = op24_23;
1637 let Inst{21-20} = op21_20;
1638 let Inst{19-18} = op19_18;
1639 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001640 let Inst{11-7} = op11_7;
1641 let Inst{6} = op6;
1642 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001643
Owen Anderson162875a2010-10-25 18:43:52 +00001644 // Instruction operands.
1645 bits<5> Vd;
1646 bits<5> Vm;
1647
1648 let Inst{15-12} = Vd{3-0};
1649 let Inst{22} = Vd{4};
1650 let Inst{3-0} = Vm{3-0};
1651 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001652}
1653
1654// Same as N2V except it doesn't have a datatype suffix.
1655class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001656 bits<5> op11_7, bit op6, bit op4,
1657 dag oops, dag iops, InstrItinClass itin,
1658 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001659 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001660 let Inst{24-23} = op24_23;
1661 let Inst{21-20} = op21_20;
1662 let Inst{19-18} = op19_18;
1663 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001664 let Inst{11-7} = op11_7;
1665 let Inst{6} = op6;
1666 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001667
Owen Anderson162875a2010-10-25 18:43:52 +00001668 // Instruction operands.
1669 bits<5> Vd;
1670 bits<5> Vm;
1671
1672 let Inst{15-12} = Vd{3-0};
1673 let Inst{22} = Vd{4};
1674 let Inst{3-0} = Vm{3-0};
1675 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001676}
1677
1678// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001679class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001680 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001681 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001682 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001683 let Inst{24} = op24;
1684 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001685 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001686 let Inst{7} = op7;
1687 let Inst{6} = op6;
1688 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001689
Owen Anderson3557d002010-10-26 20:56:57 +00001690 // Instruction operands.
1691 bits<5> Vd;
1692 bits<5> Vm;
1693 bits<6> SIMM;
1694
1695 let Inst{15-12} = Vd{3-0};
1696 let Inst{22} = Vd{4};
1697 let Inst{3-0} = Vm{3-0};
1698 let Inst{5} = Vm{4};
1699 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001700}
1701
Bob Wilson10bc69c2010-03-27 03:56:52 +00001702// NEON 3 vector register format.
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001703
1704class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001705 dag oops, dag iops, Format f, InstrItinClass itin,
1706 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001707 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001708 let Inst{24} = op24;
1709 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001710 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001711 let Inst{11-8} = op11_8;
1712 let Inst{6} = op6;
1713 let Inst{4} = op4;
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001714}
1715
1716class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1717 dag oops, dag iops, Format f, InstrItinClass itin,
1718 string opc, string dt, string asm, string cstr, list<dag> pattern>
1719 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1720 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001721
Owen Andersond451f882010-10-21 20:21:49 +00001722 // Instruction operands.
1723 bits<5> Vd;
1724 bits<5> Vn;
1725 bits<5> Vm;
1726
1727 let Inst{15-12} = Vd{3-0};
1728 let Inst{22} = Vd{4};
1729 let Inst{19-16} = Vn{3-0};
1730 let Inst{7} = Vn{4};
1731 let Inst{3-0} = Vm{3-0};
1732 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001733}
1734
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001735class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1736 dag oops, dag iops, Format f, InstrItinClass itin,
1737 string opc, string dt, string asm, string cstr, list<dag> pattern>
1738 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1739 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1740
1741 // Instruction operands.
1742 bits<5> Vd;
1743 bits<5> Vn;
1744 bits<5> Vm;
1745 bit lane;
1746
1747 let Inst{15-12} = Vd{3-0};
1748 let Inst{22} = Vd{4};
1749 let Inst{19-16} = Vn{3-0};
1750 let Inst{7} = Vn{4};
1751 let Inst{3-0} = Vm{3-0};
1752 let Inst{5} = lane;
1753}
1754
1755class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1756 dag oops, dag iops, Format f, InstrItinClass itin,
1757 string opc, string dt, string asm, string cstr, list<dag> pattern>
1758 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1759 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1760
1761 // Instruction operands.
1762 bits<5> Vd;
1763 bits<5> Vn;
1764 bits<5> Vm;
1765 bits<2> lane;
1766
1767 let Inst{15-12} = Vd{3-0};
1768 let Inst{22} = Vd{4};
1769 let Inst{19-16} = Vn{3-0};
1770 let Inst{7} = Vn{4};
1771 let Inst{2-0} = Vm{2-0};
1772 let Inst{5} = lane{1};
1773 let Inst{3} = lane{0};
1774}
1775
Johnny Chen841e8282010-03-23 21:35:03 +00001776// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001777class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1778 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001779 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001780 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001781 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001782 let Inst{24} = op24;
1783 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001784 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001785 let Inst{11-8} = op11_8;
1786 let Inst{6} = op6;
1787 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001788
Owen Anderson8c71eff2010-10-25 18:28:30 +00001789 // Instruction operands.
1790 bits<5> Vd;
1791 bits<5> Vn;
1792 bits<5> Vm;
1793
1794 let Inst{15-12} = Vd{3-0};
1795 let Inst{22} = Vd{4};
1796 let Inst{19-16} = Vn{3-0};
1797 let Inst{7} = Vn{4};
1798 let Inst{3-0} = Vm{3-0};
1799 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001800}
1801
1802// NEON VMOVs between scalar and core registers.
1803class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001804 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001805 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001806 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001807 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001808 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001809 let Inst{11-8} = opcod2;
1810 let Inst{6-5} = opcod3;
1811 let Inst{4} = 1;
Evan Chengf81bf152009-11-23 21:57:23 +00001812
1813 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001814 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001815 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001816 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001817 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001818
Chris Lattner2ac19022010-11-15 05:19:05 +00001819 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001820
Owen Andersond2fbdb72010-10-27 21:28:09 +00001821 bits<5> V;
1822 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001823 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001824 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001825
Owen Andersonf587a9352010-10-27 19:25:54 +00001826 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001827 let Inst{7} = V{4};
1828 let Inst{19-16} = V{3-0};
1829 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001830}
1831class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001832 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001833 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001834 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001835 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001836class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001837 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001838 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001839 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001840 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001841class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001842 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001843 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001844 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001845 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001846
Johnny Chene4614f72010-03-25 17:01:27 +00001847// Vector Duplicate Lane (from scalar to all elements)
1848class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1849 InstrItinClass itin, string opc, string dt, string asm,
1850 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001851 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001852 let Inst{24-23} = 0b11;
1853 let Inst{21-20} = 0b11;
1854 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001855 let Inst{11-7} = 0b11000;
1856 let Inst{6} = op6;
1857 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001858
Owen Andersonf587a9352010-10-27 19:25:54 +00001859 bits<5> Vd;
1860 bits<5> Vm;
1861 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001862
Owen Andersonf587a9352010-10-27 19:25:54 +00001863 let Inst{22} = Vd{4};
1864 let Inst{15-12} = Vd{3-0};
1865 let Inst{5} = Vm{4};
1866 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001867}
1868
David Goodwin42a83f22009-08-04 17:53:06 +00001869// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1870// for single-precision FP.
1871class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1872 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1873}