OSDN Git Service

0b266e5591b40fe97732f3f4729a71aace73389f
[android-x86/external-llvm.git] / lib / Target / X86 / X86InstrFormats.td
1 //===-- X86InstrFormats.td - X86 Instruction Formats -------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //===----------------------------------------------------------------------===//
11 // X86 Instruction Format Definitions.
12 //
13
14 // Format specifies the encoding used by the instruction.  This is part of the
15 // ad-hoc solution used to emit machine instruction encodings by our machine
16 // code emitter.
17 class Format<bits<7> val> {
18   bits<7> Value = val;
19 }
20
21 def Pseudo        : Format<0>;
22 def RawFrm        : Format<1>;
23 def AddRegFrm     : Format<2>;
24 def RawFrmMemOffs : Format<3>;
25 def RawFrmSrc     : Format<4>;
26 def RawFrmDst     : Format<5>;
27 def RawFrmDstSrc  : Format<6>;
28 def RawFrmImm8    : Format<7>;
29 def RawFrmImm16   : Format<8>;
30 def MRMDestMem     : Format<32>;
31 def MRMSrcMem      : Format<33>;
32 def MRMSrcMem4VOp3 : Format<34>;
33 def MRMSrcMemOp4   : Format<35>;
34 def MRMXm  : Format<39>;
35 def MRM0m  : Format<40>;  def MRM1m  : Format<41>;  def MRM2m  : Format<42>;
36 def MRM3m  : Format<43>;  def MRM4m  : Format<44>;  def MRM5m  : Format<45>;
37 def MRM6m  : Format<46>;  def MRM7m  : Format<47>;
38 def MRMDestReg     : Format<48>;
39 def MRMSrcReg      : Format<49>;
40 def MRMSrcReg4VOp3 : Format<50>;
41 def MRMSrcRegOp4   : Format<51>;
42 def MRMXr  : Format<55>;
43 def MRM0r  : Format<56>;  def MRM1r  : Format<57>;  def MRM2r  : Format<58>;
44 def MRM3r  : Format<59>;  def MRM4r  : Format<60>;  def MRM5r  : Format<61>;
45 def MRM6r  : Format<62>;  def MRM7r  : Format<63>;
46 def MRM_C0 : Format<64>;  def MRM_C1 : Format<65>;  def MRM_C2 : Format<66>;
47 def MRM_C3 : Format<67>;  def MRM_C4 : Format<68>;  def MRM_C5 : Format<69>;
48 def MRM_C6 : Format<70>;  def MRM_C7 : Format<71>;  def MRM_C8 : Format<72>;
49 def MRM_C9 : Format<73>;  def MRM_CA : Format<74>;  def MRM_CB : Format<75>;
50 def MRM_CC : Format<76>;  def MRM_CD : Format<77>;  def MRM_CE : Format<78>;
51 def MRM_CF : Format<79>;  def MRM_D0 : Format<80>;  def MRM_D1 : Format<81>;
52 def MRM_D2 : Format<82>;  def MRM_D3 : Format<83>;  def MRM_D4 : Format<84>;
53 def MRM_D5 : Format<85>;  def MRM_D6 : Format<86>;  def MRM_D7 : Format<87>;
54 def MRM_D8 : Format<88>;  def MRM_D9 : Format<89>;  def MRM_DA : Format<90>;
55 def MRM_DB : Format<91>;  def MRM_DC : Format<92>;  def MRM_DD : Format<93>;
56 def MRM_DE : Format<94>;  def MRM_DF : Format<95>;  def MRM_E0 : Format<96>;
57 def MRM_E1 : Format<97>;  def MRM_E2 : Format<98>;  def MRM_E3 : Format<99>;
58 def MRM_E4 : Format<100>; def MRM_E5 : Format<101>; def MRM_E6 : Format<102>;
59 def MRM_E7 : Format<103>; def MRM_E8 : Format<104>; def MRM_E9 : Format<105>;
60 def MRM_EA : Format<106>; def MRM_EB : Format<107>; def MRM_EC : Format<108>;
61 def MRM_ED : Format<109>; def MRM_EE : Format<110>; def MRM_EF : Format<111>;
62 def MRM_F0 : Format<112>; def MRM_F1 : Format<113>; def MRM_F2 : Format<114>;
63 def MRM_F3 : Format<115>; def MRM_F4 : Format<116>; def MRM_F5 : Format<117>;
64 def MRM_F6 : Format<118>; def MRM_F7 : Format<119>; def MRM_F8 : Format<120>;
65 def MRM_F9 : Format<121>; def MRM_FA : Format<122>; def MRM_FB : Format<123>;
66 def MRM_FC : Format<124>; def MRM_FD : Format<125>; def MRM_FE : Format<126>;
67 def MRM_FF : Format<127>;
68
69 // ImmType - This specifies the immediate type used by an instruction. This is
70 // part of the ad-hoc solution used to emit machine instruction encodings by our
71 // machine code emitter.
72 class ImmType<bits<4> val> {
73   bits<4> Value = val;
74 }
75 def NoImm      : ImmType<0>;
76 def Imm8       : ImmType<1>;
77 def Imm8PCRel  : ImmType<2>;
78 def Imm8Reg    : ImmType<3>; // Register encoded in [7:4].
79 def Imm16      : ImmType<4>;
80 def Imm16PCRel : ImmType<5>;
81 def Imm32      : ImmType<6>;
82 def Imm32PCRel : ImmType<7>;
83 def Imm32S     : ImmType<8>;
84 def Imm64      : ImmType<9>;
85
86 // FPFormat - This specifies what form this FP instruction has.  This is used by
87 // the Floating-Point stackifier pass.
88 class FPFormat<bits<3> val> {
89   bits<3> Value = val;
90 }
91 def NotFP      : FPFormat<0>;
92 def ZeroArgFP  : FPFormat<1>;
93 def OneArgFP   : FPFormat<2>;
94 def OneArgFPRW : FPFormat<3>;
95 def TwoArgFP   : FPFormat<4>;
96 def CompareFP  : FPFormat<5>;
97 def CondMovFP  : FPFormat<6>;
98 def SpecialFP  : FPFormat<7>;
99
100 // Class specifying the SSE execution domain, used by the SSEDomainFix pass.
101 // Keep in sync with tables in X86InstrInfo.cpp.
102 class Domain<bits<2> val> {
103   bits<2> Value = val;
104 }
105 def GenericDomain   : Domain<0>;
106 def SSEPackedSingle : Domain<1>;
107 def SSEPackedDouble : Domain<2>;
108 def SSEPackedInt    : Domain<3>;
109
110 // Class specifying the vector form of the decompressed
111 // displacement of 8-bit.
112 class CD8VForm<bits<3> val> {
113   bits<3> Value = val;
114 }
115 def CD8VF  : CD8VForm<0>;  // v := VL
116 def CD8VH  : CD8VForm<1>;  // v := VL/2
117 def CD8VQ  : CD8VForm<2>;  // v := VL/4
118 def CD8VO  : CD8VForm<3>;  // v := VL/8
119 // The tuple (subvector) forms.
120 def CD8VT1 : CD8VForm<4>;  // v := 1
121 def CD8VT2 : CD8VForm<5>;  // v := 2
122 def CD8VT4 : CD8VForm<6>;  // v := 4
123 def CD8VT8 : CD8VForm<7>;  // v := 8
124
125 // Class specifying the prefix used an opcode extension.
126 class Prefix<bits<3> val> {
127   bits<3> Value = val;
128 }
129 def NoPrfx : Prefix<0>;
130 def PS     : Prefix<1>;
131 def PD     : Prefix<2>;
132 def XS     : Prefix<3>;
133 def XD     : Prefix<4>;
134
135 // Class specifying the opcode map.
136 class Map<bits<3> val> {
137   bits<3> Value = val;
138 }
139 def OB   : Map<0>;
140 def TB   : Map<1>;
141 def T8   : Map<2>;
142 def TA   : Map<3>;
143 def XOP8 : Map<4>;
144 def XOP9 : Map<5>;
145 def XOPA : Map<6>;
146
147 // Class specifying the encoding
148 class Encoding<bits<2> val> {
149   bits<2> Value = val;
150 }
151 def EncNormal : Encoding<0>;
152 def EncVEX    : Encoding<1>;
153 def EncXOP    : Encoding<2>;
154 def EncEVEX   : Encoding<3>;
155
156 // Operand size for encodings that change based on mode.
157 class OperandSize<bits<2> val> {
158   bits<2> Value = val;
159 }
160 def OpSizeFixed  : OperandSize<0>; // Never needs a 0x66 prefix.
161 def OpSize16     : OperandSize<1>; // Needs 0x66 prefix in 32-bit mode.
162 def OpSize32     : OperandSize<2>; // Needs 0x66 prefix in 16-bit mode.
163 def OpSizeIgnore : OperandSize<3>; // Takes 0x66 prefix, never emits.
164
165 // Address size for encodings that change based on mode.
166 class AddressSize<bits<2> val> {
167   bits<2> Value = val;
168 }
169 def AdSizeX  : AddressSize<0>; // Address size determined using addr operand.
170 def AdSize16 : AddressSize<1>; // Encodes a 16-bit address.
171 def AdSize32 : AddressSize<2>; // Encodes a 32-bit address.
172 def AdSize64 : AddressSize<3>; // Encodes a 64-bit address.
173
174 // Prefix byte classes which are used to indicate to the ad-hoc machine code
175 // emitter that various prefix bytes are required.
176 class OpSize16 { OperandSize OpSize = OpSize16; }
177 class OpSize32 { OperandSize OpSize = OpSize32; }
178 class OpSizeIgnore { OperandSize OpSize = OpSizeIgnore; }
179 class AdSize16 { AddressSize AdSize = AdSize16; }
180 class AdSize32 { AddressSize AdSize = AdSize32; }
181 class AdSize64 { AddressSize AdSize = AdSize64; }
182 class REX_W  { bit hasREX_WPrefix = 1; }
183 class LOCK   { bit hasLockPrefix = 1; }
184 class REP    { bit hasREPPrefix = 1; }
185 class TB     { Map OpMap = TB; }
186 class T8     { Map OpMap = T8; }
187 class TA     { Map OpMap = TA; }
188 class XOP8   { Map OpMap = XOP8; Prefix OpPrefix = PS; }
189 class XOP9   { Map OpMap = XOP9; Prefix OpPrefix = PS; }
190 class XOPA   { Map OpMap = XOPA; Prefix OpPrefix = PS; }
191 class OBXS   { Prefix OpPrefix = XS; }
192 class PS   : TB { Prefix OpPrefix = PS; }
193 class PD   : TB { Prefix OpPrefix = PD; }
194 class XD   : TB { Prefix OpPrefix = XD; }
195 class XS   : TB { Prefix OpPrefix = XS; }
196 class T8PS : T8 { Prefix OpPrefix = PS; }
197 class T8PD : T8 { Prefix OpPrefix = PD; }
198 class T8XD : T8 { Prefix OpPrefix = XD; }
199 class T8XS : T8 { Prefix OpPrefix = XS; }
200 class TAPS : TA { Prefix OpPrefix = PS; }
201 class TAPD : TA { Prefix OpPrefix = PD; }
202 class TAXD : TA { Prefix OpPrefix = XD; }
203 class VEX    { Encoding OpEnc = EncVEX; }
204 class VEX_W    { bits<2> VEX_WPrefix = 1; }
205 class VEX_WIG  { bits<2> VEX_WPrefix = 2; }
206 class VEX_4V : VEX { bit hasVEX_4V = 1; }
207 class VEX_L  { bit hasVEX_L = 1; }
208 class VEX_LIG { bit ignoresVEX_L = 1; }
209 class EVEX : VEX { Encoding OpEnc = EncEVEX; }
210 class EVEX_4V : VEX_4V { Encoding OpEnc = EncEVEX; }
211 class EVEX_K { bit hasEVEX_K = 1; }
212 class EVEX_KZ : EVEX_K { bit hasEVEX_Z = 1; }
213 class EVEX_B { bit hasEVEX_B = 1; }
214 class EVEX_RC { bit hasEVEX_RC = 1; }
215 class EVEX_V512 { bit hasEVEX_L2 = 1; bit hasVEX_L = 0; }
216 class EVEX_V256 { bit hasEVEX_L2 = 0; bit hasVEX_L = 1; }
217 class EVEX_V128 { bit hasEVEX_L2 = 0; bit hasVEX_L = 0; }
218
219 // Specify AVX512 8-bit compressed displacement encoding based on the vector
220 // element size in bits (8, 16, 32, 64) and the CDisp8 form.
221 class EVEX_CD8<int esize, CD8VForm form> {
222   int CD8_EltSize = !srl(esize, 3);
223   bits<3> CD8_Form = form.Value;
224 }
225
226 class Has3DNow0F0FOpcode  { bit has3DNow0F0FOpcode = 1; }
227 class XOP { Encoding OpEnc = EncXOP; }
228 class XOP_4V : XOP { bit hasVEX_4V = 1; }
229
230 // Specify the alternative register form instruction to replace the current
231 // instruction in case it was picked during generation of memory folding tables
232 class FoldGenData<string _RegisterForm> {
233     string FoldGenRegForm = _RegisterForm;
234 }
235
236 // Mark the instruction as "illegal to memory fold/unfold"
237 class NotMemoryFoldable { bit isMemoryFoldable = 0; }
238
239 class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
240               string AsmStr,
241               InstrItinClass itin,
242               Domain d = GenericDomain>
243   : Instruction {
244   let Namespace = "X86";
245
246   bits<8> Opcode = opcod;
247   Format Form = f;
248   bits<7> FormBits = Form.Value;
249   ImmType ImmT = i;
250
251   dag OutOperandList = outs;
252   dag InOperandList = ins;
253   string AsmString = AsmStr;
254
255   // If this is a pseudo instruction, mark it isCodeGenOnly.
256   let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
257
258   let Itinerary = itin;
259
260   //
261   // Attributes specific to X86 instructions...
262   //
263   bit ForceDisassemble = 0; // Force instruction to disassemble even though it's
264                             // isCodeGenonly. Needed to hide an ambiguous
265                             // AsmString from the parser, but still disassemble.
266
267   OperandSize OpSize = OpSizeFixed; // Does this instruction's encoding change
268                                     // based on operand size of the mode?
269   bits<2> OpSizeBits = OpSize.Value;
270   AddressSize AdSize = AdSizeX; // Does this instruction's encoding change
271                                 // based on address size of the mode?
272   bits<2> AdSizeBits = AdSize.Value;
273
274   Prefix OpPrefix = NoPrfx; // Which prefix byte does this inst have?
275   bits<3> OpPrefixBits = OpPrefix.Value;
276   Map OpMap = OB;           // Which opcode map does this inst have?
277   bits<3> OpMapBits = OpMap.Value;
278   bit hasREX_WPrefix  = 0;  // Does this inst require the REX.W prefix?
279   FPFormat FPForm = NotFP;  // What flavor of FP instruction is this?
280   bit hasLockPrefix = 0;    // Does this inst have a 0xF0 prefix?
281   Domain ExeDomain = d;
282   bit hasREPPrefix = 0;     // Does this inst have a REP prefix?
283   Encoding OpEnc = EncNormal; // Encoding used by this instruction
284   bits<2> OpEncBits = OpEnc.Value;
285   bits<2> VEX_WPrefix = 0;  // Does this inst set the VEX_W field?
286   bit hasVEX_4V = 0;        // Does this inst require the VEX.VVVV field?
287   bit hasVEX_L = 0;         // Does this inst use large (256-bit) registers?
288   bit ignoresVEX_L = 0;     // Does this instruction ignore the L-bit
289   bit hasEVEX_K = 0;        // Does this inst require masking?
290   bit hasEVEX_Z = 0;        // Does this inst set the EVEX_Z field?
291   bit hasEVEX_L2 = 0;       // Does this inst set the EVEX_L2 field?
292   bit hasEVEX_B = 0;        // Does this inst set the EVEX_B field?
293   bits<3> CD8_Form = 0;     // Compressed disp8 form - vector-width.
294   // Declare it int rather than bits<4> so that all bits are defined when
295   // assigning to bits<7>.
296   int CD8_EltSize = 0;      // Compressed disp8 form - element-size in bytes.
297   bit has3DNow0F0FOpcode =0;// Wacky 3dNow! encoding?
298   bit hasEVEX_RC = 0;       // Explicitly specified rounding control in FP instruction.
299
300   bits<2> EVEX_LL;
301   let EVEX_LL{0} = hasVEX_L;
302   let EVEX_LL{1} = hasEVEX_L2;
303   // Vector size in bytes.
304   bits<7> VectSize = !shl(16, EVEX_LL);
305
306   // The scaling factor for AVX512's compressed displacement is either
307   //   - the size of a  power-of-two number of elements or
308   //   - the size of a single element for broadcasts or
309   //   - the total vector size divided by a power-of-two number.
310   // Possible values are: 0 (non-AVX512 inst), 1, 2, 4, 8, 16, 32 and 64.
311   bits<7> CD8_Scale = !if (!eq (OpEnc.Value, EncEVEX.Value),
312                            !if (CD8_Form{2},
313                                 !shl(CD8_EltSize, CD8_Form{1-0}),
314                                 !if (hasEVEX_B,
315                                      CD8_EltSize,
316                                      !srl(VectSize, CD8_Form{1-0}))), 0);
317
318   // Used in the memory folding generation (TableGen backend) to point to an alternative
319   // instruction to replace the current one in case it got picked during generation.
320   string FoldGenRegForm = ?;
321
322   bit isMemoryFoldable = 1;     // Is it allowed to memory fold/unfold this instruction?
323
324   // TSFlags layout should be kept in sync with X86BaseInfo.h.
325   let TSFlags{6-0}   = FormBits;
326   let TSFlags{8-7}   = OpSizeBits;
327   let TSFlags{10-9}  = AdSizeBits;
328   let TSFlags{13-11} = OpPrefixBits;
329   let TSFlags{16-14} = OpMapBits;
330   let TSFlags{17}    = hasREX_WPrefix;
331   let TSFlags{21-18} = ImmT.Value;
332   let TSFlags{24-22} = FPForm.Value;
333   let TSFlags{25}    = hasLockPrefix;
334   let TSFlags{26}    = hasREPPrefix;
335   let TSFlags{28-27} = ExeDomain.Value;
336   let TSFlags{30-29} = OpEncBits;
337   let TSFlags{38-31} = Opcode;
338   // Currently no need for second bit in TSFlags - W Ignore is equivalent to 0.
339   let TSFlags{39}    = VEX_WPrefix{0};
340   let TSFlags{40}    = hasVEX_4V;
341   let TSFlags{41}    = hasVEX_L;
342   let TSFlags{42}    = hasEVEX_K;
343   let TSFlags{43}    = hasEVEX_Z;
344   let TSFlags{44}    = hasEVEX_L2;
345   let TSFlags{45}    = hasEVEX_B;
346   // If we run out of TSFlags bits, it's possible to encode this in 3 bits.
347   let TSFlags{52-46} = CD8_Scale;
348   let TSFlags{53}    = has3DNow0F0FOpcode;
349   let TSFlags{54}    = hasEVEX_RC;
350 }
351
352 class PseudoI<dag oops, dag iops, list<dag> pattern,
353               InstrItinClass itin = NoItinerary>
354   : X86Inst<0, Pseudo, NoImm, oops, iops, "", itin> {
355   let Pattern = pattern;
356 }
357
358 class I<bits<8> o, Format f, dag outs, dag ins, string asm,
359         list<dag> pattern, InstrItinClass itin = NoItinerary,
360         Domain d = GenericDomain>
361   : X86Inst<o, f, NoImm, outs, ins, asm, itin, d> {
362   let Pattern = pattern;
363   let CodeSize = 3;
364 }
365 class Ii8 <bits<8> o, Format f, dag outs, dag ins, string asm,
366            list<dag> pattern, InstrItinClass itin = NoItinerary,
367            Domain d = GenericDomain>
368   : X86Inst<o, f, Imm8, outs, ins, asm, itin, d> {
369   let Pattern = pattern;
370   let CodeSize = 3;
371 }
372 class Ii8Reg<bits<8> o, Format f, dag outs, dag ins, string asm,
373              list<dag> pattern, InstrItinClass itin = NoItinerary,
374              Domain d = GenericDomain>
375   : X86Inst<o, f, Imm8Reg, outs, ins, asm, itin, d> {
376   let Pattern = pattern;
377   let CodeSize = 3;
378 }
379 class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
380                list<dag> pattern, InstrItinClass itin = NoItinerary>
381   : X86Inst<o, f, Imm8PCRel, outs, ins, asm, itin> {
382   let Pattern = pattern;
383   let CodeSize = 3;
384 }
385 class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
386            list<dag> pattern, InstrItinClass itin = NoItinerary>
387   : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
388   let Pattern = pattern;
389   let CodeSize = 3;
390 }
391 class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
392            list<dag> pattern, InstrItinClass itin = NoItinerary>
393   : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
394   let Pattern = pattern;
395   let CodeSize = 3;
396 }
397 class Ii32S<bits<8> o, Format f, dag outs, dag ins, string asm,
398             list<dag> pattern, InstrItinClass itin = NoItinerary>
399   : X86Inst<o, f, Imm32S, outs, ins, asm, itin> {
400   let Pattern = pattern;
401   let CodeSize = 3;
402 }
403
404 class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
405            list<dag> pattern, InstrItinClass itin = NoItinerary>
406            : X86Inst<o, f, Imm16PCRel, outs, ins, asm, itin> {
407   let Pattern = pattern;
408   let CodeSize = 3;
409 }
410
411 class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
412            list<dag> pattern, InstrItinClass itin = NoItinerary>
413   : X86Inst<o, f, Imm32PCRel, outs, ins, asm, itin> {
414   let Pattern = pattern;
415   let CodeSize = 3;
416 }
417
418 // FPStack Instruction Templates:
419 // FPI - Floating Point Instruction template.
420 class FPI<bits<8> o, Format F, dag outs, dag ins, string asm,
421           InstrItinClass itin = NoItinerary>
422   : I<o, F, outs, ins, asm, [], itin> {}
423
424 // FpI_ - Floating Point Pseudo Instruction template. Not Predicated.
425 class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern,
426            InstrItinClass itin = NoItinerary>
427   : PseudoI<outs, ins, pattern, itin> {
428   let FPForm = fp;
429 }
430
431 // Templates for instructions that use a 16- or 32-bit segmented address as
432 //  their only operand: lcall (FAR CALL) and ljmp (FAR JMP)
433 //
434 //   Iseg16 - 16-bit segment selector, 16-bit offset
435 //   Iseg32 - 16-bit segment selector, 32-bit offset
436
437 class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
438               list<dag> pattern, InstrItinClass itin = NoItinerary>
439       : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
440   let Pattern = pattern;
441   let CodeSize = 3;
442 }
443
444 class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
445               list<dag> pattern, InstrItinClass itin = NoItinerary>
446       : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
447   let Pattern = pattern;
448   let CodeSize = 3;
449 }
450
451 // SI - SSE 1 & 2 scalar instructions
452 class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
453          list<dag> pattern, InstrItinClass itin = NoItinerary,
454          Domain d = GenericDomain>
455       : I<o, F, outs, ins, asm, pattern, itin, d> {
456   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
457                    !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
458                    !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
459                    !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
460                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
461                    [UseSSE1])))));
462
463   // AVX instructions have a 'v' prefix in the mnemonic
464   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
465                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
466                   asm));
467 }
468
469 // SI - SSE 1 & 2 scalar intrinsics - vex form available on AVX512
470 class SI_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
471          list<dag> pattern, InstrItinClass itin = NoItinerary,
472          Domain d = GenericDomain>
473       : I<o, F, outs, ins, asm, pattern, itin, d> {
474   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
475                    !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
476                    !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
477                    !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
478                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
479                    [UseSSE1])))));
480
481   // AVX instructions have a 'v' prefix in the mnemonic
482   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
483                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
484                   asm));
485 }
486 // SIi8 - SSE 1 & 2 scalar instructions - vex form available on AVX512
487 class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
488            list<dag> pattern, InstrItinClass itin = NoItinerary>
489       : Ii8<o, F, outs, ins, asm, pattern, itin> {
490   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
491                    !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
492                    !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
493                    [UseSSE2])));
494
495   // AVX instructions have a 'v' prefix in the mnemonic
496   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
497                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
498                   asm));
499 }
500
501 // PI - SSE 1 & 2 packed instructions
502 class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
503          InstrItinClass itin, Domain d>
504       : I<o, F, outs, ins, asm, pattern, itin, d> {
505   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
506                    !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
507                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
508                    [UseSSE1])));
509
510   // AVX instructions have a 'v' prefix in the mnemonic
511   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
512                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
513                   asm));
514 }
515
516 // MMXPI - SSE 1 & 2 packed instructions with MMX operands
517 class MMXPI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
518             InstrItinClass itin, Domain d>
519       : I<o, F, outs, ins, asm, pattern, itin, d> {
520   let Predicates = !if(!eq(OpPrefix.Value, PD.Value), [HasSSE2],
521                        [HasSSE1]);
522 }
523
524 // PIi8 - SSE 1 & 2 packed instructions with immediate
525 class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
526            list<dag> pattern, InstrItinClass itin, Domain d>
527       : Ii8<o, F, outs, ins, asm, pattern, itin, d> {
528   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
529                    !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
530                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
531                    [UseSSE1])));
532
533   // AVX instructions have a 'v' prefix in the mnemonic
534   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
535                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
536                   asm));
537 }
538
539 // SSE1 Instruction Templates:
540 //
541 //   SSI   - SSE1 instructions with XS prefix.
542 //   PSI   - SSE1 instructions with PS prefix.
543 //   PSIi8 - SSE1 instructions with ImmT == Imm8 and PS prefix.
544 //   VSSI  - SSE1 instructions with XS prefix in AVX form.
545 //   VPSI  - SSE1 instructions with PS prefix in AVX form, packed single.
546
547 class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
548           list<dag> pattern, InstrItinClass itin = NoItinerary>
549       : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
550 class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
551             list<dag> pattern, InstrItinClass itin = NoItinerary>
552       : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
553 class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
554           list<dag> pattern, InstrItinClass itin = NoItinerary>
555       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, PS,
556         Requires<[UseSSE1]>;
557 class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
558             list<dag> pattern, InstrItinClass itin = NoItinerary>
559       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, PS,
560         Requires<[UseSSE1]>;
561 class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
562            list<dag> pattern, InstrItinClass itin = NoItinerary>
563       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
564         Requires<[HasAVX]>;
565 class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
566            list<dag> pattern, InstrItinClass itin = NoItinerary>
567       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedSingle>, PS,
568         Requires<[HasAVX]>;
569
570 // SSE2 Instruction Templates:
571 //
572 //   SDI    - SSE2 instructions with XD prefix.
573 //   SDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix.
574 //   S2SI   - SSE2 instructions with XS prefix.
575 //   SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
576 //   PDI    - SSE2 instructions with PD prefix, packed double domain.
577 //   PDIi8  - SSE2 instructions with ImmT == Imm8 and PD prefix.
578 //   VSDI   - SSE2 scalar instructions with XD prefix in AVX form.
579 //   VPDI   - SSE2 vector instructions with PD prefix in AVX form,
580 //                 packed double domain.
581 //   VS2I   - SSE2 scalar instructions with PD prefix in AVX form.
582 //   S2I    - SSE2 scalar instructions with PD prefix.
583 //   MMXSDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
584 //               MMX operands.
585 //   MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
586 //               MMX operands.
587
588 class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
589           list<dag> pattern, InstrItinClass itin = NoItinerary>
590       : I<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
591 class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
592             list<dag> pattern, InstrItinClass itin = NoItinerary>
593       : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
594 class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
595            list<dag> pattern, InstrItinClass itin = NoItinerary>
596       : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE2]>;
597 class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
598              list<dag> pattern, InstrItinClass itin = NoItinerary>
599       : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
600 class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
601           list<dag> pattern, InstrItinClass itin = NoItinerary>
602       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
603         Requires<[UseSSE2]>;
604 class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
605             list<dag> pattern, InstrItinClass itin = NoItinerary>
606       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
607         Requires<[UseSSE2]>;
608 class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
609            list<dag> pattern, InstrItinClass itin = NoItinerary>
610       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XD,
611         Requires<[UseAVX]>;
612 class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
613             list<dag> pattern, InstrItinClass itin = NoItinerary>
614       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
615         Requires<[HasAVX]>;
616 class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
617            list<dag> pattern, InstrItinClass itin = NoItinerary>
618       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedDouble>,
619         PD, Requires<[HasAVX]>;
620 class VS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
621            list<dag> pattern, InstrItinClass itin = NoItinerary>
622       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, PD,
623         Requires<[UseAVX]>;
624 class S2I<bits<8> o, Format F, dag outs, dag ins, string asm,
625            list<dag> pattern, InstrItinClass itin = NoItinerary>
626       : I<o, F, outs, ins, asm, pattern, itin>, PD, Requires<[UseSSE2]>;
627 class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
628                list<dag> pattern, InstrItinClass itin = NoItinerary>
629       : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasSSE2]>;
630 class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
631                 list<dag> pattern, InstrItinClass itin = NoItinerary>
632       : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE2]>;
633
634 // SSE3 Instruction Templates:
635 //
636 //   S3I   - SSE3 instructions with PD prefixes.
637 //   S3SI  - SSE3 instructions with XS prefix.
638 //   S3DI  - SSE3 instructions with XD prefix.
639
640 class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
641            list<dag> pattern, InstrItinClass itin = NoItinerary>
642       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, XS,
643         Requires<[UseSSE3]>;
644 class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
645            list<dag> pattern, InstrItinClass itin = NoItinerary>
646       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, XD,
647         Requires<[UseSSE3]>;
648 class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
649           list<dag> pattern, InstrItinClass itin = NoItinerary>
650       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
651         Requires<[UseSSE3]>;
652
653
654 // SSSE3 Instruction Templates:
655 //
656 //   SS38I - SSSE3 instructions with T8 prefix.
657 //   SS3AI - SSSE3 instructions with TA prefix.
658 //   MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
659 //   MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
660 //
661 // Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
662 // uses the MMX registers. The 64-bit versions are grouped with the MMX
663 // classes. They need to be enabled even if AVX is enabled.
664
665 class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
666             list<dag> pattern, InstrItinClass itin = NoItinerary>
667       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
668         Requires<[UseSSSE3]>;
669 class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
670             list<dag> pattern, InstrItinClass itin = NoItinerary>
671       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
672         Requires<[UseSSSE3]>;
673 class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
674                list<dag> pattern, InstrItinClass itin = NoItinerary>
675       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PS,
676         Requires<[HasSSSE3]>;
677 class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
678                list<dag> pattern, InstrItinClass itin = NoItinerary>
679       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPS,
680         Requires<[HasSSSE3]>;
681
682 // SSE4.1 Instruction Templates:
683 //
684 //   SS48I - SSE 4.1 instructions with T8 prefix.
685 //   SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
686 //
687 class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
688             list<dag> pattern, InstrItinClass itin = NoItinerary>
689       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
690         Requires<[UseSSE41]>;
691 class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
692             list<dag> pattern, InstrItinClass itin = NoItinerary>
693       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
694         Requires<[UseSSE41]>;
695
696 // SSE4.2 Instruction Templates:
697 //
698 //   SS428I - SSE 4.2 instructions with T8 prefix.
699 class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
700              list<dag> pattern, InstrItinClass itin = NoItinerary>
701       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
702         Requires<[UseSSE42]>;
703
704 //   SS42FI - SSE 4.2 instructions with T8XD prefix.
705 // NOTE: 'HasSSE42' is used as SS42FI is only used for CRC32 insns.
706 class SS42FI<bits<8> o, Format F, dag outs, dag ins, string asm,
707              list<dag> pattern, InstrItinClass itin = NoItinerary>
708       : I<o, F, outs, ins, asm, pattern, itin>, T8XD, Requires<[HasSSE42]>;
709
710 //   SS42AI = SSE 4.2 instructions with TA prefix
711 class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
712              list<dag> pattern, InstrItinClass itin = NoItinerary>
713       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
714         Requires<[UseSSE42]>;
715
716 // AVX Instruction Templates:
717 //   Instructions introduced in AVX (no SSE equivalent forms)
718 //
719 //   AVX8I - AVX instructions with T8PD prefix.
720 //   AVXAIi8 - AVX instructions with TAPD prefix and ImmT = Imm8.
721 class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
722             list<dag> pattern, InstrItinClass itin = NoItinerary>
723       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
724         Requires<[HasAVX]>;
725 class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
726               list<dag> pattern, InstrItinClass itin = NoItinerary>
727       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
728         Requires<[HasAVX]>;
729
730 // AVX2 Instruction Templates:
731 //   Instructions introduced in AVX2 (no SSE equivalent forms)
732 //
733 //   AVX28I - AVX2 instructions with T8PD prefix.
734 //   AVX2AIi8 - AVX2 instructions with TAPD prefix and ImmT = Imm8.
735 class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
736             list<dag> pattern, InstrItinClass itin = NoItinerary>
737       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
738         Requires<[HasAVX2]>;
739 class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
740               list<dag> pattern, InstrItinClass itin = NoItinerary>
741       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
742         Requires<[HasAVX2]>;
743
744
745 // AVX-512 Instruction Templates:
746 //   Instructions introduced in AVX-512 (no SSE equivalent forms)
747 //
748 //   AVX5128I - AVX-512 instructions with T8PD prefix.
749 //   AVX512AIi8 - AVX-512 instructions with TAPD prefix and ImmT = Imm8.
750 //   AVX512PDI  - AVX-512 instructions with PD, double packed.
751 //   AVX512PSI  - AVX-512 instructions with PS, single packed.
752 //   AVX512XS8I - AVX-512 instructions with T8 and XS prefixes.
753 //   AVX512XSI  - AVX-512 instructions with XS prefix, generic domain.
754 //   AVX512BI   - AVX-512 instructions with PD, int packed domain.
755 //   AVX512SI   - AVX-512 scalar instructions with PD prefix.
756
757 class AVX5128I<bits<8> o, Format F, dag outs, dag ins, string asm,
758             list<dag> pattern, InstrItinClass itin = NoItinerary>
759       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
760         Requires<[HasAVX512]>;
761 class AVX5128IBase : T8PD {
762   Domain ExeDomain = SSEPackedInt;
763 }
764 class AVX512XS8I<bits<8> o, Format F, dag outs, dag ins, string asm,
765             list<dag> pattern, InstrItinClass itin = NoItinerary>
766       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8XS,
767         Requires<[HasAVX512]>;
768 class AVX512XSI<bits<8> o, Format F, dag outs, dag ins, string asm,
769             list<dag> pattern, InstrItinClass itin = NoItinerary>
770       : I<o, F, outs, ins, asm, pattern, itin>, XS,
771         Requires<[HasAVX512]>;
772 class AVX512XDI<bits<8> o, Format F, dag outs, dag ins, string asm,
773             list<dag> pattern, InstrItinClass itin = NoItinerary>
774       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, XD,
775         Requires<[HasAVX512]>;
776 class AVX512BI<bits<8> o, Format F, dag outs, dag ins, string asm,
777             list<dag> pattern, InstrItinClass itin = NoItinerary>
778       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, PD,
779         Requires<[HasAVX512]>;
780 class AVX512BIBase : PD {
781   Domain ExeDomain = SSEPackedInt;
782 }
783 class AVX512BIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
784               list<dag> pattern, InstrItinClass itin = NoItinerary>
785       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, PD,
786         Requires<[HasAVX512]>;
787 class AVX512BIi8Base : PD {
788   Domain ExeDomain = SSEPackedInt;
789   ImmType ImmT = Imm8;
790 }
791 class AVX512XSIi8Base : XS {
792   Domain ExeDomain = SSEPackedInt;
793   ImmType ImmT = Imm8;
794 }
795 class AVX512XDIi8Base : XD {
796   Domain ExeDomain = SSEPackedInt;
797   ImmType ImmT = Imm8;
798 }
799 class AVX512PSIi8Base : PS {
800   Domain ExeDomain = SSEPackedSingle;
801   ImmType ImmT = Imm8;
802 }
803 class AVX512PDIi8Base : PD {
804   Domain ExeDomain = SSEPackedDouble;
805   ImmType ImmT = Imm8;
806 }
807 class AVX512AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
808               list<dag> pattern, InstrItinClass itin = NoItinerary>
809       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
810         Requires<[HasAVX512]>;
811 class AVX512AIi8Base : TAPD {
812   ImmType ImmT = Imm8;
813 }
814 class AVX512Ii8<bits<8> o, Format F, dag outs, dag ins, string asm,
815               list<dag> pattern, InstrItinClass itin = NoItinerary>
816       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>,
817         Requires<[HasAVX512]>;
818 class AVX512PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
819            list<dag> pattern, InstrItinClass itin = NoItinerary>
820       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
821         Requires<[HasAVX512]>;
822 class AVX512PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
823            list<dag> pattern, InstrItinClass itin = NoItinerary>
824       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, PS,
825         Requires<[HasAVX512]>;
826 class AVX512PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
827               list<dag> pattern, Domain d, InstrItinClass itin = NoItinerary>
828       : Ii8<o, F, outs, ins, asm, pattern, itin, d>, Requires<[HasAVX512]>;
829 class AVX512PI<bits<8> o, Format F, dag outs, dag ins, string asm,
830               list<dag> pattern, Domain d, InstrItinClass itin = NoItinerary>
831       : I<o, F, outs, ins, asm, pattern, itin, d>, Requires<[HasAVX512]>;
832 class AVX512FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
833            list<dag>pattern, InstrItinClass itin = NoItinerary>
834       : I<o, F, outs, ins, asm, pattern, itin>, T8PD,
835         EVEX_4V, Requires<[HasAVX512]>;
836 class AVX512FMA3Base : T8PD, EVEX_4V;
837
838 class AVX512<bits<8> o, Format F, dag outs, dag ins, string asm,
839            list<dag>pattern, InstrItinClass itin = NoItinerary>
840       : I<o, F, outs, ins, asm, pattern, itin>, Requires<[HasAVX512]>;
841
842 // AES Instruction Templates:
843 //
844 // AES8I
845 // These use the same encoding as the SSE4.2 T8 and TA encodings.
846 class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
847             list<dag>pattern, InstrItinClass itin = IIC_AES>
848       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
849         Requires<[NoAVX, HasAES]>;
850
851 class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
852             list<dag> pattern, InstrItinClass itin = NoItinerary>
853       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
854         Requires<[NoAVX, HasAES]>;
855
856 // PCLMUL Instruction Templates
857 class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
858                list<dag>pattern, InstrItinClass itin = NoItinerary>
859       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD;
860
861 // FMA3 Instruction Templates
862 class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
863            list<dag>pattern, InstrItinClass itin = NoItinerary>
864       : I<o, F, outs, ins, asm, pattern, itin>, T8PD,
865         VEX_4V, FMASC, Requires<[HasFMA, NoFMA4, NoVLX]>;
866 class FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
867             list<dag>pattern, InstrItinClass itin = NoItinerary>
868       : I<o, F, outs, ins, asm, pattern, itin>, T8PD,
869         VEX_4V, FMASC, Requires<[HasFMA, NoFMA4, NoAVX512]>;
870 class FMA3S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
871                 list<dag>pattern, InstrItinClass itin = NoItinerary>
872       : I<o, F, outs, ins, asm, pattern, itin>, T8PD,
873         VEX_4V, FMASC, Requires<[HasFMA, NoAVX512]>;
874
875 // FMA4 Instruction Templates
876 class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
877            list<dag>pattern, InstrItinClass itin = NoItinerary>
878       : Ii8Reg<o, F, outs, ins, asm, pattern, itin>, TAPD,
879         VEX_4V, FMASC, Requires<[HasFMA4, NoVLX]>;
880 class FMA4S<bits<8> o, Format F, dag outs, dag ins, string asm,
881             list<dag>pattern, InstrItinClass itin = NoItinerary>
882       : Ii8Reg<o, F, outs, ins, asm, pattern, itin>, TAPD,
883         VEX_4V, FMASC, Requires<[HasFMA4, NoAVX512]>;
884 class FMA4S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
885                 list<dag>pattern, InstrItinClass itin = NoItinerary>
886       : Ii8Reg<o, F, outs, ins, asm, pattern, itin>, TAPD,
887         VEX_4V, FMASC, Requires<[HasFMA4]>;
888
889 // XOP 2, 3 and 4 Operand Instruction Template
890 class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
891            list<dag> pattern, InstrItinClass itin = NoItinerary>
892       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
893          XOP9, Requires<[HasXOP]>;
894
895 // XOP 2 and 3 Operand Instruction Templates with imm byte
896 class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
897            list<dag> pattern, InstrItinClass itin = NoItinerary>
898       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
899          XOP8, Requires<[HasXOP]>;
900 // XOP 4 Operand Instruction Templates with imm byte
901 class IXOPi8Reg<bits<8> o, Format F, dag outs, dag ins, string asm,
902            list<dag> pattern, InstrItinClass itin = NoItinerary>
903       : Ii8Reg<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
904          XOP8, Requires<[HasXOP]>;
905
906 //  XOP 5 operand instruction (VEX encoding!)
907 class IXOP5<bits<8> o, Format F, dag outs, dag ins, string asm,
908            list<dag>pattern, InstrItinClass itin = NoItinerary>
909       : Ii8Reg<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
910         VEX_4V, Requires<[HasXOP]>;
911
912 // X86-64 Instruction templates...
913 //
914
915 class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
916          list<dag> pattern, InstrItinClass itin = NoItinerary>
917       : I<o, F, outs, ins, asm, pattern, itin>, REX_W;
918 class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
919             list<dag> pattern, InstrItinClass itin = NoItinerary>
920       : Ii8<o, F, outs, ins, asm, pattern, itin>, REX_W;
921 class RIi16 <bits<8> o, Format F, dag outs, dag ins, string asm,
922             list<dag> pattern, InstrItinClass itin = NoItinerary>
923       : Ii16<o, F, outs, ins, asm, pattern, itin>, REX_W;
924 class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
925              list<dag> pattern, InstrItinClass itin = NoItinerary>
926       : Ii32<o, F, outs, ins, asm, pattern, itin>, REX_W;
927 class RIi32S <bits<8> o, Format F, dag outs, dag ins, string asm,
928               list<dag> pattern, InstrItinClass itin = NoItinerary>
929       : Ii32S<o, F, outs, ins, asm, pattern, itin>, REX_W;
930
931 class RIi64<bits<8> o, Format f, dag outs, dag ins, string asm,
932             list<dag> pattern, InstrItinClass itin = NoItinerary>
933   : X86Inst<o, f, Imm64, outs, ins, asm, itin>, REX_W {
934   let Pattern = pattern;
935   let CodeSize = 3;
936 }
937
938 class RIi64_NOREX<bits<8> o, Format f, dag outs, dag ins, string asm,
939             list<dag> pattern, InstrItinClass itin = NoItinerary>
940   : X86Inst<o, f, Imm64, outs, ins, asm, itin> {
941   let Pattern = pattern;
942   let CodeSize = 3;
943 }
944
945 class RS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
946            list<dag> pattern, InstrItinClass itin = NoItinerary>
947       : S2I<o, F, outs, ins, asm, pattern, itin>, REX_W;
948 class VRS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
949            list<dag> pattern, InstrItinClass itin = NoItinerary>
950       : VS2I<o, F, outs, ins, asm, pattern, itin>, VEX_W;
951
952 // MMX Instruction templates
953 //
954
955 // MMXI   - MMX instructions with TB prefix.
956 // MMXI32 - MMX instructions with TB prefix valid only in 32 bit mode.
957 // MMXI64 - MMX instructions with TB prefix valid only in 64 bit mode.
958 // MMX2I  - MMX / SSE2 instructions with PD prefix.
959 // MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
960 // MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
961 // MMXID  - MMX instructions with XD prefix.
962 // MMXIS  - MMX instructions with XS prefix.
963 class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
964            list<dag> pattern, InstrItinClass itin = NoItinerary>
965       : I<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX]>;
966 class MMXI32<bits<8> o, Format F, dag outs, dag ins, string asm,
967              list<dag> pattern, InstrItinClass itin = NoItinerary>
968       : I<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX,Not64BitMode]>;
969 class MMXI64<bits<8> o, Format F, dag outs, dag ins, string asm,
970              list<dag> pattern, InstrItinClass itin = NoItinerary>
971       : I<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX,In64BitMode]>;
972 class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
973             list<dag> pattern, InstrItinClass itin = NoItinerary>
974       : I<o, F, outs, ins, asm, pattern, itin>, PS, REX_W, Requires<[HasMMX]>;
975 class MMX2I<bits<8> o, Format F, dag outs, dag ins, string asm,
976             list<dag> pattern, InstrItinClass itin = NoItinerary>
977       : I<o, F, outs, ins, asm, pattern, itin>, PD, Requires<[HasMMX]>;
978 class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
979              list<dag> pattern, InstrItinClass itin = NoItinerary>
980       : Ii8<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX]>;
981 class MMXID<bits<8> o, Format F, dag outs, dag ins, string asm,
982             list<dag> pattern, InstrItinClass itin = NoItinerary>
983       : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasMMX]>;
984 class MMXIS<bits<8> o, Format F, dag outs, dag ins, string asm,
985             list<dag> pattern, InstrItinClass itin = NoItinerary>
986       : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[HasMMX]>;