blob: 765cba42d0bd9839ce8babc68159c3f454aa773b [file] [log] [blame]
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson3968c6a2010-03-23 17:23:59 +00002//
Evan Cheng2d37f192008-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 Wilson3968c6a2010-03-23 17:23:59 +00007//
Evan Cheng2d37f192008-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 Wilson69ba1bc2010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng2d37f192008-08-28 23:39:26 +000020}
21
Evan Chengfabdcce2008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng2d37f192008-08-28 23:39:26 +000026
Evan Chengfabdcce2008-11-13 23:36:57 +000027def DPFrm : Format<4>;
28def DPSoRegFrm : Format<5>;
Evan Cheng2d37f192008-08-28 23:39:26 +000029
Evan Chengfabdcce2008-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 Cheng2d37f192008-08-28 23:39:26 +000035
Johnny Chen0dab68f2010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +000037
Johnny Chen0dab68f2010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson96649842010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000041
Bob Wilson96649842010-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 Cheng8cbbcb12008-11-11 21:48:44 +000052
Bob Wilson96649842010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng2d37f192008-08-28 23:39:26 +000055
Bob Wilson96649842010-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 Chenf833fad2010-03-20 00:17:00 +000071
Evan Cheng14965762009-07-08 01:46:35 +000072// Misc flags.
73
Bill Wendlingcbb08ca2010-12-01 02:42:55 +000074// The instruction has an Rn register operand.
Evan Cheng14965762009-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 Cheng2d37f192008-08-28 23:39:26 +000082
Evan Cheng2d37f192008-08-28 23:39:26 +000083//===----------------------------------------------------------------------===//
Bob Wilsona4d86b62010-03-18 23:57:57 +000084// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Chengb23b50d2009-06-29 07:51:04 +000085//
86
Jim Grosbachec86bac2011-01-18 19:59:19 +000087// FIXME: Once the JIT is MC-ized, these can go away.
Evan Chengb23b50d2009-06-29 07:51:04 +000088// Addressing mode.
Jim Grosbache9298992010-10-05 18:14:55 +000089class AddrMode<bits<5> val> {
90 bits<5> Value = val;
Evan Chengb23b50d2009-06-29 07:51:04 +000091}
Bill Wendlingb70dc872010-08-31 07:50:46 +000092def AddrModeNone : AddrMode<0>;
93def AddrMode1 : AddrMode<1>;
94def AddrMode2 : AddrMode<2>;
95def AddrMode3 : AddrMode<3>;
96def AddrMode4 : AddrMode<4>;
97def AddrMode5 : AddrMode<5>;
98def AddrMode6 : AddrMode<6>;
99def AddrModeT1_1 : AddrMode<7>;
100def AddrModeT1_2 : AddrMode<8>;
101def AddrModeT1_4 : AddrMode<9>;
102def AddrModeT1_s : AddrMode<10>;
103def AddrModeT2_i12 : AddrMode<11>;
104def AddrModeT2_i8 : AddrMode<12>;
105def AddrModeT2_so : AddrMode<13>;
106def AddrModeT2_pc : AddrMode<14>;
Bob Wilsondeb35af2009-07-01 23:16:05 +0000107def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000108def AddrMode_i12 : AddrMode<16>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000109
110// Instruction size.
111class SizeFlagVal<bits<3> val> {
112 bits<3> Value = val;
113}
114def SizeInvalid : SizeFlagVal<0>; // Unset.
115def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
116def Size8Bytes : SizeFlagVal<2>;
117def Size4Bytes : SizeFlagVal<3>;
118def Size2Bytes : SizeFlagVal<4>;
119
120// Load / store index mode.
121class IndexMode<bits<2> val> {
122 bits<2> Value = val;
123}
124def IndexModeNone : IndexMode<0>;
125def IndexModePre : IndexMode<1>;
126def IndexModePost : IndexMode<2>;
Bob Wilsonf1e8f7f2010-03-13 07:34:35 +0000127def IndexModeUpd : IndexMode<3>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000128
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000129// Instruction execution domain.
130class Domain<bits<2> val> {
131 bits<2> Value = val;
132}
133def GenericDomain : Domain<0>;
134def VFPDomain : Domain<1>; // Instructions in VFP domain only
135def NeonDomain : Domain<2>; // Instructions in Neon domain only
136def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
137
Evan Chengb23b50d2009-06-29 07:51:04 +0000138//===----------------------------------------------------------------------===//
Evan Chengcd4cdd12009-07-11 06:43:01 +0000139// ARM special operands.
140//
141
Daniel Dunbard8042b72010-08-11 06:36:53 +0000142def CondCodeOperand : AsmOperandClass {
143 let Name = "CondCode";
144 let SuperClasses = [];
145}
146
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000147def CCOutOperand : AsmOperandClass {
148 let Name = "CCOut";
149 let SuperClasses = [];
150}
151
Bruno Cardoso Lopes36dd43f2011-02-07 22:09:15 +0000152def MemBarrierOptOperand : AsmOperandClass {
153 let Name = "MemBarrierOpt";
154 let SuperClasses = [];
Jim Grosbach861e49c2011-02-12 01:34:40 +0000155 let ParserMethod = "tryParseMemBarrierOptOperand";
Bruno Cardoso Lopes36dd43f2011-02-07 22:09:15 +0000156}
157
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000158def ProcIFlagsOperand : AsmOperandClass {
159 let Name = "ProcIFlags";
160 let SuperClasses = [];
161 let ParserMethod = "tryParseProcIFlagsOperand";
162}
163
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000164def MSRMaskOperand : AsmOperandClass {
165 let Name = "MSRMask";
166 let SuperClasses = [];
167 let ParserMethod = "tryParseMSRMaskOperand";
168}
169
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000170// ARM imod and iflag operands, used only by the CPS instruction.
171def imod_op : Operand<i32> {
172 let PrintMethod = "printCPSIMod";
173}
174
175def iflags_op : Operand<i32> {
176 let PrintMethod = "printCPSIFlag";
177 let ParserMatchClass = ProcIFlagsOperand;
178}
179
Evan Chengcd4cdd12009-07-11 06:43:01 +0000180// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
181// register whose default is 0 (no register).
182def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
183 (ops (i32 14), (i32 zero_reg))> {
184 let PrintMethod = "printPredicateOperand";
Daniel Dunbard8042b72010-08-11 06:36:53 +0000185 let ParserMatchClass = CondCodeOperand;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000186}
187
188// Conditional code result for instructions whose 's' bit is set, e.g. subs.
189def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000190 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000191 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000192 let ParserMatchClass = CCOutOperand;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000193}
194
195// Same as cc_out except it defaults to setting CPSR.
196def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000197 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000198 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000199 let ParserMatchClass = CCOutOperand;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000200}
201
Johnny Chen9a3e2392010-03-10 18:59:38 +0000202// ARM special operands for disassembly only.
203//
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000204def setend_op : Operand<i32> {
205 let PrintMethod = "printSetendOperand";
206}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000207
208def cps_opt : Operand<i32> {
209 let PrintMethod = "printCPSOptionOperand";
210}
211
212def msr_mask : Operand<i32> {
213 let PrintMethod = "printMSRMaskOperand";
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000214 let ParserMatchClass = MSRMaskOperand;
Johnny Chen9a3e2392010-03-10 18:59:38 +0000215}
216
217// A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
218// The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
219def neg_zero : Operand<i32> {
220 let PrintMethod = "printNegZeroOperand";
221}
222
Evan Chengcd4cdd12009-07-11 06:43:01 +0000223//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000224// ARM Instruction templates.
225//
226
Johnny Chenc28e6292009-12-15 17:24:14 +0000227class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
228 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000229 : Instruction {
230 let Namespace = "ARM";
231
Evan Cheng2d37f192008-08-28 23:39:26 +0000232 AddrMode AM = am;
Evan Cheng2d37f192008-08-28 23:39:26 +0000233 SizeFlagVal SZ = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000234 IndexMode IM = im;
235 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000236 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000237 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000238 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000239 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000240 bit canXformTo16Bit = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000241
Chris Lattner7ff33462010-10-31 19:22:57 +0000242 // If this is a pseudo instruction, mark it isCodeGenOnly.
243 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000244
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000245 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000246 let TSFlags{4-0} = AM.Value;
247 let TSFlags{7-5} = SZ.Value;
248 let TSFlags{9-8} = IndexModeBits;
249 let TSFlags{15-10} = Form;
250 let TSFlags{16} = isUnaryDataProc;
251 let TSFlags{17} = canXformTo16Bit;
252 let TSFlags{19-18} = D.Value;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000253
Evan Cheng2d37f192008-08-28 23:39:26 +0000254 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000255 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000256}
257
Johnny Chenc28e6292009-12-15 17:24:14 +0000258class Encoding {
259 field bits<32> Inst;
260}
261
262class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
263 Format f, Domain d, string cstr, InstrItinClass itin>
264 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
265
266// This Encoding-less class is used by Thumb1 to specify the encoding bits later
267// on by adding flavors to specific instructions.
268class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
269 Format f, Domain d, string cstr, InstrItinClass itin>
270 : InstTemplate<am, sz, im, f, d, cstr, itin>;
271
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000272class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Jim Grosbach19be1fb2010-11-18 01:20:48 +0000273 // FIXME: This really should derive from InstTemplate instead, as pseudos
274 // don't need encoding information. TableGen doesn't like that
275 // currently. Need to figure out why and fix it.
Bob Wilson3968c6a2010-03-23 17:23:59 +0000276 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000277 "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000278 let OutOperandList = oops;
279 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000280 let Pattern = pattern;
281}
282
Jim Grosbachcfb66202010-11-18 01:15:56 +0000283// PseudoInst that's ARM-mode only.
Jim Grosbach0c51bb42010-11-29 23:48:41 +0000284class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000285 list<dag> pattern>
286 : PseudoInst<oops, iops, itin, pattern> {
Jim Grosbach0c51bb42010-11-29 23:48:41 +0000287 let SZ = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000288 list<Predicate> Predicates = [IsARM];
289}
290
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000291// PseudoInst that's Thumb-mode only.
292class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
293 list<dag> pattern>
294 : PseudoInst<oops, iops, itin, pattern> {
295 let SZ = sz;
296 list<Predicate> Predicates = [IsThumb];
297}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000298
Jim Grosbachd42257c2010-12-15 18:48:45 +0000299// PseudoInst that's Thumb2-mode only.
300class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
301 list<dag> pattern>
302 : PseudoInst<oops, iops, itin, pattern> {
303 let SZ = sz;
304 list<Predicate> Predicates = [IsThumb2];
305}
Evan Cheng2d37f192008-08-28 23:39:26 +0000306// Almost all ARM instructions are predicable.
Evan Cheng47b546d2008-11-06 08:47:38 +0000307class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000308 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000309 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000310 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000311 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000312 bits<4> p;
313 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000314 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000315 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000316 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000317 let Pattern = pattern;
318 list<Predicate> Predicates = [IsARM];
319}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000320
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000321// A few are not predicable
322class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000323 IndexMode im, Format f, InstrItinClass itin,
324 string opc, string asm, string cstr,
325 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000326 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
327 let OutOperandList = oops;
328 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000329 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000330 let Pattern = pattern;
331 let isPredicable = 0;
332 list<Predicate> Predicates = [IsARM];
333}
Evan Cheng2d37f192008-08-28 23:39:26 +0000334
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000335// Same as I except it can optionally modify CPSR. Note it's modeled as an input
336// operand since by default it's a zero register. It will become an implicit def
337// once it's "flipped".
Evan Cheng47b546d2008-11-06 08:47:38 +0000338class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000339 IndexMode im, Format f, InstrItinClass itin,
340 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000341 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000342 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000343 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000344 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000345 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000346 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000347
Evan Cheng2d37f192008-08-28 23:39:26 +0000348 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000349 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000350 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000351 let Pattern = pattern;
352 list<Predicate> Predicates = [IsARM];
353}
354
Evan Chenga2827232008-09-01 07:19:00 +0000355// Special cases
Evan Cheng47b546d2008-11-06 08:47:38 +0000356class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000357 IndexMode im, Format f, InstrItinClass itin,
358 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000359 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000360 let OutOperandList = oops;
361 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000362 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000363 let Pattern = pattern;
364 list<Predicate> Predicates = [IsARM];
365}
366
David Goodwinb062c232009-08-06 16:52:47 +0000367class AI<dag oops, dag iops, Format f, InstrItinClass itin,
368 string opc, string asm, list<dag> pattern>
369 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
370 opc, asm, "", pattern>;
371class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
372 string opc, string asm, list<dag> pattern>
373 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
374 opc, asm, "", pattern>;
375class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000376 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +0000377 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000378 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000379class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000380 string opc, string asm, list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000381 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000382 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000383
384// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000385class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
386 string opc, string asm, list<dag> pattern>
387 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
388 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000389 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000390}
David Goodwinb062c232009-08-06 16:52:47 +0000391class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
392 string asm, list<dag> pattern>
393 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
394 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000395 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000396}
Evan Chengfa558782008-09-01 08:25:56 +0000397
398// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000399class JTI<dag oops, dag iops, InstrItinClass itin,
400 string asm, list<dag> pattern>
401 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000402 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000403
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000404// Atomic load/store instructions
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000405class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
406 string opc, string asm, list<dag> pattern>
407 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
408 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000409 bits<4> Rt;
410 bits<4> Rn;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000411 let Inst{27-23} = 0b00011;
412 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000413 let Inst{20} = 1;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000414 let Inst{19-16} = Rn;
415 let Inst{15-12} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000416 let Inst{11-0} = 0b111110011111;
417}
418class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
419 string opc, string asm, list<dag> pattern>
420 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
421 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000422 bits<4> Rd;
423 bits<4> Rt;
424 bits<4> Rn;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000425 let Inst{27-23} = 0b00011;
426 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000427 let Inst{20} = 0;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000428 let Inst{19-16} = Rn;
429 let Inst{15-12} = Rd;
Johnny Chen098bd1b2009-12-11 19:37:26 +0000430 let Inst{11-4} = 0b11111001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000431 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000432}
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000433class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
434 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
435 bits<4> Rt;
436 bits<4> Rt2;
437 bits<4> Rn;
438 let Inst{27-23} = 0b00010;
439 let Inst{22} = b;
440 let Inst{21-20} = 0b00;
441 let Inst{19-16} = Rn;
442 let Inst{15-12} = Rt;
443 let Inst{11-4} = 0b00001001;
444 let Inst{3-0} = Rt2;
445}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000446
Evan Cheng624844b2008-09-01 01:51:14 +0000447// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000448class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
449 string opc, string asm, list<dag> pattern>
450 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
451 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000452 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000453 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000454}
David Goodwinb062c232009-08-06 16:52:47 +0000455class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
456 string opc, string asm, list<dag> pattern>
457 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
458 opc, asm, "", pattern> {
459 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000460 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000461}
462class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000463 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +0000464 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000465 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000466 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000467 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000468}
Evan Cheng624844b2008-09-01 01:51:14 +0000469
Evan Chengcccca872008-09-01 01:27:33 +0000470// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000471
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000472// LDR/LDRB/STR/STRB/...
473class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000474 Format f, InstrItinClass itin, string opc, string asm,
475 list<dag> pattern>
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000476 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
477 "", pattern> {
478 let Inst{27-25} = op;
479 let Inst{24} = 1; // 24 == P
480 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000481 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000482 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000483 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000484}
Jim Grosbach2f790742010-11-13 00:35:48 +0000485// Indexed load/stores
486class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000487 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000488 string asm, string cstr, list<dag> pattern>
489 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
490 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000491 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000492 let Inst{27-26} = 0b01;
493 let Inst{24} = isPre; // P bit
494 let Inst{22} = isByte; // B bit
495 let Inst{21} = isPre; // W bit
496 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000497 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000498}
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000499class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
500 IndexMode im, Format f, InstrItinClass itin, string opc,
501 string asm, string cstr, list<dag> pattern>
502 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
503 pattern> {
504 // AM2 store w/ two operands: (GPR, am2offset)
505 // {13} 1 == Rm, 0 == imm12
506 // {12} isAdd
507 // {11-0} imm12/Rm
508 bits<14> offset;
509 bits<4> Rn;
510 let Inst{25} = offset{13};
511 let Inst{23} = offset{12};
512 let Inst{19-16} = Rn;
513 let Inst{11-0} = offset{11-0};
514}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000515
Evan Cheng624844b2008-09-01 01:51:14 +0000516// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000517class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
518 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000519 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
520 opc, asm, "", pattern> {
521 bits<14> addr;
522 bits<4> Rt;
523 let Inst{27-25} = 0b000;
524 let Inst{24} = 1; // P bit
525 let Inst{23} = addr{8}; // U bit
526 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
527 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000528 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000529 let Inst{19-16} = addr{12-9}; // Rn
530 let Inst{15-12} = Rt; // Rt
531 let Inst{11-8} = addr{7-4}; // imm7_4/zero
532 let Inst{7-4} = op;
533 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
534}
Evan Cheng169eccc2008-09-01 07:00:14 +0000535
Jim Grosbach003c6e72010-11-19 19:41:26 +0000536class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
537 IndexMode im, Format f, InstrItinClass itin, string opc,
538 string asm, string cstr, list<dag> pattern>
539 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
540 opc, asm, cstr, pattern> {
541 bits<4> Rt;
542 let Inst{27-25} = 0b000;
543 let Inst{24} = isPre; // P bit
544 let Inst{21} = isPre; // W bit
545 let Inst{20} = op20; // L bit
546 let Inst{15-12} = Rt; // Rt
547 let Inst{7-4} = op;
548}
Jim Grosbach150b1ad2010-11-29 18:37:44 +0000549class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
550 IndexMode im, Format f, InstrItinClass itin, string opc,
551 string asm, string cstr, list<dag> pattern>
552 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
553 pattern> {
554 // AM3 store w/ two operands: (GPR, am3offset)
555 bits<14> offset;
556 bits<4> Rt;
557 bits<4> Rn;
558 let Inst{27-25} = 0b000;
559 let Inst{23} = offset{8};
560 let Inst{22} = offset{9};
561 let Inst{19-16} = Rn;
562 let Inst{15-12} = Rt; // Rt
563 let Inst{11-8} = offset{7-4}; // imm7_4/zero
564 let Inst{7-4} = op;
565 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
566}
Jim Grosbach003c6e72010-11-19 19:41:26 +0000567
Evan Cheng169eccc2008-09-01 07:00:14 +0000568// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000569class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000570 string opc, string asm, list<dag> pattern>
571 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
572 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000573 bits<14> addr;
574 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000575 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000576 let Inst{24} = 1; // P bit
577 let Inst{23} = addr{8}; // U bit
578 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
579 let Inst{21} = 0; // W bit
580 let Inst{20} = 0; // L bit
581 let Inst{19-16} = addr{12-9}; // Rn
582 let Inst{15-12} = Rt; // Rt
583 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000584 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000585 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng169eccc2008-09-01 07:00:14 +0000586}
Evan Cheng169eccc2008-09-01 07:00:14 +0000587
Evan Cheng169eccc2008-09-01 07:00:14 +0000588// Pre-indexed stores
David Goodwinb062c232009-08-06 16:52:47 +0000589class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
590 string opc, string asm, string cstr, list<dag> pattern>
591 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
592 opc, asm, cstr, pattern> {
Evan Cheng169eccc2008-09-01 07:00:14 +0000593 let Inst{4} = 1;
594 let Inst{5} = 1; // H bit
595 let Inst{6} = 0; // S bit
596 let Inst{7} = 1;
597 let Inst{20} = 0; // L bit
598 let Inst{21} = 1; // W bit
599 let Inst{24} = 1; // P bit
Evan Cheng5edd90c2009-07-08 22:51:32 +0000600 let Inst{27-25} = 0b000;
Evan Cheng169eccc2008-09-01 07:00:14 +0000601}
Johnny Chen688a90e2010-02-18 22:31:18 +0000602class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
603 string opc, string asm, string cstr, list<dag> pattern>
604 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
605 opc, asm, cstr, pattern> {
606 let Inst{4} = 1;
607 let Inst{5} = 1; // H bit
608 let Inst{6} = 1; // S bit
609 let Inst{7} = 1;
610 let Inst{20} = 0; // L bit
611 let Inst{21} = 1; // W bit
612 let Inst{24} = 1; // P bit
613 let Inst{27-25} = 0b000;
614}
Evan Cheng169eccc2008-09-01 07:00:14 +0000615
Evan Cheng169eccc2008-09-01 07:00:14 +0000616// Post-indexed stores
David Goodwinb062c232009-08-06 16:52:47 +0000617class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
618 string opc, string asm, string cstr, list<dag> pattern>
619 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
620 opc, asm, cstr,pattern> {
Evan Cheng169eccc2008-09-01 07:00:14 +0000621 let Inst{4} = 1;
622 let Inst{5} = 1; // H bit
623 let Inst{6} = 0; // S bit
624 let Inst{7} = 1;
625 let Inst{20} = 0; // L bit
Johnny Chen718ed8a2010-03-01 19:22:00 +0000626 let Inst{21} = 0; // W bit
Evan Cheng169eccc2008-09-01 07:00:14 +0000627 let Inst{24} = 0; // P bit
Evan Cheng5edd90c2009-07-08 22:51:32 +0000628 let Inst{27-25} = 0b000;
Evan Cheng169eccc2008-09-01 07:00:14 +0000629}
Johnny Chen688a90e2010-02-18 22:31:18 +0000630class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
631 string opc, string asm, string cstr, list<dag> pattern>
632 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
633 opc, asm, cstr, pattern> {
634 let Inst{4} = 1;
635 let Inst{5} = 1; // H bit
636 let Inst{6} = 1; // S bit
637 let Inst{7} = 1;
638 let Inst{20} = 0; // L bit
639 let Inst{21} = 0; // W bit
640 let Inst{24} = 0; // P bit
641 let Inst{27-25} = 0b000;
642}
Evan Cheng169eccc2008-09-01 07:00:14 +0000643
Evan Cheng624844b2008-09-01 01:51:14 +0000644// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000645class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
646 string asm, string cstr, list<dag> pattern>
647 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
648 bits<4> p;
649 bits<16> regs;
650 bits<4> Rn;
651 let Inst{31-28} = p;
652 let Inst{27-25} = 0b100;
653 let Inst{22} = 0; // S bit
654 let Inst{19-16} = Rn;
655 let Inst{15-0} = regs;
656}
Evan Cheng2d37f192008-08-28 23:39:26 +0000657
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000658// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000659class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
660 string opc, string asm, list<dag> pattern>
661 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
662 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000663 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000664 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000665 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000666}
David Goodwinb062c232009-08-06 16:52:47 +0000667class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
668 string opc, string asm, list<dag> pattern>
669 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
670 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000671 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000672 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000673}
674
675// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000676class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
677 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +0000678 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
679 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000680 bits<4> Rd;
681 bits<4> Rn;
682 bits<4> Rm;
683 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000684 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000685 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000686 let Inst{19-16} = Rd;
687 let Inst{11-8} = Rm;
688 let Inst{3-0} = Rn;
689}
690// MSW multiple w/ Ra operand
691class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
692 InstrItinClass itin, string opc, string asm, list<dag> pattern>
693 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
694 bits<4> Ra;
695 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000696}
Evan Cheng2d37f192008-08-28 23:39:26 +0000697
Evan Cheng36ae4032008-11-06 03:35:07 +0000698// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000699class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000700 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +0000701 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
702 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000703 bits<4> Rn;
704 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000705 let Inst{4} = 0;
706 let Inst{7} = 1;
707 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000708 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000709 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000710 let Inst{11-8} = Rm;
711 let Inst{3-0} = Rn;
712}
713class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
714 InstrItinClass itin, string opc, string asm, list<dag> pattern>
715 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
716 bits<4> Rd;
717 let Inst{19-16} = Rd;
718}
719
720// AMulxyI with Ra operand
721class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
722 InstrItinClass itin, string opc, string asm, list<dag> pattern>
723 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
724 bits<4> Ra;
725 let Inst{15-12} = Ra;
726}
727// SMLAL*
728class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
729 InstrItinClass itin, string opc, string asm, list<dag> pattern>
730 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
731 bits<4> RdLo;
732 bits<4> RdHi;
733 let Inst{19-16} = RdHi;
734 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000735}
736
Evan Cheng49d66522008-11-06 22:15:19 +0000737// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000738class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
739 string opc, string asm, list<dag> pattern>
740 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
741 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000742 // All AExtI instructions have Rd and Rm register operands.
743 bits<4> Rd;
744 bits<4> Rm;
745 let Inst{15-12} = Rd;
746 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000747 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000748 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000749 let Inst{27-20} = opcod;
750}
751
Evan Cheng98dc53e2008-11-07 01:41:35 +0000752// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000753class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
754 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +0000755 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
756 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000757 bits<4> Rd;
758 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000759 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000760 let Inst{19-16} = 0b1111;
761 let Inst{15-12} = Rd;
762 let Inst{11-8} = 0b1111;
763 let Inst{7-4} = opc7_4;
764 let Inst{3-0} = Rm;
765}
766
767// PKH instructions
768class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
769 string opc, string asm, list<dag> pattern>
770 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
771 opc, asm, "", pattern> {
772 bits<4> Rd;
773 bits<4> Rn;
774 bits<4> Rm;
775 bits<8> sh;
776 let Inst{27-20} = opcod;
777 let Inst{19-16} = Rn;
778 let Inst{15-12} = Rd;
779 let Inst{11-7} = sh{7-3};
780 let Inst{6} = tb;
781 let Inst{5-4} = 0b01;
782 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000783}
784
Evan Cheng2d37f192008-08-28 23:39:26 +0000785//===----------------------------------------------------------------------===//
786
787// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
788class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
789 list<Predicate> Predicates = [IsARM];
790}
791class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
792 list<Predicate> Predicates = [IsARM, HasV5TE];
793}
794class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
795 list<Predicate> Predicates = [IsARM, HasV6];
796}
Evan Chengee98fa92008-08-29 06:41:12 +0000797
798//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000799// Thumb Instruction Format Definitions.
800//
801
Evan Chengcd4cdd12009-07-11 06:43:01 +0000802class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000803 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000804 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000805 let OutOperandList = oops;
806 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000807 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000808 let Pattern = pattern;
809 list<Predicate> Predicates = [IsThumb];
810}
811
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000812// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000813class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
814 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000815
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000816// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000817class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
818 list<dag> pattern>
819 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
820 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000821
Johnny Chenc28e6292009-12-15 17:24:14 +0000822// tBL, tBX 32-bit instructions
823class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000824 dag oops, dag iops, InstrItinClass itin, string asm,
825 list<dag> pattern>
826 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
827 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +0000828 let Inst{31-27} = opcod1;
829 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000830 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +0000831}
Evan Chengee98fa92008-08-29 06:41:12 +0000832
Bruno Cardoso Lopescf99dc72011-01-20 16:35:57 +0000833// Move to/from coprocessor instructions
834class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
835 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
836 Encoding, Requires<[IsThumb, HasV6]> {
837 let Inst{31-28} = 0b1110;
838}
839
Evan Chengee98fa92008-08-29 06:41:12 +0000840// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000841class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
842 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +0000843 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000844
Evan Chengbec1dba892009-06-23 19:38:13 +0000845// Thumb1 only
Evan Chengcd4cdd12009-07-11 06:43:01 +0000846class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000847 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000848 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000849 let OutOperandList = oops;
850 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000851 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +0000852 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000853 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +0000854}
855
David Goodwinb062c232009-08-06 16:52:47 +0000856class T1I<dag oops, dag iops, InstrItinClass itin,
857 string asm, list<dag> pattern>
858 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
859class T1Ix2<dag oops, dag iops, InstrItinClass itin,
860 string asm, list<dag> pattern>
861 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000862
863// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000864class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000865 string asm, string cstr, list<dag> pattern>
Bob Wilson3968c6a2010-03-23 17:23:59 +0000866 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000867 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000868
869// Thumb1 instruction that can either be predicated or set CPSR.
870class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000871 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000872 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000873 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000874 let OutOperandList = !con(oops, (outs s_cc_out:$s));
875 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000876 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000877 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000878 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000879}
880
David Goodwinb062c232009-08-06 16:52:47 +0000881class T1sI<dag oops, dag iops, InstrItinClass itin,
882 string opc, string asm, list<dag> pattern>
883 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000884
885// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000886class T1sIt<dag oops, dag iops, InstrItinClass itin,
887 string opc, string asm, list<dag> pattern>
888 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +0000889 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000890
891// Thumb1 instruction that can be predicated.
892class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000893 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000894 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000895 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000896 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000897 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000898 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000899 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000900 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000901}
902
David Goodwinb062c232009-08-06 16:52:47 +0000903class T1pI<dag oops, dag iops, InstrItinClass itin,
904 string opc, string asm, list<dag> pattern>
905 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000906
907// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000908class T1pIt<dag oops, dag iops, InstrItinClass itin,
909 string opc, string asm, list<dag> pattern>
910 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +0000911 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000912
Bob Wilson3968c6a2010-03-23 17:23:59 +0000913class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +0000914 InstrItinClass itin, string opc, string asm, list<dag> pattern>
915 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000916
Johnny Chen466231a2009-12-16 02:32:54 +0000917class Encoding16 : Encoding {
918 let Inst{31-16} = 0x0000;
919}
920
Johnny Chenc28e6292009-12-15 17:24:14 +0000921// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +0000922class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000923 let Inst{15-10} = opcode;
924}
925
926// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000927class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000928 let Inst{15-14} = 0b00;
929 let Inst{13-9} = opcode;
930}
931
932// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000933class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000934 let Inst{15-10} = 0b010000;
935 let Inst{9-6} = opcode;
936}
937
938// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000939class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000940 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +0000941 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +0000942}
943
944// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000945class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000946 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000947 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +0000948}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000949class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +0000950
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000951// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +0000952// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +0000953//
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000954// 0b0110 => Immediate, 4 bytes
955// 0b1000 => Immediate, 2 bytes
956// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +0000957class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
958 InstrItinClass itin, string opc, string asm,
959 list<dag> pattern>
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000960 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +0000961 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000962 bits<3> Rt;
963 bits<8> addr;
964 let Inst{8-6} = addr{5-3}; // Rm
965 let Inst{5-3} = addr{2-0}; // Rn
966 let Inst{2-0} = Rt;
967}
Bill Wendlingc25545a2010-12-01 01:38:08 +0000968class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
969 InstrItinClass itin, string opc, string asm,
970 list<dag> pattern>
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000971 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +0000972 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000973 bits<3> Rt;
974 bits<8> addr;
975 let Inst{10-6} = addr{7-3}; // imm5
976 let Inst{5-3} = addr{2-0}; // Rn
977 let Inst{2-0} = Rt;
978}
979
Johnny Chenc28e6292009-12-15 17:24:14 +0000980// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000981class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000982 let Inst{15-12} = 0b1011;
983 let Inst{11-5} = opcode;
984}
985
Evan Chengd76f0be2009-06-25 02:08:06 +0000986// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
987class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +0000988 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +0000989 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000990 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +0000991 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000992 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000993 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +0000994 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +0000995 list<Predicate> Predicates = [IsThumb2];
Evan Chengd76f0be2009-06-25 02:08:06 +0000996}
997
Bill Wendlingb70dc872010-08-31 07:50:46 +0000998// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
999// input operand since by default it's a zero register. It will become an
1000// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001001//
Evan Chengd76f0be2009-06-25 02:08:06 +00001002// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1003// more consistent.
1004class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +00001005 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001006 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001007 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001008 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1009 let Inst{20} = s;
1010
Evan Chengd76f0be2009-06-25 02:08:06 +00001011 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001012 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001013 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001014 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001015 list<Predicate> Predicates = [IsThumb2];
Evan Chengd76f0be2009-06-25 02:08:06 +00001016}
1017
1018// Special cases
1019class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +00001020 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001021 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001022 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001023 let OutOperandList = oops;
1024 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001025 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001026 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001027 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001028}
1029
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001030class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001031 InstrItinClass itin,
1032 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001033 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1034 let OutOperandList = oops;
1035 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001036 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001037 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001038 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001039}
1040
David Goodwinb062c232009-08-06 16:52:47 +00001041class T2I<dag oops, dag iops, InstrItinClass itin,
1042 string opc, string asm, list<dag> pattern>
1043 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1044class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1045 string opc, string asm, list<dag> pattern>
Bob Wilson3968c6a2010-03-23 17:23:59 +00001046 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001047class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1048 string opc, string asm, list<dag> pattern>
1049 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1050class T2Iso<dag oops, dag iops, InstrItinClass itin,
1051 string opc, string asm, list<dag> pattern>
1052 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1053class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1054 string opc, string asm, list<dag> pattern>
1055 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001056class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +00001057 string opc, string asm, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001058 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1059 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001060 bits<4> Rt;
1061 bits<4> Rt2;
1062 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001063 let Inst{31-25} = 0b1110100;
1064 let Inst{24} = P;
1065 let Inst{23} = addr{8};
1066 let Inst{22} = 1;
1067 let Inst{21} = W;
1068 let Inst{20} = isLoad;
1069 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001070 let Inst{15-12} = Rt{3-0};
1071 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001072 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001073}
Evan Chengd76f0be2009-06-25 02:08:06 +00001074
David Goodwinb062c232009-08-06 16:52:47 +00001075class T2sI<dag oops, dag iops, InstrItinClass itin,
1076 string opc, string asm, list<dag> pattern>
1077 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001078
David Goodwinb062c232009-08-06 16:52:47 +00001079class T2XI<dag oops, dag iops, InstrItinClass itin,
1080 string asm, list<dag> pattern>
1081 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1082class T2JTI<dag oops, dag iops, InstrItinClass itin,
1083 string asm, list<dag> pattern>
1084 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001085
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001086// Move to/from coprocessor instructions
1087class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1088 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1089 let Inst{31-28} = 0b1111;
1090}
1091
Bob Wilson947f04b2010-03-13 01:08:20 +00001092// Two-address instructions
1093class T2XIt<dag oops, dag iops, InstrItinClass itin,
1094 string asm, string cstr, list<dag> pattern>
1095 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001096
Evan Cheng84c6cda2009-07-02 07:28:31 +00001097// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chenc28e6292009-12-15 17:24:14 +00001098class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1099 dag oops, dag iops,
1100 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001101 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001102 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001103 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001104 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001105 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001106 let Pattern = pattern;
1107 list<Predicate> Predicates = [IsThumb2];
Johnny Chenc28e6292009-12-15 17:24:14 +00001108 let Inst{31-27} = 0b11111;
1109 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001110 let Inst{24} = signed;
1111 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001112 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001113 let Inst{20} = load;
1114 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001115 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001116 let Inst{10} = pre; // The P bit.
1117 let Inst{8} = 1; // The W bit.
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001118
Owen Andersone22c7322010-11-30 00:14:31 +00001119 bits<9> addr;
1120 let Inst{7-0} = addr{7-0};
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001121 let Inst{9} = addr{8}; // Sign bit
1122
Owen Andersone22c7322010-11-30 00:14:31 +00001123 bits<4> Rt;
1124 bits<4> Rn;
1125 let Inst{15-12} = Rt{3-0};
1126 let Inst{19-16} = Rn{3-0};
Evan Cheng84c6cda2009-07-02 07:28:31 +00001127}
1128
David Goodwine5b969f2009-07-27 19:59:26 +00001129// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1130class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001131 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001132}
1133
1134// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1135class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001136 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001137}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001138
Evan Chengeab9ca72009-06-27 02:26:13 +00001139// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1140class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001141 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001142}
1143
Evan Chengee98fa92008-08-29 06:41:12 +00001144//===----------------------------------------------------------------------===//
1145
Evan Chengac2af2f2008-11-11 02:11:05 +00001146//===----------------------------------------------------------------------===//
1147// ARM VFP Instruction templates.
1148//
1149
David Goodwin81cdd212009-07-10 17:03:29 +00001150// Almost all VFP instructions are predicable.
1151class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +00001152 IndexMode im, Format f, InstrItinClass itin,
1153 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001154 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001155 bits<4> p;
1156 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001157 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001158 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001159 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001160 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001161 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin81cdd212009-07-10 17:03:29 +00001162 list<Predicate> Predicates = [HasVFP2];
1163}
1164
1165// Special cases
1166class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
David Goodwinb062c232009-08-06 16:52:47 +00001167 IndexMode im, Format f, InstrItinClass itin,
1168 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001169 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001170 bits<4> p;
1171 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001172 let OutOperandList = oops;
1173 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001174 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001175 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001176 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin81cdd212009-07-10 17:03:29 +00001177 list<Predicate> Predicates = [HasVFP2];
1178}
1179
David Goodwinb062c232009-08-06 16:52:47 +00001180class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1181 string opc, string asm, list<dag> pattern>
1182 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001183 opc, asm, "", pattern> {
1184 let PostEncoderMethod = "VFPThumb2PostEncoder";
1185}
David Goodwin81cdd212009-07-10 17:03:29 +00001186
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001187// ARM VFP addrmode5 loads and stores
1188class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001189 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001190 string opc, string asm, list<dag> pattern>
David Goodwin81cdd212009-07-10 17:03:29 +00001191 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001192 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001193 // Instruction operands.
1194 bits<5> Dd;
1195 bits<13> addr;
1196
1197 // Encode instruction operands.
1198 let Inst{23} = addr{8}; // U (add = (U == '1'))
1199 let Inst{22} = Dd{4};
1200 let Inst{19-16} = addr{12-9}; // Rn
1201 let Inst{15-12} = Dd{3-0};
1202 let Inst{7-0} = addr{7-0}; // imm8
1203
Evan Chengac2af2f2008-11-11 02:11:05 +00001204 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001205 let Inst{27-24} = opcod1;
1206 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001207 let Inst{11-9} = 0b101;
1208 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001209
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001210 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001211 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001212}
1213
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001214class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001215 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001216 string opc, string asm, list<dag> pattern>
David Goodwin81cdd212009-07-10 17:03:29 +00001217 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001218 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001219 // Instruction operands.
1220 bits<5> Sd;
1221 bits<13> addr;
1222
1223 // Encode instruction operands.
1224 let Inst{23} = addr{8}; // U (add = (U == '1'))
1225 let Inst{22} = Sd{0};
1226 let Inst{19-16} = addr{12-9}; // Rn
1227 let Inst{15-12} = Sd{4-1};
1228 let Inst{7-0} = addr{7-0}; // imm8
1229
Evan Chengac2af2f2008-11-11 02:11:05 +00001230 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001231 let Inst{27-24} = opcod1;
1232 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001233 let Inst{11-9} = 0b101;
1234 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001235
1236 // Loads & stores operate on both NEON and VFP pipelines.
1237 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001238}
1239
Bob Wilson6b853c32010-09-16 00:31:02 +00001240// VFP Load / store multiple pseudo instructions.
1241class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1242 list<dag> pattern>
1243 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1244 cstr, itin> {
1245 let OutOperandList = oops;
1246 let InOperandList = !con(iops, (ins pred:$p));
1247 let Pattern = pattern;
1248 list<Predicate> Predicates = [HasVFP2];
1249}
1250
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001251// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001252class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001253 string asm, string cstr, list<dag> pattern>
Jim Grosbachabcbe242010-09-08 00:25:50 +00001254 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001255 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001256 // Instruction operands.
1257 bits<4> Rn;
1258 bits<13> regs;
1259
1260 // Encode instruction operands.
1261 let Inst{19-16} = Rn;
1262 let Inst{22} = regs{12};
1263 let Inst{15-12} = regs{11-8};
1264 let Inst{7-0} = regs{7-0};
1265
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001266 // TODO: Mark the instructions with the appropriate subtarget info.
1267 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001268 let Inst{11-9} = 0b101;
1269 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001270}
1271
Jim Grosbachabcbe242010-09-08 00:25:50 +00001272class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001273 string asm, string cstr, list<dag> pattern>
Jim Grosbachabcbe242010-09-08 00:25:50 +00001274 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001275 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001276 // Instruction operands.
1277 bits<4> Rn;
1278 bits<13> regs;
1279
1280 // Encode instruction operands.
1281 let Inst{19-16} = Rn;
1282 let Inst{22} = regs{8};
1283 let Inst{15-12} = regs{12-9};
1284 let Inst{7-0} = regs{7-0};
1285
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001286 // TODO: Mark the instructions with the appropriate subtarget info.
1287 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001288 let Inst{11-9} = 0b101;
1289 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001290}
1291
Evan Chengac2af2f2008-11-11 02:11:05 +00001292// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001293class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1294 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1295 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001296 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001297 // Instruction operands.
1298 bits<5> Dd;
1299 bits<5> Dm;
1300
1301 // Encode instruction operands.
1302 let Inst{3-0} = Dm{3-0};
1303 let Inst{5} = Dm{4};
1304 let Inst{15-12} = Dd{3-0};
1305 let Inst{22} = Dd{4};
1306
Johnny Chen34a6afc2010-01-29 23:21:10 +00001307 let Inst{27-23} = opcod1;
1308 let Inst{21-20} = opcod2;
1309 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001310 let Inst{11-9} = 0b101;
1311 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001312 let Inst{7-6} = opcod4;
1313 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001314}
1315
1316// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001317class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001318 dag iops, InstrItinClass itin, string opc, string asm,
1319 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001320 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001321 // Instruction operands.
1322 bits<5> Dd;
1323 bits<5> Dn;
1324 bits<5> Dm;
1325
1326 // Encode instruction operands.
1327 let Inst{3-0} = Dm{3-0};
1328 let Inst{5} = Dm{4};
1329 let Inst{19-16} = Dn{3-0};
1330 let Inst{7} = Dn{4};
1331 let Inst{15-12} = Dd{3-0};
1332 let Inst{22} = Dd{4};
1333
Johnny Chen34a6afc2010-01-29 23:21:10 +00001334 let Inst{27-23} = opcod1;
1335 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001336 let Inst{11-9} = 0b101;
1337 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001338 let Inst{6} = op6;
1339 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001340}
1341
1342// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001343class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1344 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1345 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001346 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001347 // Instruction operands.
1348 bits<5> Sd;
1349 bits<5> Sm;
1350
1351 // Encode instruction operands.
1352 let Inst{3-0} = Sm{4-1};
1353 let Inst{5} = Sm{0};
1354 let Inst{15-12} = Sd{4-1};
1355 let Inst{22} = Sd{0};
1356
Johnny Chen34a6afc2010-01-29 23:21:10 +00001357 let Inst{27-23} = opcod1;
1358 let Inst{21-20} = opcod2;
1359 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001360 let Inst{11-9} = 0b101;
1361 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001362 let Inst{7-6} = opcod4;
1363 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001364}
1365
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001366// Single precision unary, if no NEON. Same as ASuI except not available if
1367// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001368class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1369 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1370 string asm, list<dag> pattern>
1371 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1372 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001373 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1374}
1375
Evan Chengac2af2f2008-11-11 02:11:05 +00001376// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001377class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1378 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001379 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001380 // Instruction operands.
1381 bits<5> Sd;
1382 bits<5> Sn;
1383 bits<5> Sm;
1384
1385 // Encode instruction operands.
1386 let Inst{3-0} = Sm{4-1};
1387 let Inst{5} = Sm{0};
1388 let Inst{19-16} = Sn{4-1};
1389 let Inst{7} = Sn{0};
1390 let Inst{15-12} = Sd{4-1};
1391 let Inst{22} = Sd{0};
1392
Johnny Chen34a6afc2010-01-29 23:21:10 +00001393 let Inst{27-23} = opcod1;
1394 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001395 let Inst{11-9} = 0b101;
1396 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001397 let Inst{6} = op6;
1398 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001399}
1400
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001401// Single precision binary, if no NEON. Same as ASbI except not available if
1402// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001403class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001404 dag iops, InstrItinClass itin, string opc, string asm,
1405 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001406 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001407 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001408
1409 // Instruction operands.
1410 bits<5> Sd;
1411 bits<5> Sn;
1412 bits<5> Sm;
1413
1414 // Encode instruction operands.
1415 let Inst{3-0} = Sm{4-1};
1416 let Inst{5} = Sm{0};
1417 let Inst{19-16} = Sn{4-1};
1418 let Inst{7} = Sn{0};
1419 let Inst{15-12} = Sd{4-1};
1420 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001421}
1422
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001423// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001424class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1425 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1426 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001427 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001428 let Inst{27-23} = opcod1;
1429 let Inst{21-20} = opcod2;
1430 let Inst{19-16} = opcod3;
1431 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001432 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001433 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001434}
1435
Johnny Chen39640592010-02-11 18:47:03 +00001436// VFP conversion between floating-point and fixed-point
1437class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001438 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1439 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001440 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1441 // size (fixed-point number): sx == 0 ? 16 : 32
1442 let Inst{7} = op5; // sx
1443}
1444
David Goodwin85b5b022009-08-10 22:17:39 +00001445// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001446class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001447 dag oops, dag iops, InstrItinClass itin,
1448 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001449 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1450 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001451 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1452}
1453
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001454class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001455 InstrItinClass itin,
1456 string opc, string asm, list<dag> pattern>
1457 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001458 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001459 let Inst{11-8} = opcod2;
1460 let Inst{4} = 1;
1461}
1462
David Goodwinb062c232009-08-06 16:52:47 +00001463class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1464 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1465 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001466
Bob Wilson3968c6a2010-03-23 17:23:59 +00001467class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001468 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1469 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001470
David Goodwinb062c232009-08-06 16:52:47 +00001471class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1472 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1473 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001474
David Goodwinb062c232009-08-06 16:52:47 +00001475class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1476 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1477 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001478
Evan Chengac2af2f2008-11-11 02:11:05 +00001479//===----------------------------------------------------------------------===//
1480
Bob Wilson2e076c42009-06-22 23:27:02 +00001481//===----------------------------------------------------------------------===//
1482// ARM NEON Instruction templates.
1483//
Evan Chengee98fa92008-08-29 06:41:12 +00001484
Johnny Chenf833fad2010-03-20 00:17:00 +00001485class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1486 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1487 list<dag> pattern>
1488 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001489 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001490 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001491 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001492 let Pattern = pattern;
1493 list<Predicate> Predicates = [HasNEON];
1494}
1495
1496// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001497class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1498 InstrItinClass itin, string opc, string asm, string cstr,
1499 list<dag> pattern>
1500 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001501 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001502 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001503 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001504 let Pattern = pattern;
1505 list<Predicate> Predicates = [HasNEON];
Evan Chengee98fa92008-08-29 06:41:12 +00001506}
1507
Bob Wilson50820a22009-10-07 21:53:04 +00001508class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1509 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001510 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001511 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1512 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001513 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001514 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001515 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001516 let Inst{11-8} = op11_8;
1517 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001518
Chris Lattner63274cb2010-11-15 05:19:05 +00001519 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbach5876e412010-11-19 22:42:55 +00001520
Owen Andersonad402342010-11-02 00:05:05 +00001521 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001522 bits<6> Rn;
1523 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001524
Owen Andersonad402342010-11-02 00:05:05 +00001525 let Inst{22} = Vd{4};
1526 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001527 let Inst{19-16} = Rn{3-0};
1528 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001529}
1530
Owen Anderson9f20daf2010-11-02 20:47:39 +00001531class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1532 dag oops, dag iops, InstrItinClass itin,
1533 string opc, string dt, string asm, string cstr, list<dag> pattern>
1534 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1535 dt, asm, cstr, pattern> {
1536 bits<3> lane;
1537}
1538
Bob Wilson9392b0e2010-08-25 23:27:42 +00001539class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1540 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1541 itin> {
1542 let OutOperandList = oops;
1543 let InOperandList = !con(iops, (ins pred:$p));
1544 list<Predicate> Predicates = [HasNEON];
1545}
1546
Jim Grosbach233b3a22010-10-06 20:36:55 +00001547class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1548 list<dag> pattern>
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001549 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1550 itin> {
1551 let OutOperandList = oops;
1552 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001553 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001554 list<Predicate> Predicates = [HasNEON];
1555}
1556
Johnny Chenac5024b2010-03-23 16:43:47 +00001557class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001558 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001559 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1560 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001561 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001562 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Cheng738a97a2009-11-23 21:57:23 +00001563}
1564
Johnny Chen020023a2010-03-23 20:40:44 +00001565class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001566 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001567 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001568 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001569 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001570 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson2e076c42009-06-22 23:27:02 +00001571}
1572
1573// NEON "one register and a modified immediate" format.
1574class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1575 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001576 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001577 string opc, string dt, string asm, string cstr,
1578 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001579 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001580 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001581 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001582 let Inst{11-8} = op11_8;
1583 let Inst{7} = op7;
1584 let Inst{6} = op6;
1585 let Inst{5} = op5;
1586 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001587
Owen Anderson284cb362010-10-26 17:40:54 +00001588 // Instruction operands.
1589 bits<5> Vd;
1590 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001591
Owen Anderson284cb362010-10-26 17:40:54 +00001592 let Inst{15-12} = Vd{3-0};
1593 let Inst{22} = Vd{4};
1594 let Inst{24} = SIMM{7};
1595 let Inst{18-16} = SIMM{6-4};
1596 let Inst{3-0} = SIMM{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001597}
1598
1599// NEON 2 vector register format.
1600class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1601 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001602 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001603 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001604 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001605 let Inst{24-23} = op24_23;
1606 let Inst{21-20} = op21_20;
1607 let Inst{19-18} = op19_18;
1608 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001609 let Inst{11-7} = op11_7;
1610 let Inst{6} = op6;
1611 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001612
Owen Anderson24774462010-10-25 18:43:52 +00001613 // Instruction operands.
1614 bits<5> Vd;
1615 bits<5> Vm;
1616
1617 let Inst{15-12} = Vd{3-0};
1618 let Inst{22} = Vd{4};
1619 let Inst{3-0} = Vm{3-0};
1620 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001621}
1622
1623// Same as N2V except it doesn't have a datatype suffix.
1624class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001625 bits<5> op11_7, bit op6, bit op4,
1626 dag oops, dag iops, InstrItinClass itin,
1627 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001628 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001629 let Inst{24-23} = op24_23;
1630 let Inst{21-20} = op21_20;
1631 let Inst{19-18} = op19_18;
1632 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001633 let Inst{11-7} = op11_7;
1634 let Inst{6} = op6;
1635 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001636
Owen Anderson24774462010-10-25 18:43:52 +00001637 // Instruction operands.
1638 bits<5> Vd;
1639 bits<5> Vm;
1640
1641 let Inst{15-12} = Vd{3-0};
1642 let Inst{22} = Vd{4};
1643 let Inst{3-0} = Vm{3-0};
1644 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001645}
1646
1647// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001648class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001649 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001650 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001651 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001652 let Inst{24} = op24;
1653 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001654 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001655 let Inst{7} = op7;
1656 let Inst{6} = op6;
1657 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001658
Owen Anderson3665fee2010-10-26 20:56:57 +00001659 // Instruction operands.
1660 bits<5> Vd;
1661 bits<5> Vm;
1662 bits<6> SIMM;
1663
1664 let Inst{15-12} = Vd{3-0};
1665 let Inst{22} = Vd{4};
1666 let Inst{3-0} = Vm{3-0};
1667 let Inst{5} = Vm{4};
1668 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001669}
1670
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001671// NEON 3 vector register format.
1672class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1673 dag oops, dag iops, Format f, InstrItinClass itin,
1674 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00001675 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001676 let Inst{24} = op24;
1677 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00001678 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001679 let Inst{11-8} = op11_8;
1680 let Inst{6} = op6;
1681 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001682
Owen Anderson9e44cf22010-10-21 20:21:49 +00001683 // Instruction operands.
1684 bits<5> Vd;
1685 bits<5> Vn;
1686 bits<5> Vm;
1687
1688 let Inst{15-12} = Vd{3-0};
1689 let Inst{22} = Vd{4};
1690 let Inst{19-16} = Vn{3-0};
1691 let Inst{7} = Vn{4};
1692 let Inst{3-0} = Vm{3-0};
1693 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001694}
1695
Johnny Chen8a687232010-03-23 21:35:03 +00001696// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001697class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1698 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001699 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001700 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001701 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001702 let Inst{24} = op24;
1703 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001704 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001705 let Inst{11-8} = op11_8;
1706 let Inst{6} = op6;
1707 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001708
Owen Andersondff239c2010-10-25 18:28:30 +00001709 // Instruction operands.
1710 bits<5> Vd;
1711 bits<5> Vn;
1712 bits<5> Vm;
1713
1714 let Inst{15-12} = Vd{3-0};
1715 let Inst{22} = Vd{4};
1716 let Inst{19-16} = Vn{3-0};
1717 let Inst{7} = Vn{4};
1718 let Inst{3-0} = Vm{3-0};
1719 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001720}
1721
1722// NEON VMOVs between scalar and core registers.
1723class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001724 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001725 string opc, string dt, string asm, list<dag> pattern>
Evan Chengb4559192010-10-26 02:03:05 +00001726 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001727 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001728 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001729 let Inst{11-8} = opcod2;
1730 let Inst{6-5} = opcod3;
1731 let Inst{4} = 1;
Evan Cheng738a97a2009-11-23 21:57:23 +00001732
1733 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001734 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001735 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001736 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001737 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001738
Chris Lattner63274cb2010-11-15 05:19:05 +00001739 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbach5876e412010-11-19 22:42:55 +00001740
Owen Andersoned9652f2010-10-27 21:28:09 +00001741 bits<5> V;
1742 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001743 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001744 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001745
Owen Anderson40d24a42010-10-27 19:25:54 +00001746 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001747 let Inst{7} = V{4};
1748 let Inst{19-16} = V{3-0};
1749 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001750}
1751class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001752 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001753 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001754 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001755 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001756class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001757 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001758 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001759 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001760 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001761class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001762 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001763 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001764 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001765 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001766
Johnny Chen45ab3f32010-03-25 17:01:27 +00001767// Vector Duplicate Lane (from scalar to all elements)
1768class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1769 InstrItinClass itin, string opc, string dt, string asm,
1770 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001771 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001772 let Inst{24-23} = 0b11;
1773 let Inst{21-20} = 0b11;
1774 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001775 let Inst{11-7} = 0b11000;
1776 let Inst{6} = op6;
1777 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001778
Owen Anderson40d24a42010-10-27 19:25:54 +00001779 bits<5> Vd;
1780 bits<5> Vm;
1781 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001782
Owen Anderson40d24a42010-10-27 19:25:54 +00001783 let Inst{22} = Vd{4};
1784 let Inst{15-12} = Vd{3-0};
1785 let Inst{5} = Vm{4};
1786 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00001787}
1788
David Goodwin3b9c52c2009-08-04 17:53:06 +00001789// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1790// for single-precision FP.
1791class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1792 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1793}