blob: c4b42bd85c1ca6ece78523ec7cb84b9795785690 [file] [log] [blame]
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson01135592010-03-23 17:23:59 +00002//
Evan Cheng37f25d92008-08-28 23:39:26 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilson01135592010-03-23 17:23:59 +00007//
Evan Cheng37f25d92008-08-28 23:39:26 +00008//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
Bob Wilson89ef7b72010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng37f25d92008-08-28 23:39:26 +000020}
21
Evan Chengffa6d962008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng37f25d92008-08-28 23:39:26 +000026
Evan Chengffa6d962008-11-13 23:36:57 +000027def DPFrm : Format<4>;
28def DPSoRegFrm : Format<5>;
Evan Cheng37f25d92008-08-28 23:39:26 +000029
Evan Chengffa6d962008-11-13 23:36:57 +000030def LdFrm : Format<6>;
31def StFrm : Format<7>;
32def LdMiscFrm : Format<8>;
33def StMiscFrm : Format<9>;
34def LdStMulFrm : Format<10>;
Evan Cheng37f25d92008-08-28 23:39:26 +000035
Johnny Chen81f04d52010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5278eb82009-12-11 01:42:04 +000037
Johnny Chen81f04d52010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson9a1c1892010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000041
Bob Wilson9a1c1892010-08-11 00:01:18 +000042def VFPUnaryFrm : Format<15>;
43def VFPBinaryFrm : Format<16>;
44def VFPConv1Frm : Format<17>;
45def VFPConv2Frm : Format<18>;
46def VFPConv3Frm : Format<19>;
47def VFPConv4Frm : Format<20>;
48def VFPConv5Frm : Format<21>;
49def VFPLdStFrm : Format<22>;
50def VFPLdStMulFrm : Format<23>;
51def VFPMiscFrm : Format<24>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000052
Bob Wilson9a1c1892010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng37f25d92008-08-28 23:39:26 +000055
Bob Wilson9a1c1892010-08-11 00:01:18 +000056def NGetLnFrm : Format<27>;
57def NSetLnFrm : Format<28>;
58def NDupFrm : Format<29>;
59def NLdStFrm : Format<30>;
60def N1RegModImmFrm: Format<31>;
61def N2RegFrm : Format<32>;
62def NVCVTFrm : Format<33>;
63def NVDupLnFrm : Format<34>;
64def N2RegVShLFrm : Format<35>;
65def N2RegVShRFrm : Format<36>;
66def N3RegFrm : Format<37>;
67def N3RegVShFrm : Format<38>;
68def NVExtFrm : Format<39>;
69def NVMulSLFrm : Format<40>;
70def NVTBLFrm : Format<41>;
Johnny Chencaa608e2010-03-20 00:17:00 +000071
Evan Cheng34a0fa32009-07-08 01:46:35 +000072// Misc flags.
73
Bill Wendling43f7b2d2010-12-01 02:42:55 +000074// The instruction has an Rn register operand.
Evan Cheng34a0fa32009-07-08 01:46:35 +000075// UnaryDP - Indicates this is a unary data processing instruction, i.e.
76// it doesn't have a Rn operand.
77class UnaryDP { bit isUnaryDataProc = 1; }
78
79// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80// a 16-bit Thumb instruction if certain conditions are met.
81class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng37f25d92008-08-28 23:39:26 +000082
Evan Cheng37f25d92008-08-28 23:39:26 +000083//===----------------------------------------------------------------------===//
Bob Wilson50622ce2010-03-18 23:57:57 +000084// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Cheng055b0312009-06-29 07:51:04 +000085//
86
Jim Grosbachff12a8b2011-01-18 19:59:19 +000087// FIXME: Once the JIT is MC-ized, these can go away.
Evan Cheng055b0312009-06-29 07:51:04 +000088// Addressing mode.
Jim Grosbachd86609f2010-10-05 18:14:55 +000089class AddrMode<bits<5> val> {
90 bits<5> Value = val;
Evan Cheng055b0312009-06-29 07:51:04 +000091}
Bill Wendlingda2ae632010-08-31 07:50:46 +000092def AddrModeNone : AddrMode<0>;
93def AddrMode1 : AddrMode<1>;
94def AddrMode2 : AddrMode<2>;
95def AddrMode3 : AddrMode<3>;
96def AddrMode4 : AddrMode<4>;
97def AddrMode5 : AddrMode<5>;
98def AddrMode6 : AddrMode<6>;
99def AddrModeT1_1 : AddrMode<7>;
100def AddrModeT1_2 : AddrMode<8>;
101def AddrModeT1_4 : AddrMode<9>;
102def AddrModeT1_s : AddrMode<10>;
103def AddrModeT2_i12 : AddrMode<11>;
104def AddrModeT2_i8 : AddrMode<12>;
105def AddrModeT2_so : AddrMode<13>;
106def AddrModeT2_pc : AddrMode<14>;
Bob Wilson8b024a52009-07-01 23:16:05 +0000107def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach3e556122010-10-26 22:37:02 +0000108def AddrMode_i12 : AddrMode<16>;
Evan Cheng055b0312009-06-29 07:51:04 +0000109
110// Instruction size.
111class SizeFlagVal<bits<3> val> {
112 bits<3> Value = val;
113}
114def SizeInvalid : SizeFlagVal<0>; // Unset.
115def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
116def Size8Bytes : SizeFlagVal<2>;
117def Size4Bytes : SizeFlagVal<3>;
118def Size2Bytes : SizeFlagVal<4>;
119
120// Load / store index mode.
121class IndexMode<bits<2> val> {
122 bits<2> Value = val;
123}
124def IndexModeNone : IndexMode<0>;
125def IndexModePre : IndexMode<1>;
126def IndexModePost : IndexMode<2>;
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000127def IndexModeUpd : IndexMode<3>;
Evan Cheng055b0312009-06-29 07:51:04 +0000128
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000129// Instruction execution domain.
Evan Cheng6557bce2011-02-22 19:53:14 +0000130class Domain<bits<3> val> {
131 bits<3> Value = val;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000132}
133def GenericDomain : Domain<0>;
134def VFPDomain : Domain<1>; // Instructions in VFP domain only
135def NeonDomain : Domain<2>; // Instructions in Neon domain only
136def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng2b943562011-02-23 02:35:33 +0000137def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000138
Evan Cheng055b0312009-06-29 07:51:04 +0000139//===----------------------------------------------------------------------===//
Evan Cheng446c4282009-07-11 06:43:01 +0000140// ARM special operands.
141//
142
Daniel Dunbar8462b302010-08-11 06:36:53 +0000143def CondCodeOperand : AsmOperandClass {
144 let Name = "CondCode";
145 let SuperClasses = [];
146}
147
Jim Grosbachd67641b2010-12-06 18:21:12 +0000148def CCOutOperand : AsmOperandClass {
149 let Name = "CCOut";
150 let SuperClasses = [];
151}
152
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000153def MemBarrierOptOperand : AsmOperandClass {
154 let Name = "MemBarrierOpt";
155 let SuperClasses = [];
Jim Grosbachf922c472011-02-12 01:34:40 +0000156 let ParserMethod = "tryParseMemBarrierOptOperand";
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000157}
158
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000159def ProcIFlagsOperand : AsmOperandClass {
160 let Name = "ProcIFlags";
161 let SuperClasses = [];
162 let ParserMethod = "tryParseProcIFlagsOperand";
163}
164
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000165def MSRMaskOperand : AsmOperandClass {
166 let Name = "MSRMask";
167 let SuperClasses = [];
168 let ParserMethod = "tryParseMSRMaskOperand";
169}
170
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000171// ARM imod and iflag operands, used only by the CPS instruction.
172def imod_op : Operand<i32> {
173 let PrintMethod = "printCPSIMod";
174}
175
176def iflags_op : Operand<i32> {
177 let PrintMethod = "printCPSIFlag";
178 let ParserMatchClass = ProcIFlagsOperand;
179}
180
Evan Cheng446c4282009-07-11 06:43:01 +0000181// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
182// register whose default is 0 (no register).
183def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
184 (ops (i32 14), (i32 zero_reg))> {
185 let PrintMethod = "printPredicateOperand";
Daniel Dunbar8462b302010-08-11 06:36:53 +0000186 let ParserMatchClass = CondCodeOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000187}
188
189// Conditional code result for instructions whose 's' bit is set, e.g. subs.
190def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000191 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000192 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000193 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000194}
195
196// Same as cc_out except it defaults to setting CPSR.
197def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000198 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000199 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000200 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000201}
202
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000203// ARM special operands for disassembly only.
204//
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000205def setend_op : Operand<i32> {
206 let PrintMethod = "printSetendOperand";
207}
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000208
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000209def msr_mask : Operand<i32> {
210 let PrintMethod = "printMSRMaskOperand";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000211 let ParserMatchClass = MSRMaskOperand;
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000212}
213
Bill Wendling3116dce2011-03-07 23:38:41 +0000214// Shift Right Immediate - A shift right immediate is encoded differently from
215// other shift immediates. The imm6 field is encoded like so:
Bill Wendlinga656b632011-03-01 01:00:59 +0000216//
Bill Wendling3116dce2011-03-07 23:38:41 +0000217// Offset Encoding
218// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
219// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
220// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
221// 64 64 - <imm> is encoded in imm6<5:0>
222def shr_imm8 : Operand<i32> {
223 let EncoderMethod = "getShiftRight8Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000224}
Bill Wendling3116dce2011-03-07 23:38:41 +0000225def shr_imm16 : Operand<i32> {
226 let EncoderMethod = "getShiftRight16Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000227}
Bill Wendling3116dce2011-03-07 23:38:41 +0000228def shr_imm32 : Operand<i32> {
229 let EncoderMethod = "getShiftRight32Imm";
230}
231def shr_imm64 : Operand<i32> {
232 let EncoderMethod = "getShiftRight64Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000233}
234
Evan Cheng446c4282009-07-11 06:43:01 +0000235//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000236// ARM Instruction templates.
237//
238
Johnny Chend68e1192009-12-15 17:24:14 +0000239class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
240 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000241 : Instruction {
242 let Namespace = "ARM";
243
Evan Cheng37f25d92008-08-28 23:39:26 +0000244 AddrMode AM = am;
Evan Cheng37f25d92008-08-28 23:39:26 +0000245 SizeFlagVal SZ = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000246 IndexMode IM = im;
247 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000248 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000249 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000250 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000251 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000252 bit canXformTo16Bit = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +0000253
Chris Lattner150d20e2010-10-31 19:22:57 +0000254 // If this is a pseudo instruction, mark it isCodeGenOnly.
255 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson01135592010-03-23 17:23:59 +0000256
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000257 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000258 let TSFlags{4-0} = AM.Value;
259 let TSFlags{7-5} = SZ.Value;
260 let TSFlags{9-8} = IndexModeBits;
261 let TSFlags{15-10} = Form;
262 let TSFlags{16} = isUnaryDataProc;
263 let TSFlags{17} = canXformTo16Bit;
Evan Cheng6557bce2011-02-22 19:53:14 +0000264 let TSFlags{20-18} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000265
Evan Cheng37f25d92008-08-28 23:39:26 +0000266 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000267 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000268}
269
Johnny Chend68e1192009-12-15 17:24:14 +0000270class Encoding {
271 field bits<32> Inst;
272}
273
274class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
275 Format f, Domain d, string cstr, InstrItinClass itin>
276 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
277
278// This Encoding-less class is used by Thumb1 to specify the encoding bits later
279// on by adding flavors to specific instructions.
280class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
281 Format f, Domain d, string cstr, InstrItinClass itin>
282 : InstTemplate<am, sz, im, f, d, cstr, itin>;
283
Jim Grosbach99594eb2010-11-18 01:38:26 +0000284class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Jim Grosbachd1689ae2011-07-06 21:35:46 +0000285 : InstTemplate<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo,
286 GenericDomain, "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000287 let OutOperandList = oops;
288 let InOperandList = iops;
Evan Cheng37f25d92008-08-28 23:39:26 +0000289 let Pattern = pattern;
Jim Grosbacha768c3d2011-03-10 19:06:39 +0000290 let isCodeGenOnly = 1;
Jim Grosbachd1689ae2011-07-06 21:35:46 +0000291 let isPseudo = 1;
Evan Cheng37f25d92008-08-28 23:39:26 +0000292}
293
Jim Grosbach53694262010-11-18 01:15:56 +0000294// PseudoInst that's ARM-mode only.
Jim Grosbach6e422112010-11-29 23:48:41 +0000295class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
Jim Grosbach99594eb2010-11-18 01:38:26 +0000296 list<dag> pattern>
297 : PseudoInst<oops, iops, itin, pattern> {
Jim Grosbach6e422112010-11-29 23:48:41 +0000298 let SZ = sz;
Jim Grosbach53694262010-11-18 01:15:56 +0000299 list<Predicate> Predicates = [IsARM];
300}
301
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000302// PseudoInst that's Thumb-mode only.
303class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
304 list<dag> pattern>
305 : PseudoInst<oops, iops, itin, pattern> {
306 let SZ = sz;
307 list<Predicate> Predicates = [IsThumb];
308}
Jim Grosbach53694262010-11-18 01:15:56 +0000309
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000310// PseudoInst that's Thumb2-mode only.
311class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
312 list<dag> pattern>
313 : PseudoInst<oops, iops, itin, pattern> {
314 let SZ = sz;
315 list<Predicate> Predicates = [IsThumb2];
316}
Jim Grosbach53e3fc42011-07-08 17:40:42 +0000317
318class ARMPseudoExpand<dag oops, dag iops, SizeFlagVal sz,
319 InstrItinClass itin, list<dag> pattern,
320 dag Result>
321 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
322 PseudoInstExpansion<Result>;
323
324class tPseudoExpand<dag oops, dag iops, SizeFlagVal sz,
325 InstrItinClass itin, list<dag> pattern,
326 dag Result>
327 : tPseudoInst<oops, iops, sz, itin, pattern>,
328 PseudoInstExpansion<Result>;
329
330class t2PseudoExpand<dag oops, dag iops, SizeFlagVal sz,
331 InstrItinClass itin, list<dag> pattern,
332 dag Result>
333 : t2PseudoInst<oops, iops, sz, itin, pattern>,
334 PseudoInstExpansion<Result>;
335
Evan Cheng37f25d92008-08-28 23:39:26 +0000336// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000337class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000338 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000339 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000340 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000341 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000342 bits<4> p;
343 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000344 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000345 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000346 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000347 let Pattern = pattern;
348 list<Predicate> Predicates = [IsARM];
349}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000350
Jim Grosbachf6b28622009-12-14 18:31:20 +0000351// A few are not predicable
352class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000353 IndexMode im, Format f, InstrItinClass itin,
354 string opc, string asm, string cstr,
355 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000356 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
357 let OutOperandList = oops;
358 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000359 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000360 let Pattern = pattern;
361 let isPredicable = 0;
362 list<Predicate> Predicates = [IsARM];
363}
Evan Cheng37f25d92008-08-28 23:39:26 +0000364
Bill Wendling4822bce2010-08-30 01:47:35 +0000365// Same as I except it can optionally modify CPSR. Note it's modeled as an input
366// operand since by default it's a zero register. It will become an implicit def
367// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000368class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000369 IndexMode im, Format f, InstrItinClass itin,
370 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000371 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000372 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000373 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000374 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000375 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000376 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000377
Evan Cheng37f25d92008-08-28 23:39:26 +0000378 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000379 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000380 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000381 let Pattern = pattern;
382 list<Predicate> Predicates = [IsARM];
383}
384
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000385// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000386class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000387 IndexMode im, Format f, InstrItinClass itin,
388 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000389 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000390 let OutOperandList = oops;
391 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000392 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000393 let Pattern = pattern;
394 list<Predicate> Predicates = [IsARM];
395}
396
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000397class AI<dag oops, dag iops, Format f, InstrItinClass itin,
398 string opc, string asm, list<dag> pattern>
399 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
400 opc, asm, "", pattern>;
401class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
402 string opc, string asm, list<dag> pattern>
403 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
404 opc, asm, "", pattern>;
405class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000406 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000407 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000408 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000409class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000410 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000411 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000412 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000413
414// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000415class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
416 string opc, string asm, list<dag> pattern>
417 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
418 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000419 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000420}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000421class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
422 string asm, list<dag> pattern>
423 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
424 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000425 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000426}
Evan Cheng3aac7882008-09-01 08:25:56 +0000427
428// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000429class JTI<dag oops, dag iops, InstrItinClass itin,
430 string asm, list<dag> pattern>
431 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000432 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000433
Jim Grosbach5278eb82009-12-11 01:42:04 +0000434// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000435class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
436 string opc, string asm, list<dag> pattern>
437 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
438 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000439 bits<4> Rt;
440 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000441 let Inst{27-23} = 0b00011;
442 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000443 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000444 let Inst{19-16} = Rn;
445 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000446 let Inst{11-0} = 0b111110011111;
447}
448class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
449 string opc, string asm, list<dag> pattern>
450 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
451 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000452 bits<4> Rd;
453 bits<4> Rt;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000454 bits<4> addr;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000455 let Inst{27-23} = 0b00011;
456 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000457 let Inst{20} = 0;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000458 let Inst{19-16} = addr;
Jim Grosbach86875a22010-10-29 19:58:57 +0000459 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000460 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000461 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000462}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000463class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
464 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
465 bits<4> Rt;
466 bits<4> Rt2;
467 bits<4> Rn;
468 let Inst{27-23} = 0b00010;
469 let Inst{22} = b;
470 let Inst{21-20} = 0b00;
471 let Inst{19-16} = Rn;
472 let Inst{15-12} = Rt;
473 let Inst{11-4} = 0b00001001;
474 let Inst{3-0} = Rt2;
475}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000476
Evan Cheng0d14fc82008-09-01 01:51:14 +0000477// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000478class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
480 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
481 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000482 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000483 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000484}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000485class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
486 string opc, string asm, list<dag> pattern>
487 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
488 opc, asm, "", pattern> {
489 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000490 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000491}
492class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000493 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000494 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000495 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000496 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000497 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000498}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000499
Evan Cheng93912732008-09-01 01:27:33 +0000500// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000501
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000502// LDR/LDRB/STR/STRB/...
503class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000504 Format f, InstrItinClass itin, string opc, string asm,
505 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000506 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
507 "", pattern> {
508 let Inst{27-25} = op;
509 let Inst{24} = 1; // 24 == P
510 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000511 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000512 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000513 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000514}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000515// Indexed load/stores
516class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000517 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000518 string asm, string cstr, list<dag> pattern>
519 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
520 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000521 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000522 let Inst{27-26} = 0b01;
523 let Inst{24} = isPre; // P bit
524 let Inst{22} = isByte; // B bit
525 let Inst{21} = isPre; // W bit
526 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000527 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000528}
Jim Grosbach953557f42010-11-19 21:35:06 +0000529class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
530 IndexMode im, Format f, InstrItinClass itin, string opc,
531 string asm, string cstr, list<dag> pattern>
532 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
533 pattern> {
534 // AM2 store w/ two operands: (GPR, am2offset)
535 // {13} 1 == Rm, 0 == imm12
536 // {12} isAdd
537 // {11-0} imm12/Rm
Bruno Cardoso Lopesb41aaab2011-03-31 15:54:36 +0000538 bits<14> offset;
539 bits<4> Rn;
540 let Inst{25} = offset{13};
541 let Inst{23} = offset{12};
542 let Inst{19-16} = Rn;
543 let Inst{11-0} = offset{11-0};
Jim Grosbach953557f42010-11-19 21:35:06 +0000544}
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000545// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
546// but for now use this class for STRT and STRBT.
547class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
548 IndexMode im, Format f, InstrItinClass itin, string opc,
549 string asm, string cstr, list<dag> pattern>
550 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
551 pattern> {
552 // AM2 store w/ two operands: (GPR, am2offset)
553 // {17-14} Rn
554 // {13} 1 == Rm, 0 == imm12
555 // {12} isAdd
556 // {11-0} imm12/Rm
557 bits<18> addr;
558 let Inst{25} = addr{13};
559 let Inst{23} = addr{12};
560 let Inst{19-16} = addr{17-14};
561 let Inst{11-0} = addr{11-0};
562}
Jim Grosbach3e556122010-10-26 22:37:02 +0000563
Evan Cheng0d14fc82008-09-01 01:51:14 +0000564// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000565class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
566 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach160f8f02010-11-18 00:46:58 +0000567 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
568 opc, asm, "", pattern> {
569 bits<14> addr;
570 bits<4> Rt;
571 let Inst{27-25} = 0b000;
572 let Inst{24} = 1; // P bit
573 let Inst{23} = addr{8}; // U bit
574 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
575 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000576 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000577 let Inst{19-16} = addr{12-9}; // Rn
578 let Inst{15-12} = Rt; // Rt
579 let Inst{11-8} = addr{7-4}; // imm7_4/zero
580 let Inst{7-4} = op;
581 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
582}
Evan Cheng840917b2008-09-01 07:00:14 +0000583
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000584class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
585 IndexMode im, Format f, InstrItinClass itin, string opc,
586 string asm, string cstr, list<dag> pattern>
587 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
588 opc, asm, cstr, pattern> {
589 bits<4> Rt;
590 let Inst{27-25} = 0b000;
591 let Inst{24} = isPre; // P bit
592 let Inst{21} = isPre; // W bit
593 let Inst{20} = op20; // L bit
594 let Inst{15-12} = Rt; // Rt
595 let Inst{7-4} = op;
596}
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000597
598// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
599// but for now use this class for LDRSBT, LDRHT, LDSHT.
600class AI3ldstidxT<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
601 IndexMode im, Format f, InstrItinClass itin, string opc,
602 string asm, string cstr, list<dag> pattern>
603 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
604 opc, asm, cstr, pattern> {
605 // {13} 1 == imm8, 0 == Rm
606 // {12-9} Rn
607 // {8} isAdd
608 // {7-4} imm7_4/zero
609 // {3-0} imm3_0/Rm
610 bits<14> addr;
611 bits<4> Rt;
612 let Inst{27-25} = 0b000;
613 let Inst{24} = isPre; // P bit
614 let Inst{23} = addr{8}; // U bit
615 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
616 let Inst{20} = op20; // L bit
617 let Inst{19-16} = addr{12-9}; // Rn
618 let Inst{15-12} = Rt; // Rt
619 let Inst{11-8} = addr{7-4}; // imm7_4/zero
620 let Inst{7-4} = op;
621 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
622 let AsmMatchConverter = "CvtLdWriteBackRegAddrMode3";
623}
624
Jim Grosbach2dc77682010-11-29 18:37:44 +0000625class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
626 IndexMode im, Format f, InstrItinClass itin, string opc,
627 string asm, string cstr, list<dag> pattern>
628 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
629 pattern> {
630 // AM3 store w/ two operands: (GPR, am3offset)
631 bits<14> offset;
632 bits<4> Rt;
633 bits<4> Rn;
634 let Inst{27-25} = 0b000;
635 let Inst{23} = offset{8};
636 let Inst{22} = offset{9};
637 let Inst{19-16} = Rn;
638 let Inst{15-12} = Rt; // Rt
639 let Inst{11-8} = offset{7-4}; // imm7_4/zero
640 let Inst{7-4} = op;
641 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
642}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000643
Evan Cheng840917b2008-09-01 07:00:14 +0000644// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000645class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000646 string opc, string asm, list<dag> pattern>
647 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
648 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000649 bits<14> addr;
650 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000651 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000652 let Inst{24} = 1; // P bit
653 let Inst{23} = addr{8}; // U bit
654 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
655 let Inst{21} = 0; // W bit
656 let Inst{20} = 0; // L bit
657 let Inst{19-16} = addr{12-9}; // Rn
658 let Inst{15-12} = Rt; // Rt
659 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000660 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000661 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000662}
Evan Cheng840917b2008-09-01 07:00:14 +0000663
Evan Cheng840917b2008-09-01 07:00:14 +0000664// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000665class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
666 string opc, string asm, string cstr, list<dag> pattern>
667 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
668 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000669 let Inst{4} = 1;
670 let Inst{5} = 1; // H bit
671 let Inst{6} = 0; // S bit
672 let Inst{7} = 1;
673 let Inst{20} = 0; // L bit
674 let Inst{21} = 1; // W bit
675 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000676 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000677}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000678class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
679 string opc, string asm, string cstr, list<dag> pattern>
680 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
681 opc, asm, cstr, pattern> {
682 let Inst{4} = 1;
683 let Inst{5} = 1; // H bit
684 let Inst{6} = 1; // S bit
685 let Inst{7} = 1;
686 let Inst{20} = 0; // L bit
687 let Inst{21} = 1; // W bit
688 let Inst{24} = 1; // P bit
689 let Inst{27-25} = 0b000;
690}
Evan Cheng840917b2008-09-01 07:00:14 +0000691
Evan Cheng840917b2008-09-01 07:00:14 +0000692// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000693class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
694 string opc, string asm, string cstr, list<dag> pattern>
695 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
696 opc, asm, cstr,pattern> {
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000697 // {13} 1 == imm8, 0 == Rm
698 // {12-9} Rn
699 // {8} isAdd
700 // {7-4} imm7_4/zero
701 // {3-0} imm3_0/Rm
702 bits<14> addr;
703 bits<4> Rt;
704 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000705 let Inst{4} = 1;
706 let Inst{5} = 1; // H bit
707 let Inst{6} = 0; // S bit
708 let Inst{7} = 1;
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000709 let Inst{11-8} = addr{7-4}; // imm7_4/zero
710 let Inst{15-12} = Rt; // Rt
711 let Inst{19-16} = addr{12-9}; // Rn
Evan Cheng840917b2008-09-01 07:00:14 +0000712 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000713 let Inst{21} = 0; // W bit
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000714 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
715 let Inst{23} = addr{8}; // U bit
Evan Cheng840917b2008-09-01 07:00:14 +0000716 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000717 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000718}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000719class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
720 string opc, string asm, string cstr, list<dag> pattern>
721 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
722 opc, asm, cstr, pattern> {
723 let Inst{4} = 1;
724 let Inst{5} = 1; // H bit
725 let Inst{6} = 1; // S bit
726 let Inst{7} = 1;
727 let Inst{20} = 0; // L bit
728 let Inst{21} = 0; // W bit
729 let Inst{24} = 0; // P bit
730 let Inst{27-25} = 0b000;
731}
Evan Cheng840917b2008-09-01 07:00:14 +0000732
Evan Cheng0d14fc82008-09-01 01:51:14 +0000733// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000734class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
735 string asm, string cstr, list<dag> pattern>
736 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
737 bits<4> p;
738 bits<16> regs;
739 bits<4> Rn;
740 let Inst{31-28} = p;
741 let Inst{27-25} = 0b100;
742 let Inst{22} = 0; // S bit
743 let Inst{19-16} = Rn;
744 let Inst{15-0} = regs;
745}
Evan Cheng37f25d92008-08-28 23:39:26 +0000746
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000747// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000748class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
749 string opc, string asm, list<dag> pattern>
750 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
751 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000752 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000753 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000754 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000755}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000756class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
757 string opc, string asm, list<dag> pattern>
758 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
759 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000760 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000761 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000762}
763
764// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000765class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
766 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000767 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
768 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000769 bits<4> Rd;
770 bits<4> Rn;
771 bits<4> Rm;
772 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000773 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000774 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000775 let Inst{19-16} = Rd;
776 let Inst{11-8} = Rm;
777 let Inst{3-0} = Rn;
778}
779// MSW multiple w/ Ra operand
780class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
781 InstrItinClass itin, string opc, string asm, list<dag> pattern>
782 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
783 bits<4> Ra;
784 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000785}
Evan Cheng37f25d92008-08-28 23:39:26 +0000786
Evan Chengeb4f52e2008-11-06 03:35:07 +0000787// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000788class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000789 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000790 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
791 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000792 bits<4> Rn;
793 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000794 let Inst{4} = 0;
795 let Inst{7} = 1;
796 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000797 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000798 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000799 let Inst{11-8} = Rm;
800 let Inst{3-0} = Rn;
801}
802class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
803 InstrItinClass itin, string opc, string asm, list<dag> pattern>
804 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
805 bits<4> Rd;
806 let Inst{19-16} = Rd;
807}
808
809// AMulxyI with Ra operand
810class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
811 InstrItinClass itin, string opc, string asm, list<dag> pattern>
812 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
813 bits<4> Ra;
814 let Inst{15-12} = Ra;
815}
816// SMLAL*
817class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
818 InstrItinClass itin, string opc, string asm, list<dag> pattern>
819 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
820 bits<4> RdLo;
821 bits<4> RdHi;
822 let Inst{19-16} = RdHi;
823 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000824}
825
Evan Cheng97f48c32008-11-06 22:15:19 +0000826// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000827class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
828 string opc, string asm, list<dag> pattern>
829 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
830 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000831 // All AExtI instructions have Rd and Rm register operands.
832 bits<4> Rd;
833 bits<4> Rm;
834 let Inst{15-12} = Rd;
835 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000836 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000837 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000838 let Inst{27-20} = opcod;
839}
840
Evan Cheng8b59db32008-11-07 01:41:35 +0000841// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000842class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
843 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000844 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
845 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000846 bits<4> Rd;
847 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000848 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000849 let Inst{19-16} = 0b1111;
850 let Inst{15-12} = Rd;
851 let Inst{11-8} = 0b1111;
852 let Inst{7-4} = opc7_4;
853 let Inst{3-0} = Rm;
854}
855
856// PKH instructions
857class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
858 string opc, string asm, list<dag> pattern>
859 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
860 opc, asm, "", pattern> {
861 bits<4> Rd;
862 bits<4> Rn;
863 bits<4> Rm;
864 bits<8> sh;
865 let Inst{27-20} = opcod;
866 let Inst{19-16} = Rn;
867 let Inst{15-12} = Rd;
868 let Inst{11-7} = sh{7-3};
869 let Inst{6} = tb;
870 let Inst{5-4} = 0b01;
871 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000872}
873
Evan Cheng37f25d92008-08-28 23:39:26 +0000874//===----------------------------------------------------------------------===//
875
876// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
877class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
878 list<Predicate> Predicates = [IsARM];
879}
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +0000880class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
881 list<Predicate> Predicates = [IsARM, HasV5T];
882}
Evan Cheng37f25d92008-08-28 23:39:26 +0000883class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
884 list<Predicate> Predicates = [IsARM, HasV5TE];
885}
886class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
887 list<Predicate> Predicates = [IsARM, HasV6];
888}
Evan Cheng13096642008-08-29 06:41:12 +0000889
890//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000891// Thumb Instruction Format Definitions.
892//
893
Evan Cheng446c4282009-07-11 06:43:01 +0000894class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000895 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000896 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000897 let OutOperandList = oops;
898 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000899 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000900 let Pattern = pattern;
901 list<Predicate> Predicates = [IsThumb];
902}
903
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000904// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000905class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
906 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000907
Evan Cheng35d6c412009-08-04 23:47:55 +0000908// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000909class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
910 list<dag> pattern>
911 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
912 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000913
Johnny Chend68e1192009-12-15 17:24:14 +0000914// tBL, tBX 32-bit instructions
915class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000916 dag oops, dag iops, InstrItinClass itin, string asm,
917 list<dag> pattern>
918 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
919 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000920 let Inst{31-27} = opcod1;
921 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000922 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000923}
Evan Cheng13096642008-08-29 06:41:12 +0000924
925// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000926class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
927 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000928 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000929
Evan Cheng09c39fc2009-06-23 19:38:13 +0000930// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +0000931class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000932 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000933 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000934 let OutOperandList = oops;
935 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000936 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000937 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000938 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000939}
940
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000941class T1I<dag oops, dag iops, InstrItinClass itin,
942 string asm, list<dag> pattern>
943 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
944class T1Ix2<dag oops, dag iops, InstrItinClass itin,
945 string asm, list<dag> pattern>
946 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000947
948// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000949class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000950 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000951 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000952 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000953
954// Thumb1 instruction that can either be predicated or set CPSR.
955class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000956 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000957 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000958 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000959 let OutOperandList = !con(oops, (outs s_cc_out:$s));
960 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000961 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000962 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000963 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000964}
965
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000966class T1sI<dag oops, dag iops, InstrItinClass itin,
967 string opc, string asm, list<dag> pattern>
968 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000969
970// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000971class T1sIt<dag oops, dag iops, InstrItinClass itin,
972 string opc, string asm, list<dag> pattern>
973 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000974 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000975
976// Thumb1 instruction that can be predicated.
977class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000978 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000979 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000980 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000981 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000982 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000983 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000984 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000985 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000986}
987
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000988class T1pI<dag oops, dag iops, InstrItinClass itin,
989 string opc, string asm, list<dag> pattern>
990 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000991
992// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000993class T1pIt<dag oops, dag iops, InstrItinClass itin,
994 string opc, string asm, list<dag> pattern>
995 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000996 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000997
Bob Wilson01135592010-03-23 17:23:59 +0000998class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000999 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1000 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +00001001
Johnny Chenbbc71b22009-12-16 02:32:54 +00001002class Encoding16 : Encoding {
1003 let Inst{31-16} = 0x0000;
1004}
1005
Johnny Chend68e1192009-12-15 17:24:14 +00001006// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +00001007class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001008 let Inst{15-10} = opcode;
1009}
1010
1011// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001012class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001013 let Inst{15-14} = 0b00;
1014 let Inst{13-9} = opcode;
1015}
1016
1017// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001018class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001019 let Inst{15-10} = 0b010000;
1020 let Inst{9-6} = opcode;
1021}
1022
1023// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001024class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001025 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +00001026 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +00001027}
1028
1029// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001030class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001031 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001032 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +00001033}
Bill Wendlingda2ae632010-08-31 07:50:46 +00001034class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +00001035
Eric Christopher33281b22011-05-27 03:50:53 +00001036class T1BranchCond<bits<4> opcode> : Encoding16 {
1037 let Inst{15-12} = opcode;
1038}
1039
Bill Wendling1fd374e2010-11-30 22:57:21 +00001040// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +00001041// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001042//
Bill Wendling1fd374e2010-11-30 22:57:21 +00001043// 0b0110 => Immediate, 4 bytes
1044// 0b1000 => Immediate, 2 bytes
1045// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +00001046class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1047 InstrItinClass itin, string opc, string asm,
1048 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +00001049 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001050 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001051 bits<3> Rt;
1052 bits<8> addr;
1053 let Inst{8-6} = addr{5-3}; // Rm
1054 let Inst{5-3} = addr{2-0}; // Rn
1055 let Inst{2-0} = Rt;
1056}
Bill Wendling40062fb2010-12-01 01:38:08 +00001057class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1058 InstrItinClass itin, string opc, string asm,
1059 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +00001060 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001061 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001062 bits<3> Rt;
1063 bits<8> addr;
1064 let Inst{10-6} = addr{7-3}; // imm5
1065 let Inst{5-3} = addr{2-0}; // Rn
1066 let Inst{2-0} = Rt;
1067}
1068
Johnny Chend68e1192009-12-15 17:24:14 +00001069// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001070class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001071 let Inst{15-12} = 0b1011;
1072 let Inst{11-5} = opcode;
1073}
1074
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001075// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1076class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001077 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001078 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001079 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001080 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001081 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001082 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001083 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001084 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001085}
1086
Bill Wendlingda2ae632010-08-31 07:50:46 +00001087// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1088// input operand since by default it's a zero register. It will become an
1089// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001090//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001091// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1092// more consistent.
1093class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001094 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001095 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001096 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001097 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1098 let Inst{20} = s;
1099
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001100 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001101 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001102 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001103 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001104 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001105}
1106
1107// Special cases
1108class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001109 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001110 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001111 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001112 let OutOperandList = oops;
1113 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001114 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001115 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001116 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001117}
1118
Jim Grosbachd1228742009-12-01 18:10:36 +00001119class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001120 InstrItinClass itin,
1121 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001122 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1123 let OutOperandList = oops;
1124 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001125 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001126 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001127 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001128}
1129
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001130class T2I<dag oops, dag iops, InstrItinClass itin,
1131 string opc, string asm, list<dag> pattern>
1132 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1133class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1134 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001135 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001136class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1137 string opc, string asm, list<dag> pattern>
1138 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1139class T2Iso<dag oops, dag iops, InstrItinClass itin,
1140 string opc, string asm, list<dag> pattern>
1141 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1142class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1143 string opc, string asm, list<dag> pattern>
1144 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001145class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001146 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001147 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1148 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001149 bits<4> Rt;
1150 bits<4> Rt2;
1151 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001152 let Inst{31-25} = 0b1110100;
1153 let Inst{24} = P;
1154 let Inst{23} = addr{8};
1155 let Inst{22} = 1;
1156 let Inst{21} = W;
1157 let Inst{20} = isLoad;
1158 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001159 let Inst{15-12} = Rt{3-0};
1160 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001161 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001162}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001163
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001164class T2sI<dag oops, dag iops, InstrItinClass itin,
1165 string opc, string asm, list<dag> pattern>
1166 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001167
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001168class T2XI<dag oops, dag iops, InstrItinClass itin,
1169 string asm, list<dag> pattern>
1170 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1171class T2JTI<dag oops, dag iops, InstrItinClass itin,
1172 string asm, list<dag> pattern>
1173 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001174
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001175// Move to/from coprocessor instructions
Jim Grosbach9bb098a2011-07-13 21:14:23 +00001176class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
1177 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
1178 let Inst{31-28} = 0b1110;
1179}
1180
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001181class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbach9bb098a2011-07-13 21:14:23 +00001182 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001183 let Inst{31-28} = 0b1111;
1184}
1185
Bob Wilson815baeb2010-03-13 01:08:20 +00001186// Two-address instructions
1187class T2XIt<dag oops, dag iops, InstrItinClass itin,
1188 string asm, string cstr, list<dag> pattern>
1189 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001190
Evan Chenge88d5ce2009-07-02 07:28:31 +00001191// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001192class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1193 dag oops, dag iops,
1194 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001195 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001196 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001197 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001198 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001199 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001200 let Pattern = pattern;
1201 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001202 let Inst{31-27} = 0b11111;
1203 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001204 let Inst{24} = signed;
1205 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001206 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001207 let Inst{20} = load;
1208 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001209 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001210 let Inst{10} = pre; // The P bit.
1211 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001212
Owen Anderson6af50f72010-11-30 00:14:31 +00001213 bits<9> addr;
1214 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001215 let Inst{9} = addr{8}; // Sign bit
1216
Owen Anderson6af50f72010-11-30 00:14:31 +00001217 bits<4> Rt;
1218 bits<4> Rn;
1219 let Inst{15-12} = Rt{3-0};
1220 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001221}
1222
David Goodwinc9d138f2009-07-27 19:59:26 +00001223// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1224class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001225 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001226}
1227
1228// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1229class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001230 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001231}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001232
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +00001233// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1234class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1235 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1236}
1237
Evan Cheng9cb9e672009-06-27 02:26:13 +00001238// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1239class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001240 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001241}
1242
Evan Cheng13096642008-08-29 06:41:12 +00001243//===----------------------------------------------------------------------===//
1244
Evan Cheng96581d32008-11-11 02:11:05 +00001245//===----------------------------------------------------------------------===//
1246// ARM VFP Instruction templates.
1247//
1248
David Goodwin3ca524e2009-07-10 17:03:29 +00001249// Almost all VFP instructions are predicable.
1250class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001251 IndexMode im, Format f, InstrItinClass itin,
1252 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001253 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001254 bits<4> p;
1255 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001256 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001257 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001258 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001259 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001260 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001261 list<Predicate> Predicates = [HasVFP2];
1262}
1263
1264// Special cases
1265class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001266 IndexMode im, Format f, InstrItinClass itin,
1267 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001268 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001269 bits<4> p;
1270 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001271 let OutOperandList = oops;
1272 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001273 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001274 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001275 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001276 list<Predicate> Predicates = [HasVFP2];
1277}
1278
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001279class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1280 string opc, string asm, list<dag> pattern>
1281 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001282 opc, asm, "", pattern> {
1283 let PostEncoderMethod = "VFPThumb2PostEncoder";
1284}
David Goodwin3ca524e2009-07-10 17:03:29 +00001285
Evan Chengcd8e66a2008-11-11 21:48:44 +00001286// ARM VFP addrmode5 loads and stores
1287class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001288 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001289 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001290 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001291 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001292 // Instruction operands.
1293 bits<5> Dd;
1294 bits<13> addr;
1295
1296 // Encode instruction operands.
1297 let Inst{23} = addr{8}; // U (add = (U == '1'))
1298 let Inst{22} = Dd{4};
1299 let Inst{19-16} = addr{12-9}; // Rn
1300 let Inst{15-12} = Dd{3-0};
1301 let Inst{7-0} = addr{7-0}; // imm8
1302
Evan Cheng96581d32008-11-11 02:11:05 +00001303 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001304 let Inst{27-24} = opcod1;
1305 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001306 let Inst{11-9} = 0b101;
1307 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001308
Evan Cheng5eda2822011-02-16 00:35:02 +00001309 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001310 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001311}
1312
Evan Chengcd8e66a2008-11-11 21:48:44 +00001313class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001314 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001315 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001316 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001317 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001318 // Instruction operands.
1319 bits<5> Sd;
1320 bits<13> addr;
1321
1322 // Encode instruction operands.
1323 let Inst{23} = addr{8}; // U (add = (U == '1'))
1324 let Inst{22} = Sd{0};
1325 let Inst{19-16} = addr{12-9}; // Rn
1326 let Inst{15-12} = Sd{4-1};
1327 let Inst{7-0} = addr{7-0}; // imm8
1328
Evan Cheng96581d32008-11-11 02:11:05 +00001329 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001330 let Inst{27-24} = opcod1;
1331 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001332 let Inst{11-9} = 0b101;
1333 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001334
1335 // Loads & stores operate on both NEON and VFP pipelines.
1336 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001337}
1338
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001339// VFP Load / store multiple pseudo instructions.
1340class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1341 list<dag> pattern>
1342 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1343 cstr, itin> {
1344 let OutOperandList = oops;
1345 let InOperandList = !con(iops, (ins pred:$p));
1346 let Pattern = pattern;
1347 list<Predicate> Predicates = [HasVFP2];
1348}
1349
Evan Chengcd8e66a2008-11-11 21:48:44 +00001350// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001351class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001352 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001353 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001354 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001355 // Instruction operands.
1356 bits<4> Rn;
1357 bits<13> regs;
1358
1359 // Encode instruction operands.
1360 let Inst{19-16} = Rn;
1361 let Inst{22} = regs{12};
1362 let Inst{15-12} = regs{11-8};
1363 let Inst{7-0} = regs{7-0};
1364
Evan Chengcd8e66a2008-11-11 21:48:44 +00001365 // TODO: Mark the instructions with the appropriate subtarget info.
1366 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001367 let Inst{11-9} = 0b101;
1368 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001369}
1370
Jim Grosbach72db1822010-09-08 00:25:50 +00001371class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001372 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001373 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001374 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001375 // Instruction operands.
1376 bits<4> Rn;
1377 bits<13> regs;
1378
1379 // Encode instruction operands.
1380 let Inst{19-16} = Rn;
1381 let Inst{22} = regs{8};
1382 let Inst{15-12} = regs{12-9};
1383 let Inst{7-0} = regs{7-0};
1384
Evan Chengcd8e66a2008-11-11 21:48:44 +00001385 // TODO: Mark the instructions with the appropriate subtarget info.
1386 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001387 let Inst{11-9} = 0b101;
1388 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001389}
1390
Evan Cheng96581d32008-11-11 02:11:05 +00001391// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001392class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1393 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1394 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001395 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001396 // Instruction operands.
1397 bits<5> Dd;
1398 bits<5> Dm;
1399
1400 // Encode instruction operands.
1401 let Inst{3-0} = Dm{3-0};
1402 let Inst{5} = Dm{4};
1403 let Inst{15-12} = Dd{3-0};
1404 let Inst{22} = Dd{4};
1405
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001406 let Inst{27-23} = opcod1;
1407 let Inst{21-20} = opcod2;
1408 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001409 let Inst{11-9} = 0b101;
1410 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001411 let Inst{7-6} = opcod4;
1412 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001413}
1414
1415// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001416class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001417 dag iops, InstrItinClass itin, string opc, string asm,
1418 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001419 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001420 // Instruction operands.
1421 bits<5> Dd;
1422 bits<5> Dn;
1423 bits<5> Dm;
1424
1425 // Encode instruction operands.
1426 let Inst{3-0} = Dm{3-0};
1427 let Inst{5} = Dm{4};
1428 let Inst{19-16} = Dn{3-0};
1429 let Inst{7} = Dn{4};
1430 let Inst{15-12} = Dd{3-0};
1431 let Inst{22} = Dd{4};
1432
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001433 let Inst{27-23} = opcod1;
1434 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001435 let Inst{11-9} = 0b101;
1436 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001437 let Inst{6} = op6;
1438 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001439}
1440
1441// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001442class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1443 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1444 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001445 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001446 // Instruction operands.
1447 bits<5> Sd;
1448 bits<5> Sm;
1449
1450 // Encode instruction operands.
1451 let Inst{3-0} = Sm{4-1};
1452 let Inst{5} = Sm{0};
1453 let Inst{15-12} = Sd{4-1};
1454 let Inst{22} = Sd{0};
1455
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001456 let Inst{27-23} = opcod1;
1457 let Inst{21-20} = opcod2;
1458 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001459 let Inst{11-9} = 0b101;
1460 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001461 let Inst{7-6} = opcod4;
1462 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001463}
1464
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001465// Single precision unary, if no NEON. Same as ASuI except not available if
1466// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001467class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1468 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1469 string asm, list<dag> pattern>
1470 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1471 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001472 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1473}
1474
Evan Cheng96581d32008-11-11 02:11:05 +00001475// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001476class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1477 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001478 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001479 // Instruction operands.
1480 bits<5> Sd;
1481 bits<5> Sn;
1482 bits<5> Sm;
1483
1484 // Encode instruction operands.
1485 let Inst{3-0} = Sm{4-1};
1486 let Inst{5} = Sm{0};
1487 let Inst{19-16} = Sn{4-1};
1488 let Inst{7} = Sn{0};
1489 let Inst{15-12} = Sd{4-1};
1490 let Inst{22} = Sd{0};
1491
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001492 let Inst{27-23} = opcod1;
1493 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001494 let Inst{11-9} = 0b101;
1495 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001496 let Inst{6} = op6;
1497 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001498}
1499
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001500// Single precision binary, if no NEON. Same as ASbI except not available if
1501// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001502class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001503 dag iops, InstrItinClass itin, string opc, string asm,
1504 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001505 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001506 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001507
1508 // Instruction operands.
1509 bits<5> Sd;
1510 bits<5> Sn;
1511 bits<5> Sm;
1512
1513 // Encode instruction operands.
1514 let Inst{3-0} = Sm{4-1};
1515 let Inst{5} = Sm{0};
1516 let Inst{19-16} = Sn{4-1};
1517 let Inst{7} = Sn{0};
1518 let Inst{15-12} = Sd{4-1};
1519 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001520}
1521
Evan Cheng80a11982008-11-12 06:41:41 +00001522// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001523class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1524 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1525 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001526 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001527 let Inst{27-23} = opcod1;
1528 let Inst{21-20} = opcod2;
1529 let Inst{19-16} = opcod3;
1530 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001531 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001532 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001533}
1534
Johnny Chen811663f2010-02-11 18:47:03 +00001535// VFP conversion between floating-point and fixed-point
1536class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001537 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1538 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001539 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1540 // size (fixed-point number): sx == 0 ? 16 : 32
1541 let Inst{7} = op5; // sx
1542}
1543
David Goodwin338268c2009-08-10 22:17:39 +00001544// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001545class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001546 dag oops, dag iops, InstrItinClass itin,
1547 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001548 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1549 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001550 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1551}
1552
Evan Cheng80a11982008-11-12 06:41:41 +00001553class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001554 InstrItinClass itin,
1555 string opc, string asm, list<dag> pattern>
1556 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001557 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001558 let Inst{11-8} = opcod2;
1559 let Inst{4} = 1;
1560}
1561
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001562class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1563 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1564 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001565
Bob Wilson01135592010-03-23 17:23:59 +00001566class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001567 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1568 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001569
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001570class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1571 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1572 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001573
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001574class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1575 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1576 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001577
Evan Cheng96581d32008-11-11 02:11:05 +00001578//===----------------------------------------------------------------------===//
1579
Bob Wilson5bafff32009-06-22 23:27:02 +00001580//===----------------------------------------------------------------------===//
1581// ARM NEON Instruction templates.
1582//
Evan Cheng13096642008-08-29 06:41:12 +00001583
Johnny Chencaa608e2010-03-20 00:17:00 +00001584class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1585 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1586 list<dag> pattern>
1587 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001588 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001589 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001590 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001591 let Pattern = pattern;
1592 list<Predicate> Predicates = [HasNEON];
1593}
1594
1595// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001596class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1597 InstrItinClass itin, string opc, string asm, string cstr,
1598 list<dag> pattern>
1599 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001600 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001601 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001602 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001603 let Pattern = pattern;
1604 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001605}
1606
Bob Wilsonb07c1712009-10-07 21:53:04 +00001607class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1608 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001609 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001610 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1611 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001612 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001613 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001614 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001615 let Inst{11-8} = op11_8;
1616 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001617
Chris Lattner2ac19022010-11-15 05:19:05 +00001618 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001619
Owen Andersond9aa7d32010-11-02 00:05:05 +00001620 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001621 bits<6> Rn;
1622 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001623
Owen Andersond9aa7d32010-11-02 00:05:05 +00001624 let Inst{22} = Vd{4};
1625 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001626 let Inst{19-16} = Rn{3-0};
1627 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001628}
1629
Owen Andersond138d702010-11-02 20:47:39 +00001630class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1631 dag oops, dag iops, InstrItinClass itin,
1632 string opc, string dt, string asm, string cstr, list<dag> pattern>
1633 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1634 dt, asm, cstr, pattern> {
1635 bits<3> lane;
1636}
1637
Bob Wilson709d5922010-08-25 23:27:42 +00001638class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1639 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1640 itin> {
1641 let OutOperandList = oops;
1642 let InOperandList = !con(iops, (ins pred:$p));
1643 list<Predicate> Predicates = [HasNEON];
1644}
1645
Jim Grosbach7cd27292010-10-06 20:36:55 +00001646class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1647 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001648 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1649 itin> {
1650 let OutOperandList = oops;
1651 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001652 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001653 list<Predicate> Predicates = [HasNEON];
1654}
1655
Johnny Chen785516a2010-03-23 16:43:47 +00001656class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001657 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001658 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1659 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001660 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001661 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001662}
1663
Johnny Chen927b88f2010-03-23 20:40:44 +00001664class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001665 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001666 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001667 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001668 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001669 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001670}
1671
1672// NEON "one register and a modified immediate" format.
1673class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1674 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001675 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001676 string opc, string dt, string asm, string cstr,
1677 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001678 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001679 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001680 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001681 let Inst{11-8} = op11_8;
1682 let Inst{7} = op7;
1683 let Inst{6} = op6;
1684 let Inst{5} = op5;
1685 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001686
Owen Andersona88ea032010-10-26 17:40:54 +00001687 // Instruction operands.
1688 bits<5> Vd;
1689 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001690
Owen Andersona88ea032010-10-26 17:40:54 +00001691 let Inst{15-12} = Vd{3-0};
1692 let Inst{22} = Vd{4};
1693 let Inst{24} = SIMM{7};
1694 let Inst{18-16} = SIMM{6-4};
1695 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001696}
1697
1698// NEON 2 vector register format.
1699class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1700 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001701 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001702 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001703 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001704 let Inst{24-23} = op24_23;
1705 let Inst{21-20} = op21_20;
1706 let Inst{19-18} = op19_18;
1707 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001708 let Inst{11-7} = op11_7;
1709 let Inst{6} = op6;
1710 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001711
Owen Anderson162875a2010-10-25 18:43:52 +00001712 // Instruction operands.
1713 bits<5> Vd;
1714 bits<5> Vm;
1715
1716 let Inst{15-12} = Vd{3-0};
1717 let Inst{22} = Vd{4};
1718 let Inst{3-0} = Vm{3-0};
1719 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001720}
1721
1722// Same as N2V except it doesn't have a datatype suffix.
1723class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001724 bits<5> op11_7, bit op6, bit op4,
1725 dag oops, dag iops, InstrItinClass itin,
1726 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001727 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001728 let Inst{24-23} = op24_23;
1729 let Inst{21-20} = op21_20;
1730 let Inst{19-18} = op19_18;
1731 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001732 let Inst{11-7} = op11_7;
1733 let Inst{6} = op6;
1734 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001735
Owen Anderson162875a2010-10-25 18:43:52 +00001736 // Instruction operands.
1737 bits<5> Vd;
1738 bits<5> Vm;
1739
1740 let Inst{15-12} = Vd{3-0};
1741 let Inst{22} = Vd{4};
1742 let Inst{3-0} = Vm{3-0};
1743 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001744}
1745
1746// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001747class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001748 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001749 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001750 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001751 let Inst{24} = op24;
1752 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001753 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001754 let Inst{7} = op7;
1755 let Inst{6} = op6;
1756 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001757
Owen Anderson3557d002010-10-26 20:56:57 +00001758 // Instruction operands.
1759 bits<5> Vd;
1760 bits<5> Vm;
1761 bits<6> SIMM;
1762
1763 let Inst{15-12} = Vd{3-0};
1764 let Inst{22} = Vd{4};
1765 let Inst{3-0} = Vm{3-0};
1766 let Inst{5} = Vm{4};
1767 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001768}
1769
Bob Wilson10bc69c2010-03-27 03:56:52 +00001770// NEON 3 vector register format.
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001771
Jim Grosbach6635b042011-05-19 17:34:53 +00001772class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1773 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1774 string opc, string dt, string asm, string cstr,
1775 list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001776 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001777 let Inst{24} = op24;
1778 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001779 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001780 let Inst{11-8} = op11_8;
1781 let Inst{6} = op6;
1782 let Inst{4} = op4;
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001783}
1784
1785class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1786 dag oops, dag iops, Format f, InstrItinClass itin,
1787 string opc, string dt, string asm, string cstr, list<dag> pattern>
1788 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1789 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001790
Owen Andersond451f882010-10-21 20:21:49 +00001791 // Instruction operands.
1792 bits<5> Vd;
1793 bits<5> Vn;
1794 bits<5> Vm;
1795
1796 let Inst{15-12} = Vd{3-0};
1797 let Inst{22} = Vd{4};
1798 let Inst{19-16} = Vn{3-0};
1799 let Inst{7} = Vn{4};
1800 let Inst{3-0} = Vm{3-0};
1801 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001802}
1803
Jim Grosbach6635b042011-05-19 17:34:53 +00001804class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1805 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1806 string opc, string dt, string asm, string cstr,
1807 list<dag> pattern>
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001808 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1809 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1810
1811 // Instruction operands.
1812 bits<5> Vd;
1813 bits<5> Vn;
1814 bits<5> Vm;
1815 bit lane;
1816
1817 let Inst{15-12} = Vd{3-0};
1818 let Inst{22} = Vd{4};
1819 let Inst{19-16} = Vn{3-0};
1820 let Inst{7} = Vn{4};
1821 let Inst{3-0} = Vm{3-0};
1822 let Inst{5} = lane;
1823}
1824
Jim Grosbach6635b042011-05-19 17:34:53 +00001825class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1826 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1827 string opc, string dt, string asm, string cstr,
1828 list<dag> pattern>
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001829 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1830 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1831
1832 // Instruction operands.
1833 bits<5> Vd;
1834 bits<5> Vn;
1835 bits<5> Vm;
1836 bits<2> lane;
1837
1838 let Inst{15-12} = Vd{3-0};
1839 let Inst{22} = Vd{4};
1840 let Inst{19-16} = Vn{3-0};
1841 let Inst{7} = Vn{4};
1842 let Inst{2-0} = Vm{2-0};
1843 let Inst{5} = lane{1};
1844 let Inst{3} = lane{0};
1845}
1846
Johnny Chen841e8282010-03-23 21:35:03 +00001847// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001848class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1849 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001850 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001851 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001852 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001853 let Inst{24} = op24;
1854 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001855 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001856 let Inst{11-8} = op11_8;
1857 let Inst{6} = op6;
1858 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001859
Owen Anderson8c71eff2010-10-25 18:28:30 +00001860 // Instruction operands.
1861 bits<5> Vd;
1862 bits<5> Vn;
1863 bits<5> Vm;
1864
1865 let Inst{15-12} = Vd{3-0};
1866 let Inst{22} = Vd{4};
1867 let Inst{19-16} = Vn{3-0};
1868 let Inst{7} = Vn{4};
1869 let Inst{3-0} = Vm{3-0};
1870 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001871}
1872
1873// NEON VMOVs between scalar and core registers.
1874class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001875 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001876 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001877 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001878 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001879 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001880 let Inst{11-8} = opcod2;
1881 let Inst{6-5} = opcod3;
1882 let Inst{4} = 1;
Johnny Chena9611542011-04-06 18:27:46 +00001883 // A8.6.303, A8.6.328, A8.6.329
1884 let Inst{3-0} = 0b0000;
Evan Chengf81bf152009-11-23 21:57:23 +00001885
1886 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001887 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001888 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001889 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001890 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001891
Chris Lattner2ac19022010-11-15 05:19:05 +00001892 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001893
Owen Andersond2fbdb72010-10-27 21:28:09 +00001894 bits<5> V;
1895 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001896 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001897 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001898
Owen Andersonf587a9352010-10-27 19:25:54 +00001899 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001900 let Inst{7} = V{4};
1901 let Inst{19-16} = V{3-0};
1902 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001903}
1904class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001905 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001906 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001907 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001908 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001909class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001910 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001911 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001912 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001913 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001914class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001915 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001916 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001917 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001918 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001919
Johnny Chene4614f72010-03-25 17:01:27 +00001920// Vector Duplicate Lane (from scalar to all elements)
1921class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1922 InstrItinClass itin, string opc, string dt, string asm,
1923 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001924 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001925 let Inst{24-23} = 0b11;
1926 let Inst{21-20} = 0b11;
1927 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001928 let Inst{11-7} = 0b11000;
1929 let Inst{6} = op6;
1930 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001931
Owen Andersonf587a9352010-10-27 19:25:54 +00001932 bits<5> Vd;
1933 bits<5> Vm;
1934 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001935
Owen Andersonf587a9352010-10-27 19:25:54 +00001936 let Inst{22} = Vd{4};
1937 let Inst{15-12} = Vd{3-0};
1938 let Inst{5} = Vm{4};
1939 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001940}
1941
David Goodwin42a83f22009-08-04 17:53:06 +00001942// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1943// for single-precision FP.
1944class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1945 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1946}