]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/X86/X86InstrFormats.td
Merge clang trunk r300422 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / 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
164 // Address size for encodings that change based on mode.
165 class AddressSize<bits<2> val> {
166   bits<2> Value = val;
167 }
168 def AdSizeX  : AddressSize<0>; // Address size determined using addr operand.
169 def AdSize16 : AddressSize<1>; // Encodes a 16-bit address.
170 def AdSize32 : AddressSize<2>; // Encodes a 32-bit address.
171 def AdSize64 : AddressSize<3>; // Encodes a 64-bit address.
172
173 // Prefix byte classes which are used to indicate to the ad-hoc machine code
174 // emitter that various prefix bytes are required.
175 class OpSize16 { OperandSize OpSize = OpSize16; }
176 class OpSize32 { OperandSize OpSize = OpSize32; }
177 class AdSize16 { AddressSize AdSize = AdSize16; }
178 class AdSize32 { AddressSize AdSize = AdSize32; }
179 class AdSize64 { AddressSize AdSize = AdSize64; }
180 class REX_W  { bit hasREX_WPrefix = 1; }
181 class LOCK   { bit hasLockPrefix = 1; }
182 class REP    { bit hasREPPrefix = 1; }
183 class TB     { Map OpMap = TB; }
184 class T8     { Map OpMap = T8; }
185 class TA     { Map OpMap = TA; }
186 class XOP8   { Map OpMap = XOP8; Prefix OpPrefix = PS; }
187 class XOP9   { Map OpMap = XOP9; Prefix OpPrefix = PS; }
188 class XOPA   { Map OpMap = XOPA; Prefix OpPrefix = PS; }
189 class OBXS   { Prefix OpPrefix = XS; }
190 class PS   : TB { Prefix OpPrefix = PS; }
191 class PD   : TB { Prefix OpPrefix = PD; }
192 class XD   : TB { Prefix OpPrefix = XD; }
193 class XS   : TB { Prefix OpPrefix = XS; }
194 class T8PS : T8 { Prefix OpPrefix = PS; }
195 class T8PD : T8 { Prefix OpPrefix = PD; }
196 class T8XD : T8 { Prefix OpPrefix = XD; }
197 class T8XS : T8 { Prefix OpPrefix = XS; }
198 class TAPS : TA { Prefix OpPrefix = PS; }
199 class TAPD : TA { Prefix OpPrefix = PD; }
200 class TAXD : TA { Prefix OpPrefix = XD; }
201 class VEX    { Encoding OpEnc = EncVEX; }
202 class VEX_W    { bits<2> VEX_WPrefix = 1; }
203 class VEX_WIG  { bits<2> VEX_WPrefix = 2; }
204 class VEX_4V : VEX { bit hasVEX_4V = 1; }
205 class VEX_L  { bit hasVEX_L = 1; }
206 class VEX_LIG { bit ignoresVEX_L = 1; }
207 class EVEX : VEX { Encoding OpEnc = EncEVEX; }
208 class EVEX_4V : VEX_4V { Encoding OpEnc = EncEVEX; }
209 class EVEX_K { bit hasEVEX_K = 1; }
210 class EVEX_KZ : EVEX_K { bit hasEVEX_Z = 1; }
211 class EVEX_B { bit hasEVEX_B = 1; }
212 class EVEX_RC { bit hasEVEX_RC = 1; }
213 class EVEX_V512 { bit hasEVEX_L2 = 1; bit hasVEX_L = 0; }
214 class EVEX_V256 { bit hasEVEX_L2 = 0; bit hasVEX_L = 1; }
215 class EVEX_V128 { bit hasEVEX_L2 = 0; bit hasVEX_L = 0; }
216
217 // Specify AVX512 8-bit compressed displacement encoding based on the vector
218 // element size in bits (8, 16, 32, 64) and the CDisp8 form.
219 class EVEX_CD8<int esize, CD8VForm form> {
220   int CD8_EltSize = !srl(esize, 3);
221   bits<3> CD8_Form = form.Value;
222 }
223
224 class Has3DNow0F0FOpcode  { bit has3DNow0F0FOpcode = 1; }
225 class XOP { Encoding OpEnc = EncXOP; }
226 class XOP_4V : XOP { bit hasVEX_4V = 1; }
227
228 class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
229               string AsmStr,
230               InstrItinClass itin,
231               Domain d = GenericDomain>
232   : Instruction {
233   let Namespace = "X86";
234
235   bits<8> Opcode = opcod;
236   Format Form = f;
237   bits<7> FormBits = Form.Value;
238   ImmType ImmT = i;
239
240   dag OutOperandList = outs;
241   dag InOperandList = ins;
242   string AsmString = AsmStr;
243
244   // If this is a pseudo instruction, mark it isCodeGenOnly.
245   let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
246
247   let Itinerary = itin;
248
249   //
250   // Attributes specific to X86 instructions...
251   //
252   bit ForceDisassemble = 0; // Force instruction to disassemble even though it's
253                             // isCodeGenonly. Needed to hide an ambiguous
254                             // AsmString from the parser, but still disassemble.
255
256   OperandSize OpSize = OpSizeFixed; // Does this instruction's encoding change
257                                     // based on operand size of the mode?
258   bits<2> OpSizeBits = OpSize.Value;
259   AddressSize AdSize = AdSizeX; // Does this instruction's encoding change
260                                 // based on address size of the mode?
261   bits<2> AdSizeBits = AdSize.Value;
262
263   Prefix OpPrefix = NoPrfx; // Which prefix byte does this inst have?
264   bits<3> OpPrefixBits = OpPrefix.Value;
265   Map OpMap = OB;           // Which opcode map does this inst have?
266   bits<3> OpMapBits = OpMap.Value;
267   bit hasREX_WPrefix  = 0;  // Does this inst require the REX.W prefix?
268   FPFormat FPForm = NotFP;  // What flavor of FP instruction is this?
269   bit hasLockPrefix = 0;    // Does this inst have a 0xF0 prefix?
270   Domain ExeDomain = d;
271   bit hasREPPrefix = 0;     // Does this inst have a REP prefix?
272   Encoding OpEnc = EncNormal; // Encoding used by this instruction
273   bits<2> OpEncBits = OpEnc.Value;
274   bits<2> VEX_WPrefix = 0;  // Does this inst set the VEX_W field?
275   bit hasVEX_4V = 0;        // Does this inst require the VEX.VVVV field?
276   bit hasVEX_L = 0;         // Does this inst use large (256-bit) registers?
277   bit ignoresVEX_L = 0;     // Does this instruction ignore the L-bit
278   bit hasEVEX_K = 0;        // Does this inst require masking?
279   bit hasEVEX_Z = 0;        // Does this inst set the EVEX_Z field?
280   bit hasEVEX_L2 = 0;       // Does this inst set the EVEX_L2 field?
281   bit hasEVEX_B = 0;        // Does this inst set the EVEX_B field?
282   bits<3> CD8_Form = 0;     // Compressed disp8 form - vector-width.
283   // Declare it int rather than bits<4> so that all bits are defined when
284   // assigning to bits<7>.
285   int CD8_EltSize = 0;      // Compressed disp8 form - element-size in bytes.
286   bit has3DNow0F0FOpcode =0;// Wacky 3dNow! encoding?
287   bit hasEVEX_RC = 0;       // Explicitly specified rounding control in FP instruction.
288
289   bits<2> EVEX_LL;
290   let EVEX_LL{0} = hasVEX_L;
291   let EVEX_LL{1} = hasEVEX_L2;
292   // Vector size in bytes.
293   bits<7> VectSize = !shl(16, EVEX_LL);
294
295   // The scaling factor for AVX512's compressed displacement is either
296   //   - the size of a  power-of-two number of elements or
297   //   - the size of a single element for broadcasts or
298   //   - the total vector size divided by a power-of-two number.
299   // Possible values are: 0 (non-AVX512 inst), 1, 2, 4, 8, 16, 32 and 64.
300   bits<7> CD8_Scale = !if (!eq (OpEnc.Value, EncEVEX.Value),
301                            !if (CD8_Form{2},
302                                 !shl(CD8_EltSize, CD8_Form{1-0}),
303                                 !if (hasEVEX_B,
304                                      CD8_EltSize,
305                                      !srl(VectSize, CD8_Form{1-0}))), 0);
306
307   // TSFlags layout should be kept in sync with X86BaseInfo.h.
308   let TSFlags{6-0}   = FormBits;
309   let TSFlags{8-7}   = OpSizeBits;
310   let TSFlags{10-9}  = AdSizeBits;
311   let TSFlags{13-11} = OpPrefixBits;
312   let TSFlags{16-14} = OpMapBits;
313   let TSFlags{17}    = hasREX_WPrefix;
314   let TSFlags{21-18} = ImmT.Value;
315   let TSFlags{24-22} = FPForm.Value;
316   let TSFlags{25}    = hasLockPrefix;
317   let TSFlags{26}    = hasREPPrefix;
318   let TSFlags{28-27} = ExeDomain.Value;
319   let TSFlags{30-29} = OpEncBits;
320   let TSFlags{38-31} = Opcode;
321   // Currently no need for second bit in TSFlags - W Ignore is equivalent to 0.
322   let TSFlags{39}    = VEX_WPrefix{0};
323   let TSFlags{40}    = hasVEX_4V;
324   let TSFlags{41}    = hasVEX_L;
325   let TSFlags{42}    = hasEVEX_K;
326   let TSFlags{43}    = hasEVEX_Z;
327   let TSFlags{44}    = hasEVEX_L2;
328   let TSFlags{45}    = hasEVEX_B;
329   // If we run out of TSFlags bits, it's possible to encode this in 3 bits.
330   let TSFlags{52-46} = CD8_Scale;
331   let TSFlags{53}    = has3DNow0F0FOpcode;
332   let TSFlags{54}    = hasEVEX_RC;
333 }
334
335 class PseudoI<dag oops, dag iops, list<dag> pattern>
336   : X86Inst<0, Pseudo, NoImm, oops, iops, "", NoItinerary> {
337   let Pattern = pattern;
338 }
339
340 class I<bits<8> o, Format f, dag outs, dag ins, string asm,
341         list<dag> pattern, InstrItinClass itin = NoItinerary,
342         Domain d = GenericDomain>
343   : X86Inst<o, f, NoImm, outs, ins, asm, itin, d> {
344   let Pattern = pattern;
345   let CodeSize = 3;
346 }
347 class Ii8 <bits<8> o, Format f, dag outs, dag ins, string asm,
348            list<dag> pattern, InstrItinClass itin = NoItinerary,
349            Domain d = GenericDomain>
350   : X86Inst<o, f, Imm8, outs, ins, asm, itin, d> {
351   let Pattern = pattern;
352   let CodeSize = 3;
353 }
354 class Ii8Reg<bits<8> o, Format f, dag outs, dag ins, string asm,
355              list<dag> pattern, InstrItinClass itin = NoItinerary,
356              Domain d = GenericDomain>
357   : X86Inst<o, f, Imm8Reg, outs, ins, asm, itin, d> {
358   let Pattern = pattern;
359   let CodeSize = 3;
360 }
361 class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
362                list<dag> pattern, InstrItinClass itin = NoItinerary>
363   : X86Inst<o, f, Imm8PCRel, outs, ins, asm, itin> {
364   let Pattern = pattern;
365   let CodeSize = 3;
366 }
367 class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
368            list<dag> pattern, InstrItinClass itin = NoItinerary>
369   : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
370   let Pattern = pattern;
371   let CodeSize = 3;
372 }
373 class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
374            list<dag> pattern, InstrItinClass itin = NoItinerary>
375   : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
376   let Pattern = pattern;
377   let CodeSize = 3;
378 }
379 class Ii32S<bits<8> o, Format f, dag outs, dag ins, string asm,
380             list<dag> pattern, InstrItinClass itin = NoItinerary>
381   : X86Inst<o, f, Imm32S, outs, ins, asm, itin> {
382   let Pattern = pattern;
383   let CodeSize = 3;
384 }
385
386 class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
387            list<dag> pattern, InstrItinClass itin = NoItinerary>
388            : X86Inst<o, f, Imm16PCRel, outs, ins, asm, itin> {
389   let Pattern = pattern;
390   let CodeSize = 3;
391 }
392
393 class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
394            list<dag> pattern, InstrItinClass itin = NoItinerary>
395   : X86Inst<o, f, Imm32PCRel, outs, ins, asm, itin> {
396   let Pattern = pattern;
397   let CodeSize = 3;
398 }
399
400 // FPStack Instruction Templates:
401 // FPI - Floating Point Instruction template.
402 class FPI<bits<8> o, Format F, dag outs, dag ins, string asm,
403           InstrItinClass itin = NoItinerary>
404   : I<o, F, outs, ins, asm, [], itin> {}
405
406 // FpI_ - Floating Point Pseudo Instruction template. Not Predicated.
407 class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern,
408            InstrItinClass itin = NoItinerary>
409   : X86Inst<0, Pseudo, NoImm, outs, ins, "", itin> {
410   let FPForm = fp;
411   let Pattern = pattern;
412 }
413
414 // Templates for instructions that use a 16- or 32-bit segmented address as
415 //  their only operand: lcall (FAR CALL) and ljmp (FAR JMP)
416 //
417 //   Iseg16 - 16-bit segment selector, 16-bit offset
418 //   Iseg32 - 16-bit segment selector, 32-bit offset
419
420 class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
421               list<dag> pattern, InstrItinClass itin = NoItinerary>
422       : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
423   let Pattern = pattern;
424   let CodeSize = 3;
425 }
426
427 class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
428               list<dag> pattern, InstrItinClass itin = NoItinerary>
429       : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
430   let Pattern = pattern;
431   let CodeSize = 3;
432 }
433
434 // SI - SSE 1 & 2 scalar instructions
435 class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
436          list<dag> pattern, InstrItinClass itin = NoItinerary,
437          Domain d = GenericDomain>
438       : I<o, F, outs, ins, asm, pattern, itin, d> {
439   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
440                    !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
441                    !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
442                    !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
443                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
444                    [UseSSE1])))));
445
446   // AVX instructions have a 'v' prefix in the mnemonic
447   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
448                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
449                   asm));
450 }
451
452 // SI - SSE 1 & 2 scalar intrinsics - vex form available on AVX512
453 class SI_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
454          list<dag> pattern, InstrItinClass itin = NoItinerary,
455          Domain d = GenericDomain>
456       : I<o, F, outs, ins, asm, pattern, itin, d> {
457   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
458                    !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
459                    !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
460                    !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
461                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
462                    [UseSSE1])))));
463
464   // AVX instructions have a 'v' prefix in the mnemonic
465   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
466                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
467                   asm));
468 }
469 // SIi8 - SSE 1 & 2 scalar instructions - vex form available on AVX512
470 class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
471            list<dag> pattern, InstrItinClass itin = NoItinerary>
472       : Ii8<o, F, outs, ins, asm, pattern, itin> {
473   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
474                    !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
475                    !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
476                    [UseSSE2])));
477
478   // AVX instructions have a 'v' prefix in the mnemonic
479   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
480                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
481                   asm));
482 }
483
484 // PI - SSE 1 & 2 packed instructions
485 class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
486          InstrItinClass itin, Domain d>
487       : I<o, F, outs, ins, asm, pattern, itin, d> {
488   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
489                    !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
490                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
491                    [UseSSE1])));
492
493   // AVX instructions have a 'v' prefix in the mnemonic
494   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
495                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
496                   asm));
497 }
498
499 // MMXPI - SSE 1 & 2 packed instructions with MMX operands
500 class MMXPI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
501             InstrItinClass itin, Domain d>
502       : I<o, F, outs, ins, asm, pattern, itin, d> {
503   let Predicates = !if(!eq(OpPrefix.Value, PD.Value), [HasSSE2],
504                        [HasSSE1]);
505 }
506
507 // PIi8 - SSE 1 & 2 packed instructions with immediate
508 class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
509            list<dag> pattern, InstrItinClass itin, Domain d>
510       : Ii8<o, F, outs, ins, asm, pattern, itin, d> {
511   let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
512                    !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
513                    !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
514                    [UseSSE1])));
515
516   // AVX instructions have a 'v' prefix in the mnemonic
517   let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
518                   !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
519                   asm));
520 }
521
522 // SSE1 Instruction Templates:
523 //
524 //   SSI   - SSE1 instructions with XS prefix.
525 //   PSI   - SSE1 instructions with PS prefix.
526 //   PSIi8 - SSE1 instructions with ImmT == Imm8 and PS prefix.
527 //   VSSI  - SSE1 instructions with XS prefix in AVX form.
528 //   VPSI  - SSE1 instructions with PS prefix in AVX form, packed single.
529
530 class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
531           list<dag> pattern, InstrItinClass itin = NoItinerary>
532       : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
533 class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
534             list<dag> pattern, InstrItinClass itin = NoItinerary>
535       : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
536 class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
537           list<dag> pattern, InstrItinClass itin = NoItinerary>
538       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, PS,
539         Requires<[UseSSE1]>;
540 class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
541             list<dag> pattern, InstrItinClass itin = NoItinerary>
542       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, PS,
543         Requires<[UseSSE1]>;
544 class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
545            list<dag> pattern, InstrItinClass itin = NoItinerary>
546       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
547         Requires<[HasAVX]>;
548 class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
549            list<dag> pattern, InstrItinClass itin = NoItinerary>
550       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedSingle>, PS,
551         Requires<[HasAVX]>;
552
553 // SSE2 Instruction Templates:
554 //
555 //   SDI    - SSE2 instructions with XD prefix.
556 //   SDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix.
557 //   S2SI   - SSE2 instructions with XS prefix.
558 //   SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
559 //   PDI    - SSE2 instructions with PD prefix, packed double domain.
560 //   PDIi8  - SSE2 instructions with ImmT == Imm8 and PD prefix.
561 //   VSDI   - SSE2 scalar instructions with XD prefix in AVX form.
562 //   VPDI   - SSE2 vector instructions with PD prefix in AVX form,
563 //                 packed double domain.
564 //   VS2I   - SSE2 scalar instructions with PD prefix in AVX form.
565 //   S2I    - SSE2 scalar instructions with PD prefix.
566 //   MMXSDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
567 //               MMX operands.
568 //   MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
569 //               MMX operands.
570
571 class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
572           list<dag> pattern, InstrItinClass itin = NoItinerary>
573       : I<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
574 class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
575             list<dag> pattern, InstrItinClass itin = NoItinerary>
576       : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
577 class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
578            list<dag> pattern, InstrItinClass itin = NoItinerary>
579       : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE2]>;
580 class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
581              list<dag> pattern, InstrItinClass itin = NoItinerary>
582       : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
583 class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
584           list<dag> pattern, InstrItinClass itin = NoItinerary>
585       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
586         Requires<[UseSSE2]>;
587 class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
588             list<dag> pattern, InstrItinClass itin = NoItinerary>
589       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
590         Requires<[UseSSE2]>;
591 class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
592            list<dag> pattern, InstrItinClass itin = NoItinerary>
593       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XD,
594         Requires<[UseAVX]>;
595 class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
596             list<dag> pattern, InstrItinClass itin = NoItinerary>
597       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
598         Requires<[HasAVX]>;
599 class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
600            list<dag> pattern, InstrItinClass itin = NoItinerary>
601       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedDouble>,
602         PD, Requires<[HasAVX]>;
603 class VS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
604            list<dag> pattern, InstrItinClass itin = NoItinerary>
605       : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, PD,
606         Requires<[UseAVX]>;
607 class S2I<bits<8> o, Format F, dag outs, dag ins, string asm,
608            list<dag> pattern, InstrItinClass itin = NoItinerary>
609       : I<o, F, outs, ins, asm, pattern, itin>, PD, Requires<[UseSSE2]>;
610 class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
611                list<dag> pattern, InstrItinClass itin = NoItinerary>
612       : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasSSE2]>;
613 class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
614                 list<dag> pattern, InstrItinClass itin = NoItinerary>
615       : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE2]>;
616
617 // SSE3 Instruction Templates:
618 //
619 //   S3I   - SSE3 instructions with PD prefixes.
620 //   S3SI  - SSE3 instructions with XS prefix.
621 //   S3DI  - SSE3 instructions with XD prefix.
622
623 class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
624            list<dag> pattern, InstrItinClass itin = NoItinerary>
625       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, XS,
626         Requires<[UseSSE3]>;
627 class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
628            list<dag> pattern, InstrItinClass itin = NoItinerary>
629       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, XD,
630         Requires<[UseSSE3]>;
631 class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
632           list<dag> pattern, InstrItinClass itin = NoItinerary>
633       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
634         Requires<[UseSSE3]>;
635
636
637 // SSSE3 Instruction Templates:
638 //
639 //   SS38I - SSSE3 instructions with T8 prefix.
640 //   SS3AI - SSSE3 instructions with TA prefix.
641 //   MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
642 //   MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
643 //
644 // Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
645 // uses the MMX registers. The 64-bit versions are grouped with the MMX
646 // classes. They need to be enabled even if AVX is enabled.
647
648 class SS38I<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, SSEPackedInt>, T8PD,
651         Requires<[UseSSSE3]>;
652 class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
653             list<dag> pattern, InstrItinClass itin = NoItinerary>
654       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
655         Requires<[UseSSSE3]>;
656 class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
657                list<dag> pattern, InstrItinClass itin = NoItinerary>
658       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PS,
659         Requires<[HasSSSE3]>;
660 class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
661                list<dag> pattern, InstrItinClass itin = NoItinerary>
662       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPS,
663         Requires<[HasSSSE3]>;
664
665 // SSE4.1 Instruction Templates:
666 //
667 //   SS48I - SSE 4.1 instructions with T8 prefix.
668 //   SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
669 //
670 class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
671             list<dag> pattern, InstrItinClass itin = NoItinerary>
672       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
673         Requires<[UseSSE41]>;
674 class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
675             list<dag> pattern, InstrItinClass itin = NoItinerary>
676       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
677         Requires<[UseSSE41]>;
678
679 // SSE4.2 Instruction Templates:
680 //
681 //   SS428I - SSE 4.2 instructions with T8 prefix.
682 class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
683              list<dag> pattern, InstrItinClass itin = NoItinerary>
684       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
685         Requires<[UseSSE42]>;
686
687 //   SS42FI - SSE 4.2 instructions with T8XD prefix.
688 // NOTE: 'HasSSE42' is used as SS42FI is only used for CRC32 insns.
689 class SS42FI<bits<8> o, Format F, dag outs, dag ins, string asm,
690              list<dag> pattern, InstrItinClass itin = NoItinerary>
691       : I<o, F, outs, ins, asm, pattern, itin>, T8XD, Requires<[HasSSE42]>;
692
693 //   SS42AI = SSE 4.2 instructions with TA prefix
694 class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
695              list<dag> pattern, InstrItinClass itin = NoItinerary>
696       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
697         Requires<[UseSSE42]>;
698
699 // AVX Instruction Templates:
700 //   Instructions introduced in AVX (no SSE equivalent forms)
701 //
702 //   AVX8I - AVX instructions with T8PD prefix.
703 //   AVXAIi8 - AVX instructions with TAPD prefix and ImmT = Imm8.
704 class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
705             list<dag> pattern, InstrItinClass itin = NoItinerary>
706       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
707         Requires<[HasAVX]>;
708 class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
709               list<dag> pattern, InstrItinClass itin = NoItinerary>
710       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
711         Requires<[HasAVX]>;
712
713 // AVX2 Instruction Templates:
714 //   Instructions introduced in AVX2 (no SSE equivalent forms)
715 //
716 //   AVX28I - AVX2 instructions with T8PD prefix.
717 //   AVX2AIi8 - AVX2 instructions with TAPD prefix and ImmT = Imm8.
718 class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
719             list<dag> pattern, InstrItinClass itin = NoItinerary>
720       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
721         Requires<[HasAVX2]>;
722 class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
723               list<dag> pattern, InstrItinClass itin = NoItinerary>
724       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
725         Requires<[HasAVX2]>;
726
727
728 // AVX-512 Instruction Templates:
729 //   Instructions introduced in AVX-512 (no SSE equivalent forms)
730 //
731 //   AVX5128I - AVX-512 instructions with T8PD prefix.
732 //   AVX512AIi8 - AVX-512 instructions with TAPD prefix and ImmT = Imm8.
733 //   AVX512PDI  - AVX-512 instructions with PD, double packed.
734 //   AVX512PSI  - AVX-512 instructions with PS, single packed.
735 //   AVX512XS8I - AVX-512 instructions with T8 and XS prefixes.
736 //   AVX512XSI  - AVX-512 instructions with XS prefix, generic domain.
737 //   AVX512BI   - AVX-512 instructions with PD, int packed domain.
738 //   AVX512SI   - AVX-512 scalar instructions with PD prefix.
739
740 class AVX5128I<bits<8> o, Format F, dag outs, dag ins, string asm,
741             list<dag> pattern, InstrItinClass itin = NoItinerary>
742       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
743         Requires<[HasAVX512]>;
744 class AVX5128IBase : T8PD {
745   Domain ExeDomain = SSEPackedInt;
746 }
747 class AVX512XS8I<bits<8> o, Format F, dag outs, dag ins, string asm,
748             list<dag> pattern, InstrItinClass itin = NoItinerary>
749       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8XS,
750         Requires<[HasAVX512]>;
751 class AVX512XSI<bits<8> o, Format F, dag outs, dag ins, string asm,
752             list<dag> pattern, InstrItinClass itin = NoItinerary>
753       : I<o, F, outs, ins, asm, pattern, itin>, XS,
754         Requires<[HasAVX512]>;
755 class AVX512XDI<bits<8> o, Format F, dag outs, dag ins, string asm,
756             list<dag> pattern, InstrItinClass itin = NoItinerary>
757       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, XD,
758         Requires<[HasAVX512]>;
759 class AVX512BI<bits<8> o, Format F, dag outs, dag ins, string asm,
760             list<dag> pattern, InstrItinClass itin = NoItinerary>
761       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, PD,
762         Requires<[HasAVX512]>;
763 class AVX512BIBase : PD {
764   Domain ExeDomain = SSEPackedInt;
765 }
766 class AVX512BIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
767               list<dag> pattern, InstrItinClass itin = NoItinerary>
768       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, PD,
769         Requires<[HasAVX512]>;
770 class AVX512BIi8Base : PD {
771   Domain ExeDomain = SSEPackedInt;
772   ImmType ImmT = Imm8;
773 }
774 class AVX512XSIi8Base : XS {
775   Domain ExeDomain = SSEPackedInt;
776   ImmType ImmT = Imm8;
777 }
778 class AVX512XDIi8Base : XD {
779   Domain ExeDomain = SSEPackedInt;
780   ImmType ImmT = Imm8;
781 }
782 class AVX512PSIi8Base : PS {
783   Domain ExeDomain = SSEPackedSingle;
784   ImmType ImmT = Imm8;
785 }
786 class AVX512PDIi8Base : PD {
787   Domain ExeDomain = SSEPackedDouble;
788   ImmType ImmT = Imm8;
789 }
790 class AVX512AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
791               list<dag> pattern, InstrItinClass itin = NoItinerary>
792       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
793         Requires<[HasAVX512]>;
794 class AVX512AIi8Base : TAPD {
795   ImmType ImmT = Imm8;
796 }
797 class AVX512Ii8<bits<8> o, Format F, dag outs, dag ins, string asm,
798               list<dag> pattern, InstrItinClass itin = NoItinerary>
799       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>,
800         Requires<[HasAVX512]>;
801 class AVX512PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
802            list<dag> pattern, InstrItinClass itin = NoItinerary>
803       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, PD,
804         Requires<[HasAVX512]>;
805 class AVX512PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
806            list<dag> pattern, InstrItinClass itin = NoItinerary>
807       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, PS,
808         Requires<[HasAVX512]>;
809 class AVX512PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
810               list<dag> pattern, Domain d, InstrItinClass itin = NoItinerary>
811       : Ii8<o, F, outs, ins, asm, pattern, itin, d>, Requires<[HasAVX512]>;
812 class AVX512PI<bits<8> o, Format F, dag outs, dag ins, string asm,
813               list<dag> pattern, Domain d, InstrItinClass itin = NoItinerary>
814       : I<o, F, outs, ins, asm, pattern, itin, d>, Requires<[HasAVX512]>;
815 class AVX512FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
816            list<dag>pattern, InstrItinClass itin = NoItinerary>
817       : I<o, F, outs, ins, asm, pattern, itin>, T8PD,
818         EVEX_4V, Requires<[HasAVX512]>;
819 class AVX512FMA3Base : T8PD, EVEX_4V;
820
821 class AVX512<bits<8> o, Format F, dag outs, dag ins, string asm,
822            list<dag>pattern, InstrItinClass itin = NoItinerary>
823       : I<o, F, outs, ins, asm, pattern, itin>, Requires<[HasAVX512]>;
824
825 // AES Instruction Templates:
826 //
827 // AES8I
828 // These use the same encoding as the SSE4.2 T8 and TA encodings.
829 class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
830             list<dag>pattern, InstrItinClass itin = IIC_AES>
831       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8PD,
832         Requires<[HasAES]>;
833
834 class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
835             list<dag> pattern, InstrItinClass itin = NoItinerary>
836       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
837         Requires<[HasAES]>;
838
839 // PCLMUL Instruction Templates
840 class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
841                list<dag>pattern, InstrItinClass itin = NoItinerary>
842       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
843         Requires<[HasPCLMUL]>;
844
845 class AVXPCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
846                   list<dag>pattern, InstrItinClass itin = NoItinerary>
847       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TAPD,
848         VEX_4V, Requires<[HasAVX, HasPCLMUL]>;
849
850 // FMA3 Instruction Templates
851 class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
852            list<dag>pattern, InstrItinClass itin = NoItinerary>
853       : I<o, F, outs, ins, asm, pattern, itin>, T8PD,
854         VEX_4V, FMASC, Requires<[HasFMA, NoVLX]>;
855
856 // FMA4 Instruction Templates
857 class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
858            list<dag>pattern, InstrItinClass itin = NoItinerary>
859       : Ii8Reg<o, F, outs, ins, asm, pattern, itin>, TAPD,
860         VEX_4V, FMASC, Requires<[HasFMA4]>;
861
862 // XOP 2, 3 and 4 Operand Instruction Template
863 class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
864            list<dag> pattern, InstrItinClass itin = NoItinerary>
865       : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
866          XOP9, Requires<[HasXOP]>;
867
868 // XOP 2 and 3 Operand Instruction Templates with imm byte
869 class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
870            list<dag> pattern, InstrItinClass itin = NoItinerary>
871       : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
872          XOP8, Requires<[HasXOP]>;
873 // XOP 4 Operand Instruction Templates with imm byte
874 class IXOPi8Reg<bits<8> o, Format F, dag outs, dag ins, string asm,
875            list<dag> pattern, InstrItinClass itin = NoItinerary>
876       : Ii8Reg<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
877          XOP8, Requires<[HasXOP]>;
878
879 //  XOP 5 operand instruction (VEX encoding!)
880 class IXOP5<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, SSEPackedInt>, TAPD,
883         VEX_4V, Requires<[HasXOP]>;
884
885 // X86-64 Instruction templates...
886 //
887
888 class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
889          list<dag> pattern, InstrItinClass itin = NoItinerary>
890       : I<o, F, outs, ins, asm, pattern, itin>, REX_W;
891 class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
892             list<dag> pattern, InstrItinClass itin = NoItinerary>
893       : Ii8<o, F, outs, ins, asm, pattern, itin>, REX_W;
894 class RIi16 <bits<8> o, Format F, dag outs, dag ins, string asm,
895             list<dag> pattern, InstrItinClass itin = NoItinerary>
896       : Ii16<o, F, outs, ins, asm, pattern, itin>, REX_W;
897 class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
898              list<dag> pattern, InstrItinClass itin = NoItinerary>
899       : Ii32<o, F, outs, ins, asm, pattern, itin>, REX_W;
900 class RIi32S <bits<8> o, Format F, dag outs, dag ins, string asm,
901               list<dag> pattern, InstrItinClass itin = NoItinerary>
902       : Ii32S<o, F, outs, ins, asm, pattern, itin>, REX_W;
903
904 class RIi64<bits<8> o, Format f, dag outs, dag ins, string asm,
905             list<dag> pattern, InstrItinClass itin = NoItinerary>
906   : X86Inst<o, f, Imm64, outs, ins, asm, itin>, REX_W {
907   let Pattern = pattern;
908   let CodeSize = 3;
909 }
910
911 class RIi64_NOREX<bits<8> o, Format f, dag outs, dag ins, string asm,
912             list<dag> pattern, InstrItinClass itin = NoItinerary>
913   : X86Inst<o, f, Imm64, outs, ins, asm, itin> {
914   let Pattern = pattern;
915   let CodeSize = 3;
916 }
917
918 class RS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
919            list<dag> pattern, InstrItinClass itin = NoItinerary>
920       : S2I<o, F, outs, ins, asm, pattern, itin>, REX_W;
921 class VRS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
922            list<dag> pattern, InstrItinClass itin = NoItinerary>
923       : VS2I<o, F, outs, ins, asm, pattern, itin>, VEX_W;
924
925 // MMX Instruction templates
926 //
927
928 // MMXI   - MMX instructions with TB prefix.
929 // MMXI32 - MMX instructions with TB prefix valid only in 32 bit mode.
930 // MMXI64 - MMX instructions with TB prefix valid only in 64 bit mode.
931 // MMX2I  - MMX / SSE2 instructions with PD prefix.
932 // MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
933 // MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
934 // MMXID  - MMX instructions with XD prefix.
935 // MMXIS  - MMX instructions with XS prefix.
936 class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
937            list<dag> pattern, InstrItinClass itin = NoItinerary>
938       : I<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX]>;
939 class MMXI32<bits<8> o, Format F, dag outs, dag ins, string asm,
940              list<dag> pattern, InstrItinClass itin = NoItinerary>
941       : I<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX,Not64BitMode]>;
942 class MMXI64<bits<8> o, Format F, dag outs, dag ins, string asm,
943              list<dag> pattern, InstrItinClass itin = NoItinerary>
944       : I<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX,In64BitMode]>;
945 class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
946             list<dag> pattern, InstrItinClass itin = NoItinerary>
947       : I<o, F, outs, ins, asm, pattern, itin>, PS, REX_W, Requires<[HasMMX]>;
948 class MMX2I<bits<8> o, Format F, dag outs, dag ins, string asm,
949             list<dag> pattern, InstrItinClass itin = NoItinerary>
950       : I<o, F, outs, ins, asm, pattern, itin>, PD, Requires<[HasMMX]>;
951 class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
952              list<dag> pattern, InstrItinClass itin = NoItinerary>
953       : Ii8<o, F, outs, ins, asm, pattern, itin>, PS, Requires<[HasMMX]>;
954 class MMXID<bits<8> o, Format F, dag outs, dag ins, string asm,
955             list<dag> pattern, InstrItinClass itin = NoItinerary>
956       : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasMMX]>;
957 class MMXIS<bits<8> o, Format F, dag outs, dag ins, string asm,
958             list<dag> pattern, InstrItinClass itin = NoItinerary>
959       : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[HasMMX]>;