blob: 088c8153a2f20be8598b8f628ff2387c224d47b9 [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}
Evan Cheng37f25d92008-08-28 23:39:26 +0000317// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000318class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000319 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000320 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000321 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000322 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000323 bits<4> p;
324 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000325 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000326 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000327 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000328 let Pattern = pattern;
329 list<Predicate> Predicates = [IsARM];
330}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000331
Jim Grosbachf6b28622009-12-14 18:31:20 +0000332// A few are not predicable
333class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000334 IndexMode im, Format f, InstrItinClass itin,
335 string opc, string asm, string cstr,
336 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000337 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
338 let OutOperandList = oops;
339 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000340 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000341 let Pattern = pattern;
342 let isPredicable = 0;
343 list<Predicate> Predicates = [IsARM];
344}
Evan Cheng37f25d92008-08-28 23:39:26 +0000345
Bill Wendling4822bce2010-08-30 01:47:35 +0000346// Same as I except it can optionally modify CPSR. Note it's modeled as an input
347// operand since by default it's a zero register. It will become an implicit def
348// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000349class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000350 IndexMode im, Format f, InstrItinClass itin,
351 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000352 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000353 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000354 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000355 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000356 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000357 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000358
Evan Cheng37f25d92008-08-28 23:39:26 +0000359 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000360 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000361 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000362 let Pattern = pattern;
363 list<Predicate> Predicates = [IsARM];
364}
365
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000366// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000367class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000368 IndexMode im, Format f, InstrItinClass itin,
369 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000370 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000371 let OutOperandList = oops;
372 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000373 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000374 let Pattern = pattern;
375 list<Predicate> Predicates = [IsARM];
376}
377
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000378class AI<dag oops, dag iops, Format f, InstrItinClass itin,
379 string opc, string asm, list<dag> pattern>
380 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
381 opc, asm, "", pattern>;
382class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
383 string opc, string asm, list<dag> pattern>
384 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
385 opc, asm, "", pattern>;
386class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000387 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000388 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000389 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000390class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000391 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000392 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000393 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000394
395// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000396class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
397 string opc, string asm, list<dag> pattern>
398 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
399 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000400 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000401}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000402class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
403 string asm, list<dag> pattern>
404 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
405 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000406 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000407}
Evan Cheng3aac7882008-09-01 08:25:56 +0000408
409// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000410class JTI<dag oops, dag iops, InstrItinClass itin,
411 string asm, list<dag> pattern>
412 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000413 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000414
Jim Grosbach5278eb82009-12-11 01:42:04 +0000415// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000416class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
417 string opc, string asm, list<dag> pattern>
418 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
419 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000420 bits<4> Rt;
421 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000422 let Inst{27-23} = 0b00011;
423 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000424 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000425 let Inst{19-16} = Rn;
426 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000427 let Inst{11-0} = 0b111110011111;
428}
429class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
430 string opc, string asm, list<dag> pattern>
431 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
432 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000433 bits<4> Rd;
434 bits<4> Rt;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000435 bits<4> addr;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000436 let Inst{27-23} = 0b00011;
437 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000438 let Inst{20} = 0;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000439 let Inst{19-16} = addr;
Jim Grosbach86875a22010-10-29 19:58:57 +0000440 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000441 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000442 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000443}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000444class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
445 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
446 bits<4> Rt;
447 bits<4> Rt2;
448 bits<4> Rn;
449 let Inst{27-23} = 0b00010;
450 let Inst{22} = b;
451 let Inst{21-20} = 0b00;
452 let Inst{19-16} = Rn;
453 let Inst{15-12} = Rt;
454 let Inst{11-4} = 0b00001001;
455 let Inst{3-0} = Rt2;
456}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000457
Evan Cheng0d14fc82008-09-01 01:51:14 +0000458// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000459class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
460 string opc, string asm, list<dag> pattern>
461 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
462 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000463 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000464 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000465}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000466class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
467 string opc, string asm, list<dag> pattern>
468 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
469 opc, asm, "", pattern> {
470 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000471 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000472}
473class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000474 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000475 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000476 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000477 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000478 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000479}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000480
Evan Cheng93912732008-09-01 01:27:33 +0000481// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000482
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000483// LDR/LDRB/STR/STRB/...
484class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000485 Format f, InstrItinClass itin, string opc, string asm,
486 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000487 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
488 "", pattern> {
489 let Inst{27-25} = op;
490 let Inst{24} = 1; // 24 == P
491 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000492 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000493 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000494 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000495}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000496// Indexed load/stores
497class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000498 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000499 string asm, string cstr, list<dag> pattern>
500 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
501 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000502 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000503 let Inst{27-26} = 0b01;
504 let Inst{24} = isPre; // P bit
505 let Inst{22} = isByte; // B bit
506 let Inst{21} = isPre; // W bit
507 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000508 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000509}
Jim Grosbach953557f42010-11-19 21:35:06 +0000510class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
511 IndexMode im, Format f, InstrItinClass itin, string opc,
512 string asm, string cstr, list<dag> pattern>
513 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
514 pattern> {
515 // AM2 store w/ two operands: (GPR, am2offset)
516 // {13} 1 == Rm, 0 == imm12
517 // {12} isAdd
518 // {11-0} imm12/Rm
Bruno Cardoso Lopesb41aaab2011-03-31 15:54:36 +0000519 bits<14> offset;
520 bits<4> Rn;
521 let Inst{25} = offset{13};
522 let Inst{23} = offset{12};
523 let Inst{19-16} = Rn;
524 let Inst{11-0} = offset{11-0};
Jim Grosbach953557f42010-11-19 21:35:06 +0000525}
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000526// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
527// but for now use this class for STRT and STRBT.
528class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
529 IndexMode im, Format f, InstrItinClass itin, string opc,
530 string asm, string cstr, list<dag> pattern>
531 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
532 pattern> {
533 // AM2 store w/ two operands: (GPR, am2offset)
534 // {17-14} Rn
535 // {13} 1 == Rm, 0 == imm12
536 // {12} isAdd
537 // {11-0} imm12/Rm
538 bits<18> addr;
539 let Inst{25} = addr{13};
540 let Inst{23} = addr{12};
541 let Inst{19-16} = addr{17-14};
542 let Inst{11-0} = addr{11-0};
543}
Jim Grosbach3e556122010-10-26 22:37:02 +0000544
Evan Cheng0d14fc82008-09-01 01:51:14 +0000545// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000546class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
547 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach160f8f02010-11-18 00:46:58 +0000548 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
549 opc, asm, "", pattern> {
550 bits<14> addr;
551 bits<4> Rt;
552 let Inst{27-25} = 0b000;
553 let Inst{24} = 1; // P bit
554 let Inst{23} = addr{8}; // U bit
555 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
556 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000557 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000558 let Inst{19-16} = addr{12-9}; // Rn
559 let Inst{15-12} = Rt; // Rt
560 let Inst{11-8} = addr{7-4}; // imm7_4/zero
561 let Inst{7-4} = op;
562 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
563}
Evan Cheng840917b2008-09-01 07:00:14 +0000564
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000565class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
566 IndexMode im, Format f, InstrItinClass itin, string opc,
567 string asm, string cstr, list<dag> pattern>
568 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
569 opc, asm, cstr, pattern> {
570 bits<4> Rt;
571 let Inst{27-25} = 0b000;
572 let Inst{24} = isPre; // P bit
573 let Inst{21} = isPre; // W bit
574 let Inst{20} = op20; // L bit
575 let Inst{15-12} = Rt; // Rt
576 let Inst{7-4} = op;
577}
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000578
579// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
580// but for now use this class for LDRSBT, LDRHT, LDSHT.
581class AI3ldstidxT<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
582 IndexMode im, Format f, InstrItinClass itin, string opc,
583 string asm, string cstr, list<dag> pattern>
584 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
585 opc, asm, cstr, pattern> {
586 // {13} 1 == imm8, 0 == Rm
587 // {12-9} Rn
588 // {8} isAdd
589 // {7-4} imm7_4/zero
590 // {3-0} imm3_0/Rm
591 bits<14> addr;
592 bits<4> Rt;
593 let Inst{27-25} = 0b000;
594 let Inst{24} = isPre; // P bit
595 let Inst{23} = addr{8}; // U bit
596 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
597 let Inst{20} = op20; // L bit
598 let Inst{19-16} = addr{12-9}; // Rn
599 let Inst{15-12} = Rt; // Rt
600 let Inst{11-8} = addr{7-4}; // imm7_4/zero
601 let Inst{7-4} = op;
602 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
603 let AsmMatchConverter = "CvtLdWriteBackRegAddrMode3";
604}
605
Jim Grosbach2dc77682010-11-29 18:37:44 +0000606class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
607 IndexMode im, Format f, InstrItinClass itin, string opc,
608 string asm, string cstr, list<dag> pattern>
609 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
610 pattern> {
611 // AM3 store w/ two operands: (GPR, am3offset)
612 bits<14> offset;
613 bits<4> Rt;
614 bits<4> Rn;
615 let Inst{27-25} = 0b000;
616 let Inst{23} = offset{8};
617 let Inst{22} = offset{9};
618 let Inst{19-16} = Rn;
619 let Inst{15-12} = Rt; // Rt
620 let Inst{11-8} = offset{7-4}; // imm7_4/zero
621 let Inst{7-4} = op;
622 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
623}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000624
Evan Cheng840917b2008-09-01 07:00:14 +0000625// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000626class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000627 string opc, string asm, list<dag> pattern>
628 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
629 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000630 bits<14> addr;
631 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000632 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000633 let Inst{24} = 1; // P bit
634 let Inst{23} = addr{8}; // U bit
635 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
636 let Inst{21} = 0; // W bit
637 let Inst{20} = 0; // L bit
638 let Inst{19-16} = addr{12-9}; // Rn
639 let Inst{15-12} = Rt; // Rt
640 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000641 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000642 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000643}
Evan Cheng840917b2008-09-01 07:00:14 +0000644
Evan Cheng840917b2008-09-01 07:00:14 +0000645// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000646class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
647 string opc, string asm, string cstr, list<dag> pattern>
648 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
649 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000650 let Inst{4} = 1;
651 let Inst{5} = 1; // H bit
652 let Inst{6} = 0; // S bit
653 let Inst{7} = 1;
654 let Inst{20} = 0; // L bit
655 let Inst{21} = 1; // W bit
656 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000657 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000658}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000659class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
660 string opc, string asm, string cstr, list<dag> pattern>
661 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
662 opc, asm, cstr, pattern> {
663 let Inst{4} = 1;
664 let Inst{5} = 1; // H bit
665 let Inst{6} = 1; // S bit
666 let Inst{7} = 1;
667 let Inst{20} = 0; // L bit
668 let Inst{21} = 1; // W bit
669 let Inst{24} = 1; // P bit
670 let Inst{27-25} = 0b000;
671}
Evan Cheng840917b2008-09-01 07:00:14 +0000672
Evan Cheng840917b2008-09-01 07:00:14 +0000673// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000674class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
675 string opc, string asm, string cstr, list<dag> pattern>
676 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
677 opc, asm, cstr,pattern> {
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000678 // {13} 1 == imm8, 0 == Rm
679 // {12-9} Rn
680 // {8} isAdd
681 // {7-4} imm7_4/zero
682 // {3-0} imm3_0/Rm
683 bits<14> addr;
684 bits<4> Rt;
685 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000686 let Inst{4} = 1;
687 let Inst{5} = 1; // H bit
688 let Inst{6} = 0; // S bit
689 let Inst{7} = 1;
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000690 let Inst{11-8} = addr{7-4}; // imm7_4/zero
691 let Inst{15-12} = Rt; // Rt
692 let Inst{19-16} = addr{12-9}; // Rn
Evan Cheng840917b2008-09-01 07:00:14 +0000693 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000694 let Inst{21} = 0; // W bit
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000695 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
696 let Inst{23} = addr{8}; // U bit
Evan Cheng840917b2008-09-01 07:00:14 +0000697 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000698 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000699}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000700class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
701 string opc, string asm, string cstr, list<dag> pattern>
702 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
703 opc, asm, cstr, pattern> {
704 let Inst{4} = 1;
705 let Inst{5} = 1; // H bit
706 let Inst{6} = 1; // S bit
707 let Inst{7} = 1;
708 let Inst{20} = 0; // L bit
709 let Inst{21} = 0; // W bit
710 let Inst{24} = 0; // P bit
711 let Inst{27-25} = 0b000;
712}
Evan Cheng840917b2008-09-01 07:00:14 +0000713
Evan Cheng0d14fc82008-09-01 01:51:14 +0000714// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000715class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
716 string asm, string cstr, list<dag> pattern>
717 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
718 bits<4> p;
719 bits<16> regs;
720 bits<4> Rn;
721 let Inst{31-28} = p;
722 let Inst{27-25} = 0b100;
723 let Inst{22} = 0; // S bit
724 let Inst{19-16} = Rn;
725 let Inst{15-0} = regs;
726}
Evan Cheng37f25d92008-08-28 23:39:26 +0000727
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000728// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000729class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
730 string opc, string asm, list<dag> pattern>
731 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
732 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000733 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000734 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000735 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000736}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000737class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
738 string opc, string asm, list<dag> pattern>
739 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
740 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000741 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000742 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000743}
744
745// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000746class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
747 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000748 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
749 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000750 bits<4> Rd;
751 bits<4> Rn;
752 bits<4> Rm;
753 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000754 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000755 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000756 let Inst{19-16} = Rd;
757 let Inst{11-8} = Rm;
758 let Inst{3-0} = Rn;
759}
760// MSW multiple w/ Ra operand
761class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
762 InstrItinClass itin, string opc, string asm, list<dag> pattern>
763 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
764 bits<4> Ra;
765 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000766}
Evan Cheng37f25d92008-08-28 23:39:26 +0000767
Evan Chengeb4f52e2008-11-06 03:35:07 +0000768// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000769class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000770 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000771 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
772 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000773 bits<4> Rn;
774 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000775 let Inst{4} = 0;
776 let Inst{7} = 1;
777 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000778 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000779 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000780 let Inst{11-8} = Rm;
781 let Inst{3-0} = Rn;
782}
783class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
784 InstrItinClass itin, string opc, string asm, list<dag> pattern>
785 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
786 bits<4> Rd;
787 let Inst{19-16} = Rd;
788}
789
790// AMulxyI with Ra operand
791class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
792 InstrItinClass itin, string opc, string asm, list<dag> pattern>
793 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
794 bits<4> Ra;
795 let Inst{15-12} = Ra;
796}
797// SMLAL*
798class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
799 InstrItinClass itin, string opc, string asm, list<dag> pattern>
800 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
801 bits<4> RdLo;
802 bits<4> RdHi;
803 let Inst{19-16} = RdHi;
804 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000805}
806
Evan Cheng97f48c32008-11-06 22:15:19 +0000807// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000808class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
809 string opc, string asm, list<dag> pattern>
810 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
811 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000812 // All AExtI instructions have Rd and Rm register operands.
813 bits<4> Rd;
814 bits<4> Rm;
815 let Inst{15-12} = Rd;
816 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000817 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000818 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000819 let Inst{27-20} = opcod;
820}
821
Evan Cheng8b59db32008-11-07 01:41:35 +0000822// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000823class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
824 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000825 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
826 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000827 bits<4> Rd;
828 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000829 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000830 let Inst{19-16} = 0b1111;
831 let Inst{15-12} = Rd;
832 let Inst{11-8} = 0b1111;
833 let Inst{7-4} = opc7_4;
834 let Inst{3-0} = Rm;
835}
836
837// PKH instructions
838class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
839 string opc, string asm, list<dag> pattern>
840 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
841 opc, asm, "", pattern> {
842 bits<4> Rd;
843 bits<4> Rn;
844 bits<4> Rm;
845 bits<8> sh;
846 let Inst{27-20} = opcod;
847 let Inst{19-16} = Rn;
848 let Inst{15-12} = Rd;
849 let Inst{11-7} = sh{7-3};
850 let Inst{6} = tb;
851 let Inst{5-4} = 0b01;
852 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000853}
854
Evan Cheng37f25d92008-08-28 23:39:26 +0000855//===----------------------------------------------------------------------===//
856
857// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
858class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
859 list<Predicate> Predicates = [IsARM];
860}
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +0000861class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
862 list<Predicate> Predicates = [IsARM, HasV5T];
863}
Evan Cheng37f25d92008-08-28 23:39:26 +0000864class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
865 list<Predicate> Predicates = [IsARM, HasV5TE];
866}
867class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
868 list<Predicate> Predicates = [IsARM, HasV6];
869}
Evan Cheng13096642008-08-29 06:41:12 +0000870
871//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000872// Thumb Instruction Format Definitions.
873//
874
Evan Cheng446c4282009-07-11 06:43:01 +0000875class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000876 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000877 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000878 let OutOperandList = oops;
879 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000880 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000881 let Pattern = pattern;
882 list<Predicate> Predicates = [IsThumb];
883}
884
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000885// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000886class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
887 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000888
Evan Cheng35d6c412009-08-04 23:47:55 +0000889// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000890class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
891 list<dag> pattern>
892 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
893 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000894
Johnny Chend68e1192009-12-15 17:24:14 +0000895// tBL, tBX 32-bit instructions
896class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000897 dag oops, dag iops, InstrItinClass itin, string asm,
898 list<dag> pattern>
899 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
900 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000901 let Inst{31-27} = opcod1;
902 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000903 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000904}
Evan Cheng13096642008-08-29 06:41:12 +0000905
Bruno Cardoso Lopesfa5bd272011-01-20 16:35:57 +0000906// Move to/from coprocessor instructions
907class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
908 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
909 Encoding, Requires<[IsThumb, HasV6]> {
910 let Inst{31-28} = 0b1110;
911}
912
Evan Cheng13096642008-08-29 06:41:12 +0000913// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000914class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
915 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000916 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000917
Evan Cheng09c39fc2009-06-23 19:38:13 +0000918// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +0000919class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000920 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000921 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000922 let OutOperandList = oops;
923 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000924 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000925 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000926 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000927}
928
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000929class T1I<dag oops, dag iops, InstrItinClass itin,
930 string asm, list<dag> pattern>
931 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
932class T1Ix2<dag oops, dag iops, InstrItinClass itin,
933 string asm, list<dag> pattern>
934 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000935
936// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000937class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000938 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000939 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000940 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000941
942// Thumb1 instruction that can either be predicated or set CPSR.
943class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000944 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000945 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000946 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000947 let OutOperandList = !con(oops, (outs s_cc_out:$s));
948 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000949 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000950 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000951 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000952}
953
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000954class T1sI<dag oops, dag iops, InstrItinClass itin,
955 string opc, string asm, list<dag> pattern>
956 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000957
958// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000959class T1sIt<dag oops, dag iops, InstrItinClass itin,
960 string opc, string asm, list<dag> pattern>
961 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000962 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000963
964// Thumb1 instruction that can be predicated.
965class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000966 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000967 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000968 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000969 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000970 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000971 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000972 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000973 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000974}
975
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000976class T1pI<dag oops, dag iops, InstrItinClass itin,
977 string opc, string asm, list<dag> pattern>
978 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000979
980// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000981class T1pIt<dag oops, dag iops, InstrItinClass itin,
982 string opc, string asm, list<dag> pattern>
983 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000984 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000985
Bob Wilson01135592010-03-23 17:23:59 +0000986class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000987 InstrItinClass itin, string opc, string asm, list<dag> pattern>
988 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000989
Johnny Chenbbc71b22009-12-16 02:32:54 +0000990class Encoding16 : Encoding {
991 let Inst{31-16} = 0x0000;
992}
993
Johnny Chend68e1192009-12-15 17:24:14 +0000994// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +0000995class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000996 let Inst{15-10} = opcode;
997}
998
999// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001000class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001001 let Inst{15-14} = 0b00;
1002 let Inst{13-9} = opcode;
1003}
1004
1005// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001006class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001007 let Inst{15-10} = 0b010000;
1008 let Inst{9-6} = opcode;
1009}
1010
1011// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001012class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001013 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +00001014 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +00001015}
1016
1017// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001018class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001019 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001020 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +00001021}
Bill Wendlingda2ae632010-08-31 07:50:46 +00001022class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +00001023
Eric Christopher33281b22011-05-27 03:50:53 +00001024class T1BranchCond<bits<4> opcode> : Encoding16 {
1025 let Inst{15-12} = opcode;
1026}
1027
Bill Wendling1fd374e2010-11-30 22:57:21 +00001028// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +00001029// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001030//
Bill Wendling1fd374e2010-11-30 22:57:21 +00001031// 0b0110 => Immediate, 4 bytes
1032// 0b1000 => Immediate, 2 bytes
1033// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +00001034class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1035 InstrItinClass itin, string opc, string asm,
1036 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +00001037 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001038 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001039 bits<3> Rt;
1040 bits<8> addr;
1041 let Inst{8-6} = addr{5-3}; // Rm
1042 let Inst{5-3} = addr{2-0}; // Rn
1043 let Inst{2-0} = Rt;
1044}
Bill Wendling40062fb2010-12-01 01:38:08 +00001045class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1046 InstrItinClass itin, string opc, string asm,
1047 list<dag> pattern>
Bill Wendling1fd374e2010-11-30 22:57:21 +00001048 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001049 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001050 bits<3> Rt;
1051 bits<8> addr;
1052 let Inst{10-6} = addr{7-3}; // imm5
1053 let Inst{5-3} = addr{2-0}; // Rn
1054 let Inst{2-0} = Rt;
1055}
1056
Johnny Chend68e1192009-12-15 17:24:14 +00001057// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001058class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001059 let Inst{15-12} = 0b1011;
1060 let Inst{11-5} = opcode;
1061}
1062
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001063// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1064class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001065 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001066 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001067 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001068 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001069 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001070 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001071 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001072 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001073}
1074
Bill Wendlingda2ae632010-08-31 07:50:46 +00001075// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1076// input operand since by default it's a zero register. It will become an
1077// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001078//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001079// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1080// more consistent.
1081class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001082 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001083 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001084 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001085 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1086 let Inst{20} = s;
1087
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001088 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001089 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001090 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001091 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001092 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001093}
1094
1095// Special cases
1096class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001097 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001098 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001099 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001100 let OutOperandList = oops;
1101 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001102 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001103 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001104 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001105}
1106
Jim Grosbachd1228742009-12-01 18:10:36 +00001107class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001108 InstrItinClass itin,
1109 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001110 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1111 let OutOperandList = oops;
1112 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001113 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001114 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001115 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001116}
1117
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001118class T2I<dag oops, dag iops, InstrItinClass itin,
1119 string opc, string asm, list<dag> pattern>
1120 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1121class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1122 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001123 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001124class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1125 string opc, string asm, list<dag> pattern>
1126 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1127class T2Iso<dag oops, dag iops, InstrItinClass itin,
1128 string opc, string asm, list<dag> pattern>
1129 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1130class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1131 string opc, string asm, list<dag> pattern>
1132 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001133class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001134 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001135 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1136 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001137 bits<4> Rt;
1138 bits<4> Rt2;
1139 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001140 let Inst{31-25} = 0b1110100;
1141 let Inst{24} = P;
1142 let Inst{23} = addr{8};
1143 let Inst{22} = 1;
1144 let Inst{21} = W;
1145 let Inst{20} = isLoad;
1146 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001147 let Inst{15-12} = Rt{3-0};
1148 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001149 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001150}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001151
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001152class T2sI<dag oops, dag iops, InstrItinClass itin,
1153 string opc, string asm, list<dag> pattern>
1154 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001155
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001156class T2XI<dag oops, dag iops, InstrItinClass itin,
1157 string asm, list<dag> pattern>
1158 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1159class T2JTI<dag oops, dag iops, InstrItinClass itin,
1160 string asm, list<dag> pattern>
1161 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001162
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001163// Move to/from coprocessor instructions
1164class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1165 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1166 let Inst{31-28} = 0b1111;
1167}
1168
Bob Wilson815baeb2010-03-13 01:08:20 +00001169// Two-address instructions
1170class T2XIt<dag oops, dag iops, InstrItinClass itin,
1171 string asm, string cstr, list<dag> pattern>
1172 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001173
Evan Chenge88d5ce2009-07-02 07:28:31 +00001174// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001175class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1176 dag oops, dag iops,
1177 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001178 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001179 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001180 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001181 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001182 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001183 let Pattern = pattern;
1184 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001185 let Inst{31-27} = 0b11111;
1186 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001187 let Inst{24} = signed;
1188 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001189 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001190 let Inst{20} = load;
1191 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001192 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001193 let Inst{10} = pre; // The P bit.
1194 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001195
Owen Anderson6af50f72010-11-30 00:14:31 +00001196 bits<9> addr;
1197 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001198 let Inst{9} = addr{8}; // Sign bit
1199
Owen Anderson6af50f72010-11-30 00:14:31 +00001200 bits<4> Rt;
1201 bits<4> Rn;
1202 let Inst{15-12} = Rt{3-0};
1203 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001204}
1205
David Goodwinc9d138f2009-07-27 19:59:26 +00001206// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1207class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001208 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001209}
1210
1211// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1212class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001213 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001214}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001215
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +00001216// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1217class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1218 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1219}
1220
Evan Cheng9cb9e672009-06-27 02:26:13 +00001221// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1222class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001223 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001224}
1225
Evan Cheng13096642008-08-29 06:41:12 +00001226//===----------------------------------------------------------------------===//
1227
Evan Cheng96581d32008-11-11 02:11:05 +00001228//===----------------------------------------------------------------------===//
1229// ARM VFP Instruction templates.
1230//
1231
David Goodwin3ca524e2009-07-10 17:03:29 +00001232// Almost all VFP instructions are predicable.
1233class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001234 IndexMode im, Format f, InstrItinClass itin,
1235 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001236 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001237 bits<4> p;
1238 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001239 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001240 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001241 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001242 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001243 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001244 list<Predicate> Predicates = [HasVFP2];
1245}
1246
1247// Special cases
1248class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001249 IndexMode im, Format f, InstrItinClass itin,
1250 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001251 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001252 bits<4> p;
1253 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001254 let OutOperandList = oops;
1255 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001256 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001257 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001258 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001259 list<Predicate> Predicates = [HasVFP2];
1260}
1261
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001262class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1263 string opc, string asm, list<dag> pattern>
1264 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001265 opc, asm, "", pattern> {
1266 let PostEncoderMethod = "VFPThumb2PostEncoder";
1267}
David Goodwin3ca524e2009-07-10 17:03:29 +00001268
Evan Chengcd8e66a2008-11-11 21:48:44 +00001269// ARM VFP addrmode5 loads and stores
1270class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001271 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001272 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001273 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001274 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001275 // Instruction operands.
1276 bits<5> Dd;
1277 bits<13> addr;
1278
1279 // Encode instruction operands.
1280 let Inst{23} = addr{8}; // U (add = (U == '1'))
1281 let Inst{22} = Dd{4};
1282 let Inst{19-16} = addr{12-9}; // Rn
1283 let Inst{15-12} = Dd{3-0};
1284 let Inst{7-0} = addr{7-0}; // imm8
1285
Evan Cheng96581d32008-11-11 02:11:05 +00001286 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001287 let Inst{27-24} = opcod1;
1288 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001289 let Inst{11-9} = 0b101;
1290 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001291
Evan Cheng5eda2822011-02-16 00:35:02 +00001292 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001293 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001294}
1295
Evan Chengcd8e66a2008-11-11 21:48:44 +00001296class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001297 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001298 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001299 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001300 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001301 // Instruction operands.
1302 bits<5> Sd;
1303 bits<13> addr;
1304
1305 // Encode instruction operands.
1306 let Inst{23} = addr{8}; // U (add = (U == '1'))
1307 let Inst{22} = Sd{0};
1308 let Inst{19-16} = addr{12-9}; // Rn
1309 let Inst{15-12} = Sd{4-1};
1310 let Inst{7-0} = addr{7-0}; // imm8
1311
Evan Cheng96581d32008-11-11 02:11:05 +00001312 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001313 let Inst{27-24} = opcod1;
1314 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001315 let Inst{11-9} = 0b101;
1316 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001317
1318 // Loads & stores operate on both NEON and VFP pipelines.
1319 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001320}
1321
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001322// VFP Load / store multiple pseudo instructions.
1323class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1324 list<dag> pattern>
1325 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1326 cstr, itin> {
1327 let OutOperandList = oops;
1328 let InOperandList = !con(iops, (ins pred:$p));
1329 let Pattern = pattern;
1330 list<Predicate> Predicates = [HasVFP2];
1331}
1332
Evan Chengcd8e66a2008-11-11 21:48:44 +00001333// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001334class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001335 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001336 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001337 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001338 // Instruction operands.
1339 bits<4> Rn;
1340 bits<13> regs;
1341
1342 // Encode instruction operands.
1343 let Inst{19-16} = Rn;
1344 let Inst{22} = regs{12};
1345 let Inst{15-12} = regs{11-8};
1346 let Inst{7-0} = regs{7-0};
1347
Evan Chengcd8e66a2008-11-11 21:48:44 +00001348 // TODO: Mark the instructions with the appropriate subtarget info.
1349 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001350 let Inst{11-9} = 0b101;
1351 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001352}
1353
Jim Grosbach72db1822010-09-08 00:25:50 +00001354class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001355 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001356 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001357 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001358 // Instruction operands.
1359 bits<4> Rn;
1360 bits<13> regs;
1361
1362 // Encode instruction operands.
1363 let Inst{19-16} = Rn;
1364 let Inst{22} = regs{8};
1365 let Inst{15-12} = regs{12-9};
1366 let Inst{7-0} = regs{7-0};
1367
Evan Chengcd8e66a2008-11-11 21:48:44 +00001368 // TODO: Mark the instructions with the appropriate subtarget info.
1369 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001370 let Inst{11-9} = 0b101;
1371 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001372}
1373
Evan Cheng96581d32008-11-11 02:11:05 +00001374// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001375class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1376 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1377 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001378 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001379 // Instruction operands.
1380 bits<5> Dd;
1381 bits<5> Dm;
1382
1383 // Encode instruction operands.
1384 let Inst{3-0} = Dm{3-0};
1385 let Inst{5} = Dm{4};
1386 let Inst{15-12} = Dd{3-0};
1387 let Inst{22} = Dd{4};
1388
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001389 let Inst{27-23} = opcod1;
1390 let Inst{21-20} = opcod2;
1391 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001392 let Inst{11-9} = 0b101;
1393 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001394 let Inst{7-6} = opcod4;
1395 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001396}
1397
1398// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001399class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001400 dag iops, InstrItinClass itin, string opc, string asm,
1401 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001402 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001403 // Instruction operands.
1404 bits<5> Dd;
1405 bits<5> Dn;
1406 bits<5> Dm;
1407
1408 // Encode instruction operands.
1409 let Inst{3-0} = Dm{3-0};
1410 let Inst{5} = Dm{4};
1411 let Inst{19-16} = Dn{3-0};
1412 let Inst{7} = Dn{4};
1413 let Inst{15-12} = Dd{3-0};
1414 let Inst{22} = Dd{4};
1415
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001416 let Inst{27-23} = opcod1;
1417 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001418 let Inst{11-9} = 0b101;
1419 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001420 let Inst{6} = op6;
1421 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001422}
1423
1424// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001425class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1426 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1427 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001428 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001429 // Instruction operands.
1430 bits<5> Sd;
1431 bits<5> Sm;
1432
1433 // Encode instruction operands.
1434 let Inst{3-0} = Sm{4-1};
1435 let Inst{5} = Sm{0};
1436 let Inst{15-12} = Sd{4-1};
1437 let Inst{22} = Sd{0};
1438
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001439 let Inst{27-23} = opcod1;
1440 let Inst{21-20} = opcod2;
1441 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001442 let Inst{11-9} = 0b101;
1443 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001444 let Inst{7-6} = opcod4;
1445 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001446}
1447
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001448// Single precision unary, if no NEON. Same as ASuI except not available if
1449// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001450class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1451 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1452 string asm, list<dag> pattern>
1453 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1454 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001455 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1456}
1457
Evan Cheng96581d32008-11-11 02:11:05 +00001458// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001459class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1460 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001461 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001462 // Instruction operands.
1463 bits<5> Sd;
1464 bits<5> Sn;
1465 bits<5> Sm;
1466
1467 // Encode instruction operands.
1468 let Inst{3-0} = Sm{4-1};
1469 let Inst{5} = Sm{0};
1470 let Inst{19-16} = Sn{4-1};
1471 let Inst{7} = Sn{0};
1472 let Inst{15-12} = Sd{4-1};
1473 let Inst{22} = Sd{0};
1474
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001475 let Inst{27-23} = opcod1;
1476 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001477 let Inst{11-9} = 0b101;
1478 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001479 let Inst{6} = op6;
1480 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001481}
1482
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001483// Single precision binary, if no NEON. Same as ASbI except not available if
1484// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001485class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001486 dag iops, InstrItinClass itin, string opc, string asm,
1487 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001488 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001489 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001490
1491 // Instruction operands.
1492 bits<5> Sd;
1493 bits<5> Sn;
1494 bits<5> Sm;
1495
1496 // Encode instruction operands.
1497 let Inst{3-0} = Sm{4-1};
1498 let Inst{5} = Sm{0};
1499 let Inst{19-16} = Sn{4-1};
1500 let Inst{7} = Sn{0};
1501 let Inst{15-12} = Sd{4-1};
1502 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001503}
1504
Evan Cheng80a11982008-11-12 06:41:41 +00001505// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001506class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1507 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1508 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001509 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001510 let Inst{27-23} = opcod1;
1511 let Inst{21-20} = opcod2;
1512 let Inst{19-16} = opcod3;
1513 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001514 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001515 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001516}
1517
Johnny Chen811663f2010-02-11 18:47:03 +00001518// VFP conversion between floating-point and fixed-point
1519class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001520 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1521 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001522 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1523 // size (fixed-point number): sx == 0 ? 16 : 32
1524 let Inst{7} = op5; // sx
1525}
1526
David Goodwin338268c2009-08-10 22:17:39 +00001527// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001528class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001529 dag oops, dag iops, InstrItinClass itin,
1530 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001531 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1532 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001533 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1534}
1535
Evan Cheng80a11982008-11-12 06:41:41 +00001536class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001537 InstrItinClass itin,
1538 string opc, string asm, list<dag> pattern>
1539 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001540 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001541 let Inst{11-8} = opcod2;
1542 let Inst{4} = 1;
1543}
1544
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001545class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1546 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1547 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001548
Bob Wilson01135592010-03-23 17:23:59 +00001549class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001550 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1551 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001552
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001553class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1554 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1555 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001556
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001557class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1558 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1559 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001560
Evan Cheng96581d32008-11-11 02:11:05 +00001561//===----------------------------------------------------------------------===//
1562
Bob Wilson5bafff32009-06-22 23:27:02 +00001563//===----------------------------------------------------------------------===//
1564// ARM NEON Instruction templates.
1565//
Evan Cheng13096642008-08-29 06:41:12 +00001566
Johnny Chencaa608e2010-03-20 00:17:00 +00001567class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1568 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1569 list<dag> pattern>
1570 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001571 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001572 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001573 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001574 let Pattern = pattern;
1575 list<Predicate> Predicates = [HasNEON];
1576}
1577
1578// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001579class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1580 InstrItinClass itin, string opc, string asm, string cstr,
1581 list<dag> pattern>
1582 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001583 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001584 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001585 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001586 let Pattern = pattern;
1587 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001588}
1589
Bob Wilsonb07c1712009-10-07 21:53:04 +00001590class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1591 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001592 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001593 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1594 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001595 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001596 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001597 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001598 let Inst{11-8} = op11_8;
1599 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001600
Chris Lattner2ac19022010-11-15 05:19:05 +00001601 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001602
Owen Andersond9aa7d32010-11-02 00:05:05 +00001603 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001604 bits<6> Rn;
1605 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001606
Owen Andersond9aa7d32010-11-02 00:05:05 +00001607 let Inst{22} = Vd{4};
1608 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001609 let Inst{19-16} = Rn{3-0};
1610 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001611}
1612
Owen Andersond138d702010-11-02 20:47:39 +00001613class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1614 dag oops, dag iops, InstrItinClass itin,
1615 string opc, string dt, string asm, string cstr, list<dag> pattern>
1616 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1617 dt, asm, cstr, pattern> {
1618 bits<3> lane;
1619}
1620
Bob Wilson709d5922010-08-25 23:27:42 +00001621class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1622 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1623 itin> {
1624 let OutOperandList = oops;
1625 let InOperandList = !con(iops, (ins pred:$p));
1626 list<Predicate> Predicates = [HasNEON];
1627}
1628
Jim Grosbach7cd27292010-10-06 20:36:55 +00001629class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1630 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001631 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1632 itin> {
1633 let OutOperandList = oops;
1634 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001635 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001636 list<Predicate> Predicates = [HasNEON];
1637}
1638
Johnny Chen785516a2010-03-23 16:43:47 +00001639class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001640 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001641 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1642 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001643 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001644 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001645}
1646
Johnny Chen927b88f2010-03-23 20:40:44 +00001647class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001648 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001649 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001650 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001651 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001652 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001653}
1654
1655// NEON "one register and a modified immediate" format.
1656class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1657 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001658 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001659 string opc, string dt, string asm, string cstr,
1660 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001661 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001662 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001663 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001664 let Inst{11-8} = op11_8;
1665 let Inst{7} = op7;
1666 let Inst{6} = op6;
1667 let Inst{5} = op5;
1668 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001669
Owen Andersona88ea032010-10-26 17:40:54 +00001670 // Instruction operands.
1671 bits<5> Vd;
1672 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001673
Owen Andersona88ea032010-10-26 17:40:54 +00001674 let Inst{15-12} = Vd{3-0};
1675 let Inst{22} = Vd{4};
1676 let Inst{24} = SIMM{7};
1677 let Inst{18-16} = SIMM{6-4};
1678 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001679}
1680
1681// NEON 2 vector register format.
1682class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1683 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001684 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001685 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001686 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001687 let Inst{24-23} = op24_23;
1688 let Inst{21-20} = op21_20;
1689 let Inst{19-18} = op19_18;
1690 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001691 let Inst{11-7} = op11_7;
1692 let Inst{6} = op6;
1693 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001694
Owen Anderson162875a2010-10-25 18:43:52 +00001695 // Instruction operands.
1696 bits<5> Vd;
1697 bits<5> Vm;
1698
1699 let Inst{15-12} = Vd{3-0};
1700 let Inst{22} = Vd{4};
1701 let Inst{3-0} = Vm{3-0};
1702 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001703}
1704
1705// Same as N2V except it doesn't have a datatype suffix.
1706class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001707 bits<5> op11_7, bit op6, bit op4,
1708 dag oops, dag iops, InstrItinClass itin,
1709 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001710 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001711 let Inst{24-23} = op24_23;
1712 let Inst{21-20} = op21_20;
1713 let Inst{19-18} = op19_18;
1714 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001715 let Inst{11-7} = op11_7;
1716 let Inst{6} = op6;
1717 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001718
Owen Anderson162875a2010-10-25 18:43:52 +00001719 // Instruction operands.
1720 bits<5> Vd;
1721 bits<5> Vm;
1722
1723 let Inst{15-12} = Vd{3-0};
1724 let Inst{22} = Vd{4};
1725 let Inst{3-0} = Vm{3-0};
1726 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001727}
1728
1729// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001730class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001731 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001732 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001733 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001734 let Inst{24} = op24;
1735 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001736 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001737 let Inst{7} = op7;
1738 let Inst{6} = op6;
1739 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001740
Owen Anderson3557d002010-10-26 20:56:57 +00001741 // Instruction operands.
1742 bits<5> Vd;
1743 bits<5> Vm;
1744 bits<6> SIMM;
1745
1746 let Inst{15-12} = Vd{3-0};
1747 let Inst{22} = Vd{4};
1748 let Inst{3-0} = Vm{3-0};
1749 let Inst{5} = Vm{4};
1750 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001751}
1752
Bob Wilson10bc69c2010-03-27 03:56:52 +00001753// NEON 3 vector register format.
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001754
Jim Grosbach6635b042011-05-19 17:34:53 +00001755class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1756 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1757 string opc, string dt, string asm, string cstr,
1758 list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001759 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001760 let Inst{24} = op24;
1761 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001762 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001763 let Inst{11-8} = op11_8;
1764 let Inst{6} = op6;
1765 let Inst{4} = op4;
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001766}
1767
1768class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1769 dag oops, dag iops, Format f, InstrItinClass itin,
1770 string opc, string dt, string asm, string cstr, list<dag> pattern>
1771 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1772 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001773
Owen Andersond451f882010-10-21 20:21:49 +00001774 // Instruction operands.
1775 bits<5> Vd;
1776 bits<5> Vn;
1777 bits<5> Vm;
1778
1779 let Inst{15-12} = Vd{3-0};
1780 let Inst{22} = Vd{4};
1781 let Inst{19-16} = Vn{3-0};
1782 let Inst{7} = Vn{4};
1783 let Inst{3-0} = Vm{3-0};
1784 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001785}
1786
Jim Grosbach6635b042011-05-19 17:34:53 +00001787class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1788 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1789 string opc, string dt, string asm, string cstr,
1790 list<dag> pattern>
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001791 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1792 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1793
1794 // Instruction operands.
1795 bits<5> Vd;
1796 bits<5> Vn;
1797 bits<5> Vm;
1798 bit lane;
1799
1800 let Inst{15-12} = Vd{3-0};
1801 let Inst{22} = Vd{4};
1802 let Inst{19-16} = Vn{3-0};
1803 let Inst{7} = Vn{4};
1804 let Inst{3-0} = Vm{3-0};
1805 let Inst{5} = lane;
1806}
1807
Jim Grosbach6635b042011-05-19 17:34:53 +00001808class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1809 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1810 string opc, string dt, string asm, string cstr,
1811 list<dag> pattern>
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001812 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1813 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1814
1815 // Instruction operands.
1816 bits<5> Vd;
1817 bits<5> Vn;
1818 bits<5> Vm;
1819 bits<2> lane;
1820
1821 let Inst{15-12} = Vd{3-0};
1822 let Inst{22} = Vd{4};
1823 let Inst{19-16} = Vn{3-0};
1824 let Inst{7} = Vn{4};
1825 let Inst{2-0} = Vm{2-0};
1826 let Inst{5} = lane{1};
1827 let Inst{3} = lane{0};
1828}
1829
Johnny Chen841e8282010-03-23 21:35:03 +00001830// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001831class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1832 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001833 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001834 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001835 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001836 let Inst{24} = op24;
1837 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001838 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001839 let Inst{11-8} = op11_8;
1840 let Inst{6} = op6;
1841 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001842
Owen Anderson8c71eff2010-10-25 18:28:30 +00001843 // Instruction operands.
1844 bits<5> Vd;
1845 bits<5> Vn;
1846 bits<5> Vm;
1847
1848 let Inst{15-12} = Vd{3-0};
1849 let Inst{22} = Vd{4};
1850 let Inst{19-16} = Vn{3-0};
1851 let Inst{7} = Vn{4};
1852 let Inst{3-0} = Vm{3-0};
1853 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001854}
1855
1856// NEON VMOVs between scalar and core registers.
1857class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001858 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001859 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001860 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001861 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001862 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001863 let Inst{11-8} = opcod2;
1864 let Inst{6-5} = opcod3;
1865 let Inst{4} = 1;
Johnny Chena9611542011-04-06 18:27:46 +00001866 // A8.6.303, A8.6.328, A8.6.329
1867 let Inst{3-0} = 0b0000;
Evan Chengf81bf152009-11-23 21:57:23 +00001868
1869 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001870 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001871 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001872 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001873 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001874
Chris Lattner2ac19022010-11-15 05:19:05 +00001875 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001876
Owen Andersond2fbdb72010-10-27 21:28:09 +00001877 bits<5> V;
1878 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001879 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001880 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001881
Owen Andersonf587a9352010-10-27 19:25:54 +00001882 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001883 let Inst{7} = V{4};
1884 let Inst{19-16} = V{3-0};
1885 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001886}
1887class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001888 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001889 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001890 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001891 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001892class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001893 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001894 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001895 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001896 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001897class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001898 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001899 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001900 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001901 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001902
Johnny Chene4614f72010-03-25 17:01:27 +00001903// Vector Duplicate Lane (from scalar to all elements)
1904class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1905 InstrItinClass itin, string opc, string dt, string asm,
1906 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001907 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001908 let Inst{24-23} = 0b11;
1909 let Inst{21-20} = 0b11;
1910 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001911 let Inst{11-7} = 0b11000;
1912 let Inst{6} = op6;
1913 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001914
Owen Andersonf587a9352010-10-27 19:25:54 +00001915 bits<5> Vd;
1916 bits<5> Vm;
1917 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001918
Owen Andersonf587a9352010-10-27 19:25:54 +00001919 let Inst{22} = Vd{4};
1920 let Inst{15-12} = Vd{3-0};
1921 let Inst{5} = Vm{4};
1922 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001923}
1924
David Goodwin42a83f22009-08-04 17:53:06 +00001925// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1926// for single-precision FP.
1927class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1928 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1929}