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