xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86InstrFormats.td (revision 5def4c47d4bd90b209b9b4a4ba9faec15846d8fd)
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
356  // TSFlags layout should be kept in sync with X86BaseInfo.h.
357  let TSFlags{6-0}   = FormBits;
358  let TSFlags{8-7}   = OpSizeBits;
359  let TSFlags{10-9}  = AdSizeBits;
360  // No need for 3rd bit, we don't need to distinguish NoPrfx from PS.
361  let TSFlags{12-11} = OpPrefixBits{1-0};
362  let TSFlags{15-13} = OpMapBits;
363  let TSFlags{16}    = hasREX_WPrefix;
364  let TSFlags{20-17} = ImmT.Value;
365  let TSFlags{23-21} = FPForm.Value;
366  let TSFlags{24}    = hasLockPrefix;
367  let TSFlags{25}    = hasREPPrefix;
368  let TSFlags{27-26} = ExeDomain.Value;
369  let TSFlags{29-28} = OpEncBits;
370  let TSFlags{37-30} = Opcode;
371  // Currently no need for second bit in TSFlags - W Ignore is equivalent to 0.
372  let TSFlags{38}    = HasVEX_W;
373  let TSFlags{39}    = hasVEX_4V;
374  let TSFlags{40}    = hasVEX_L;
375  let TSFlags{41}    = hasEVEX_K;
376  let TSFlags{42}    = hasEVEX_Z;
377  let TSFlags{43}    = hasEVEX_L2;
378  let TSFlags{44}    = hasEVEX_B;
379  // If we run out of TSFlags bits, it's possible to encode this in 3 bits.
380  let TSFlags{51-45} = CD8_Scale;
381  let TSFlags{52}    = hasEVEX_RC;
382  let TSFlags{53}    = hasNoTrackPrefix;
383  let TSFlags{54}    = ExplicitVEXPrefix;
384}
385
386class PseudoI<dag oops, dag iops, list<dag> pattern>
387  : X86Inst<0, Pseudo, NoImm, oops, iops, ""> {
388  let Pattern = pattern;
389}
390
391class I<bits<8> o, Format f, dag outs, dag ins, string asm,
392        list<dag> pattern, Domain d = GenericDomain>
393  : X86Inst<o, f, NoImm, outs, ins, asm, d> {
394  let Pattern = pattern;
395  let CodeSize = 3;
396}
397class Ii8<bits<8> o, Format f, dag outs, dag ins, string asm,
398          list<dag> pattern, Domain d = GenericDomain>
399  : X86Inst<o, f, Imm8, outs, ins, asm, d> {
400  let Pattern = pattern;
401  let CodeSize = 3;
402}
403class Ii8Reg<bits<8> o, Format f, dag outs, dag ins, string asm,
404             list<dag> pattern, Domain d = GenericDomain>
405  : X86Inst<o, f, Imm8Reg, outs, ins, asm, d> {
406  let Pattern = pattern;
407  let CodeSize = 3;
408}
409class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
410               list<dag> pattern>
411  : X86Inst<o, f, Imm8PCRel, outs, ins, asm> {
412  let Pattern = pattern;
413  let CodeSize = 3;
414}
415class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
416           list<dag> pattern>
417  : X86Inst<o, f, Imm16, outs, ins, asm> {
418  let Pattern = pattern;
419  let CodeSize = 3;
420}
421class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
422           list<dag> pattern>
423  : X86Inst<o, f, Imm32, outs, ins, asm> {
424  let Pattern = pattern;
425  let CodeSize = 3;
426}
427class Ii32S<bits<8> o, Format f, dag outs, dag ins, string asm,
428            list<dag> pattern>
429  : X86Inst<o, f, Imm32S, outs, ins, asm> {
430  let Pattern = pattern;
431  let CodeSize = 3;
432}
433
434class Ii64<bits<8> o, Format f, dag outs, dag ins, string asm,
435           list<dag> pattern>
436  : X86Inst<o, f, Imm64, outs, ins, asm> {
437  let Pattern = pattern;
438  let CodeSize = 3;
439}
440
441class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
442           list<dag> pattern>
443           : X86Inst<o, f, Imm16PCRel, outs, ins, asm> {
444  let Pattern = pattern;
445  let CodeSize = 3;
446}
447
448class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
449           list<dag> pattern>
450  : X86Inst<o, f, Imm32PCRel, outs, ins, asm> {
451  let Pattern = pattern;
452  let CodeSize = 3;
453}
454
455// FPStack Instruction Templates:
456// FPI - Floating Point Instruction template.
457class FPI<bits<8> o, Format F, dag outs, dag ins, string asm>
458  : I<o, F, outs, ins, asm, []> {
459  let Defs = [FPSW];
460}
461
462// FpI_ - Floating Point Pseudo Instruction template. Not Predicated.
463class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern>
464  : PseudoI<outs, ins, pattern> {
465  let FPForm = fp;
466  let Defs = [FPSW];
467}
468
469// Templates for instructions that use a 16- or 32-bit segmented address as
470//  their only operand: lcall (FAR CALL) and ljmp (FAR JMP)
471//
472//   Iseg16 - 16-bit segment selector, 16-bit offset
473//   Iseg32 - 16-bit segment selector, 32-bit offset
474
475class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
476              list<dag> pattern>
477      : X86Inst<o, f, Imm16, outs, ins, asm> {
478  let Pattern = pattern;
479  let CodeSize = 3;
480}
481
482class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
483              list<dag> pattern>
484      : X86Inst<o, f, Imm32, outs, ins, asm> {
485  let Pattern = pattern;
486  let CodeSize = 3;
487}
488
489// SI - SSE 1 & 2 scalar instructions
490class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
491         list<dag> pattern, Domain d = GenericDomain>
492      : I<o, F, outs, ins, asm, pattern, d> {
493  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
494                   !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
495                   !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
496                   !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
497                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
498                   [UseSSE1])))));
499
500  // AVX instructions have a 'v' prefix in the mnemonic
501  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
502                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
503                  asm));
504}
505
506// SI - SSE 1 & 2 scalar intrinsics - vex form available on AVX512
507class SI_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
508         list<dag> pattern, Domain d = GenericDomain>
509      : I<o, F, outs, ins, asm, pattern, d> {
510  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
511                   !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
512                   !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
513                   !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
514                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
515                   [UseSSE1])))));
516
517  // AVX instructions have a 'v' prefix in the mnemonic
518  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
519                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
520                  asm));
521}
522// SIi8 - SSE 1 & 2 scalar instructions - vex form available on AVX512
523class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
524           list<dag> pattern>
525      : Ii8<o, F, outs, ins, asm, pattern> {
526  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
527                   !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
528                   !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
529                   [UseSSE2])));
530
531  // AVX instructions have a 'v' prefix in the mnemonic
532  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
533                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
534                  asm));
535}
536
537// PI - SSE 1 & 2 packed instructions
538class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
539         Domain d>
540      : I<o, F, outs, ins, asm, pattern, d> {
541  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
542                   !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
543                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
544                   [UseSSE1])));
545
546  // AVX instructions have a 'v' prefix in the mnemonic
547  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
548                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
549                  asm));
550}
551
552// MMXPI - SSE 1 & 2 packed instructions with MMX operands
553class MMXPI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
554            Domain d>
555      : I<o, F, outs, ins, asm, pattern, d> {
556  let Predicates = !if(!eq(OpPrefix.Value, PD.Value), [HasMMX, HasSSE2],
557                       [HasMMX, HasSSE1]);
558}
559
560// PIi8 - SSE 1 & 2 packed instructions with immediate
561class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
562           list<dag> pattern, Domain d>
563      : Ii8<o, F, outs, ins, asm, pattern, d> {
564  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
565                   !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
566                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
567                   [UseSSE1])));
568
569  // AVX instructions have a 'v' prefix in the mnemonic
570  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
571                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
572                  asm));
573}
574
575// SSE1 Instruction Templates:
576//
577//   SSI   - SSE1 instructions with XS prefix.
578//   PSI   - SSE1 instructions with PS prefix.
579//   PSIi8 - SSE1 instructions with ImmT == Imm8 and PS prefix.
580//   VSSI  - SSE1 instructions with XS prefix in AVX form.
581//   VPSI  - SSE1 instructions with PS prefix in AVX form, packed single.
582
583class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
584          list<dag> pattern>
585      : I<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE1]>;
586class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
587            list<dag> pattern>
588      : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE1]>;
589class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
590          list<dag> pattern>
591      : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, PS,
592        Requires<[UseSSE1]>;
593class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
594            list<dag> pattern>
595      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedSingle>, PS,
596        Requires<[UseSSE1]>;
597class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
598           list<dag> pattern>
599      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, XS,
600        Requires<[HasAVX]>;
601class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
602           list<dag> pattern>
603      : I<o, F, outs, ins, !strconcat("v", asm), pattern, SSEPackedSingle>, PS,
604        Requires<[HasAVX]>;
605
606// SSE2 Instruction Templates:
607//
608//   SDI    - SSE2 instructions with XD prefix.
609//   SDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix.
610//   S2SI   - SSE2 instructions with XS prefix.
611//   SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
612//   PDI    - SSE2 instructions with PD prefix, packed double domain.
613//   PDIi8  - SSE2 instructions with ImmT == Imm8 and PD prefix.
614//   VSDI   - SSE2 scalar instructions with XD prefix in AVX form.
615//   VPDI   - SSE2 vector instructions with PD prefix in AVX form,
616//                 packed double domain.
617//   VS2I   - SSE2 scalar instructions with PD prefix in AVX form.
618//   S2I    - SSE2 scalar instructions with PD prefix.
619//   MMXSDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
620//               MMX operands.
621//   MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
622//               MMX operands.
623
624class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
625          list<dag> pattern>
626      : I<o, F, outs, ins, asm, pattern>, XD, Requires<[UseSSE2]>;
627class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
628            list<dag> pattern>
629      : Ii8<o, F, outs, ins, asm, pattern>, XD, Requires<[UseSSE2]>;
630class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
631           list<dag> pattern>
632      : I<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
633class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
634             list<dag> pattern>
635      : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
636class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
637          list<dag> pattern>
638      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
639        Requires<[UseSSE2]>;
640class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
641            list<dag> pattern>
642      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
643        Requires<[UseSSE2]>;
644class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
645           list<dag> pattern>
646      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, XD,
647        Requires<[UseAVX]>;
648class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
649            list<dag> pattern>
650      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, XS,
651        Requires<[HasAVX]>;
652class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
653           list<dag> pattern>
654      : I<o, F, outs, ins, !strconcat("v", asm), pattern, SSEPackedDouble>,
655        PD, Requires<[HasAVX]>;
656class VS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
657           list<dag> pattern>
658      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, PD,
659        Requires<[UseAVX]>;
660class S2I<bits<8> o, Format F, dag outs, dag ins, string asm,
661           list<dag> pattern>
662      : I<o, F, outs, ins, asm, pattern>, PD, Requires<[UseSSE2]>;
663class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
664               list<dag> pattern>
665      : Ii8<o, F, outs, ins, asm, pattern>, XD, Requires<[HasMMX, HasSSE2]>;
666class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
667                list<dag> pattern>
668      : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasMMX, HasSSE2]>;
669
670// SSE3 Instruction Templates:
671//
672//   S3I   - SSE3 instructions with PD prefixes.
673//   S3SI  - SSE3 instructions with XS prefix.
674//   S3DI  - SSE3 instructions with XD prefix.
675
676class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
677           list<dag> pattern>
678      : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, XS,
679        Requires<[UseSSE3]>;
680class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
681           list<dag> pattern>
682      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, XD,
683        Requires<[UseSSE3]>;
684class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
685          list<dag> pattern>
686      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
687        Requires<[UseSSE3]>;
688
689
690// SSSE3 Instruction Templates:
691//
692//   SS38I - SSSE3 instructions with T8 prefix.
693//   SS3AI - SSSE3 instructions with TA prefix.
694//   MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
695//   MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
696//
697// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
698// uses the MMX registers. The 64-bit versions are grouped with the MMX
699// classes. They need to be enabled even if AVX is enabled.
700
701class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
702            list<dag> pattern>
703      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
704        Requires<[UseSSSE3]>;
705class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
706            list<dag> pattern>
707      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
708        Requires<[UseSSSE3]>;
709class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
710               list<dag> pattern>
711      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PS,
712        Requires<[HasMMX, HasSSSE3]>;
713class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
714               list<dag> pattern>
715      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPS,
716        Requires<[HasMMX, HasSSSE3]>;
717
718// SSE4.1 Instruction Templates:
719//
720//   SS48I - SSE 4.1 instructions with T8 prefix.
721//   SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
722//
723class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
724            list<dag> pattern>
725      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
726        Requires<[UseSSE41]>;
727class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
728            list<dag> pattern>
729      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
730        Requires<[UseSSE41]>;
731
732// SSE4.2 Instruction Templates:
733//
734//   SS428I - SSE 4.2 instructions with T8 prefix.
735class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
736             list<dag> pattern>
737      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
738        Requires<[UseSSE42]>;
739
740//   SS42FI - SSE 4.2 instructions with T8XD prefix.
741// NOTE: 'HasSSE42' is used as SS42FI is only used for CRC32 insns.
742class SS42FI<bits<8> o, Format F, dag outs, dag ins, string asm,
743             list<dag> pattern>
744      : I<o, F, outs, ins, asm, pattern>, T8XD, Requires<[HasSSE42]>;
745
746//   SS42AI = SSE 4.2 instructions with TA prefix
747class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
748             list<dag> pattern>
749      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
750        Requires<[UseSSE42]>;
751
752// AVX Instruction Templates:
753//   Instructions introduced in AVX (no SSE equivalent forms)
754//
755//   AVX8I - AVX instructions with T8PD prefix.
756//   AVXAIi8 - AVX instructions with TAPD prefix and ImmT = Imm8.
757class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
758            list<dag> pattern>
759      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
760        Requires<[HasAVX]>;
761class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
762              list<dag> pattern>
763      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
764        Requires<[HasAVX]>;
765
766// AVX2 Instruction Templates:
767//   Instructions introduced in AVX2 (no SSE equivalent forms)
768//
769//   AVX28I - AVX2 instructions with T8PD prefix.
770//   AVX2AIi8 - AVX2 instructions with TAPD prefix and ImmT = Imm8.
771class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
772            list<dag> pattern>
773      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
774        Requires<[HasAVX2]>;
775class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
776              list<dag> pattern>
777      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
778        Requires<[HasAVX2]>;
779
780
781// AVX-512 Instruction Templates:
782//   Instructions introduced in AVX-512 (no SSE equivalent forms)
783//
784//   AVX5128I - AVX-512 instructions with T8PD prefix.
785//   AVX512AIi8 - AVX-512 instructions with TAPD prefix and ImmT = Imm8.
786//   AVX512PDI  - AVX-512 instructions with PD, double packed.
787//   AVX512PSI  - AVX-512 instructions with PS, single packed.
788//   AVX512XS8I - AVX-512 instructions with T8 and XS prefixes.
789//   AVX512XSI  - AVX-512 instructions with XS prefix, generic domain.
790//   AVX512BI   - AVX-512 instructions with PD, int packed domain.
791//   AVX512SI   - AVX-512 scalar instructions with PD prefix.
792
793class AVX5128I<bits<8> o, Format F, dag outs, dag ins, string asm,
794            list<dag> pattern>
795      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
796        Requires<[HasAVX512]>;
797class AVX5128IBase : T8PD {
798  Domain ExeDomain = SSEPackedInt;
799}
800class AVX512XS8I<bits<8> o, Format F, dag outs, dag ins, string asm,
801            list<dag> pattern>
802      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8XS,
803        Requires<[HasAVX512]>;
804class AVX512XSI<bits<8> o, Format F, dag outs, dag ins, string asm,
805            list<dag> pattern>
806      : I<o, F, outs, ins, asm, pattern>, XS,
807        Requires<[HasAVX512]>;
808class AVX512XDI<bits<8> o, Format F, dag outs, dag ins, string asm,
809            list<dag> pattern>
810      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, XD,
811        Requires<[HasAVX512]>;
812class AVX512BI<bits<8> o, Format F, dag outs, dag ins, string asm,
813            list<dag> pattern>
814      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, PD,
815        Requires<[HasAVX512]>;
816class AVX512BIBase : PD {
817  Domain ExeDomain = SSEPackedInt;
818}
819class AVX512BIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
820              list<dag> pattern>
821      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, PD,
822        Requires<[HasAVX512]>;
823class AVX512BIi8Base : PD {
824  Domain ExeDomain = SSEPackedInt;
825  ImmType ImmT = Imm8;
826}
827class AVX512XSIi8Base : XS {
828  Domain ExeDomain = SSEPackedInt;
829  ImmType ImmT = Imm8;
830}
831class AVX512XDIi8Base : XD {
832  Domain ExeDomain = SSEPackedInt;
833  ImmType ImmT = Imm8;
834}
835class AVX512PSIi8Base : PS {
836  Domain ExeDomain = SSEPackedSingle;
837  ImmType ImmT = Imm8;
838}
839class AVX512PDIi8Base : PD {
840  Domain ExeDomain = SSEPackedDouble;
841  ImmType ImmT = Imm8;
842}
843class AVX512AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
844              list<dag> pattern>
845      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
846        Requires<[HasAVX512]>;
847class AVX512AIi8Base : TAPD {
848  ImmType ImmT = Imm8;
849}
850class AVX512Ii8<bits<8> o, Format F, dag outs, dag ins, string asm,
851              list<dag> pattern>
852      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>,
853        Requires<[HasAVX512]>;
854class AVX512PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
855           list<dag> pattern>
856      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, PD,
857        Requires<[HasAVX512]>;
858class AVX512PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
859           list<dag> pattern>
860      : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, PS,
861        Requires<[HasAVX512]>;
862class AVX512PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
863              list<dag> pattern, Domain d>
864      : Ii8<o, F, outs, ins, asm, pattern, d>, Requires<[HasAVX512]>;
865class AVX512PI<bits<8> o, Format F, dag outs, dag ins, string asm,
866              list<dag> pattern, Domain d>
867      : I<o, F, outs, ins, asm, pattern, d>, Requires<[HasAVX512]>;
868class AVX512FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
869           list<dag>pattern>
870      : I<o, F, outs, ins, asm, pattern>, T8PD,
871        EVEX_4V, Requires<[HasAVX512]>;
872class AVX512FMA3Base : T8PD, EVEX_4V;
873
874class AVX512<bits<8> o, Format F, dag outs, dag ins, string asm,
875           list<dag>pattern>
876      : I<o, F, outs, ins, asm, pattern>, Requires<[HasAVX512]>;
877
878// AES Instruction Templates:
879//
880// AES8I
881// These use the same encoding as the SSE4.2 T8 and TA encodings.
882class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
883            list<dag>pattern>
884      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8PD,
885        Requires<[NoAVX, HasAES]>;
886
887class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
888            list<dag> pattern>
889      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
890        Requires<[NoAVX, HasAES]>;
891
892// PCLMUL Instruction Templates
893class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
894               list<dag>pattern>
895      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD;
896
897// FMA3 Instruction Templates
898class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
899           list<dag>pattern>
900      : I<o, F, outs, ins, asm, pattern>, T8PD,
901        VEX_4V, FMASC, Requires<[HasFMA, NoFMA4, NoVLX]>;
902class FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
903            list<dag>pattern>
904      : I<o, F, outs, ins, asm, pattern>, T8PD,
905        VEX_4V, FMASC, Requires<[HasFMA, NoFMA4, NoAVX512]>;
906class FMA3S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
907                list<dag>pattern>
908      : I<o, F, outs, ins, asm, pattern>, T8PD,
909        VEX_4V, FMASC, Requires<[HasFMA, NoAVX512]>;
910
911// FMA4 Instruction Templates
912class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
913           list<dag>pattern>
914      : Ii8Reg<o, F, outs, ins, asm, pattern>, TAPD,
915        VEX_4V, FMASC, Requires<[HasFMA4, NoVLX]>;
916class FMA4S<bits<8> o, Format F, dag outs, dag ins, string asm,
917            list<dag>pattern>
918      : Ii8Reg<o, F, outs, ins, asm, pattern>, TAPD,
919        VEX_4V, FMASC, Requires<[HasFMA4, NoAVX512]>;
920class FMA4S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
921                list<dag>pattern>
922      : Ii8Reg<o, F, outs, ins, asm, pattern>, TAPD,
923        VEX_4V, FMASC, Requires<[HasFMA4]>;
924
925// XOP 2, 3 and 4 Operand Instruction Template
926class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
927           list<dag> pattern>
928      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
929         XOP9, Requires<[HasXOP]>;
930
931// XOP 2 and 3 Operand Instruction Templates with imm byte
932class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
933           list<dag> pattern>
934      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
935         XOP8, Requires<[HasXOP]>;
936// XOP 4 Operand Instruction Templates with imm byte
937class IXOPi8Reg<bits<8> o, Format F, dag outs, dag ins, string asm,
938           list<dag> pattern>
939      : Ii8Reg<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
940         XOP8, Requires<[HasXOP]>;
941
942//  XOP 5 operand instruction (VEX encoding!)
943class IXOP5<bits<8> o, Format F, dag outs, dag ins, string asm,
944           list<dag>pattern>
945      : Ii8Reg<o, F, outs, ins, asm, pattern, SSEPackedInt>, TAPD,
946        VEX_4V, Requires<[HasXOP]>;
947
948// X86-64 Instruction templates...
949//
950
951class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
952         list<dag> pattern>
953      : I<o, F, outs, ins, asm, pattern>, REX_W;
954class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
955            list<dag> pattern>
956      : Ii8<o, F, outs, ins, asm, pattern>, REX_W;
957class RIi16 <bits<8> o, Format F, dag outs, dag ins, string asm,
958            list<dag> pattern>
959      : Ii16<o, F, outs, ins, asm, pattern>, REX_W;
960class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
961             list<dag> pattern>
962      : Ii32<o, F, outs, ins, asm, pattern>, REX_W;
963class RIi32S <bits<8> o, Format F, dag outs, dag ins, string asm,
964              list<dag> pattern>
965      : Ii32S<o, F, outs, ins, asm, pattern>, REX_W;
966class RIi64<bits<8> o, Format F, dag outs, dag ins, string asm,
967            list<dag> pattern>
968      : Ii64<o, F, outs, ins, asm, pattern>, REX_W;
969
970class RS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
971           list<dag> pattern>
972      : S2I<o, F, outs, ins, asm, pattern>, REX_W;
973class VRS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
974           list<dag> pattern>
975      : VS2I<o, F, outs, ins, asm, pattern>, VEX_W;
976
977// MMX Instruction templates
978//
979
980// MMXI   - MMX instructions with TB prefix.
981// MMXI32 - MMX instructions with TB prefix valid only in 32 bit mode.
982// MMXI64 - MMX instructions with TB prefix valid only in 64 bit mode.
983// MMX2I  - MMX / SSE2 instructions with PD prefix.
984// MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
985// MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
986// MMXID  - MMX instructions with XD prefix.
987// MMXIS  - MMX instructions with XS prefix.
988class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
989           list<dag> pattern>
990      : I<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX]>;
991class MMXI32<bits<8> o, Format F, dag outs, dag ins, string asm,
992             list<dag> pattern>
993      : I<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX,Not64BitMode]>;
994class MMXI64<bits<8> o, Format F, dag outs, dag ins, string asm,
995             list<dag> pattern>
996      : I<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX,In64BitMode]>;
997class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
998            list<dag> pattern>
999      : I<o, F, outs, ins, asm, pattern>, PS, REX_W, Requires<[HasMMX]>;
1000class MMX2I<bits<8> o, Format F, dag outs, dag ins, string asm,
1001            list<dag> pattern>
1002      : I<o, F, outs, ins, asm, pattern>, PD, Requires<[HasMMX]>;
1003class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
1004             list<dag> pattern>
1005      : Ii8<o, F, outs, ins, asm, pattern>, PS, Requires<[HasMMX]>;
1006class MMXID<bits<8> o, Format F, dag outs, dag ins, string asm,
1007            list<dag> pattern>
1008      : Ii8<o, F, outs, ins, asm, pattern>, XD, Requires<[HasMMX]>;
1009class MMXIS<bits<8> o, Format F, dag outs, dag ins, string asm,
1010            list<dag> pattern>
1011      : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasMMX]>;
1012