blob: 81577dafe66961c6c2f1e16cc6359e2344122f08 [file] [log] [blame]
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson01135592010-03-23 17:23:59 +00002//
Evan Cheng37f25d92008-08-28 23:39:26 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilson01135592010-03-23 17:23:59 +00007//
Evan Cheng37f25d92008-08-28 23:39:26 +00008//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
Bob Wilson89ef7b72010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng37f25d92008-08-28 23:39:26 +000020}
21
Evan Chengffa6d962008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng37f25d92008-08-28 23:39:26 +000026
Evan Chengffa6d962008-11-13 23:36:57 +000027def DPFrm : Format<4>;
28def DPSoRegFrm : Format<5>;
Evan Cheng37f25d92008-08-28 23:39:26 +000029
Evan Chengffa6d962008-11-13 23:36:57 +000030def LdFrm : Format<6>;
31def StFrm : Format<7>;
32def LdMiscFrm : Format<8>;
33def StMiscFrm : Format<9>;
34def LdStMulFrm : Format<10>;
Evan Cheng37f25d92008-08-28 23:39:26 +000035
Johnny Chen81f04d52010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5278eb82009-12-11 01:42:04 +000037
Johnny Chen81f04d52010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson9a1c1892010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000041
Bob Wilson9a1c1892010-08-11 00:01:18 +000042def VFPUnaryFrm : Format<15>;
43def VFPBinaryFrm : Format<16>;
44def VFPConv1Frm : Format<17>;
45def VFPConv2Frm : Format<18>;
46def VFPConv3Frm : Format<19>;
47def VFPConv4Frm : Format<20>;
48def VFPConv5Frm : Format<21>;
49def VFPLdStFrm : Format<22>;
50def VFPLdStMulFrm : Format<23>;
51def VFPMiscFrm : Format<24>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000052
Bob Wilson9a1c1892010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng37f25d92008-08-28 23:39:26 +000055
Bob Wilson9a1c1892010-08-11 00:01:18 +000056def NGetLnFrm : Format<27>;
57def NSetLnFrm : Format<28>;
58def NDupFrm : Format<29>;
59def NLdStFrm : Format<30>;
60def N1RegModImmFrm: Format<31>;
61def N2RegFrm : Format<32>;
62def NVCVTFrm : Format<33>;
63def NVDupLnFrm : Format<34>;
64def N2RegVShLFrm : Format<35>;
65def N2RegVShRFrm : Format<36>;
66def N3RegFrm : Format<37>;
67def N3RegVShFrm : Format<38>;
68def NVExtFrm : Format<39>;
69def NVMulSLFrm : Format<40>;
70def NVTBLFrm : Format<41>;
Johnny Chencaa608e2010-03-20 00:17:00 +000071
Evan Cheng34a0fa32009-07-08 01:46:35 +000072// Misc flags.
73
Bill Wendling43f7b2d2010-12-01 02:42:55 +000074// The instruction has an Rn register operand.
Evan Cheng34a0fa32009-07-08 01:46:35 +000075// UnaryDP - Indicates this is a unary data processing instruction, i.e.
76// it doesn't have a Rn operand.
77class UnaryDP { bit isUnaryDataProc = 1; }
78
79// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80// a 16-bit Thumb instruction if certain conditions are met.
81class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng37f25d92008-08-28 23:39:26 +000082
Evan Cheng37f25d92008-08-28 23:39:26 +000083//===----------------------------------------------------------------------===//
Bob Wilson50622ce2010-03-18 23:57:57 +000084// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Cheng055b0312009-06-29 07:51:04 +000085//
86
Jim Grosbachff12a8b2011-01-18 19:59:19 +000087// FIXME: Once the JIT is MC-ized, these can go away.
Evan Cheng055b0312009-06-29 07:51:04 +000088// Addressing mode.
Jim Grosbachd86609f2010-10-05 18:14:55 +000089class AddrMode<bits<5> val> {
90 bits<5> Value = val;
Evan Cheng055b0312009-06-29 07:51:04 +000091}
Bill Wendlingda2ae632010-08-31 07:50:46 +000092def AddrModeNone : AddrMode<0>;
93def AddrMode1 : AddrMode<1>;
94def AddrMode2 : AddrMode<2>;
95def AddrMode3 : AddrMode<3>;
96def AddrMode4 : AddrMode<4>;
97def AddrMode5 : AddrMode<5>;
98def AddrMode6 : AddrMode<6>;
99def AddrModeT1_1 : AddrMode<7>;
100def AddrModeT1_2 : AddrMode<8>;
101def AddrModeT1_4 : AddrMode<9>;
102def AddrModeT1_s : AddrMode<10>;
103def AddrModeT2_i12 : AddrMode<11>;
104def AddrModeT2_i8 : AddrMode<12>;
105def AddrModeT2_so : AddrMode<13>;
106def AddrModeT2_pc : AddrMode<14>;
Bob Wilson8b024a52009-07-01 23:16:05 +0000107def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach3e556122010-10-26 22:37:02 +0000108def AddrMode_i12 : AddrMode<16>;
Evan Cheng055b0312009-06-29 07:51:04 +0000109
110// Instruction size.
111class SizeFlagVal<bits<3> val> {
112 bits<3> Value = val;
113}
114def SizeInvalid : SizeFlagVal<0>; // Unset.
115def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
116def Size8Bytes : SizeFlagVal<2>;
117def Size4Bytes : SizeFlagVal<3>;
118def Size2Bytes : SizeFlagVal<4>;
119
120// Load / store index mode.
121class IndexMode<bits<2> val> {
122 bits<2> Value = val;
123}
124def IndexModeNone : IndexMode<0>;
125def IndexModePre : IndexMode<1>;
126def IndexModePost : IndexMode<2>;
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000127def IndexModeUpd : IndexMode<3>;
Evan Cheng055b0312009-06-29 07:51:04 +0000128
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000129// Instruction execution domain.
Evan Cheng6557bce2011-02-22 19:53:14 +0000130class Domain<bits<3> val> {
131 bits<3> Value = val;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000132}
133def GenericDomain : Domain<0>;
134def VFPDomain : Domain<1>; // Instructions in VFP domain only
135def NeonDomain : Domain<2>; // Instructions in Neon domain only
136def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng2b943562011-02-23 02:35:33 +0000137def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000138
Evan Cheng055b0312009-06-29 07:51:04 +0000139//===----------------------------------------------------------------------===//
Evan Cheng446c4282009-07-11 06:43:01 +0000140// ARM special operands.
141//
142
Daniel Dunbar8462b302010-08-11 06:36:53 +0000143def CondCodeOperand : AsmOperandClass {
144 let Name = "CondCode";
145 let SuperClasses = [];
146}
147
Jim Grosbachd67641b2010-12-06 18:21:12 +0000148def CCOutOperand : AsmOperandClass {
149 let Name = "CCOut";
150 let SuperClasses = [];
151}
152
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000153def MemBarrierOptOperand : AsmOperandClass {
154 let Name = "MemBarrierOpt";
155 let SuperClasses = [];
Jim Grosbachf922c472011-02-12 01:34:40 +0000156 let ParserMethod = "tryParseMemBarrierOptOperand";
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000157}
158
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000159def ProcIFlagsOperand : AsmOperandClass {
160 let Name = "ProcIFlags";
161 let SuperClasses = [];
162 let ParserMethod = "tryParseProcIFlagsOperand";
163}
164
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000165def MSRMaskOperand : AsmOperandClass {
166 let Name = "MSRMask";
167 let SuperClasses = [];
168 let ParserMethod = "tryParseMSRMaskOperand";
169}
170
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000171// ARM imod and iflag operands, used only by the CPS instruction.
172def imod_op : Operand<i32> {
173 let PrintMethod = "printCPSIMod";
174}
175
176def iflags_op : Operand<i32> {
177 let PrintMethod = "printCPSIFlag";
178 let ParserMatchClass = ProcIFlagsOperand;
179}
180
Evan Cheng446c4282009-07-11 06:43:01 +0000181// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
182// register whose default is 0 (no register).
183def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
184 (ops (i32 14), (i32 zero_reg))> {
185 let PrintMethod = "printPredicateOperand";
Daniel Dunbar8462b302010-08-11 06:36:53 +0000186 let ParserMatchClass = CondCodeOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000187}
188
189// Conditional code result for instructions whose 's' bit is set, e.g. subs.
190def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000191 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000192 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000193 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000194}
195
196// Same as cc_out except it defaults to setting CPSR.
197def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000198 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000199 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000200 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000201}
202
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000203// ARM special operands for disassembly only.
204//
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000205def setend_op : Operand<i32> {
206 let PrintMethod = "printSetendOperand";
207}
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000208
209def cps_opt : Operand<i32> {
210 let PrintMethod = "printCPSOptionOperand";
211}
212
213def msr_mask : Operand<i32> {
214 let PrintMethod = "printMSRMaskOperand";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000215 let ParserMatchClass = MSRMaskOperand;
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000216}
217
218// A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
219// The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
220def neg_zero : Operand<i32> {
221 let PrintMethod = "printNegZeroOperand";
222}
223
Bill Wendling3116dce2011-03-07 23:38:41 +0000224// Shift Right Immediate - A shift right immediate is encoded differently from
225// other shift immediates. The imm6 field is encoded like so:
Bill Wendlinga656b632011-03-01 01:00:59 +0000226//
Bill Wendling3116dce2011-03-07 23:38:41 +0000227// Offset Encoding
228// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
229// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
230// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
231// 64 64 - <imm> is encoded in imm6<5:0>
232def shr_imm8 : Operand<i32> {
233 let EncoderMethod = "getShiftRight8Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000234}
Bill Wendling3116dce2011-03-07 23:38:41 +0000235def shr_imm16 : Operand<i32> {
236 let EncoderMethod = "getShiftRight16Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000237}
Bill Wendling3116dce2011-03-07 23:38:41 +0000238def shr_imm32 : Operand<i32> {
239 let EncoderMethod = "getShiftRight32Imm";
240}
241def shr_imm64 : Operand<i32> {
242 let EncoderMethod = "getShiftRight64Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000243}
244
Evan Cheng446c4282009-07-11 06:43:01 +0000245//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000246// ARM Instruction templates.
247//
248
Johnny Chend68e1192009-12-15 17:24:14 +0000249class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
250 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000251 : Instruction {
252 let Namespace = "ARM";
253
Evan Cheng37f25d92008-08-28 23:39:26 +0000254 AddrMode AM = am;
Evan Cheng37f25d92008-08-28 23:39:26 +0000255 SizeFlagVal SZ = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000256 IndexMode IM = im;
257 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000258 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000259 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000260 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000261 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000262 bit canXformTo16Bit = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +0000263
Chris Lattner150d20e2010-10-31 19:22:57 +0000264 // If this is a pseudo instruction, mark it isCodeGenOnly.
265 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson01135592010-03-23 17:23:59 +0000266
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000267 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000268 let TSFlags{4-0} = AM.Value;
269 let TSFlags{7-5} = SZ.Value;
270 let TSFlags{9-8} = IndexModeBits;
271 let TSFlags{15-10} = Form;
272 let TSFlags{16} = isUnaryDataProc;
273 let TSFlags{17} = canXformTo16Bit;
Evan Cheng6557bce2011-02-22 19:53:14 +0000274 let TSFlags{20-18} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000275
Evan Cheng37f25d92008-08-28 23:39:26 +0000276 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000277 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000278}
279
Johnny Chend68e1192009-12-15 17:24:14 +0000280class Encoding {
281 field bits<32> Inst;
282}
283
284class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
285 Format f, Domain d, string cstr, InstrItinClass itin>
286 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
287
288// This Encoding-less class is used by Thumb1 to specify the encoding bits later
289// on by adding flavors to specific instructions.
290class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
291 Format f, Domain d, string cstr, InstrItinClass itin>
292 : InstTemplate<am, sz, im, f, d, cstr, itin>;
293
Jim Grosbach99594eb2010-11-18 01:38:26 +0000294class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Jim Grosbachc6961f12010-11-18 01:20:48 +0000295 // FIXME: This really should derive from InstTemplate instead, as pseudos
296 // don't need encoding information. TableGen doesn't like that
297 // currently. Need to figure out why and fix it.
Bob Wilson01135592010-03-23 17:23:59 +0000298 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000299 "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000300 let OutOperandList = oops;
301 let InOperandList = iops;
Evan Cheng37f25d92008-08-28 23:39:26 +0000302 let Pattern = pattern;
Jim Grosbacha768c3d2011-03-10 19:06:39 +0000303 let isCodeGenOnly = 1;
Evan Cheng37f25d92008-08-28 23:39:26 +0000304}
305
Jim Grosbach53694262010-11-18 01:15:56 +0000306// PseudoInst that's ARM-mode only.
Jim Grosbach6e422112010-11-29 23:48:41 +0000307class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
Jim Grosbach99594eb2010-11-18 01:38:26 +0000308 list<dag> pattern>
309 : PseudoInst<oops, iops, itin, pattern> {
Jim Grosbach6e422112010-11-29 23:48:41 +0000310 let SZ = sz;
Jim Grosbach53694262010-11-18 01:15:56 +0000311 list<Predicate> Predicates = [IsARM];
312}
313
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000314// PseudoInst that's Thumb-mode only.
315class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
316 list<dag> pattern>
317 : PseudoInst<oops, iops, itin, pattern> {
318 let SZ = sz;
319 list<Predicate> Predicates = [IsThumb];
320}
Jim Grosbach53694262010-11-18 01:15:56 +0000321
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000322// PseudoInst that's Thumb2-mode only.
323class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
324 list<dag> pattern>
325 : PseudoInst<oops, iops, itin, pattern> {
326 let SZ = sz;
327 list<Predicate> Predicates = [IsThumb2];
328}
Evan Cheng37f25d92008-08-28 23:39:26 +0000329// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000330class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000331 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000332 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000333 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000334 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000335 bits<4> p;
336 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000337 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000338 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000339 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000340 let Pattern = pattern;
341 list<Predicate> Predicates = [IsARM];
342}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000343
Jim Grosbachf6b28622009-12-14 18:31:20 +0000344// A few are not predicable
345class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000346 IndexMode im, Format f, InstrItinClass itin,
347 string opc, string asm, string cstr,
348 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000349 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
350 let OutOperandList = oops;
351 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000352 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000353 let Pattern = pattern;
354 let isPredicable = 0;
355 list<Predicate> Predicates = [IsARM];
356}
Evan Cheng37f25d92008-08-28 23:39:26 +0000357
Bill Wendling4822bce2010-08-30 01:47:35 +0000358// Same as I except it can optionally modify CPSR. Note it's modeled as an input
359// operand since by default it's a zero register. It will become an implicit def
360// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000361class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000362 IndexMode im, Format f, InstrItinClass itin,
363 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000364 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000365 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000366 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000367 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000368 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000369 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000370
Evan Cheng37f25d92008-08-28 23:39:26 +0000371 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000372 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000373 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000374 let Pattern = pattern;
375 list<Predicate> Predicates = [IsARM];
376}
377
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000378// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000379class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000380 IndexMode im, Format f, InstrItinClass itin,
381 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000382 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000383 let OutOperandList = oops;
384 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000385 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000386 let Pattern = pattern;
387 list<Predicate> Predicates = [IsARM];
388}
389
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000390class AI<dag oops, dag iops, Format f, InstrItinClass itin,
391 string opc, string asm, list<dag> pattern>
392 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
393 opc, asm, "", pattern>;
394class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
395 string opc, string asm, list<dag> pattern>
396 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
397 opc, asm, "", pattern>;
398class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000399 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000400 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000401 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000402class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000403 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000404 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000405 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000406
407// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000408class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
409 string opc, string asm, list<dag> pattern>
410 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
411 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000412 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000413}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000414class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
415 string asm, list<dag> pattern>
416 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
417 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000418 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000419}
Evan Cheng3aac7882008-09-01 08:25:56 +0000420
421// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000422class JTI<dag oops, dag iops, InstrItinClass itin,
423 string asm, list<dag> pattern>
424 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000425 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000426
Jim Grosbach5278eb82009-12-11 01:42:04 +0000427// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000428class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
429 string opc, string asm, list<dag> pattern>
430 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
431 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000432 bits<4> Rt;
433 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000434 let Inst{27-23} = 0b00011;
435 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000436 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000437 let Inst{19-16} = Rn;
438 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000439 let Inst{11-0} = 0b111110011111;
440}
441class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
442 string opc, string asm, list<dag> pattern>
443 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
444 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000445 bits<4> Rd;
446 bits<4> Rt;
447 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000448 let Inst{27-23} = 0b00011;
449 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000450 let Inst{20} = 0;
Jim Grosbach86875a22010-10-29 19:58:57 +0000451 let Inst{19-16} = Rn;
452 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000453 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000454 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000455}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000456class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
457 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
458 bits<4> Rt;
459 bits<4> Rt2;
460 bits<4> Rn;
461 let Inst{27-23} = 0b00010;
462 let Inst{22} = b;
463 let Inst{21-20} = 0b00;
464 let Inst{19-16} = Rn;
465 let Inst{15-12} = Rt;
466 let Inst{11-4} = 0b00001001;
467 let Inst{3-0} = Rt2;
468}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000469
Evan Cheng0d14fc82008-09-01 01:51:14 +0000470// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000471class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
472 string opc, string asm, list<dag> pattern>
473 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
474 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000475 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000476 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000477}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000478class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
480 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
481 opc, asm, "", pattern> {
482 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000483 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000484}
485class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000486 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000487 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000488 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000489 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000490 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000491}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000492
Evan Cheng93912732008-09-01 01:27:33 +0000493// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000494
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000495// LDR/LDRB/STR/STRB/...
496class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000497 Format f, InstrItinClass itin, string opc, string asm,
498 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000499 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
500 "", pattern> {
501 let Inst{27-25} = op;
502 let Inst{24} = 1; // 24 == P
503 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000504 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000505 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000506 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000507}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000508// Indexed load/stores
509class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000510 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000511 string asm, string cstr, list<dag> pattern>
512 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
513 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000514 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000515 let Inst{27-26} = 0b01;
516 let Inst{24} = isPre; // P bit
517 let Inst{22} = isByte; // B bit
518 let Inst{21} = isPre; // W bit
519 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000520 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000521}
Jim Grosbach953557f42010-11-19 21:35:06 +0000522class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
523 IndexMode im, Format f, InstrItinClass itin, string opc,
524 string asm, string cstr, list<dag> pattern>
525 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
526 pattern> {
527 // AM2 store w/ two operands: (GPR, am2offset)
528 // {13} 1 == Rm, 0 == imm12
529 // {12} isAdd
530 // {11-0} imm12/Rm
531 bits<14> offset;
532 bits<4> Rn;
533 let Inst{25} = offset{13};
534 let Inst{23} = offset{12};
535 let Inst{19-16} = Rn;
536 let Inst{11-0} = offset{11-0};
537}
Jim Grosbach3e556122010-10-26 22:37:02 +0000538
Evan Cheng0d14fc82008-09-01 01:51:14 +0000539// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000540class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
541 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach160f8f02010-11-18 00:46:58 +0000542 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
543 opc, asm, "", pattern> {
544 bits<14> addr;
545 bits<4> Rt;
546 let Inst{27-25} = 0b000;
547 let Inst{24} = 1; // P bit
548 let Inst{23} = addr{8}; // U bit
549 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
550 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000551 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000552 let Inst{19-16} = addr{12-9}; // Rn
553 let Inst{15-12} = Rt; // Rt
554 let Inst{11-8} = addr{7-4}; // imm7_4/zero
555 let Inst{7-4} = op;
556 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
557}
Evan Cheng840917b2008-09-01 07:00:14 +0000558
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000559class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
560 IndexMode im, Format f, InstrItinClass itin, string opc,
561 string asm, string cstr, list<dag> pattern>
562 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
563 opc, asm, cstr, pattern> {
564 bits<4> Rt;
565 let Inst{27-25} = 0b000;
566 let Inst{24} = isPre; // P bit
567 let Inst{21} = isPre; // W bit
568 let Inst{20} = op20; // L bit
569 let Inst{15-12} = Rt; // Rt
570 let Inst{7-4} = op;
571}
Jim Grosbach2dc77682010-11-29 18:37:44 +0000572class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
573 IndexMode im, Format f, InstrItinClass itin, string opc,
574 string asm, string cstr, list<dag> pattern>
575 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
576 pattern> {
577 // AM3 store w/ two operands: (GPR, am3offset)
578 bits<14> offset;
579 bits<4> Rt;
580 bits<4> Rn;
581 let Inst{27-25} = 0b000;
582 let Inst{23} = offset{8};
583 let Inst{22} = offset{9};
584 let Inst{19-16} = Rn;
585 let Inst{15-12} = Rt; // Rt
586 let Inst{11-8} = offset{7-4}; // imm7_4/zero
587 let Inst{7-4} = op;
588 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
589}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000590
Evan Cheng840917b2008-09-01 07:00:14 +0000591// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000592class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000593 string opc, string asm, list<dag> pattern>
594 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
595 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000596 bits<14> addr;
597 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000598 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000599 let Inst{24} = 1; // P bit
600 let Inst{23} = addr{8}; // U bit
601 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
602 let Inst{21} = 0; // W bit
603 let Inst{20} = 0; // L bit
604 let Inst{19-16} = addr{12-9}; // Rn
605 let Inst{15-12} = Rt; // Rt
606 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000607 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000608 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000609}
Evan Cheng840917b2008-09-01 07:00:14 +0000610
Evan Cheng840917b2008-09-01 07:00:14 +0000611// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000612class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
613 string opc, string asm, string cstr, list<dag> pattern>
614 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
615 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000616 let Inst{4} = 1;
617 let Inst{5} = 1; // H bit
618 let Inst{6} = 0; // S bit
619 let Inst{7} = 1;
620 let Inst{20} = 0; // L bit
621 let Inst{21} = 1; // W bit
622 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000623 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000624}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000625class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
626 string opc, string asm, string cstr, list<dag> pattern>
627 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
628 opc, asm, cstr, pattern> {
629 let Inst{4} = 1;
630 let Inst{5} = 1; // H bit
631 let Inst{6} = 1; // S bit
632 let Inst{7} = 1;
633 let Inst{20} = 0; // L bit
634 let Inst{21} = 1; // W bit
635 let Inst{24} = 1; // P bit
636 let Inst{27-25} = 0b000;
637}
Evan Cheng840917b2008-09-01 07:00:14 +0000638
Evan Cheng840917b2008-09-01 07:00:14 +0000639// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000640class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
641 string opc, string asm, string cstr, list<dag> pattern>
642 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
643 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000644 let Inst{4} = 1;
645 let Inst{5} = 1; // H bit
646 let Inst{6} = 0; // S bit
647 let Inst{7} = 1;
648 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000649 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000650 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000651 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000652}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000653class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
654 string opc, string asm, string cstr, list<dag> pattern>
655 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
656 opc, asm, cstr, pattern> {
657 let Inst{4} = 1;
658 let Inst{5} = 1; // H bit
659 let Inst{6} = 1; // S bit
660 let Inst{7} = 1;
661 let Inst{20} = 0; // L bit
662 let Inst{21} = 0; // W bit
663 let Inst{24} = 0; // P bit
664 let Inst{27-25} = 0b000;
665}
Evan Cheng840917b2008-09-01 07:00:14 +0000666
Evan Cheng0d14fc82008-09-01 01:51:14 +0000667// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000668class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
669 string asm, string cstr, list<dag> pattern>
670 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
671 bits<4> p;
672 bits<16> regs;
673 bits<4> Rn;
674 let Inst{31-28} = p;
675 let Inst{27-25} = 0b100;
676 let Inst{22} = 0; // S bit
677 let Inst{19-16} = Rn;
678 let Inst{15-0} = regs;
679}
Evan Cheng37f25d92008-08-28 23:39:26 +0000680
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000681// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000682class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
683 string opc, string asm, list<dag> pattern>
684 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
685 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000686 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000687 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000688 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000689}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000690class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
691 string opc, string asm, list<dag> pattern>
692 : sI<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 Chengd87293c2008-11-06 08:47:38 +0000695 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000696}
697
698// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000699class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
700 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000701 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
702 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000703 bits<4> Rd;
704 bits<4> Rn;
705 bits<4> Rm;
706 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000707 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000708 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000709 let Inst{19-16} = Rd;
710 let Inst{11-8} = Rm;
711 let Inst{3-0} = Rn;
712}
713// MSW multiple w/ Ra operand
714class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
715 InstrItinClass itin, string opc, string asm, list<dag> pattern>
716 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
717 bits<4> Ra;
718 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000719}
Evan Cheng37f25d92008-08-28 23:39:26 +0000720
Evan Chengeb4f52e2008-11-06 03:35:07 +0000721// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000722class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000723 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000724 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
725 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000726 bits<4> Rn;
727 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000728 let Inst{4} = 0;
729 let Inst{7} = 1;
730 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000731 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000732 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000733 let Inst{11-8} = Rm;
734 let Inst{3-0} = Rn;
735}
736class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
737 InstrItinClass itin, string opc, string asm, list<dag> pattern>
738 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
739 bits<4> Rd;
740 let Inst{19-16} = Rd;
741}
742
743// AMulxyI with Ra operand
744class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
745 InstrItinClass itin, string opc, string asm, list<dag> pattern>
746 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
747 bits<4> Ra;
748 let Inst{15-12} = Ra;
749}
750// SMLAL*
751class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
752 InstrItinClass itin, string opc, string asm, list<dag> pattern>
753 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
754 bits<4> RdLo;
755 bits<4> RdHi;
756 let Inst{19-16} = RdHi;
757 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000758}
759
Evan Cheng97f48c32008-11-06 22:15:19 +0000760// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000761class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
762 string opc, string asm, list<dag> pattern>
763 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
764 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000765 // All AExtI instructions have Rd and Rm register operands.
766 bits<4> Rd;
767 bits<4> Rm;
768 let Inst{15-12} = Rd;
769 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000770 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000771 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000772 let Inst{27-20} = opcod;
773}
774
Evan Cheng8b59db32008-11-07 01:41:35 +0000775// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000776class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
777 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000778 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
779 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000780 bits<4> Rd;
781 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000782 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000783 let Inst{19-16} = 0b1111;
784 let Inst{15-12} = Rd;
785 let Inst{11-8} = 0b1111;
786 let Inst{7-4} = opc7_4;
787 let Inst{3-0} = Rm;
788}
789
790// PKH instructions
791class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
792 string opc, string asm, list<dag> pattern>
793 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
794 opc, asm, "", pattern> {
795 bits<4> Rd;
796 bits<4> Rn;
797 bits<4> Rm;
798 bits<8> sh;
799 let Inst{27-20} = opcod;
800 let Inst{19-16} = Rn;
801 let Inst{15-12} = Rd;
802 let Inst{11-7} = sh{7-3};
803 let Inst{6} = tb;
804 let Inst{5-4} = 0b01;
805 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000806}
807
Evan Cheng37f25d92008-08-28 23:39:26 +0000808//===----------------------------------------------------------------------===//
809
810// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
811class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
812 list<Predicate> Predicates = [IsARM];
813}
814class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
815 list<Predicate> Predicates = [IsARM, HasV5TE];
816}
817class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
818 list<Predicate> Predicates = [IsARM, HasV6];
819}
Evan Cheng13096642008-08-29 06:41:12 +0000820
821//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000822// Thumb Instruction Format Definitions.
823//
824
Evan Cheng446c4282009-07-11 06:43:01 +0000825class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000826 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000827 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000828 let OutOperandList = oops;
829 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000830 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000831 let Pattern = pattern;
832 list<Predicate> Predicates = [IsThumb];
833}
834
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000835// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000836class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
837 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000838
Evan Cheng35d6c412009-08-04 23:47:55 +0000839// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000840class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
841 list<dag> pattern>
842 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
843 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000844
Johnny Chend68e1192009-12-15 17:24:14 +0000845// tBL, tBX 32-bit instructions
846class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000847 dag oops, dag iops, InstrItinClass itin, string asm,
848 list<dag> pattern>
849 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
850 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000851 let Inst{31-27} = opcod1;
852 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000853 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000854}
Evan Cheng13096642008-08-29 06:41:12 +0000855
Bruno Cardoso Lopesfa5bd272011-01-20 16:35:57 +0000856// Move to/from coprocessor instructions
857class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
858 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
859 Encoding, Requires<[IsThumb, HasV6]> {
860 let Inst{31-28} = 0b1110;
861}
862
Evan Cheng13096642008-08-29 06:41:12 +0000863// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000864class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
865 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000866 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000867
Evan Cheng09c39fc2009-06-23 19:38:13 +0000868// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +0000869class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000870 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000871 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000872 let OutOperandList = oops;
873 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000874 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000875 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000876 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000877}
878
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000879class T1I<dag oops, dag iops, InstrItinClass itin,
880 string asm, list<dag> pattern>
881 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
882class T1Ix2<dag oops, dag iops, InstrItinClass itin,
883 string asm, list<dag> pattern>
884 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000885
886// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000887class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000888 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000889 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000890 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000891
892// Thumb1 instruction that can either be predicated or set CPSR.
893class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000894 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000895 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000896 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000897 let OutOperandList = !con(oops, (outs s_cc_out:$s));
898 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000899 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000900 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000901 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000902}
903
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000904class T1sI<dag oops, dag iops, InstrItinClass itin,
905 string opc, string asm, list<dag> pattern>
906 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000907
908// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000909class T1sIt<dag oops, dag iops, InstrItinClass itin,
910 string opc, string asm, list<dag> pattern>
911 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000912 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000913
914// Thumb1 instruction that can be predicated.
915class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000916 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000917 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000918 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000919 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000920 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000921 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000922 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000923 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000924}
925
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000926class T1pI<dag oops, dag iops, InstrItinClass itin,
927 string opc, string asm, list<dag> pattern>
928 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000929
930// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000931class T1pIt<dag oops, dag iops, InstrItinClass itin,
932 string opc, string asm, list<dag> pattern>
933 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000934 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000935
Bob Wilson01135592010-03-23 17:23:59 +0000936class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000937 InstrItinClass itin, string opc, string asm, list<dag> pattern>
938 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000939
Johnny Chenbbc71b22009-12-16 02:32:54 +0000940class Encoding16 : Encoding {
941 let Inst{31-16} = 0x0000;
942}
943
Johnny Chend68e1192009-12-15 17:24:14 +0000944// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +0000945class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000946 let Inst{15-10} = opcode;
947}
948
949// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000950class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000951 let Inst{15-14} = 0b00;
952 let Inst{13-9} = opcode;
953}
954
955// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000956class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000957 let Inst{15-10} = 0b010000;
958 let Inst{9-6} = opcode;
959}
960
961// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000962class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000963 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +0000964 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +0000965}
966
967// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +0000968class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000969 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000970 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +0000971}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000972class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +0000973
Bill Wendling1fd374e2010-11-30 22:57:21 +0000974// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +0000975// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +0000976//
Bill Wendling1fd374e2010-11-30 22:57:21 +0000977// 0b0110 => Immediate, 4 bytes
978// 0b1000 => Immediate, 2 bytes
979// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +0000980class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
981 InstrItinClass itin, string opc, string asm,
982 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000983 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000984 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000985 bits<3> Rt;
986 bits<8> addr;
987 let Inst{8-6} = addr{5-3}; // Rm
988 let Inst{5-3} = addr{2-0}; // Rn
989 let Inst{2-0} = Rt;
990}
Bill Wendling40062fb2010-12-01 01:38:08 +0000991class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
992 InstrItinClass itin, string opc, string asm,
993 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +0000994 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +0000995 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +0000996 bits<3> Rt;
997 bits<8> addr;
998 let Inst{10-6} = addr{7-3}; // imm5
999 let Inst{5-3} = addr{2-0}; // Rn
1000 let Inst{2-0} = Rt;
1001}
1002
Johnny Chend68e1192009-12-15 17:24:14 +00001003// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001004class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001005 let Inst{15-12} = 0b1011;
1006 let Inst{11-5} = opcode;
1007}
1008
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001009// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1010class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001011 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001012 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001013 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001014 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001015 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001016 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001017 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001018 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001019}
1020
Bill Wendlingda2ae632010-08-31 07:50:46 +00001021// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1022// input operand since by default it's a zero register. It will become an
1023// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001024//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001025// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1026// more consistent.
1027class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001028 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001029 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001030 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001031 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1032 let Inst{20} = s;
1033
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001034 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001035 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001036 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001037 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001038 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001039}
1040
1041// Special cases
1042class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001043 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001044 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001045 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001046 let OutOperandList = oops;
1047 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001048 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001049 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001050 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001051}
1052
Jim Grosbachd1228742009-12-01 18:10:36 +00001053class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001054 InstrItinClass itin,
1055 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001056 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1057 let OutOperandList = oops;
1058 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001059 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001060 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001061 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001062}
1063
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001064class T2I<dag oops, dag iops, InstrItinClass itin,
1065 string opc, string asm, list<dag> pattern>
1066 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1067class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1068 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001069 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001070class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1071 string opc, string asm, list<dag> pattern>
1072 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1073class T2Iso<dag oops, dag iops, InstrItinClass itin,
1074 string opc, string asm, list<dag> pattern>
1075 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1076class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1077 string opc, string asm, list<dag> pattern>
1078 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001079class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001080 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001081 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1082 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001083 bits<4> Rt;
1084 bits<4> Rt2;
1085 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001086 let Inst{31-25} = 0b1110100;
1087 let Inst{24} = P;
1088 let Inst{23} = addr{8};
1089 let Inst{22} = 1;
1090 let Inst{21} = W;
1091 let Inst{20} = isLoad;
1092 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001093 let Inst{15-12} = Rt{3-0};
1094 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001095 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001096}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001097
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001098class T2sI<dag oops, dag iops, InstrItinClass itin,
1099 string opc, string asm, list<dag> pattern>
1100 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001101
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001102class T2XI<dag oops, dag iops, InstrItinClass itin,
1103 string asm, list<dag> pattern>
1104 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1105class T2JTI<dag oops, dag iops, InstrItinClass itin,
1106 string asm, list<dag> pattern>
1107 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001108
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001109// Move to/from coprocessor instructions
1110class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1111 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1112 let Inst{31-28} = 0b1111;
1113}
1114
Bob Wilson815baeb2010-03-13 01:08:20 +00001115// Two-address instructions
1116class T2XIt<dag oops, dag iops, InstrItinClass itin,
1117 string asm, string cstr, list<dag> pattern>
1118 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001119
Evan Chenge88d5ce2009-07-02 07:28:31 +00001120// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001121class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1122 dag oops, dag iops,
1123 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001124 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001125 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001126 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001127 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001128 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001129 let Pattern = pattern;
1130 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001131 let Inst{31-27} = 0b11111;
1132 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001133 let Inst{24} = signed;
1134 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001135 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001136 let Inst{20} = load;
1137 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001138 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001139 let Inst{10} = pre; // The P bit.
1140 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001141
Owen Anderson6af50f72010-11-30 00:14:31 +00001142 bits<9> addr;
1143 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001144 let Inst{9} = addr{8}; // Sign bit
1145
Owen Anderson6af50f72010-11-30 00:14:31 +00001146 bits<4> Rt;
1147 bits<4> Rn;
1148 let Inst{15-12} = Rt{3-0};
1149 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001150}
1151
David Goodwinc9d138f2009-07-27 19:59:26 +00001152// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1153class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001154 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001155}
1156
1157// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1158class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001159 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001160}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001161
Evan Cheng9cb9e672009-06-27 02:26:13 +00001162// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1163class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001164 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001165}
1166
Evan Cheng13096642008-08-29 06:41:12 +00001167//===----------------------------------------------------------------------===//
1168
Evan Cheng96581d32008-11-11 02:11:05 +00001169//===----------------------------------------------------------------------===//
1170// ARM VFP Instruction templates.
1171//
1172
David Goodwin3ca524e2009-07-10 17:03:29 +00001173// Almost all VFP instructions are predicable.
1174class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001175 IndexMode im, Format f, InstrItinClass itin,
1176 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001177 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001178 bits<4> p;
1179 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001180 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001181 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001182 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001183 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001184 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001185 list<Predicate> Predicates = [HasVFP2];
1186}
1187
1188// Special cases
1189class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001190 IndexMode im, Format f, InstrItinClass itin,
1191 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001192 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001193 bits<4> p;
1194 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001195 let OutOperandList = oops;
1196 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001197 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001198 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001199 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001200 list<Predicate> Predicates = [HasVFP2];
1201}
1202
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001203class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1204 string opc, string asm, list<dag> pattern>
1205 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001206 opc, asm, "", pattern> {
1207 let PostEncoderMethod = "VFPThumb2PostEncoder";
1208}
David Goodwin3ca524e2009-07-10 17:03:29 +00001209
Evan Chengcd8e66a2008-11-11 21:48:44 +00001210// ARM VFP addrmode5 loads and stores
1211class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001212 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001213 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001214 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001215 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001216 // Instruction operands.
1217 bits<5> Dd;
1218 bits<13> addr;
1219
1220 // Encode instruction operands.
1221 let Inst{23} = addr{8}; // U (add = (U == '1'))
1222 let Inst{22} = Dd{4};
1223 let Inst{19-16} = addr{12-9}; // Rn
1224 let Inst{15-12} = Dd{3-0};
1225 let Inst{7-0} = addr{7-0}; // imm8
1226
Evan Cheng96581d32008-11-11 02:11:05 +00001227 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001228 let Inst{27-24} = opcod1;
1229 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001230 let Inst{11-9} = 0b101;
1231 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001232
Evan Cheng5eda2822011-02-16 00:35:02 +00001233 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001234 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001235}
1236
Evan Chengcd8e66a2008-11-11 21:48:44 +00001237class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001238 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001239 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001240 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001241 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001242 // Instruction operands.
1243 bits<5> Sd;
1244 bits<13> addr;
1245
1246 // Encode instruction operands.
1247 let Inst{23} = addr{8}; // U (add = (U == '1'))
1248 let Inst{22} = Sd{0};
1249 let Inst{19-16} = addr{12-9}; // Rn
1250 let Inst{15-12} = Sd{4-1};
1251 let Inst{7-0} = addr{7-0}; // imm8
1252
Evan Cheng96581d32008-11-11 02:11:05 +00001253 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001254 let Inst{27-24} = opcod1;
1255 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001256 let Inst{11-9} = 0b101;
1257 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001258
1259 // Loads & stores operate on both NEON and VFP pipelines.
1260 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001261}
1262
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001263// VFP Load / store multiple pseudo instructions.
1264class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1265 list<dag> pattern>
1266 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1267 cstr, itin> {
1268 let OutOperandList = oops;
1269 let InOperandList = !con(iops, (ins pred:$p));
1270 let Pattern = pattern;
1271 list<Predicate> Predicates = [HasVFP2];
1272}
1273
Evan Chengcd8e66a2008-11-11 21:48:44 +00001274// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001275class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001276 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001277 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001278 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001279 // Instruction operands.
1280 bits<4> Rn;
1281 bits<13> regs;
1282
1283 // Encode instruction operands.
1284 let Inst{19-16} = Rn;
1285 let Inst{22} = regs{12};
1286 let Inst{15-12} = regs{11-8};
1287 let Inst{7-0} = regs{7-0};
1288
Evan Chengcd8e66a2008-11-11 21:48:44 +00001289 // TODO: Mark the instructions with the appropriate subtarget info.
1290 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001291 let Inst{11-9} = 0b101;
1292 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001293}
1294
Jim Grosbach72db1822010-09-08 00:25:50 +00001295class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001296 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001297 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001298 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001299 // Instruction operands.
1300 bits<4> Rn;
1301 bits<13> regs;
1302
1303 // Encode instruction operands.
1304 let Inst{19-16} = Rn;
1305 let Inst{22} = regs{8};
1306 let Inst{15-12} = regs{12-9};
1307 let Inst{7-0} = regs{7-0};
1308
Evan Chengcd8e66a2008-11-11 21:48:44 +00001309 // TODO: Mark the instructions with the appropriate subtarget info.
1310 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001311 let Inst{11-9} = 0b101;
1312 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001313}
1314
Evan Cheng96581d32008-11-11 02:11:05 +00001315// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001316class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1317 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1318 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001319 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001320 // Instruction operands.
1321 bits<5> Dd;
1322 bits<5> Dm;
1323
1324 // Encode instruction operands.
1325 let Inst{3-0} = Dm{3-0};
1326 let Inst{5} = Dm{4};
1327 let Inst{15-12} = Dd{3-0};
1328 let Inst{22} = Dd{4};
1329
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001330 let Inst{27-23} = opcod1;
1331 let Inst{21-20} = opcod2;
1332 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001333 let Inst{11-9} = 0b101;
1334 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001335 let Inst{7-6} = opcod4;
1336 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001337}
1338
1339// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001340class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001341 dag iops, InstrItinClass itin, string opc, string asm,
1342 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001343 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001344 // Instruction operands.
1345 bits<5> Dd;
1346 bits<5> Dn;
1347 bits<5> Dm;
1348
1349 // Encode instruction operands.
1350 let Inst{3-0} = Dm{3-0};
1351 let Inst{5} = Dm{4};
1352 let Inst{19-16} = Dn{3-0};
1353 let Inst{7} = Dn{4};
1354 let Inst{15-12} = Dd{3-0};
1355 let Inst{22} = Dd{4};
1356
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001357 let Inst{27-23} = opcod1;
1358 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001359 let Inst{11-9} = 0b101;
1360 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001361 let Inst{6} = op6;
1362 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001363}
1364
1365// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001366class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1367 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1368 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001369 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001370 // Instruction operands.
1371 bits<5> Sd;
1372 bits<5> Sm;
1373
1374 // Encode instruction operands.
1375 let Inst{3-0} = Sm{4-1};
1376 let Inst{5} = Sm{0};
1377 let Inst{15-12} = Sd{4-1};
1378 let Inst{22} = Sd{0};
1379
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001380 let Inst{27-23} = opcod1;
1381 let Inst{21-20} = opcod2;
1382 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001383 let Inst{11-9} = 0b101;
1384 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001385 let Inst{7-6} = opcod4;
1386 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001387}
1388
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001389// Single precision unary, if no NEON. Same as ASuI except not available if
1390// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001391class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1392 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1393 string asm, list<dag> pattern>
1394 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1395 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001396 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1397}
1398
Evan Cheng96581d32008-11-11 02:11:05 +00001399// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001400class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1401 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001402 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001403 // Instruction operands.
1404 bits<5> Sd;
1405 bits<5> Sn;
1406 bits<5> Sm;
1407
1408 // Encode instruction operands.
1409 let Inst{3-0} = Sm{4-1};
1410 let Inst{5} = Sm{0};
1411 let Inst{19-16} = Sn{4-1};
1412 let Inst{7} = Sn{0};
1413 let Inst{15-12} = Sd{4-1};
1414 let Inst{22} = Sd{0};
1415
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001416 let Inst{27-23} = opcod1;
1417 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001418 let Inst{11-9} = 0b101;
1419 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001420 let Inst{6} = op6;
1421 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001422}
1423
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001424// Single precision binary, if no NEON. Same as ASbI except not available if
1425// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001426class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001427 dag iops, InstrItinClass itin, string opc, string asm,
1428 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001429 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001430 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001431
1432 // Instruction operands.
1433 bits<5> Sd;
1434 bits<5> Sn;
1435 bits<5> Sm;
1436
1437 // Encode instruction operands.
1438 let Inst{3-0} = Sm{4-1};
1439 let Inst{5} = Sm{0};
1440 let Inst{19-16} = Sn{4-1};
1441 let Inst{7} = Sn{0};
1442 let Inst{15-12} = Sd{4-1};
1443 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001444}
1445
Evan Cheng80a11982008-11-12 06:41:41 +00001446// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001447class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1448 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1449 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001450 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001451 let Inst{27-23} = opcod1;
1452 let Inst{21-20} = opcod2;
1453 let Inst{19-16} = opcod3;
1454 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001455 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001456 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001457}
1458
Johnny Chen811663f2010-02-11 18:47:03 +00001459// VFP conversion between floating-point and fixed-point
1460class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001461 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1462 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001463 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1464 // size (fixed-point number): sx == 0 ? 16 : 32
1465 let Inst{7} = op5; // sx
1466}
1467
David Goodwin338268c2009-08-10 22:17:39 +00001468// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001469class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001470 dag oops, dag iops, InstrItinClass itin,
1471 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001472 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1473 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001474 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1475}
1476
Evan Cheng80a11982008-11-12 06:41:41 +00001477class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001478 InstrItinClass itin,
1479 string opc, string asm, list<dag> pattern>
1480 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001481 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001482 let Inst{11-8} = opcod2;
1483 let Inst{4} = 1;
1484}
1485
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001486class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1487 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1488 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001489
Bob Wilson01135592010-03-23 17:23:59 +00001490class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001491 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1492 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001493
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001494class AVConv4I<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, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001497
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001498class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1499 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1500 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001501
Evan Cheng96581d32008-11-11 02:11:05 +00001502//===----------------------------------------------------------------------===//
1503
Bob Wilson5bafff32009-06-22 23:27:02 +00001504//===----------------------------------------------------------------------===//
1505// ARM NEON Instruction templates.
1506//
Evan Cheng13096642008-08-29 06:41:12 +00001507
Johnny Chencaa608e2010-03-20 00:17:00 +00001508class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1509 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1510 list<dag> pattern>
1511 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001512 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001513 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001514 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001515 let Pattern = pattern;
1516 list<Predicate> Predicates = [HasNEON];
1517}
1518
1519// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001520class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1521 InstrItinClass itin, string opc, string asm, string cstr,
1522 list<dag> pattern>
1523 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001524 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001525 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001526 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001527 let Pattern = pattern;
1528 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001529}
1530
Bob Wilsonb07c1712009-10-07 21:53:04 +00001531class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1532 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001533 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001534 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1535 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001536 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001537 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001538 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001539 let Inst{11-8} = op11_8;
1540 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001541
Chris Lattner2ac19022010-11-15 05:19:05 +00001542 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001543
Owen Andersond9aa7d32010-11-02 00:05:05 +00001544 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001545 bits<6> Rn;
1546 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001547
Owen Andersond9aa7d32010-11-02 00:05:05 +00001548 let Inst{22} = Vd{4};
1549 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001550 let Inst{19-16} = Rn{3-0};
1551 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001552}
1553
Owen Andersond138d702010-11-02 20:47:39 +00001554class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1555 dag oops, dag iops, InstrItinClass itin,
1556 string opc, string dt, string asm, string cstr, list<dag> pattern>
1557 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1558 dt, asm, cstr, pattern> {
1559 bits<3> lane;
1560}
1561
Bob Wilson709d5922010-08-25 23:27:42 +00001562class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1563 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1564 itin> {
1565 let OutOperandList = oops;
1566 let InOperandList = !con(iops, (ins pred:$p));
1567 list<Predicate> Predicates = [HasNEON];
1568}
1569
Jim Grosbach7cd27292010-10-06 20:36:55 +00001570class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1571 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001572 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1573 itin> {
1574 let OutOperandList = oops;
1575 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001576 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001577 list<Predicate> Predicates = [HasNEON];
1578}
1579
Johnny Chen785516a2010-03-23 16:43:47 +00001580class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001581 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001582 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1583 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001584 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001585 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001586}
1587
Johnny Chen927b88f2010-03-23 20:40:44 +00001588class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001589 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001590 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001591 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001592 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001593 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001594}
1595
1596// NEON "one register and a modified immediate" format.
1597class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1598 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001599 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001600 string opc, string dt, string asm, string cstr,
1601 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001602 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001603 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001604 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001605 let Inst{11-8} = op11_8;
1606 let Inst{7} = op7;
1607 let Inst{6} = op6;
1608 let Inst{5} = op5;
1609 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001610
Owen Andersona88ea032010-10-26 17:40:54 +00001611 // Instruction operands.
1612 bits<5> Vd;
1613 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001614
Owen Andersona88ea032010-10-26 17:40:54 +00001615 let Inst{15-12} = Vd{3-0};
1616 let Inst{22} = Vd{4};
1617 let Inst{24} = SIMM{7};
1618 let Inst{18-16} = SIMM{6-4};
1619 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001620}
1621
1622// NEON 2 vector register format.
1623class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1624 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001625 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001626 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001627 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001628 let Inst{24-23} = op24_23;
1629 let Inst{21-20} = op21_20;
1630 let Inst{19-18} = op19_18;
1631 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001632 let Inst{11-7} = op11_7;
1633 let Inst{6} = op6;
1634 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001635
Owen Anderson162875a2010-10-25 18:43:52 +00001636 // Instruction operands.
1637 bits<5> Vd;
1638 bits<5> Vm;
1639
1640 let Inst{15-12} = Vd{3-0};
1641 let Inst{22} = Vd{4};
1642 let Inst{3-0} = Vm{3-0};
1643 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001644}
1645
1646// Same as N2V except it doesn't have a datatype suffix.
1647class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001648 bits<5> op11_7, bit op6, bit op4,
1649 dag oops, dag iops, InstrItinClass itin,
1650 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001651 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001652 let Inst{24-23} = op24_23;
1653 let Inst{21-20} = op21_20;
1654 let Inst{19-18} = op19_18;
1655 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001656 let Inst{11-7} = op11_7;
1657 let Inst{6} = op6;
1658 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001659
Owen Anderson162875a2010-10-25 18:43:52 +00001660 // Instruction operands.
1661 bits<5> Vd;
1662 bits<5> Vm;
1663
1664 let Inst{15-12} = Vd{3-0};
1665 let Inst{22} = Vd{4};
1666 let Inst{3-0} = Vm{3-0};
1667 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001668}
1669
1670// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001671class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001672 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001673 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001674 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001675 let Inst{24} = op24;
1676 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001677 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001678 let Inst{7} = op7;
1679 let Inst{6} = op6;
1680 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001681
Owen Anderson3557d002010-10-26 20:56:57 +00001682 // Instruction operands.
1683 bits<5> Vd;
1684 bits<5> Vm;
1685 bits<6> SIMM;
1686
1687 let Inst{15-12} = Vd{3-0};
1688 let Inst{22} = Vd{4};
1689 let Inst{3-0} = Vm{3-0};
1690 let Inst{5} = Vm{4};
1691 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001692}
1693
Bob Wilson10bc69c2010-03-27 03:56:52 +00001694// NEON 3 vector register format.
1695class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1696 dag oops, dag iops, Format f, InstrItinClass itin,
1697 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001698 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001699 let Inst{24} = op24;
1700 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001701 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001702 let Inst{11-8} = op11_8;
1703 let Inst{6} = op6;
1704 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001705
Owen Andersond451f882010-10-21 20:21:49 +00001706 // Instruction operands.
1707 bits<5> Vd;
1708 bits<5> Vn;
1709 bits<5> Vm;
1710
1711 let Inst{15-12} = Vd{3-0};
1712 let Inst{22} = Vd{4};
1713 let Inst{19-16} = Vn{3-0};
1714 let Inst{7} = Vn{4};
1715 let Inst{3-0} = Vm{3-0};
1716 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001717}
1718
Johnny Chen841e8282010-03-23 21:35:03 +00001719// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001720class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1721 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001722 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001723 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001724 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001725 let Inst{24} = op24;
1726 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001727 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001728 let Inst{11-8} = op11_8;
1729 let Inst{6} = op6;
1730 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001731
Owen Anderson8c71eff2010-10-25 18:28:30 +00001732 // Instruction operands.
1733 bits<5> Vd;
1734 bits<5> Vn;
1735 bits<5> Vm;
1736
1737 let Inst{15-12} = Vd{3-0};
1738 let Inst{22} = Vd{4};
1739 let Inst{19-16} = Vn{3-0};
1740 let Inst{7} = Vn{4};
1741 let Inst{3-0} = Vm{3-0};
1742 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001743}
1744
1745// NEON VMOVs between scalar and core registers.
1746class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001747 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001748 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001749 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001750 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001751 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001752 let Inst{11-8} = opcod2;
1753 let Inst{6-5} = opcod3;
1754 let Inst{4} = 1;
Evan Chengf81bf152009-11-23 21:57:23 +00001755
1756 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001757 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001758 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001759 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001760 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001761
Chris Lattner2ac19022010-11-15 05:19:05 +00001762 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001763
Owen Andersond2fbdb72010-10-27 21:28:09 +00001764 bits<5> V;
1765 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001766 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001767 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001768
Owen Andersonf587a9352010-10-27 19:25:54 +00001769 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001770 let Inst{7} = V{4};
1771 let Inst{19-16} = V{3-0};
1772 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001773}
1774class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001775 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001776 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001777 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001778 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001779class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001780 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001781 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001782 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001783 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001784class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001785 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001786 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001787 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001788 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001789
Johnny Chene4614f72010-03-25 17:01:27 +00001790// Vector Duplicate Lane (from scalar to all elements)
1791class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1792 InstrItinClass itin, string opc, string dt, string asm,
1793 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001794 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001795 let Inst{24-23} = 0b11;
1796 let Inst{21-20} = 0b11;
1797 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001798 let Inst{11-7} = 0b11000;
1799 let Inst{6} = op6;
1800 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001801
Owen Andersonf587a9352010-10-27 19:25:54 +00001802 bits<5> Vd;
1803 bits<5> Vm;
1804 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001805
Owen Andersonf587a9352010-10-27 19:25:54 +00001806 let Inst{22} = Vd{4};
1807 let Inst{15-12} = Vd{3-0};
1808 let Inst{5} = Vm{4};
1809 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001810}
1811
David Goodwin42a83f22009-08-04 17:53:06 +00001812// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1813// for single-precision FP.
1814class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1815 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1816}