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