1 //===-- X86InstrFormats.td - X86 Instruction Formats -------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // X86 Instruction Format Definitions.
14 // Format specifies the encoding used by the instruction. This is part of the
15 // ad-hoc solution used to emit machine instruction encodings by our machine
17 class Format<bits<6> val> {
21 def Pseudo : Format<0>; def RawFrm : Format<1>;
22 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
23 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
24 def MRMSrcMem : Format<6>;
25 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
26 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
27 def MRM6r : Format<22>; def MRM7r : Format<23>;
28 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
29 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
30 def MRM6m : Format<30>; def MRM7m : Format<31>;
31 def MRMInitReg : Format<32>;
32 def MRM_C1 : Format<33>;
33 def MRM_C2 : Format<34>;
34 def MRM_C3 : Format<35>;
35 def MRM_C4 : Format<36>;
36 def MRM_C8 : Format<37>;
37 def MRM_C9 : Format<38>;
38 def MRM_E8 : Format<39>;
39 def MRM_F0 : Format<40>;
40 def MRM_F8 : Format<41>;
41 def MRM_F9 : Format<42>;
42 def RawFrmImm8 : Format<43>;
43 def RawFrmImm16 : Format<44>;
44 def MRM_D0 : Format<45>;
45 def MRM_D1 : Format<46>;
46 def MRM_D4 : Format<47>;
47 def MRM_D8 : Format<48>;
48 def MRM_D9 : Format<49>;
49 def MRM_DA : Format<50>;
50 def MRM_DB : Format<51>;
51 def MRM_DC : Format<52>;
52 def MRM_DD : Format<53>;
53 def MRM_DE : Format<54>;
54 def MRM_DF : Format<55>;
56 // ImmType - This specifies the immediate type used by an instruction. This is
57 // part of the ad-hoc solution used to emit machine instruction encodings by our
58 // machine code emitter.
59 class ImmType<bits<3> val> {
62 def NoImm : ImmType<0>;
63 def Imm8 : ImmType<1>;
64 def Imm8PCRel : ImmType<2>;
65 def Imm16 : ImmType<3>;
66 def Imm16PCRel : ImmType<4>;
67 def Imm32 : ImmType<5>;
68 def Imm32PCRel : ImmType<6>;
69 def Imm64 : ImmType<7>;
71 // FPFormat - This specifies what form this FP instruction has. This is used by
72 // the Floating-Point stackifier pass.
73 class FPFormat<bits<3> val> {
76 def NotFP : FPFormat<0>;
77 def ZeroArgFP : FPFormat<1>;
78 def OneArgFP : FPFormat<2>;
79 def OneArgFPRW : FPFormat<3>;
80 def TwoArgFP : FPFormat<4>;
81 def CompareFP : FPFormat<5>;
82 def CondMovFP : FPFormat<6>;
83 def SpecialFP : FPFormat<7>;
85 // Class specifying the SSE execution domain, used by the SSEDomainFix pass.
86 // Keep in sync with tables in X86InstrInfo.cpp.
87 class Domain<bits<2> val> {
90 def GenericDomain : Domain<0>;
91 def SSEPackedSingle : Domain<1>;
92 def SSEPackedDouble : Domain<2>;
93 def SSEPackedInt : Domain<3>;
95 // Prefix byte classes which are used to indicate to the ad-hoc machine code
96 // emitter that various prefix bytes are required.
97 class OpSize { bit hasOpSizePrefix = 1; }
98 class AdSize { bit hasAdSizePrefix = 1; }
99 class REX_W { bit hasREX_WPrefix = 1; }
100 class LOCK { bit hasLockPrefix = 1; }
101 class SegFS { bits<2> SegOvrBits = 1; }
102 class SegGS { bits<2> SegOvrBits = 2; }
103 class TB { bits<5> Prefix = 1; }
104 class REP { bits<5> Prefix = 2; }
105 class D8 { bits<5> Prefix = 3; }
106 class D9 { bits<5> Prefix = 4; }
107 class DA { bits<5> Prefix = 5; }
108 class DB { bits<5> Prefix = 6; }
109 class DC { bits<5> Prefix = 7; }
110 class DD { bits<5> Prefix = 8; }
111 class DE { bits<5> Prefix = 9; }
112 class DF { bits<5> Prefix = 10; }
113 class XD { bits<5> Prefix = 11; }
114 class XS { bits<5> Prefix = 12; }
115 class T8 { bits<5> Prefix = 13; }
116 class TA { bits<5> Prefix = 14; }
117 class A6 { bits<5> Prefix = 15; }
118 class A7 { bits<5> Prefix = 16; }
119 class T8XD { bits<5> Prefix = 17; }
120 class T8XS { bits<5> Prefix = 18; }
121 class TAXD { bits<5> Prefix = 19; }
122 class XOP8 { bits<5> Prefix = 20; }
123 class XOP9 { bits<5> Prefix = 21; }
124 class VEX { bit hasVEXPrefix = 1; }
125 class VEX_W { bit hasVEX_WPrefix = 1; }
126 class VEX_4V : VEX { bit hasVEX_4VPrefix = 1; }
127 class VEX_4VOp3 : VEX { bit hasVEX_4VOp3Prefix = 1; }
128 class VEX_I8IMM { bit hasVEX_i8ImmReg = 1; }
129 class VEX_L { bit hasVEX_L = 1; }
130 class VEX_LIG { bit ignoresVEX_L = 1; }
131 class Has3DNow0F0FOpcode { bit has3DNow0F0FOpcode = 1; }
132 class MemOp4 { bit hasMemOp4Prefix = 1; }
133 class XOP { bit hasXOP_Prefix = 1; }
134 class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
137 Domain d = GenericDomain>
139 let Namespace = "X86";
141 bits<8> Opcode = opcod;
143 bits<6> FormBits = Form.Value;
146 dag OutOperandList = outs;
147 dag InOperandList = ins;
148 string AsmString = AsmStr;
150 // If this is a pseudo instruction, mark it isCodeGenOnly.
151 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
153 let Itinerary = itin;
156 // Attributes specific to X86 instructions...
158 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
159 bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
161 bits<5> Prefix = 0; // Which prefix byte does this inst have?
162 bit hasREX_WPrefix = 0; // Does this inst require the REX.W prefix?
163 FPFormat FPForm = NotFP; // What flavor of FP instruction is this?
164 bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
165 bits<2> SegOvrBits = 0; // Segment override prefix.
166 Domain ExeDomain = d;
167 bit hasVEXPrefix = 0; // Does this inst require a VEX prefix?
168 bit hasVEX_WPrefix = 0; // Does this inst set the VEX_W field?
169 bit hasVEX_4VPrefix = 0; // Does this inst require the VEX.VVVV field?
170 bit hasVEX_4VOp3Prefix = 0; // Does this inst require the VEX.VVVV field to
171 // encode the third operand?
172 bit hasVEX_i8ImmReg = 0; // Does this inst require the last source register
173 // to be encoded in a immediate field?
174 bit hasVEX_L = 0; // Does this inst use large (256-bit) registers?
175 bit ignoresVEX_L = 0; // Does this instruction ignore the L-bit
176 bit has3DNow0F0FOpcode =0;// Wacky 3dNow! encoding?
177 bit hasMemOp4Prefix = 0; // Same bit as VEX_W, but used for swapping operands
178 bit hasXOP_Prefix = 0; // Does this inst require an XOP prefix?
180 // TSFlags layout should be kept in sync with X86InstrInfo.h.
181 let TSFlags{5-0} = FormBits;
182 let TSFlags{6} = hasOpSizePrefix;
183 let TSFlags{7} = hasAdSizePrefix;
184 let TSFlags{12-8} = Prefix;
185 let TSFlags{13} = hasREX_WPrefix;
186 let TSFlags{16-14} = ImmT.Value;
187 let TSFlags{19-17} = FPForm.Value;
188 let TSFlags{20} = hasLockPrefix;
189 let TSFlags{22-21} = SegOvrBits;
190 let TSFlags{24-23} = ExeDomain.Value;
191 let TSFlags{32-25} = Opcode;
192 let TSFlags{33} = hasVEXPrefix;
193 let TSFlags{34} = hasVEX_WPrefix;
194 let TSFlags{35} = hasVEX_4VPrefix;
195 let TSFlags{36} = hasVEX_4VOp3Prefix;
196 let TSFlags{37} = hasVEX_i8ImmReg;
197 let TSFlags{38} = hasVEX_L;
198 let TSFlags{39} = ignoresVEX_L;
199 let TSFlags{40} = has3DNow0F0FOpcode;
200 let TSFlags{41} = hasMemOp4Prefix;
201 let TSFlags{42} = hasXOP_Prefix;
204 class PseudoI<dag oops, dag iops, list<dag> pattern>
205 : X86Inst<0, Pseudo, NoImm, oops, iops, "", NoItinerary> {
206 let Pattern = pattern;
209 class I<bits<8> o, Format f, dag outs, dag ins, string asm,
210 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT,
211 Domain d = GenericDomain>
212 : X86Inst<o, f, NoImm, outs, ins, asm, itin, d> {
213 let Pattern = pattern;
216 class Ii8 <bits<8> o, Format f, dag outs, dag ins, string asm,
217 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT,
218 Domain d = GenericDomain>
219 : X86Inst<o, f, Imm8, outs, ins, asm, itin, d> {
220 let Pattern = pattern;
223 class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
224 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
225 : X86Inst<o, f, Imm8PCRel, outs, ins, asm, itin> {
226 let Pattern = pattern;
229 class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
230 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
231 : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
232 let Pattern = pattern;
235 class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
236 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
237 : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
238 let Pattern = pattern;
242 class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
243 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
244 : X86Inst<o, f, Imm16PCRel, outs, ins, asm, itin> {
245 let Pattern = pattern;
249 class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
250 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
251 : X86Inst<o, f, Imm32PCRel, outs, ins, asm, itin> {
252 let Pattern = pattern;
256 // FPStack Instruction Templates:
257 // FPI - Floating Point Instruction template.
258 class FPI<bits<8> o, Format F, dag outs, dag ins, string asm,
259 InstrItinClass itin = IIC_DEFAULT>
260 : I<o, F, outs, ins, asm, [], itin> {}
262 // FpI_ - Floating Point Pseudo Instruction template. Not Predicated.
263 class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern,
264 InstrItinClass itin = IIC_DEFAULT>
265 : X86Inst<0, Pseudo, NoImm, outs, ins, "", itin> {
267 let Pattern = pattern;
270 // Templates for instructions that use a 16- or 32-bit segmented address as
271 // their only operand: lcall (FAR CALL) and ljmp (FAR JMP)
273 // Iseg16 - 16-bit segment selector, 16-bit offset
274 // Iseg32 - 16-bit segment selector, 32-bit offset
276 class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
277 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
278 : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
279 let Pattern = pattern;
283 class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
284 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
285 : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
286 let Pattern = pattern;
292 // SI - SSE 1 & 2 scalar instructions
293 class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
294 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
295 : I<o, F, outs, ins, asm, pattern, itin> {
296 let Predicates = !if(hasVEXPrefix /* VEX */, [HasAVX],
297 !if(!eq(Prefix, __xs.Prefix), [UseSSE1], [UseSSE2]));
299 // AVX instructions have a 'v' prefix in the mnemonic
300 let AsmString = !if(hasVEXPrefix, !strconcat("v", asm), asm);
303 // SIi8 - SSE 1 & 2 scalar instructions
304 class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
305 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
306 : Ii8<o, F, outs, ins, asm, pattern, itin> {
307 let Predicates = !if(hasVEXPrefix /* VEX */, [HasAVX],
308 !if(!eq(Prefix, __xs.Prefix), [UseSSE1], [UseSSE2]));
310 // AVX instructions have a 'v' prefix in the mnemonic
311 let AsmString = !if(hasVEXPrefix, !strconcat("v", asm), asm);
314 // PI - SSE 1 & 2 packed instructions
315 class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
316 InstrItinClass itin, Domain d>
317 : I<o, F, outs, ins, asm, pattern, itin, d> {
318 let Predicates = !if(hasVEXPrefix /* VEX */, [HasAVX],
319 !if(hasOpSizePrefix /* OpSize */, [UseSSE2], [UseSSE1]));
321 // AVX instructions have a 'v' prefix in the mnemonic
322 let AsmString = !if(hasVEXPrefix, !strconcat("v", asm), asm);
325 // MMXPI - SSE 1 & 2 packed instructions with MMX operands
326 class MMXPI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
327 InstrItinClass itin, Domain d>
328 : I<o, F, outs, ins, asm, pattern, itin, d> {
329 let Predicates = !if(hasOpSizePrefix /* OpSize */, [HasSSE2], [HasSSE1]);
332 // PIi8 - SSE 1 & 2 packed instructions with immediate
333 class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
334 list<dag> pattern, InstrItinClass itin, Domain d>
335 : Ii8<o, F, outs, ins, asm, pattern, itin, d> {
336 let Predicates = !if(hasVEX_4VPrefix /* VEX */, [HasAVX],
337 !if(hasOpSizePrefix /* OpSize */, [UseSSE2], [UseSSE1]));
339 // AVX instructions have a 'v' prefix in the mnemonic
340 let AsmString = !if(hasVEX_4VPrefix, !strconcat("v", asm), asm);
343 // SSE1 Instruction Templates:
345 // SSI - SSE1 instructions with XS prefix.
346 // PSI - SSE1 instructions with TB prefix.
347 // PSIi8 - SSE1 instructions with ImmT == Imm8 and TB prefix.
348 // VSSI - SSE1 instructions with XS prefix in AVX form.
349 // VPSI - SSE1 instructions with TB prefix in AVX form.
351 class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
352 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
353 : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
354 class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
355 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
356 : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
357 class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
358 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
359 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, TB,
361 class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
362 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
363 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, TB,
365 class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
366 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
367 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
369 class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
370 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
371 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedSingle>, TB,
374 // SSE2 Instruction Templates:
376 // SDI - SSE2 instructions with XD prefix.
377 // SDIi8 - SSE2 instructions with ImmT == Imm8 and XD prefix.
378 // S2SI - SSE2 instructions with XS prefix.
379 // SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
380 // PDI - SSE2 instructions with TB and OpSize prefixes.
381 // PDIi8 - SSE2 instructions with ImmT == Imm8 and TB and OpSize prefixes.
382 // VSDI - SSE2 instructions with XD prefix in AVX form.
383 // VPDI - SSE2 instructions with TB and OpSize prefixes in AVX form.
384 // MMXSDIi8 - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
386 // MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
389 class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
390 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
391 : I<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
392 class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
393 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
394 : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
395 class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
396 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
397 : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE2]>;
398 class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
399 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
400 : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
401 class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
402 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
403 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, TB, OpSize,
405 class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
406 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
407 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, TB, OpSize,
409 class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
410 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
411 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XD,
413 class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
414 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
415 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
417 class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
418 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
419 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedDouble>, TB,
420 OpSize, Requires<[HasAVX]>;
421 class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
422 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
423 : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasSSE2]>;
424 class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
425 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
426 : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE2]>;
428 // SSE3 Instruction Templates:
430 // S3I - SSE3 instructions with TB and OpSize prefixes.
431 // S3SI - SSE3 instructions with XS prefix.
432 // S3DI - SSE3 instructions with XD prefix.
434 class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
435 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
436 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, XS,
438 class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
439 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
440 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, XD,
442 class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
443 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
444 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, TB, OpSize,
448 // SSSE3 Instruction Templates:
450 // SS38I - SSSE3 instructions with T8 prefix.
451 // SS3AI - SSSE3 instructions with TA prefix.
452 // MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
453 // MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
455 // Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
456 // uses the MMX registers. The 64-bit versions are grouped with the MMX
457 // classes. They need to be enabled even if AVX is enabled.
459 class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
460 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
461 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
462 Requires<[UseSSSE3]>;
463 class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
464 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
465 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
466 Requires<[UseSSSE3]>;
467 class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
468 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
469 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
470 Requires<[HasSSSE3]>;
471 class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
472 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
473 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
474 Requires<[HasSSSE3]>;
476 // SSE4.1 Instruction Templates:
478 // SS48I - SSE 4.1 instructions with T8 prefix.
479 // SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
481 class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
482 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
483 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
484 Requires<[UseSSE41]>;
485 class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
486 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
487 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
488 Requires<[UseSSE41]>;
490 // SSE4.2 Instruction Templates:
492 // SS428I - SSE 4.2 instructions with T8 prefix.
493 class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
494 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
495 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
496 Requires<[UseSSE42]>;
498 // SS42FI - SSE 4.2 instructions with T8XD prefix.
499 // NOTE: 'HasSSE42' is used as SS42FI is only used for CRC32 insns.
500 class SS42FI<bits<8> o, Format F, dag outs, dag ins, string asm,
501 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
502 : I<o, F, outs, ins, asm, pattern, itin>, T8XD, Requires<[HasSSE42]>;
504 // SS42AI = SSE 4.2 instructions with TA prefix
505 class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
506 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
507 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
508 Requires<[UseSSE42]>;
510 // AVX Instruction Templates:
511 // Instructions introduced in AVX (no SSE equivalent forms)
513 // AVX8I - AVX instructions with T8 and OpSize prefix.
514 // AVXAIi8 - AVX instructions with TA, OpSize prefix and ImmT = Imm8.
515 class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
516 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
517 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8, OpSize,
519 class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
520 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
521 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA, OpSize,
524 // AVX2 Instruction Templates:
525 // Instructions introduced in AVX2 (no SSE equivalent forms)
527 // AVX28I - AVX2 instructions with T8 and OpSize prefix.
528 // AVX2AIi8 - AVX2 instructions with TA, OpSize prefix and ImmT = Imm8.
529 class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
530 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
531 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8, OpSize,
533 class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
534 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
535 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA, OpSize,
538 // AES Instruction Templates:
541 // These use the same encoding as the SSE4.2 T8 and TA encodings.
542 class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
543 list<dag>pattern, InstrItinClass itin = IIC_DEFAULT>
544 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
547 class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
548 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
549 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
552 // PCLMUL Instruction Templates
553 class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
554 list<dag>pattern, InstrItinClass itin = IIC_DEFAULT>
555 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
556 OpSize, Requires<[HasPCLMUL]>;
558 class AVXPCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
559 list<dag>pattern, InstrItinClass itin = IIC_DEFAULT>
560 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
561 OpSize, VEX_4V, Requires<[HasAVX, HasPCLMUL]>;
563 // FMA3 Instruction Templates
564 class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
565 list<dag>pattern, InstrItinClass itin = IIC_DEFAULT>
566 : I<o, F, outs, ins, asm, pattern, itin>, T8,
567 OpSize, VEX_4V, Requires<[HasFMA]>;
569 // FMA4 Instruction Templates
570 class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
571 list<dag>pattern, InstrItinClass itin = IIC_DEFAULT>
572 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
573 OpSize, VEX_4V, VEX_I8IMM, Requires<[HasFMA4]>;
575 // XOP 2, 3 and 4 Operand Instruction Template
576 class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
577 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
578 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
579 XOP, XOP9, Requires<[HasXOP]>;
581 // XOP 2, 3 and 4 Operand Instruction Templates with imm byte
582 class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
583 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
584 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
585 XOP, XOP8, Requires<[HasXOP]>;
587 // XOP 5 operand instruction (VEX encoding!)
588 class IXOP5<bits<8> o, Format F, dag outs, dag ins, string asm,
589 list<dag>pattern, InstrItinClass itin = IIC_DEFAULT>
590 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
591 OpSize, VEX_4V, VEX_I8IMM, Requires<[HasXOP]>;
593 // X86-64 Instruction templates...
596 class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
597 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
598 : I<o, F, outs, ins, asm, pattern, itin>, REX_W;
599 class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
600 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
601 : Ii8<o, F, outs, ins, asm, pattern, itin>, REX_W;
602 class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
603 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
604 : Ii32<o, F, outs, ins, asm, pattern, itin>, REX_W;
606 class RIi64<bits<8> o, Format f, dag outs, dag ins, string asm,
607 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
608 : X86Inst<o, f, Imm64, outs, ins, asm, itin>, REX_W {
609 let Pattern = pattern;
613 class RSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
614 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
615 : SSI<o, F, outs, ins, asm, pattern, itin>, REX_W;
616 class RSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
617 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
618 : SDI<o, F, outs, ins, asm, pattern, itin>, REX_W;
619 class RPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
620 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
621 : PDI<o, F, outs, ins, asm, pattern, itin>, REX_W;
622 class VRPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
623 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
624 : VPDI<o, F, outs, ins, asm, pattern, itin>, VEX_W;
626 // MMX Instruction templates
629 // MMXI - MMX instructions with TB prefix.
630 // MMXI64 - MMX instructions with TB prefix valid only in 64 bit mode.
631 // MMX2I - MMX / SSE2 instructions with TB and OpSize prefixes.
632 // MMXIi8 - MMX instructions with ImmT == Imm8 and TB prefix.
633 // MMXIi8 - MMX instructions with ImmT == Imm8 and TB prefix.
634 // MMXID - MMX instructions with XD prefix.
635 // MMXIS - MMX instructions with XS prefix.
636 class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
637 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
638 : I<o, F, outs, ins, asm, pattern, itin>, TB, Requires<[HasMMX]>;
639 class MMXI64<bits<8> o, Format F, dag outs, dag ins, string asm,
640 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
641 : I<o, F, outs, ins, asm, pattern, itin>, TB, Requires<[HasMMX,In64BitMode]>;
642 class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
643 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
644 : I<o, F, outs, ins, asm, pattern, itin>, TB, REX_W, Requires<[HasMMX]>;
645 class MMX2I<bits<8> o, Format F, dag outs, dag ins, string asm,
646 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
647 : I<o, F, outs, ins, asm, pattern, itin>, TB, OpSize, Requires<[HasMMX]>;
648 class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
649 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
650 : Ii8<o, F, outs, ins, asm, pattern, itin>, TB, Requires<[HasMMX]>;
651 class MMXID<bits<8> o, Format F, dag outs, dag ins, string asm,
652 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
653 : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasMMX]>;
654 class MMXIS<bits<8> o, Format F, dag outs, dag ins, string asm,
655 list<dag> pattern, InstrItinClass itin = IIC_DEFAULT>
656 : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[HasMMX]>;