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