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