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