OSDN Git Service

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