blob: c3627b5bcfe8f3d111f459ef8948facb934801bf [file] [log] [blame]
Evan Cheng37f25d92008-08-28 23:39:26 +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
Evan Chengedda31c2008-11-05 18:35:52 +000074// the instruction has a 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
87// Addressing mode.
Jim Grosbachd86609f2010-10-05 18:14:55 +000088class AddrMode<bits<5> val> {
89 bits<5> Value = val;
Evan Cheng055b0312009-06-29 07:51:04 +000090}
Bill Wendlingda2ae632010-08-31 07:50:46 +000091def AddrModeNone : AddrMode<0>;
92def AddrMode1 : AddrMode<1>;
93def AddrMode2 : AddrMode<2>;
94def AddrMode3 : AddrMode<3>;
95def AddrMode4 : AddrMode<4>;
96def AddrMode5 : AddrMode<5>;
97def AddrMode6 : AddrMode<6>;
98def AddrModeT1_1 : AddrMode<7>;
99def AddrModeT1_2 : AddrMode<8>;
100def AddrModeT1_4 : AddrMode<9>;
101def AddrModeT1_s : AddrMode<10>;
102def AddrModeT2_i12 : AddrMode<11>;
103def AddrModeT2_i8 : AddrMode<12>;
104def AddrModeT2_so : AddrMode<13>;
105def AddrModeT2_pc : AddrMode<14>;
Bob Wilson8b024a52009-07-01 23:16:05 +0000106def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach3e556122010-10-26 22:37:02 +0000107def AddrMode_i12 : AddrMode<16>;
Evan Cheng055b0312009-06-29 07:51:04 +0000108
109// Instruction size.
110class SizeFlagVal<bits<3> val> {
111 bits<3> Value = val;
112}
113def SizeInvalid : SizeFlagVal<0>; // Unset.
114def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
115def Size8Bytes : SizeFlagVal<2>;
116def Size4Bytes : SizeFlagVal<3>;
117def Size2Bytes : SizeFlagVal<4>;
118
119// Load / store index mode.
120class IndexMode<bits<2> val> {
121 bits<2> Value = val;
122}
123def IndexModeNone : IndexMode<0>;
124def IndexModePre : IndexMode<1>;
125def IndexModePost : IndexMode<2>;
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000126def IndexModeUpd : IndexMode<3>;
Evan Cheng055b0312009-06-29 07:51:04 +0000127
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000128// Instruction execution domain.
129class Domain<bits<2> val> {
130 bits<2> Value = val;
131}
132def GenericDomain : Domain<0>;
133def VFPDomain : Domain<1>; // Instructions in VFP domain only
134def NeonDomain : Domain<2>; // Instructions in Neon domain only
135def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
136
Evan Cheng055b0312009-06-29 07:51:04 +0000137//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000138
Evan Cheng446c4282009-07-11 06:43:01 +0000139// ARM special operands.
140//
141
Daniel Dunbar8462b302010-08-11 06:36:53 +0000142def CondCodeOperand : AsmOperandClass {
143 let Name = "CondCode";
144 let SuperClasses = [];
145}
146
Evan Cheng446c4282009-07-11 06:43:01 +0000147// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
148// register whose default is 0 (no register).
149def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
150 (ops (i32 14), (i32 zero_reg))> {
151 let PrintMethod = "printPredicateOperand";
Daniel Dunbar8462b302010-08-11 06:36:53 +0000152 let ParserMatchClass = CondCodeOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000153}
154
155// Conditional code result for instructions whose 's' bit is set, e.g. subs.
156def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Jim Grosbach08bd5492010-10-12 23:00:24 +0000157 string EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000158 let PrintMethod = "printSBitModifierOperand";
159}
160
161// Same as cc_out except it defaults to setting CPSR.
162def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Jim Grosbach08bd5492010-10-12 23:00:24 +0000163 string EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000164 let PrintMethod = "printSBitModifierOperand";
165}
166
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000167// ARM special operands for disassembly only.
168//
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000169def setend_op : Operand<i32> {
170 let PrintMethod = "printSetendOperand";
171}
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000172
173def cps_opt : Operand<i32> {
174 let PrintMethod = "printCPSOptionOperand";
175}
176
177def msr_mask : Operand<i32> {
178 let PrintMethod = "printMSRMaskOperand";
179}
180
181// A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
182// The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
183def neg_zero : Operand<i32> {
184 let PrintMethod = "printNegZeroOperand";
185}
186
Evan Cheng446c4282009-07-11 06:43:01 +0000187//===----------------------------------------------------------------------===//
188
Evan Cheng37f25d92008-08-28 23:39:26 +0000189// ARM Instruction templates.
190//
191
Johnny Chend68e1192009-12-15 17:24:14 +0000192class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
193 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000194 : Instruction {
195 let Namespace = "ARM";
196
Evan Cheng37f25d92008-08-28 23:39:26 +0000197 AddrMode AM = am;
Evan Cheng37f25d92008-08-28 23:39:26 +0000198 SizeFlagVal SZ = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000199 IndexMode IM = im;
200 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000201 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000202 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000203 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000204 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000205 bit canXformTo16Bit = 0;
Bob Wilson01135592010-03-23 17:23:59 +0000206
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000207 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000208 let TSFlags{4-0} = AM.Value;
209 let TSFlags{7-5} = SZ.Value;
210 let TSFlags{9-8} = IndexModeBits;
211 let TSFlags{15-10} = Form;
212 let TSFlags{16} = isUnaryDataProc;
213 let TSFlags{17} = canXformTo16Bit;
214 let TSFlags{19-18} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000215
Evan Cheng37f25d92008-08-28 23:39:26 +0000216 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000217 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000218}
219
Johnny Chend68e1192009-12-15 17:24:14 +0000220class Encoding {
221 field bits<32> Inst;
222}
223
224class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
225 Format f, Domain d, string cstr, InstrItinClass itin>
226 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
227
228// This Encoding-less class is used by Thumb1 to specify the encoding bits later
229// on by adding flavors to specific instructions.
230class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
231 Format f, Domain d, string cstr, InstrItinClass itin>
232 : InstTemplate<am, sz, im, f, d, cstr, itin>;
233
Bob Wilson01135592010-03-23 17:23:59 +0000234class PseudoInst<dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000235 string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +0000236 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000237 "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000238 let OutOperandList = oops;
239 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000240 let AsmString = asm;
Evan Cheng37f25d92008-08-28 23:39:26 +0000241 let Pattern = pattern;
242}
243
244// Almost all ARM instructions are predicable.
Evan Chengd87293c2008-11-06 08:47:38 +0000245class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000246 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000247 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000248 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000249 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000250 bits<4> p;
251 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000252 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000253 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000254 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000255 let Pattern = pattern;
256 list<Predicate> Predicates = [IsARM];
257}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000258
Jim Grosbachf6b28622009-12-14 18:31:20 +0000259// A few are not predicable
260class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +0000261 IndexMode im, Format f, InstrItinClass itin,
262 string opc, string asm, string cstr,
263 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000264 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
265 let OutOperandList = oops;
266 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000267 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000268 let Pattern = pattern;
269 let isPredicable = 0;
270 list<Predicate> Predicates = [IsARM];
271}
Evan Cheng37f25d92008-08-28 23:39:26 +0000272
Bill Wendling4822bce2010-08-30 01:47:35 +0000273// Same as I except it can optionally modify CPSR. Note it's modeled as an input
274// operand since by default it's a zero register. It will become an implicit def
275// once it's "flipped".
Evan Chengd87293c2008-11-06 08:47:38 +0000276class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000277 IndexMode im, Format f, InstrItinClass itin,
278 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000279 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000280 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000281 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000282 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000283 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000284 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000285
Evan Cheng37f25d92008-08-28 23:39:26 +0000286 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000287 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000288 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000289 let Pattern = pattern;
290 list<Predicate> Predicates = [IsARM];
291}
292
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000293// Special cases
Evan Chengd87293c2008-11-06 08:47:38 +0000294class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000295 IndexMode im, Format f, InstrItinClass itin,
296 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000297 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000298 let OutOperandList = oops;
299 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000300 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000301 let Pattern = pattern;
302 list<Predicate> Predicates = [IsARM];
303}
304
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000305class AI<dag oops, dag iops, Format f, InstrItinClass itin,
306 string opc, string asm, list<dag> pattern>
307 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
308 opc, asm, "", pattern>;
309class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
310 string opc, string asm, list<dag> pattern>
311 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
312 opc, asm, "", pattern>;
313class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000314 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000315 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000316 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000317class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000318 string opc, string asm, list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000319 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000320 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000321
322// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000323class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
324 string opc, string asm, list<dag> pattern>
325 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
326 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000327 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000328}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000329class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
330 string asm, list<dag> pattern>
331 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
332 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000333 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000334}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000335class ABXIx2<dag oops, dag iops, InstrItinClass itin,
336 string asm, list<dag> pattern>
Xerxes Ranby99ccffe2010-07-22 17:28:34 +0000337 : XI<oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, Pseudo, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000338 asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000339
340// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000341class JTI<dag oops, dag iops, InstrItinClass itin,
342 string asm, list<dag> pattern>
343 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000344 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000345
Jim Grosbach5278eb82009-12-11 01:42:04 +0000346// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000347class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
348 string opc, string asm, list<dag> pattern>
349 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
350 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000351 bits<4> Rt;
352 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000353 let Inst{27-23} = 0b00011;
354 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000355 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000356 let Inst{19-16} = Rn;
357 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000358 let Inst{11-0} = 0b111110011111;
359}
360class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
361 string opc, string asm, list<dag> pattern>
362 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
363 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000364 bits<4> Rd;
365 bits<4> Rt;
366 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000367 let Inst{27-23} = 0b00011;
368 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000369 let Inst{20} = 0;
Jim Grosbach86875a22010-10-29 19:58:57 +0000370 let Inst{19-16} = Rn;
371 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000372 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000373 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000374}
375
Evan Cheng0d14fc82008-09-01 01:51:14 +0000376// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000377class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
378 string opc, string asm, list<dag> pattern>
379 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
380 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000381 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000382 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000383}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000384class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
385 string opc, string asm, list<dag> pattern>
386 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
387 opc, asm, "", pattern> {
388 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000389 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000390}
391class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000392 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000393 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000394 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000395 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000396 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000397}
Bob Wilson01135592010-03-23 17:23:59 +0000398class AI1x2<dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000399 string opc, string asm, list<dag> pattern>
400 : I<oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, itin,
401 opc, asm, "", pattern>;
Evan Cheng17222df2008-08-31 19:02:21 +0000402
Evan Cheng0d14fc82008-09-01 01:51:14 +0000403
404// addrmode2 loads and stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000405class AI2<dag oops, dag iops, Format f, InstrItinClass itin,
406 string opc, string asm, list<dag> pattern>
407 : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
408 opc, asm, "", pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +0000409 let Inst{27-26} = 0b01;
Evan Cheng17222df2008-08-31 19:02:21 +0000410}
Evan Cheng93912732008-09-01 01:27:33 +0000411
412// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000413
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000414// LDR/LDRB/STR/STRB
415class AIldst1<bits<3> op, bit opc22, bit isLd, dag oops, dag iops, AddrMode am,
416 Format f, InstrItinClass itin, string opc, string asm,
417 list<dag> pattern>
Jim Grosbach3e556122010-10-26 22:37:02 +0000418 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
419 "", pattern> {
420 let Inst{27-25} = op;
421 let Inst{24} = 1; // 24 == P
422 // 23 == U
423 let Inst{22} = opc22;
424 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000425 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000426}
427// LDRH/LDRSB/LDRSH/LDRD
428class AIldr2<bits<4> op, bit opc22, bit opc20, dag oops, dag iops, AddrMode am,
429 Format f, InstrItinClass itin, string opc, string asm,
430 list<dag> pattern>
431 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
432 "", pattern> {
433 let Inst{27-25} = 0b000;
434 let Inst{24} = 1; // 24 == P
435 // 23 == U
436 let Inst{22} = opc22;
437 let Inst{21} = 0; // 21 == W
438 let Inst{20} = opc20;
439
440 let Inst{7-4} = op;
441}
442
443
444
445
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000446class AI2ldw<dag oops, dag iops, Format f, InstrItinClass itin,
447 string opc, string asm, list<dag> pattern>
448 : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
449 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000450 let Inst{20} = 1; // L bit
Evan Cheng17222df2008-08-31 19:02:21 +0000451 let Inst{21} = 0; // W bit
452 let Inst{22} = 0; // B bit
453 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000454 let Inst{27-26} = 0b01;
Evan Cheng17222df2008-08-31 19:02:21 +0000455}
Bob Wilson01135592010-03-23 17:23:59 +0000456class AXI2ldw<dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000457 string asm, list<dag> pattern>
458 : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000459 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000460 let Inst{20} = 1; // L bit
461 let Inst{21} = 0; // W bit
462 let Inst{22} = 0; // B bit
463 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000464 let Inst{27-26} = 0b01;
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000465}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000466class AI2ldb<dag oops, dag iops, Format f, InstrItinClass itin,
467 string opc, string asm, list<dag> pattern>
468 : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
469 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000470 let Inst{20} = 1; // L bit
Evan Cheng17222df2008-08-31 19:02:21 +0000471 let Inst{21} = 0; // W bit
472 let Inst{22} = 1; // B bit
473 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000474 let Inst{27-26} = 0b01;
Evan Cheng17222df2008-08-31 19:02:21 +0000475}
Bob Wilson01135592010-03-23 17:23:59 +0000476class AXI2ldb<dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000477 string asm, list<dag> pattern>
478 : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000479 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000480 let Inst{20} = 1; // L bit
481 let Inst{21} = 0; // W bit
482 let Inst{22} = 1; // B bit
483 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000484 let Inst{27-26} = 0b01;
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000485}
Evan Cheng17222df2008-08-31 19:02:21 +0000486
Evan Cheng93912732008-09-01 01:27:33 +0000487// stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000488class AI2stw<dag oops, dag iops, Format f, InstrItinClass itin,
489 string opc, string asm, list<dag> pattern>
490 : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
491 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000492 let Inst{20} = 0; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000493 let Inst{21} = 0; // W bit
494 let Inst{22} = 0; // B bit
495 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000496 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000497}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000498class AXI2stw<dag oops, dag iops, Format f, InstrItinClass itin,
499 string asm, list<dag> pattern>
500 : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000501 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000502 let Inst{20} = 0; // L bit
503 let Inst{21} = 0; // W bit
504 let Inst{22} = 0; // B bit
505 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000506 let Inst{27-26} = 0b01;
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000507}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000508class AI2stb<dag oops, dag iops, Format f, InstrItinClass itin,
509 string opc, string asm, list<dag> pattern>
510 : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
511 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000512 let Inst{20} = 0; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000513 let Inst{21} = 0; // W bit
514 let Inst{22} = 1; // B bit
515 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000516 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000517}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000518class AXI2stb<dag oops, dag iops, Format f, InstrItinClass itin,
519 string asm, list<dag> pattern>
520 : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000521 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000522 let Inst{20} = 0; // L bit
523 let Inst{21} = 0; // W bit
524 let Inst{22} = 1; // B bit
525 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000526 let Inst{27-26} = 0b01;
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000527}
Evan Cheng93912732008-09-01 01:27:33 +0000528
Evan Cheng840917b2008-09-01 07:00:14 +0000529// Pre-indexed loads
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000530class AI2ldwpr<dag oops, dag iops, Format f, InstrItinClass itin,
531 string opc, string asm, string cstr, list<dag> pattern>
532 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
533 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000534 let Inst{20} = 1; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000535 let Inst{21} = 1; // W bit
536 let Inst{22} = 0; // B bit
537 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000538 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000539}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000540class AI2ldbpr<dag oops, dag iops, Format f, InstrItinClass itin,
541 string opc, string asm, string cstr, list<dag> pattern>
542 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
543 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000544 let Inst{20} = 1; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000545 let Inst{21} = 1; // W bit
546 let Inst{22} = 1; // B bit
547 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000548 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000549}
550
Evan Cheng840917b2008-09-01 07:00:14 +0000551// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000552class AI2stwpr<dag oops, dag iops, Format f, InstrItinClass itin,
553 string opc, string asm, string cstr, list<dag> pattern>
554 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
555 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000556 let Inst{20} = 0; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000557 let Inst{21} = 1; // W bit
558 let Inst{22} = 0; // B bit
559 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000560 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000561}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000562class AI2stbpr<dag oops, dag iops, Format f, InstrItinClass itin,
563 string opc, string asm, string cstr, list<dag> pattern>
564 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
565 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000566 let Inst{20} = 0; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000567 let Inst{21} = 1; // W bit
568 let Inst{22} = 1; // B bit
569 let Inst{24} = 1; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000570 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000571}
572
Evan Cheng840917b2008-09-01 07:00:14 +0000573// Post-indexed loads
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000574class AI2ldwpo<dag oops, dag iops, Format f, InstrItinClass itin,
575 string opc, string asm, string cstr, list<dag> pattern>
576 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
577 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000578 let Inst{20} = 1; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000579 let Inst{21} = 0; // W bit
580 let Inst{22} = 0; // B bit
581 let Inst{24} = 0; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000582 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000583}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000584class AI2ldbpo<dag oops, dag iops, Format f, InstrItinClass itin,
585 string opc, string asm, string cstr, list<dag> pattern>
586 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
587 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000588 let Inst{20} = 1; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000589 let Inst{21} = 0; // W bit
590 let Inst{22} = 1; // B bit
591 let Inst{24} = 0; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000592 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000593}
594
Evan Cheng840917b2008-09-01 07:00:14 +0000595// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000596class AI2stwpo<dag oops, dag iops, Format f, InstrItinClass itin,
597 string opc, string asm, string cstr, list<dag> pattern>
598 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
599 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000600 let Inst{20} = 0; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000601 let Inst{21} = 0; // W bit
602 let Inst{22} = 0; // B bit
603 let Inst{24} = 0; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000604 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000605}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000606class AI2stbpo<dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, string cstr, list<dag> pattern>
608 : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
609 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000610 let Inst{20} = 0; // L bit
Evan Cheng93912732008-09-01 01:27:33 +0000611 let Inst{21} = 0; // W bit
612 let Inst{22} = 1; // B bit
613 let Inst{24} = 0; // P bit
Bill Wendlingda2ae632010-08-31 07:50:46 +0000614 let Inst{27-26} = 0b01;
Evan Cheng93912732008-09-01 01:27:33 +0000615}
616
Evan Cheng0d14fc82008-09-01 01:51:14 +0000617// addrmode3 instructions
Bob Wilson01135592010-03-23 17:23:59 +0000618class AI3<dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000619 string opc, string asm, list<dag> pattern>
620 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
621 opc, asm, "", pattern>;
622class AXI3<dag oops, dag iops, Format f, InstrItinClass itin,
623 string asm, list<dag> pattern>
624 : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
625 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000626
Evan Cheng840917b2008-09-01 07:00:14 +0000627// loads
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000628class AI3ldh<dag oops, dag iops, Format f, InstrItinClass itin,
629 string opc, string asm, list<dag> pattern>
630 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
631 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000632 let Inst{4} = 1;
633 let Inst{5} = 1; // H bit
634 let Inst{6} = 0; // S bit
635 let Inst{7} = 1;
636 let Inst{20} = 1; // L bit
637 let Inst{21} = 0; // W bit
638 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000639 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000640}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000641class AXI3ldh<dag oops, dag iops, Format f, InstrItinClass itin,
642 string asm, list<dag> pattern>
643 : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000644 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000645 let Inst{4} = 1;
646 let Inst{5} = 1; // H bit
647 let Inst{6} = 0; // S bit
648 let Inst{7} = 1;
649 let Inst{20} = 1; // L bit
650 let Inst{21} = 0; // W bit
651 let Inst{24} = 1; // P bit
652}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000653class AI3ldsh<dag oops, dag iops, Format f, InstrItinClass itin,
654 string opc, string asm, list<dag> pattern>
655 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
656 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000657 let Inst{4} = 1;
658 let Inst{5} = 1; // H bit
659 let Inst{6} = 1; // S bit
660 let Inst{7} = 1;
661 let Inst{20} = 1; // L bit
662 let Inst{21} = 0; // W bit
663 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000664 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000665}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000666class AXI3ldsh<dag oops, dag iops, Format f, InstrItinClass itin,
667 string asm, list<dag> pattern>
668 : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000669 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000670 let Inst{4} = 1;
671 let Inst{5} = 1; // H bit
672 let Inst{6} = 1; // S bit
673 let Inst{7} = 1;
674 let Inst{20} = 1; // L bit
675 let Inst{21} = 0; // W bit
676 let Inst{24} = 1; // P bit
677}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000678class AI3ldsb<dag oops, dag iops, Format f, InstrItinClass itin,
679 string opc, string asm, list<dag> pattern>
680 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
681 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000682 let Inst{4} = 1;
683 let Inst{5} = 0; // H bit
684 let Inst{6} = 1; // S bit
685 let Inst{7} = 1;
686 let Inst{20} = 1; // L bit
687 let Inst{21} = 0; // W bit
688 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000689 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000690}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000691class AXI3ldsb<dag oops, dag iops, Format f, InstrItinClass itin,
692 string asm, list<dag> pattern>
693 : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000694 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000695 let Inst{4} = 1;
696 let Inst{5} = 0; // H bit
697 let Inst{6} = 1; // S bit
698 let Inst{7} = 1;
699 let Inst{20} = 1; // L bit
700 let Inst{21} = 0; // W bit
701 let Inst{24} = 1; // P bit
702}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000703class AI3ldd<dag oops, dag iops, Format f, InstrItinClass itin,
704 string opc, string asm, list<dag> pattern>
705 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
706 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000707 let Inst{4} = 1;
708 let Inst{5} = 0; // H bit
709 let Inst{6} = 1; // S bit
710 let Inst{7} = 1;
711 let Inst{20} = 0; // L bit
712 let Inst{21} = 0; // W bit
713 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000714 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000715}
716
717// stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000718class AI3sth<dag oops, dag iops, Format f, InstrItinClass itin,
719 string opc, string asm, list<dag> pattern>
720 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
721 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000722 let Inst{4} = 1;
723 let Inst{5} = 1; // H bit
724 let Inst{6} = 0; // S bit
725 let Inst{7} = 1;
726 let Inst{20} = 0; // L bit
727 let Inst{21} = 0; // W bit
728 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000729 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000730}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000731class AXI3sth<dag oops, dag iops, Format f, InstrItinClass itin,
732 string asm, list<dag> pattern>
733 : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng83b5cf02008-11-05 23:22:34 +0000734 asm, "", pattern> {
Evan Cheng5d2c1cf2008-09-01 07:34:13 +0000735 let Inst{4} = 1;
736 let Inst{5} = 1; // H bit
737 let Inst{6} = 0; // S bit
738 let Inst{7} = 1;
739 let Inst{20} = 0; // L bit
740 let Inst{21} = 0; // W bit
741 let Inst{24} = 1; // P bit
742}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000743class AI3std<dag oops, dag iops, Format f, InstrItinClass itin,
744 string opc, string asm, list<dag> pattern>
745 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
746 opc, asm, "", pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000747 let Inst{4} = 1;
748 let Inst{5} = 1; // H bit
749 let Inst{6} = 1; // S bit
750 let Inst{7} = 1;
751 let Inst{20} = 0; // L bit
752 let Inst{21} = 0; // W bit
753 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000754 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000755}
756
757// Pre-indexed loads
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000758class AI3ldhpr<dag oops, dag iops, Format f, InstrItinClass itin,
759 string opc, string asm, string cstr, list<dag> pattern>
760 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
761 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000762 let Inst{4} = 1;
763 let Inst{5} = 1; // H bit
764 let Inst{6} = 0; // S bit
765 let Inst{7} = 1;
766 let Inst{20} = 1; // L bit
767 let Inst{21} = 1; // W bit
768 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000769 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000770}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000771class AI3ldshpr<dag oops, dag iops, Format f, InstrItinClass itin,
772 string opc, string asm, string cstr, list<dag> pattern>
773 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
774 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000775 let Inst{4} = 1;
776 let Inst{5} = 1; // H bit
777 let Inst{6} = 1; // S bit
778 let Inst{7} = 1;
779 let Inst{20} = 1; // L bit
780 let Inst{21} = 1; // W bit
781 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000782 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000783}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000784class AI3ldsbpr<dag oops, dag iops, Format f, InstrItinClass itin,
785 string opc, string asm, string cstr, list<dag> pattern>
786 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
787 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000788 let Inst{4} = 1;
789 let Inst{5} = 0; // H bit
790 let Inst{6} = 1; // S bit
791 let Inst{7} = 1;
792 let Inst{20} = 1; // L bit
793 let Inst{21} = 1; // W bit
794 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000795 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000796}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000797class AI3lddpr<dag oops, dag iops, Format f, InstrItinClass itin,
798 string opc, string asm, string cstr, list<dag> pattern>
799 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
800 opc, asm, cstr, pattern> {
801 let Inst{4} = 1;
802 let Inst{5} = 0; // H bit
803 let Inst{6} = 1; // S bit
804 let Inst{7} = 1;
805 let Inst{20} = 0; // L bit
806 let Inst{21} = 1; // W bit
807 let Inst{24} = 1; // P bit
808 let Inst{27-25} = 0b000;
809}
810
Evan Cheng840917b2008-09-01 07:00:14 +0000811
812// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000813class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
814 string opc, string asm, string cstr, list<dag> pattern>
815 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
816 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000817 let Inst{4} = 1;
818 let Inst{5} = 1; // H bit
819 let Inst{6} = 0; // S bit
820 let Inst{7} = 1;
821 let Inst{20} = 0; // L bit
822 let Inst{21} = 1; // W bit
823 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000824 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000825}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000826class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
827 string opc, string asm, string cstr, list<dag> pattern>
828 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
829 opc, asm, cstr, pattern> {
830 let Inst{4} = 1;
831 let Inst{5} = 1; // H bit
832 let Inst{6} = 1; // S bit
833 let Inst{7} = 1;
834 let Inst{20} = 0; // L bit
835 let Inst{21} = 1; // W bit
836 let Inst{24} = 1; // P bit
837 let Inst{27-25} = 0b000;
838}
Evan Cheng840917b2008-09-01 07:00:14 +0000839
840// Post-indexed loads
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000841class AI3ldhpo<dag oops, dag iops, Format f, InstrItinClass itin,
842 string opc, string asm, string cstr, list<dag> pattern>
843 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
844 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000845 let Inst{4} = 1;
846 let Inst{5} = 1; // H bit
847 let Inst{6} = 0; // S bit
848 let Inst{7} = 1;
849 let Inst{20} = 1; // L bit
Johnny Chenadb561d2010-02-18 03:27:42 +0000850 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000851 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000852 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000853}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000854class AI3ldshpo<dag oops, dag iops, Format f, InstrItinClass itin,
855 string opc, string asm, string cstr, list<dag> pattern>
856 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
857 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000858 let Inst{4} = 1;
859 let Inst{5} = 1; // H bit
860 let Inst{6} = 1; // S bit
861 let Inst{7} = 1;
862 let Inst{20} = 1; // L bit
Johnny Chenadb561d2010-02-18 03:27:42 +0000863 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000864 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000865 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000866}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000867class AI3ldsbpo<dag oops, dag iops, Format f, InstrItinClass itin,
868 string opc, string asm, string cstr, list<dag> pattern>
869 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
870 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000871 let Inst{4} = 1;
872 let Inst{5} = 0; // H bit
873 let Inst{6} = 1; // S bit
874 let Inst{7} = 1;
875 let Inst{20} = 1; // L bit
Johnny Chenadb561d2010-02-18 03:27:42 +0000876 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000877 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000878 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000879}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000880class AI3lddpo<dag oops, dag iops, Format f, InstrItinClass itin,
881 string opc, string asm, string cstr, list<dag> pattern>
882 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
883 opc, asm, cstr, pattern> {
884 let Inst{4} = 1;
885 let Inst{5} = 0; // H bit
886 let Inst{6} = 1; // S bit
887 let Inst{7} = 1;
888 let Inst{20} = 0; // L bit
889 let Inst{21} = 0; // W bit
890 let Inst{24} = 0; // P bit
891 let Inst{27-25} = 0b000;
892}
Evan Cheng840917b2008-09-01 07:00:14 +0000893
894// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000895class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
896 string opc, string asm, string cstr, list<dag> pattern>
897 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
898 opc, asm, cstr,pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000899 let Inst{4} = 1;
900 let Inst{5} = 1; // H bit
901 let Inst{6} = 0; // S bit
902 let Inst{7} = 1;
903 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000904 let Inst{21} = 0; // W bit
Evan Cheng840917b2008-09-01 07:00:14 +0000905 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000906 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000907}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000908class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
909 string opc, string asm, string cstr, list<dag> pattern>
910 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
911 opc, asm, cstr, pattern> {
912 let Inst{4} = 1;
913 let Inst{5} = 1; // H bit
914 let Inst{6} = 1; // S bit
915 let Inst{7} = 1;
916 let Inst{20} = 0; // L bit
917 let Inst{21} = 0; // W bit
918 let Inst{24} = 0; // P bit
919 let Inst{27-25} = 0b000;
920}
Evan Cheng840917b2008-09-01 07:00:14 +0000921
Evan Cheng0d14fc82008-09-01 01:51:14 +0000922// addrmode4 instructions
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000923class AXI4ld<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000924 string asm, string cstr, list<dag> pattern>
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000925 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000926 asm, cstr, pattern> {
Evan Cheng3c2ee492008-09-01 07:48:18 +0000927 let Inst{20} = 1; // L bit
928 let Inst{22} = 0; // S bit
Jim Grosbach26421962008-10-14 20:36:24 +0000929 let Inst{27-25} = 0b100;
Evan Cheng3c2ee492008-09-01 07:48:18 +0000930}
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000931class AXI4st<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000932 string asm, string cstr, list<dag> pattern>
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000933 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000934 asm, cstr, pattern> {
Evan Cheng3c2ee492008-09-01 07:48:18 +0000935 let Inst{20} = 0; // L bit
936 let Inst{22} = 0; // S bit
Jim Grosbach26421962008-10-14 20:36:24 +0000937 let Inst{27-25} = 0b100;
Evan Cheng3c2ee492008-09-01 07:48:18 +0000938}
Evan Cheng37f25d92008-08-28 23:39:26 +0000939
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000940// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000941class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
942 string opc, string asm, list<dag> pattern>
943 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
944 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000945 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000946 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000947 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000948}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000949class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
950 string opc, string asm, list<dag> pattern>
951 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
952 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000953 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000954 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000955}
956
957// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000958class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
959 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000960 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
961 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000962 bits<4> Rd;
963 bits<4> Rn;
964 bits<4> Rm;
965 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000966 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000967 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000968 let Inst{19-16} = Rd;
969 let Inst{11-8} = Rm;
970 let Inst{3-0} = Rn;
971}
972// MSW multiple w/ Ra operand
973class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
974 InstrItinClass itin, string opc, string asm, list<dag> pattern>
975 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
976 bits<4> Ra;
977 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000978}
Evan Cheng37f25d92008-08-28 23:39:26 +0000979
Evan Chengeb4f52e2008-11-06 03:35:07 +0000980// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000981class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000982 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000983 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
984 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000985 bits<4> Rn;
986 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000987 let Inst{4} = 0;
988 let Inst{7} = 1;
989 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000990 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000991 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000992 let Inst{11-8} = Rm;
993 let Inst{3-0} = Rn;
994}
995class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
996 InstrItinClass itin, string opc, string asm, list<dag> pattern>
997 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
998 bits<4> Rd;
999 let Inst{19-16} = Rd;
1000}
1001
1002// AMulxyI with Ra operand
1003class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1004 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1005 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1006 bits<4> Ra;
1007 let Inst{15-12} = Ra;
1008}
1009// SMLAL*
1010class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1011 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1012 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1013 bits<4> RdLo;
1014 bits<4> RdHi;
1015 let Inst{19-16} = RdHi;
1016 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +00001017}
1018
Evan Cheng97f48c32008-11-06 22:15:19 +00001019// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001020class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1021 string opc, string asm, list<dag> pattern>
1022 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
1023 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +00001024 // All AExtI instructions have Rd and Rm register operands.
1025 bits<4> Rd;
1026 bits<4> Rm;
1027 let Inst{15-12} = Rd;
1028 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +00001029 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +00001030 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +00001031 let Inst{27-20} = opcod;
1032}
1033
Evan Cheng8b59db32008-11-07 01:41:35 +00001034// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +00001035class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1036 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001037 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
1038 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +00001039 bits<4> Rd;
1040 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +00001041 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +00001042 let Inst{19-16} = 0b1111;
1043 let Inst{15-12} = Rd;
1044 let Inst{11-8} = 0b1111;
1045 let Inst{7-4} = opc7_4;
1046 let Inst{3-0} = Rm;
1047}
1048
1049// PKH instructions
1050class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1051 string opc, string asm, list<dag> pattern>
1052 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
1053 opc, asm, "", pattern> {
1054 bits<4> Rd;
1055 bits<4> Rn;
1056 bits<4> Rm;
1057 bits<8> sh;
1058 let Inst{27-20} = opcod;
1059 let Inst{19-16} = Rn;
1060 let Inst{15-12} = Rd;
1061 let Inst{11-7} = sh{7-3};
1062 let Inst{6} = tb;
1063 let Inst{5-4} = 0b01;
1064 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +00001065}
1066
Evan Cheng37f25d92008-08-28 23:39:26 +00001067//===----------------------------------------------------------------------===//
1068
1069// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1070class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1071 list<Predicate> Predicates = [IsARM];
1072}
1073class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1074 list<Predicate> Predicates = [IsARM, HasV5TE];
1075}
1076class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1077 list<Predicate> Predicates = [IsARM, HasV6];
1078}
Evan Cheng13096642008-08-29 06:41:12 +00001079
1080//===----------------------------------------------------------------------===//
1081//
1082// Thumb Instruction Format Definitions.
1083//
1084
Evan Cheng13096642008-08-29 06:41:12 +00001085// TI - Thumb instruction.
1086
Evan Cheng446c4282009-07-11 06:43:01 +00001087class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001088 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001089 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +00001090 let OutOperandList = oops;
1091 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001092 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +00001093 let Pattern = pattern;
1094 list<Predicate> Predicates = [IsThumb];
1095}
1096
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001097class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1098 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +00001099
Evan Cheng35d6c412009-08-04 23:47:55 +00001100// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +00001101class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1102 list<dag> pattern>
1103 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
1104 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +00001105
Johnny Chend68e1192009-12-15 17:24:14 +00001106// tBL, tBX 32-bit instructions
1107class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +00001108 dag oops, dag iops, InstrItinClass itin, string asm,
1109 list<dag> pattern>
1110 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
1111 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +00001112 let Inst{31-27} = opcod1;
1113 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001114 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +00001115}
Evan Cheng13096642008-08-29 06:41:12 +00001116
1117// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +00001118class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1119 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001120 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +00001121
Evan Cheng09c39fc2009-06-23 19:38:13 +00001122// Thumb1 only
Evan Cheng446c4282009-07-11 06:43:01 +00001123class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001124 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001125 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +00001126 let OutOperandList = oops;
1127 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001128 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +00001129 let Pattern = pattern;
1130 list<Predicate> Predicates = [IsThumb1Only];
1131}
1132
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001133class T1I<dag oops, dag iops, InstrItinClass itin,
1134 string asm, list<dag> pattern>
1135 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
1136class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1137 string asm, list<dag> pattern>
1138 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1139class T1JTI<dag oops, dag iops, InstrItinClass itin,
1140 string asm, list<dag> pattern>
Johnny Chenbbc71b22009-12-16 02:32:54 +00001141 : Thumb1I<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +00001142
1143// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001144class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001145 string asm, string cstr, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001146 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001147 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +00001148
1149// Thumb1 instruction that can either be predicated or set CPSR.
1150class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001151 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +00001152 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001153 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +00001154 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1155 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001156 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +00001157 let Pattern = pattern;
1158 list<Predicate> Predicates = [IsThumb1Only];
1159}
1160
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001161class T1sI<dag oops, dag iops, InstrItinClass itin,
1162 string opc, string asm, list<dag> pattern>
1163 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +00001164
1165// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001166class T1sIt<dag oops, dag iops, InstrItinClass itin,
1167 string opc, string asm, list<dag> pattern>
1168 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001169 "$lhs = $dst", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +00001170
1171// Thumb1 instruction that can be predicated.
1172class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001173 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +00001174 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001175 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +00001176 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001177 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001178 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +00001179 let Pattern = pattern;
1180 list<Predicate> Predicates = [IsThumb1Only];
1181}
1182
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001183class T1pI<dag oops, dag iops, InstrItinClass itin,
1184 string opc, string asm, list<dag> pattern>
1185 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +00001186
1187// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001188class T1pIt<dag oops, dag iops, InstrItinClass itin,
1189 string opc, string asm, list<dag> pattern>
1190 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001191 "$lhs = $dst", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +00001192
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001193class T1pI1<dag oops, dag iops, InstrItinClass itin,
1194 string opc, string asm, list<dag> pattern>
1195 : Thumb1pI<oops, iops, AddrModeT1_1, Size2Bytes, itin, opc, asm, "", pattern>;
1196class T1pI2<dag oops, dag iops, InstrItinClass itin,
1197 string opc, string asm, list<dag> pattern>
1198 : Thumb1pI<oops, iops, AddrModeT1_2, Size2Bytes, itin, opc, asm, "", pattern>;
1199class T1pI4<dag oops, dag iops, InstrItinClass itin,
1200 string opc, string asm, list<dag> pattern>
1201 : Thumb1pI<oops, iops, AddrModeT1_4, Size2Bytes, itin, opc, asm, "", pattern>;
Bob Wilson01135592010-03-23 17:23:59 +00001202class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001203 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1204 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +00001205
Johnny Chenbbc71b22009-12-16 02:32:54 +00001206class Encoding16 : Encoding {
1207 let Inst{31-16} = 0x0000;
1208}
1209
Johnny Chend68e1192009-12-15 17:24:14 +00001210// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +00001211class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001212 let Inst{15-10} = opcode;
1213}
1214
1215// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001216class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001217 let Inst{15-14} = 0b00;
1218 let Inst{13-9} = opcode;
1219}
1220
1221// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001222class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001223 let Inst{15-10} = 0b010000;
1224 let Inst{9-6} = opcode;
1225}
1226
1227// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001228class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001229 let Inst{15-10} = 0b010001;
1230 let Inst{9-6} = opcode;
1231}
1232
1233// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001234class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001235 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001236 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +00001237}
Bill Wendlingda2ae632010-08-31 07:50:46 +00001238class T1LdSt<bits<3> opB> : T1LoadStore<0b0101, opB>;
Johnny Chend68e1192009-12-15 17:24:14 +00001239class T1LdSt4Imm<bits<3> opB> : T1LoadStore<0b0110, opB>; // Immediate, 4 bytes
1240class T1LdSt1Imm<bits<3> opB> : T1LoadStore<0b0111, opB>; // Immediate, 1 byte
1241class T1LdSt2Imm<bits<3> opB> : T1LoadStore<0b1000, opB>; // Immediate, 2 bytes
Bill Wendlingda2ae632010-08-31 07:50:46 +00001242class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +00001243
1244// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001245class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001246 let Inst{15-12} = 0b1011;
1247 let Inst{11-5} = opcode;
1248}
1249
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001250// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1251class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001252 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001253 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001254 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001255 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001256 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001257 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001258 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001259 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001260}
1261
Bill Wendlingda2ae632010-08-31 07:50:46 +00001262// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1263// input operand since by default it's a zero register. It will become an
1264// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001265//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001266// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1267// more consistent.
1268class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001269 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001270 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001271 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001272 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001273 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001274 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001275 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001276 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001277}
1278
1279// Special cases
1280class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001281 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001282 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001283 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001284 let OutOperandList = oops;
1285 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001286 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001287 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001288 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001289}
1290
Jim Grosbachd1228742009-12-01 18:10:36 +00001291class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson01135592010-03-23 17:23:59 +00001292 InstrItinClass itin,
1293 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001294 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1295 let OutOperandList = oops;
1296 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001297 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001298 let Pattern = pattern;
1299 list<Predicate> Predicates = [IsThumb1Only];
1300}
1301
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001302class T2I<dag oops, dag iops, InstrItinClass itin,
1303 string opc, string asm, list<dag> pattern>
1304 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1305class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1306 string opc, string asm, list<dag> pattern>
Bob Wilson01135592010-03-23 17:23:59 +00001307 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001308class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1309 string opc, string asm, list<dag> pattern>
1310 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1311class T2Iso<dag oops, dag iops, InstrItinClass itin,
1312 string opc, string asm, list<dag> pattern>
1313 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1314class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1315 string opc, string asm, list<dag> pattern>
1316 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Johnny Chend68e1192009-12-15 17:24:14 +00001317class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001318 string opc, string asm, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +00001319 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1320 pattern> {
1321 let Inst{31-27} = 0b11101;
1322 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001323 let Inst{24} = P;
1324 let Inst{23} = ?; // The U bit.
1325 let Inst{22} = 1;
1326 let Inst{21} = W;
1327 let Inst{20} = load;
Johnny Chend68e1192009-12-15 17:24:14 +00001328}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001329
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001330class T2sI<dag oops, dag iops, InstrItinClass itin,
1331 string opc, string asm, list<dag> pattern>
1332 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001333
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001334class T2XI<dag oops, dag iops, InstrItinClass itin,
1335 string asm, list<dag> pattern>
1336 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1337class T2JTI<dag oops, dag iops, InstrItinClass itin,
1338 string asm, list<dag> pattern>
1339 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001340
Evan Cheng5adb66a2009-09-28 09:14:39 +00001341class T2Ix2<dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001342 string opc, string asm, list<dag> pattern>
Evan Cheng5adb66a2009-09-28 09:14:39 +00001343 : Thumb2I<oops, iops, AddrModeNone, Size8Bytes, itin, opc, asm, "", pattern>;
1344
Bob Wilson815baeb2010-03-13 01:08:20 +00001345// Two-address instructions
1346class T2XIt<dag oops, dag iops, InstrItinClass itin,
1347 string asm, string cstr, list<dag> pattern>
1348 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001349
Evan Chenge88d5ce2009-07-02 07:28:31 +00001350// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001351class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1352 dag oops, dag iops,
1353 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001354 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001355 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001356 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001357 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001358 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001359 let Pattern = pattern;
1360 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001361 let Inst{31-27} = 0b11111;
1362 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001363 let Inst{24} = signed;
1364 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001365 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001366 let Inst{20} = load;
1367 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001368 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001369 let Inst{10} = pre; // The P bit.
1370 let Inst{8} = 1; // The W bit.
Evan Chenge88d5ce2009-07-02 07:28:31 +00001371}
1372
Johnny Chenadc77332010-02-26 22:04:29 +00001373// Helper class for disassembly only
1374// A6.3.16 & A6.3.17
1375// T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
1376class T2I_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops, dag iops,
1377 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1378 : T2I<oops, iops, itin, opc, asm, pattern> {
1379 let Inst{31-27} = 0b11111;
1380 let Inst{26-24} = 0b011;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001381 let Inst{23} = long;
Johnny Chenadc77332010-02-26 22:04:29 +00001382 let Inst{22-20} = op22_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001383 let Inst{7-4} = op7_4;
Johnny Chenadc77332010-02-26 22:04:29 +00001384}
1385
David Goodwinc9d138f2009-07-27 19:59:26 +00001386// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1387class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1388 list<Predicate> Predicates = [IsThumb1Only, HasV5T];
1389}
1390
1391// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1392class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1393 list<Predicate> Predicates = [IsThumb1Only];
1394}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001395
Evan Cheng9cb9e672009-06-27 02:26:13 +00001396// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1397class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001398 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001399}
1400
Evan Cheng13096642008-08-29 06:41:12 +00001401//===----------------------------------------------------------------------===//
1402
Evan Cheng96581d32008-11-11 02:11:05 +00001403//===----------------------------------------------------------------------===//
1404// ARM VFP Instruction templates.
1405//
1406
David Goodwin3ca524e2009-07-10 17:03:29 +00001407// Almost all VFP instructions are predicable.
1408class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001409 IndexMode im, Format f, InstrItinClass itin,
1410 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001411 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001412 bits<4> p;
1413 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001414 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001415 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001416 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001417 let Pattern = pattern;
1418 list<Predicate> Predicates = [HasVFP2];
1419}
1420
1421// Special cases
1422class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001423 IndexMode im, Format f, InstrItinClass itin,
1424 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001425 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
David Goodwin3ca524e2009-07-10 17:03:29 +00001426 let OutOperandList = oops;
1427 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001428 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001429 let Pattern = pattern;
1430 list<Predicate> Predicates = [HasVFP2];
1431}
1432
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001433class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1434 string opc, string asm, list<dag> pattern>
1435 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1436 opc, asm, "", pattern>;
David Goodwin3ca524e2009-07-10 17:03:29 +00001437
Evan Chengcd8e66a2008-11-11 21:48:44 +00001438// ARM VFP addrmode5 loads and stores
1439class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001440 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001441 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001442 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001443 VFPLdStFrm, itin, opc, asm, "", pattern> {
Evan Cheng96581d32008-11-11 02:11:05 +00001444 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001445 let Inst{27-24} = opcod1;
1446 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001447 let Inst{11-9} = 0b101;
1448 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001449
1450 // 64-bit loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001451 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001452}
1453
Evan Chengcd8e66a2008-11-11 21:48:44 +00001454class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001455 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001456 string opc, string asm, list<dag> pattern>
David Goodwin3ca524e2009-07-10 17:03:29 +00001457 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001458 VFPLdStFrm, itin, opc, asm, "", pattern> {
Evan Cheng96581d32008-11-11 02:11:05 +00001459 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001460 let Inst{27-24} = opcod1;
1461 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001462 let Inst{11-9} = 0b101;
1463 let Inst{8} = 0; // Single precision
Evan Cheng96581d32008-11-11 02:11:05 +00001464}
1465
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001466// VFP Load / store multiple pseudo instructions.
1467class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1468 list<dag> pattern>
1469 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1470 cstr, itin> {
1471 let OutOperandList = oops;
1472 let InOperandList = !con(iops, (ins pred:$p));
1473 let Pattern = pattern;
1474 list<Predicate> Predicates = [HasVFP2];
1475}
1476
Evan Chengcd8e66a2008-11-11 21:48:44 +00001477// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001478class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001479 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001480 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001481 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Evan Chengcd8e66a2008-11-11 21:48:44 +00001482 // TODO: Mark the instructions with the appropriate subtarget info.
1483 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001484 let Inst{11-9} = 0b101;
1485 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001486
1487 // 64-bit loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001488 let D = VFPNeonDomain;
Evan Chengcd8e66a2008-11-11 21:48:44 +00001489}
1490
Jim Grosbach72db1822010-09-08 00:25:50 +00001491class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001492 string asm, string cstr, list<dag> pattern>
Jim Grosbach72db1822010-09-08 00:25:50 +00001493 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson01135592010-03-23 17:23:59 +00001494 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Evan Chengcd8e66a2008-11-11 21:48:44 +00001495 // TODO: Mark the instructions with the appropriate subtarget info.
1496 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001497 let Inst{11-9} = 0b101;
1498 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001499}
1500
Evan Cheng96581d32008-11-11 02:11:05 +00001501// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001502class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1503 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1504 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001505 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001506 let Inst{27-23} = opcod1;
1507 let Inst{21-20} = opcod2;
1508 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001509 let Inst{11-9} = 0b101;
1510 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001511 let Inst{7-6} = opcod4;
1512 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001513}
1514
1515// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001516class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001517 dag iops, InstrItinClass itin, string opc, string asm,
1518 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001519 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001520 let Inst{27-23} = opcod1;
1521 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001522 let Inst{11-9} = 0b101;
1523 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001524 let Inst{6} = op6;
1525 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001526}
1527
Jim Grosbach26767372010-03-24 22:31:46 +00001528// Double precision, binary, VML[AS] (for additional predicate)
1529class ADbI_vmlX<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1530 dag iops, InstrItinClass itin, string opc, string asm,
1531 list<dag> pattern>
1532 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1533 let Inst{27-23} = opcod1;
1534 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001535 let Inst{11-9} = 0b101;
1536 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001537 let Inst{6} = op6;
1538 let Inst{4} = op4;
Jim Grosbach26767372010-03-24 22:31:46 +00001539 list<Predicate> Predicates = [HasVFP2, UseVMLx];
1540}
1541
Evan Cheng96581d32008-11-11 02:11:05 +00001542// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001543class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1544 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1545 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001546 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001547 let Inst{27-23} = opcod1;
1548 let Inst{21-20} = opcod2;
1549 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001550 let Inst{11-9} = 0b101;
1551 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001552 let Inst{7-6} = opcod4;
1553 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001554}
1555
David Goodwin338268c2009-08-10 22:17:39 +00001556// Single precision unary, if no NEON
David Goodwin53e44712009-08-04 20:39:05 +00001557// Same as ASuI except not available if NEON is enabled
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001558class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1559 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1560 string asm, list<dag> pattern>
1561 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1562 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001563 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1564}
1565
Evan Cheng96581d32008-11-11 02:11:05 +00001566// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001567class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1568 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001569 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001570 let Inst{27-23} = opcod1;
1571 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001572 let Inst{11-9} = 0b101;
1573 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001574 let Inst{6} = op6;
1575 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001576}
1577
David Goodwin338268c2009-08-10 22:17:39 +00001578// Single precision binary, if no NEON
David Goodwin42a83f22009-08-04 17:53:06 +00001579// Same as ASbI except not available if NEON is enabled
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001580class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001581 dag iops, InstrItinClass itin, string opc, string asm,
1582 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001583 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001584 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1585}
1586
Evan Cheng80a11982008-11-12 06:41:41 +00001587// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001588class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1589 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1590 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001591 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001592 let Inst{27-23} = opcod1;
1593 let Inst{21-20} = opcod2;
1594 let Inst{19-16} = opcod3;
1595 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001596 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001597 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001598}
1599
Johnny Chen811663f2010-02-11 18:47:03 +00001600// VFP conversion between floating-point and fixed-point
1601class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001602 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1603 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001604 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1605 // size (fixed-point number): sx == 0 ? 16 : 32
1606 let Inst{7} = op5; // sx
1607}
1608
David Goodwin338268c2009-08-10 22:17:39 +00001609// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001610class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001611 dag oops, dag iops, InstrItinClass itin,
1612 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001613 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1614 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001615 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1616}
1617
Evan Cheng80a11982008-11-12 06:41:41 +00001618class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001619 InstrItinClass itin,
1620 string opc, string asm, list<dag> pattern>
1621 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001622 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001623 let Inst{11-8} = opcod2;
1624 let Inst{4} = 1;
1625}
1626
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001627class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1628 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1629 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001630
Bob Wilson01135592010-03-23 17:23:59 +00001631class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001632 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1633 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001634
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001635class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1636 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1637 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001638
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001639class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1640 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1641 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001642
Evan Cheng96581d32008-11-11 02:11:05 +00001643//===----------------------------------------------------------------------===//
1644
Bob Wilson5bafff32009-06-22 23:27:02 +00001645//===----------------------------------------------------------------------===//
1646// ARM NEON Instruction templates.
1647//
Evan Cheng13096642008-08-29 06:41:12 +00001648
Johnny Chencaa608e2010-03-20 00:17:00 +00001649class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1650 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1651 list<dag> pattern>
1652 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001653 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001654 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001655 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001656 let Pattern = pattern;
1657 list<Predicate> Predicates = [HasNEON];
1658}
1659
1660// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001661class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1662 InstrItinClass itin, string opc, string asm, string cstr,
1663 list<dag> pattern>
1664 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001665 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001666 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001667 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001668 let Pattern = pattern;
1669 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001670}
1671
Bob Wilsonb07c1712009-10-07 21:53:04 +00001672class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1673 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001674 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001675 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1676 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001677 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001678 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001679 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001680 let Inst{11-8} = op11_8;
1681 let Inst{7-4} = op7_4;
Bob Wilson205a5ca2009-07-08 18:11:30 +00001682}
1683
Bob Wilson709d5922010-08-25 23:27:42 +00001684class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1685 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1686 itin> {
1687 let OutOperandList = oops;
1688 let InOperandList = !con(iops, (ins pred:$p));
1689 list<Predicate> Predicates = [HasNEON];
1690}
1691
Jim Grosbach7cd27292010-10-06 20:36:55 +00001692class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1693 list<dag> pattern>
Bob Wilsonbd916c52010-09-13 23:55:10 +00001694 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1695 itin> {
1696 let OutOperandList = oops;
1697 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001698 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001699 list<Predicate> Predicates = [HasNEON];
1700}
1701
Johnny Chen785516a2010-03-23 16:43:47 +00001702class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001703 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001704 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1705 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001706 let Inst{31-25} = 0b1111001;
1707}
1708
Johnny Chen927b88f2010-03-23 20:40:44 +00001709class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001710 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001711 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001712 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001713 let Inst{31-25} = 0b1111001;
1714}
1715
1716// NEON "one register and a modified immediate" format.
1717class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1718 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001719 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001720 string opc, string dt, string asm, string cstr,
1721 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001722 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001723 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001724 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001725 let Inst{11-8} = op11_8;
1726 let Inst{7} = op7;
1727 let Inst{6} = op6;
1728 let Inst{5} = op5;
1729 let Inst{4} = op4;
Owen Andersona88ea032010-10-26 17:40:54 +00001730
1731 // Instruction operands.
1732 bits<5> Vd;
1733 bits<13> SIMM;
1734
1735 let Inst{15-12} = Vd{3-0};
1736 let Inst{22} = Vd{4};
1737 let Inst{24} = SIMM{7};
1738 let Inst{18-16} = SIMM{6-4};
1739 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001740}
1741
1742// NEON 2 vector register format.
1743class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1744 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001745 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001746 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001747 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001748 let Inst{24-23} = op24_23;
1749 let Inst{21-20} = op21_20;
1750 let Inst{19-18} = op19_18;
1751 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001752 let Inst{11-7} = op11_7;
1753 let Inst{6} = op6;
1754 let Inst{4} = op4;
Owen Anderson162875a2010-10-25 18:43:52 +00001755
1756 // Instruction operands.
1757 bits<5> Vd;
1758 bits<5> Vm;
1759
1760 let Inst{15-12} = Vd{3-0};
1761 let Inst{22} = Vd{4};
1762 let Inst{3-0} = Vm{3-0};
1763 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001764}
1765
1766// Same as N2V except it doesn't have a datatype suffix.
1767class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001768 bits<5> op11_7, bit op6, bit op4,
1769 dag oops, dag iops, InstrItinClass itin,
1770 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001771 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001772 let Inst{24-23} = op24_23;
1773 let Inst{21-20} = op21_20;
1774 let Inst{19-18} = op19_18;
1775 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001776 let Inst{11-7} = op11_7;
1777 let Inst{6} = op6;
1778 let Inst{4} = op4;
Owen Anderson162875a2010-10-25 18:43:52 +00001779
1780 // Instruction operands.
1781 bits<5> Vd;
1782 bits<5> Vm;
1783
1784 let Inst{15-12} = Vd{3-0};
1785 let Inst{22} = Vd{4};
1786 let Inst{3-0} = Vm{3-0};
1787 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001788}
1789
1790// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001791class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001792 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001793 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001794 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001795 let Inst{24} = op24;
1796 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001797 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001798 let Inst{7} = op7;
1799 let Inst{6} = op6;
1800 let Inst{4} = op4;
Owen Anderson3557d002010-10-26 20:56:57 +00001801
1802 // Instruction operands.
1803 bits<5> Vd;
1804 bits<5> Vm;
1805 bits<6> SIMM;
1806
1807 let Inst{15-12} = Vd{3-0};
1808 let Inst{22} = Vd{4};
1809 let Inst{3-0} = Vm{3-0};
1810 let Inst{5} = Vm{4};
1811 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001812}
1813
Bob Wilson10bc69c2010-03-27 03:56:52 +00001814// NEON 3 vector register format.
1815class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1816 dag oops, dag iops, Format f, InstrItinClass itin,
1817 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001818 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001819 let Inst{24} = op24;
1820 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001821 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001822 let Inst{11-8} = op11_8;
1823 let Inst{6} = op6;
1824 let Inst{4} = op4;
Owen Andersond451f882010-10-21 20:21:49 +00001825
1826 // Instruction operands.
1827 bits<5> Vd;
1828 bits<5> Vn;
1829 bits<5> Vm;
1830
1831 let Inst{15-12} = Vd{3-0};
1832 let Inst{22} = Vd{4};
1833 let Inst{19-16} = Vn{3-0};
1834 let Inst{7} = Vn{4};
1835 let Inst{3-0} = Vm{3-0};
1836 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001837}
1838
Johnny Chen841e8282010-03-23 21:35:03 +00001839// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001840class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1841 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001842 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001843 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001844 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001845 let Inst{24} = op24;
1846 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001847 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001848 let Inst{11-8} = op11_8;
1849 let Inst{6} = op6;
1850 let Inst{4} = op4;
Owen Anderson8c71eff2010-10-25 18:28:30 +00001851
1852 // Instruction operands.
1853 bits<5> Vd;
1854 bits<5> Vn;
1855 bits<5> Vm;
1856
1857 let Inst{15-12} = Vd{3-0};
1858 let Inst{22} = Vd{4};
1859 let Inst{19-16} = Vn{3-0};
1860 let Inst{7} = Vn{4};
1861 let Inst{3-0} = Vm{3-0};
1862 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001863}
1864
1865// NEON VMOVs between scalar and core registers.
1866class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001867 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001868 string opc, string dt, string asm, list<dag> pattern>
Evan Cheng0e9996c2010-10-26 02:03:05 +00001869 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001870 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001871 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001872 let Inst{11-8} = opcod2;
1873 let Inst{6-5} = opcod3;
1874 let Inst{4} = 1;
Evan Chengf81bf152009-11-23 21:57:23 +00001875
1876 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001877 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001878 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001879 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001880 list<Predicate> Predicates = [HasNEON];
Owen Andersonf587a9352010-10-27 19:25:54 +00001881
Owen Andersond2fbdb72010-10-27 21:28:09 +00001882 bits<5> V;
1883 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001884 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001885 bits<4> lane;
Owen Andersonf587a9352010-10-27 19:25:54 +00001886
1887 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001888 let Inst{7} = V{4};
1889 let Inst{19-16} = V{3-0};
1890 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001891}
1892class NVGetLane<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, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001896 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001897class NVSetLane<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, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001901 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001902class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001903 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001904 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001905 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001906 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001907
Johnny Chene4614f72010-03-25 17:01:27 +00001908// Vector Duplicate Lane (from scalar to all elements)
1909class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1910 InstrItinClass itin, string opc, string dt, string asm,
1911 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001912 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001913 let Inst{24-23} = 0b11;
1914 let Inst{21-20} = 0b11;
1915 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001916 let Inst{11-7} = 0b11000;
1917 let Inst{6} = op6;
1918 let Inst{4} = 0;
Owen Andersonf587a9352010-10-27 19:25:54 +00001919
1920 bits<5> Vd;
1921 bits<5> Vm;
1922 bits<4> lane;
1923
1924 let Inst{22} = Vd{4};
1925 let Inst{15-12} = Vd{3-0};
1926 let Inst{5} = Vm{4};
1927 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001928}
1929
David Goodwin42a83f22009-08-04 17:53:06 +00001930// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1931// for single-precision FP.
1932class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1933 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1934}