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