blob: f3ac028802a030f23959465134e95d11922734ef [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86InstrFormats.td - X86 Instruction Formats -------*- tablegen -*-===//
2//
Evan Cheng12c6be82007-07-31 08:04:03 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jia Liub22310f2012-02-18 12:03:15 +00007//
Evan Cheng12c6be82007-07-31 08:04:03 +00008//===----------------------------------------------------------------------===//
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.
17class Format<bits<6> val> {
18 bits<6> Value = val;
19}
20
21def Pseudo : Format<0>; def RawFrm : Format<1>;
22def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
23def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
24def MRMSrcMem : Format<6>;
25def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
26def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
27def MRM6r : Format<22>; def MRM7r : Format<23>;
28def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
29def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
30def MRM6m : Format<30>; def MRM7m : Format<31>;
31def MRMInitReg : Format<32>;
Chris Lattnerf7477e52010-02-12 02:06:33 +000032def MRM_C1 : Format<33>;
Chris Lattner140caa72010-02-13 00:41:14 +000033def MRM_C2 : Format<34>;
34def MRM_C3 : Format<35>;
35def MRM_C4 : Format<36>;
36def MRM_C8 : Format<37>;
37def MRM_C9 : Format<38>;
Michael Liao95d944032013-04-11 04:52:28 +000038def MRM_CA : Format<39>;
39def MRM_CB : Format<40>;
40def MRM_E8 : Format<41>;
41def MRM_F0 : Format<42>;
Chris Lattnercea0a8d2010-09-17 18:02:29 +000042def RawFrmImm8 : Format<43>;
43def RawFrmImm16 : Format<44>;
Michael Liao95d944032013-04-11 04:52:28 +000044def MRM_F8 : Format<45>;
45def MRM_F9 : Format<46>;
46def MRM_D0 : Format<47>;
47def MRM_D1 : Format<48>;
48def MRM_D4 : Format<49>;
49def MRM_D5 : Format<50>;
50def MRM_D6 : Format<51>;
51def MRM_D8 : Format<52>;
52def MRM_D9 : Format<53>;
53def MRM_DA : Format<54>;
54def MRM_DB : Format<55>;
55def MRM_DC : Format<56>;
56def MRM_DD : Format<57>;
57def MRM_DE : Format<58>;
58def MRM_DF : Format<59>;
Evan Cheng12c6be82007-07-31 08:04:03 +000059
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.
63class ImmType<bits<3> val> {
64 bits<3> Value = val;
65}
Chris Lattner12455ca2010-02-12 22:27:07 +000066def NoImm : ImmType<0>;
67def Imm8 : ImmType<1>;
68def Imm8PCRel : ImmType<2>;
69def Imm16 : ImmType<3>;
Chris Lattnerac588122010-07-07 22:27:31 +000070def Imm16PCRel : ImmType<4>;
71def Imm32 : ImmType<5>;
72def Imm32PCRel : ImmType<6>;
73def Imm64 : ImmType<7>;
Evan Cheng12c6be82007-07-31 08:04:03 +000074
75// FPFormat - This specifies what form this FP instruction has. This is used by
76// the Floating-Point stackifier pass.
77class FPFormat<bits<3> val> {
78 bits<3> Value = val;
79}
80def NotFP : FPFormat<0>;
81def ZeroArgFP : FPFormat<1>;
82def OneArgFP : FPFormat<2>;
83def OneArgFPRW : FPFormat<3>;
84def TwoArgFP : FPFormat<4>;
85def CompareFP : FPFormat<5>;
86def CondMovFP : FPFormat<6>;
87def SpecialFP : FPFormat<7>;
88
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +000089// Class specifying the SSE execution domain, used by the SSEDomainFix pass.
Jakob Stoklund Olesendbff4e82010-03-30 22:46:53 +000090// Keep in sync with tables in X86InstrInfo.cpp.
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +000091class Domain<bits<2> val> {
92 bits<2> Value = val;
93}
94def GenericDomain : Domain<0>;
Jakob Stoklund Olesendbff4e82010-03-30 22:46:53 +000095def SSEPackedSingle : Domain<1>;
96def SSEPackedDouble : Domain<2>;
97def SSEPackedInt : Domain<3>;
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +000098
Evan Cheng12c6be82007-07-31 08:04:03 +000099// Prefix byte classes which are used to indicate to the ad-hoc machine code
100// emitter that various prefix bytes are required.
101class OpSize { bit hasOpSizePrefix = 1; }
102class AdSize { bit hasAdSizePrefix = 1; }
103class REX_W { bit hasREX_WPrefix = 1; }
Andrew Lenharth0070dd12008-03-01 13:37:02 +0000104class LOCK { bit hasLockPrefix = 1; }
Anton Korobeynikov25897772008-10-11 19:09:15 +0000105class SegFS { bits<2> SegOvrBits = 1; }
106class SegGS { bits<2> SegOvrBits = 2; }
Joerg Sonnenbergercc53d992011-04-04 15:58:30 +0000107class TB { bits<5> Prefix = 1; }
108class REP { bits<5> Prefix = 2; }
109class D8 { bits<5> Prefix = 3; }
110class D9 { bits<5> Prefix = 4; }
111class DA { bits<5> Prefix = 5; }
112class DB { bits<5> Prefix = 6; }
113class DC { bits<5> Prefix = 7; }
114class DD { bits<5> Prefix = 8; }
115class DE { bits<5> Prefix = 9; }
116class DF { bits<5> Prefix = 10; }
117class XD { bits<5> Prefix = 11; }
118class XS { bits<5> Prefix = 12; }
119class T8 { bits<5> Prefix = 13; }
120class TA { bits<5> Prefix = 14; }
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000121class A6 { bits<5> Prefix = 15; }
122class A7 { bits<5> Prefix = 16; }
Craig Topper96fa5972011-10-16 16:50:08 +0000123class T8XD { bits<5> Prefix = 17; }
124class T8XS { bits<5> Prefix = 18; }
Craig Topper980d5982011-10-23 07:34:00 +0000125class TAXD { bits<5> Prefix = 19; }
Jan Sjödin6dd24882011-12-12 19:12:26 +0000126class XOP8 { bits<5> Prefix = 20; }
127class XOP9 { bits<5> Prefix = 21; }
Bruno Cardoso Lopes1a890f92010-06-22 22:38:56 +0000128class VEX { bit hasVEXPrefix = 1; }
Bruno Cardoso Lopes05166742010-07-01 01:20:06 +0000129class VEX_W { bit hasVEX_WPrefix = 1; }
Bruno Cardoso Lopes1a890f92010-06-22 22:38:56 +0000130class VEX_4V : VEX { bit hasVEX_4VPrefix = 1; }
Craig Topperaea148c2011-10-16 07:55:05 +0000131class VEX_4VOp3 : VEX { bit hasVEX_4VOp3Prefix = 1; }
Bruno Cardoso Lopese2bd0582010-07-06 22:36:24 +0000132class VEX_I8IMM { bit hasVEX_i8ImmReg = 1; }
Bruno Cardoso Lopesfd8bfcd2010-07-13 21:07:28 +0000133class VEX_L { bit hasVEX_L = 1; }
Craig Topperf18c8962011-10-04 06:30:42 +0000134class VEX_LIG { bit ignoresVEX_L = 1; }
Chris Lattner45270db2010-10-03 18:08:05 +0000135class Has3DNow0F0FOpcode { bit has3DNow0F0FOpcode = 1; }
Craig Toppercd93de92011-12-30 04:48:54 +0000136class MemOp4 { bit hasMemOp4Prefix = 1; }
Jan Sjödin6dd24882011-12-12 19:12:26 +0000137class XOP { bit hasXOP_Prefix = 1; }
Evan Cheng12c6be82007-07-31 08:04:03 +0000138class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
Andrew Trick8523b162012-02-01 23:20:51 +0000139 string AsmStr,
140 InstrItinClass itin,
141 Domain d = GenericDomain>
Evan Cheng12c6be82007-07-31 08:04:03 +0000142 : 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;
Evan Cheng12c6be82007-07-31 08:04:03 +0000149
150 dag OutOperandList = outs;
151 dag InOperandList = ins;
152 string AsmString = AsmStr;
153
Chris Lattner7ff33462010-10-31 19:22:57 +0000154 // If this is a pseudo instruction, mark it isCodeGenOnly.
155 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
156
Andrew Trick8523b162012-02-01 23:20:51 +0000157 let Itinerary = itin;
158
Evan Cheng12c6be82007-07-31 08:04:03 +0000159 //
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
Joerg Sonnenbergercc53d992011-04-04 15:58:30 +0000165 bits<5> Prefix = 0; // Which prefix byte does this inst have?
Eric Christopher3a8ae232010-11-30 09:11:54 +0000166 bit hasREX_WPrefix = 0; // Does this inst require the REX.W prefix?
Jakob Stoklund Olesenf8d7eda2010-03-25 18:52:01 +0000167 FPFormat FPForm = NotFP; // What flavor of FP instruction is this?
Dan Gohmana21bdda2008-08-20 13:46:21 +0000168 bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
Anton Korobeynikov25897772008-10-11 19:09:15 +0000169 bits<2> SegOvrBits = 0; // Segment override prefix.
Jakob Stoklund Olesenf8d7eda2010-03-25 18:52:01 +0000170 Domain ExeDomain = d;
Eric Christopher3a8ae232010-11-30 09:11:54 +0000171 bit hasVEXPrefix = 0; // Does this inst require a VEX prefix?
Bruno Cardoso Lopes05166742010-07-01 01:20:06 +0000172 bit hasVEX_WPrefix = 0; // Does this inst set the VEX_W field?
Eric Christopher3a8ae232010-11-30 09:11:54 +0000173 bit hasVEX_4VPrefix = 0; // Does this inst require the VEX.VVVV field?
Craig Topperaea148c2011-10-16 07:55:05 +0000174 bit hasVEX_4VOp3Prefix = 0; // Does this inst require the VEX.VVVV field to
175 // encode the third operand?
Eric Christopher3a8ae232010-11-30 09:11:54 +0000176 bit hasVEX_i8ImmReg = 0; // Does this inst require the last source register
Bruno Cardoso Lopese2bd0582010-07-06 22:36:24 +0000177 // to be encoded in a immediate field?
Eric Christopher3a8ae232010-11-30 09:11:54 +0000178 bit hasVEX_L = 0; // Does this inst use large (256-bit) registers?
Craig Topperf18c8962011-10-04 06:30:42 +0000179 bit ignoresVEX_L = 0; // Does this instruction ignore the L-bit
Chris Lattner45270db2010-10-03 18:08:05 +0000180 bit has3DNow0F0FOpcode =0;// Wacky 3dNow! encoding?
Craig Toppercd93de92011-12-30 04:48:54 +0000181 bit hasMemOp4Prefix = 0; // Same bit as VEX_W, but used for swapping operands
Jan Sjödin6dd24882011-12-12 19:12:26 +0000182 bit hasXOP_Prefix = 0; // Does this inst require an XOP prefix?
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000183
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;
Joerg Sonnenbergercc53d992011-04-04 15:58:30 +0000188 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;
Craig Topperaea148c2011-10-16 07:55:05 +0000199 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;
Craig Toppercd93de92011-12-30 04:48:54 +0000204 let TSFlags{41} = hasMemOp4Prefix;
Jan Sjödin6dd24882011-12-12 19:12:26 +0000205 let TSFlags{42} = hasXOP_Prefix;
Evan Cheng12c6be82007-07-31 08:04:03 +0000206}
207
Eric Christopheref62f572010-11-30 08:57:23 +0000208class PseudoI<dag oops, dag iops, list<dag> pattern>
Andrew Trick8523b162012-02-01 23:20:51 +0000209 : X86Inst<0, Pseudo, NoImm, oops, iops, "", NoItinerary> {
Eric Christopheref62f572010-11-30 08:57:23 +0000210 let Pattern = pattern;
211}
212
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +0000213class I<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000214 list<dag> pattern, InstrItinClass itin = NoItinerary,
Andrew Trick8523b162012-02-01 23:20:51 +0000215 Domain d = GenericDomain>
216 : X86Inst<o, f, NoImm, outs, ins, asm, itin, d> {
Evan Cheng12c6be82007-07-31 08:04:03 +0000217 let Pattern = pattern;
218 let CodeSize = 3;
219}
Sean Callanan04d8cb72009-12-18 00:01:26 +0000220class Ii8 <bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000221 list<dag> pattern, InstrItinClass itin = NoItinerary,
Andrew Trick8523b162012-02-01 23:20:51 +0000222 Domain d = GenericDomain>
223 : X86Inst<o, f, Imm8, outs, ins, asm, itin, d> {
Evan Cheng12c6be82007-07-31 08:04:03 +0000224 let Pattern = pattern;
225 let CodeSize = 3;
226}
Chris Lattner12455ca2010-02-12 22:27:07 +0000227class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000228 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000229 : X86Inst<o, f, Imm8PCRel, outs, ins, asm, itin> {
Chris Lattner12455ca2010-02-12 22:27:07 +0000230 let Pattern = pattern;
231 let CodeSize = 3;
232}
Sean Callanan04d8cb72009-12-18 00:01:26 +0000233class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000234 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000235 : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
Evan Cheng12c6be82007-07-31 08:04:03 +0000236 let Pattern = pattern;
237 let CodeSize = 3;
238}
Sean Callanan04d8cb72009-12-18 00:01:26 +0000239class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000240 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000241 : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
Evan Cheng12c6be82007-07-31 08:04:03 +0000242 let Pattern = pattern;
243 let CodeSize = 3;
244}
245
Chris Lattnerac588122010-07-07 22:27:31 +0000246class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000247 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000248 : X86Inst<o, f, Imm16PCRel, outs, ins, asm, itin> {
Chris Lattnerac588122010-07-07 22:27:31 +0000249 let Pattern = pattern;
250 let CodeSize = 3;
251}
252
Chris Lattner12455ca2010-02-12 22:27:07 +0000253class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000254 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000255 : X86Inst<o, f, Imm32PCRel, outs, ins, asm, itin> {
Chris Lattner12455ca2010-02-12 22:27:07 +0000256 let Pattern = pattern;
257 let CodeSize = 3;
258}
259
Evan Cheng12c6be82007-07-31 08:04:03 +0000260// FPStack Instruction Templates:
261// FPI - Floating Point Instruction template.
Preston Gurdfa3f6cb2012-05-02 16:03:35 +0000262class FPI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000263 InstrItinClass itin = NoItinerary>
Preston Gurdfa3f6cb2012-05-02 16:03:35 +0000264 : I<o, F, outs, ins, asm, [], itin> {}
Evan Cheng12c6be82007-07-31 08:04:03 +0000265
Bob Wilsona967c422010-08-26 18:08:11 +0000266// FpI_ - Floating Point Pseudo Instruction template. Not Predicated.
Andrew Trick8523b162012-02-01 23:20:51 +0000267class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000268 InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000269 : X86Inst<0, Pseudo, NoImm, outs, ins, "", itin> {
Jakob Stoklund Olesenf8d7eda2010-03-25 18:52:01 +0000270 let FPForm = fp;
Evan Cheng12c6be82007-07-31 08:04:03 +0000271 let Pattern = pattern;
272}
273
Sean Callanan050e0cd2009-09-15 00:35:17 +0000274// 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
280class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000281 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000282 : X86Inst<o, f, Imm16, outs, ins, asm, itin> {
Sean Callanan050e0cd2009-09-15 00:35:17 +0000283 let Pattern = pattern;
284 let CodeSize = 3;
285}
286
287class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000288 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000289 : X86Inst<o, f, Imm32, outs, ins, asm, itin> {
Sean Callanan050e0cd2009-09-15 00:35:17 +0000290 let Pattern = pattern;
291 let CodeSize = 3;
292}
293
Michael Liaobbd10792012-08-30 16:54:46 +0000294def __xs : XS;
Elena Demikhovskyfad02922013-05-21 12:04:22 +0000295def __xd : XD;
Michael Liaobbd10792012-08-30 16:54:46 +0000296
Bruno Cardoso Lopes6b98f712010-06-17 23:05:30 +0000297// SI - SSE 1 & 2 scalar instructions
Andrew Trick8523b162012-02-01 23:20:51 +0000298class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000299 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000300 : I<o, F, outs, ins, asm, pattern, itin> {
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000301 let Predicates = !if(hasVEXPrefix /* VEX */, [HasAVX],
Elena Demikhovskyfad02922013-05-21 12:04:22 +0000302 !if(!eq(Prefix, __xs.Prefix), [UseSSE1],
303 !if(!eq(Prefix, __xd.Prefix), [UseSSE2],
304 !if(hasOpSizePrefix, [UseSSE2], [UseSSE1]))));
Bruno Cardoso Lopes6b98f712010-06-17 23:05:30 +0000305
306 // AVX instructions have a 'v' prefix in the mnemonic
Bruno Cardoso Lopes1a890f92010-06-22 22:38:56 +0000307 let AsmString = !if(hasVEXPrefix, !strconcat("v", asm), asm);
Bruno Cardoso Lopes6b98f712010-06-17 23:05:30 +0000308}
309
Bruno Cardoso Lopes191a1cd2010-06-24 00:32:06 +0000310// SIi8 - SSE 1 & 2 scalar instructions
311class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000312 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000313 : Ii8<o, F, outs, ins, asm, pattern, itin> {
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000314 let Predicates = !if(hasVEXPrefix /* VEX */, [HasAVX],
Michael Liaobbd10792012-08-30 16:54:46 +0000315 !if(!eq(Prefix, __xs.Prefix), [UseSSE1], [UseSSE2]));
Bruno Cardoso Lopes191a1cd2010-06-24 00:32:06 +0000316
317 // AVX instructions have a 'v' prefix in the mnemonic
318 let AsmString = !if(hasVEXPrefix, !strconcat("v", asm), asm);
319}
320
Bruno Cardoso Lopes2bfad412010-06-18 23:13:35 +0000321// PI - SSE 1 & 2 packed instructions
322class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
Andrew Trick8523b162012-02-01 23:20:51 +0000323 InstrItinClass itin, Domain d>
324 : I<o, F, outs, ins, asm, pattern, itin, d> {
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000325 let Predicates = !if(hasVEXPrefix /* VEX */, [HasAVX],
Michael Liaobbd10792012-08-30 16:54:46 +0000326 !if(hasOpSizePrefix /* OpSize */, [UseSSE2], [UseSSE1]));
Bruno Cardoso Lopes2bfad412010-06-18 23:13:35 +0000327
328 // AVX instructions have a 'v' prefix in the mnemonic
Bruno Cardoso Lopes1a890f92010-06-22 22:38:56 +0000329 let AsmString = !if(hasVEXPrefix, !strconcat("v", asm), asm);
Bruno Cardoso Lopes2bfad412010-06-18 23:13:35 +0000330}
331
Michael Liaobbd10792012-08-30 16:54:46 +0000332// MMXPI - SSE 1 & 2 packed instructions with MMX operands
333class 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
Bruno Cardoso Lopes1e13c172010-06-22 23:37:59 +0000339// PIi8 - SSE 1 & 2 packed instructions with immediate
340class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Andrew Trick8523b162012-02-01 23:20:51 +0000341 list<dag> pattern, InstrItinClass itin, Domain d>
342 : Ii8<o, F, outs, ins, asm, pattern, itin, d> {
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000343 let Predicates = !if(hasVEX_4VPrefix /* VEX */, [HasAVX],
Michael Liaobbd10792012-08-30 16:54:46 +0000344 !if(hasOpSizePrefix /* OpSize */, [UseSSE2], [UseSSE1]));
Bruno Cardoso Lopes1e13c172010-06-22 23:37:59 +0000345
346 // AVX instructions have a 'v' prefix in the mnemonic
347 let AsmString = !if(hasVEX_4VPrefix, !strconcat("v", asm), asm);
348}
349
Evan Cheng12c6be82007-07-31 08:04:03 +0000350// 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.
Bruno Cardoso Lopesc2f87b72010-06-08 22:51:23 +0000355// VSSI - SSE1 instructions with XS prefix in AVX form.
Bruno Cardoso Lopesb06f54b2010-06-12 01:23:26 +0000356// VPSI - SSE1 instructions with TB prefix in AVX form.
Evan Cheng12c6be82007-07-31 08:04:03 +0000357
Andrew Trick8523b162012-02-01 23:20:51 +0000358class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000359 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000360 : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +0000361class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000362 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000363 : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE1]>;
Andrew Trick8523b162012-02-01 23:20:51 +0000364class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000365 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000366 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, TB,
Michael Liaobbd10792012-08-30 16:54:46 +0000367 Requires<[UseSSE1]>;
Evan Cheng12c6be82007-07-31 08:04:03 +0000368class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000369 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000370 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, TB,
Michael Liaobbd10792012-08-30 16:54:46 +0000371 Requires<[UseSSE1]>;
Bruno Cardoso Lopesc2f87b72010-06-08 22:51:23 +0000372class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000373 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000374 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000375 Requires<[HasAVX]>;
Bruno Cardoso Lopesb06f54b2010-06-12 01:23:26 +0000376class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000377 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000378 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedSingle>, TB,
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000379 Requires<[HasAVX]>;
Evan Cheng12c6be82007-07-31 08:04:03 +0000380
381// SSE2 Instruction Templates:
382//
Bill Wendling76105a42008-08-27 21:32:04 +0000383// SDI - SSE2 instructions with XD prefix.
384// SDIi8 - SSE2 instructions with ImmT == Imm8 and XD prefix.
Craig Topperf881d382012-07-30 02:14:02 +0000385// S2SI - SSE2 instructions with XS prefix.
Bill Wendling76105a42008-08-27 21:32:04 +0000386// SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
387// PDI - SSE2 instructions with TB and OpSize prefixes.
388// PDIi8 - SSE2 instructions with ImmT == Imm8 and TB and OpSize prefixes.
Bruno Cardoso Lopesc2f87b72010-06-08 22:51:23 +0000389// VSDI - SSE2 instructions with XD prefix in AVX form.
Bruno Cardoso Lopesb06f54b2010-06-12 01:23:26 +0000390// VPDI - SSE2 instructions with TB and OpSize prefixes in AVX form.
Michael Liaobbd10792012-08-30 16:54:46 +0000391// MMXSDIi8 - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
392// MMX operands.
393// MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
394// MMX operands.
Evan Cheng12c6be82007-07-31 08:04:03 +0000395
Andrew Trick8523b162012-02-01 23:20:51 +0000396class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000397 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000398 : I<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
Evan Cheng01c7c192007-12-20 19:57:09 +0000399class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000400 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000401 : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[UseSSE2]>;
Craig Topperf881d382012-07-30 02:14:02 +0000402class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000403 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000404 : I<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[UseSSE2]>;
Craig Topperf881d382012-07-30 02:14:02 +0000405class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000406 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000407 : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[UseSSE2]>;
Andrew Trick8523b162012-02-01 23:20:51 +0000408class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000409 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000410 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, TB, OpSize,
Michael Liaobbd10792012-08-30 16:54:46 +0000411 Requires<[UseSSE2]>;
Evan Cheng12c6be82007-07-31 08:04:03 +0000412class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000413 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000414 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, TB, OpSize,
Michael Liaobbd10792012-08-30 16:54:46 +0000415 Requires<[UseSSE2]>;
Bruno Cardoso Lopesc2f87b72010-06-08 22:51:23 +0000416class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000417 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000418 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XD,
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000419 Requires<[HasAVX]>;
Craig Topperf881d382012-07-30 02:14:02 +0000420class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000421 list<dag> pattern, InstrItinClass itin = NoItinerary>
Craig Topperf881d382012-07-30 02:14:02 +0000422 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin>, XS,
423 Requires<[HasAVX]>;
Bruno Cardoso Lopesb06f54b2010-06-12 01:23:26 +0000424class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000425 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000426 : I<o, F, outs, ins, !strconcat("v", asm), pattern, itin, SSEPackedDouble>, TB,
Bruno Cardoso Lopes77a3c442010-07-13 00:38:47 +0000427 OpSize, Requires<[HasAVX]>;
Michael Liaobbd10792012-08-30 16:54:46 +0000428class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000429 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000430 : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasSSE2]>;
431class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000432 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000433 : Ii8<o, F, outs, ins, asm, pattern>, XS, Requires<[HasSSE2]>;
Evan Cheng12c6be82007-07-31 08:04:03 +0000434
435// SSE3 Instruction Templates:
436//
437// S3I - SSE3 instructions with TB and OpSize prefixes.
438// S3SI - SSE3 instructions with XS prefix.
439// S3DI - SSE3 instructions with XD prefix.
440
Sean Callanan04d8cb72009-12-18 00:01:26 +0000441class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000442 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000443 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedSingle>, XS,
Michael Liaobbd10792012-08-30 16:54:46 +0000444 Requires<[UseSSE3]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000445class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000446 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000447 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, XD,
Michael Liaobbd10792012-08-30 16:54:46 +0000448 Requires<[UseSSE3]>;
Andrew Trick8523b162012-02-01 23:20:51 +0000449class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000450 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000451 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>, TB, OpSize,
Michael Liaobbd10792012-08-30 16:54:46 +0000452 Requires<[UseSSE3]>;
Evan Cheng12c6be82007-07-31 08:04:03 +0000453
454
Nate Begeman8ef50212008-02-12 22:51:28 +0000455// SSSE3 Instruction Templates:
456//
457// SS38I - SSSE3 instructions with T8 prefix.
458// SS3AI - SSSE3 instructions with TA prefix.
Michael Liaobbd10792012-08-30 16:54:46 +0000459// MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
460// MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
Nate Begeman8ef50212008-02-12 22:51:28 +0000461//
462// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
Craig Topper744f6312012-01-09 00:11:29 +0000463// uses the MMX registers. The 64-bit versions are grouped with the MMX
464// classes. They need to be enabled even if AVX is enabled.
Nate Begeman8ef50212008-02-12 22:51:28 +0000465
466class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000467 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000468 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
Michael Liaobbd10792012-08-30 16:54:46 +0000469 Requires<[UseSSSE3]>;
Nate Begeman8ef50212008-02-12 22:51:28 +0000470class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000471 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000472 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Michael Liaobbd10792012-08-30 16:54:46 +0000473 Requires<[UseSSSE3]>;
474class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000475 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000476 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
477 Requires<[HasSSSE3]>;
478class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000479 list<dag> pattern, InstrItinClass itin = NoItinerary>
Michael Liaobbd10792012-08-30 16:54:46 +0000480 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +0000481 Requires<[HasSSSE3]>;
Nate Begeman8ef50212008-02-12 22:51:28 +0000482
483// SSE4.1 Instruction Templates:
484//
485// SS48I - SSE 4.1 instructions with T8 prefix.
Evan Cheng96bdbd62008-03-14 07:39:27 +0000486// SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
Nate Begeman8ef50212008-02-12 22:51:28 +0000487//
488class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000489 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000490 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
Michael Liaobbd10792012-08-30 16:54:46 +0000491 Requires<[UseSSE41]>;
Evan Cheng96bdbd62008-03-14 07:39:27 +0000492class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000493 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000494 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Michael Liaobbd10792012-08-30 16:54:46 +0000495 Requires<[UseSSE41]>;
Nate Begeman8ef50212008-02-12 22:51:28 +0000496
Nate Begeman55b7bec2008-07-17 16:51:19 +0000497// SSE4.2 Instruction Templates:
498//
499// SS428I - SSE 4.2 instructions with T8 prefix.
500class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000501 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000502 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
Michael Liaobbd10792012-08-30 16:54:46 +0000503 Requires<[UseSSE42]>;
Nate Begeman8ef50212008-02-12 22:51:28 +0000504
Craig Topper96fa5972011-10-16 16:50:08 +0000505// SS42FI - SSE 4.2 instructions with T8XD prefix.
Michael Liaobbd10792012-08-30 16:54:46 +0000506// NOTE: 'HasSSE42' is used as SS42FI is only used for CRC32 insns.
Eric Christopher7dfa9f22009-08-08 21:55:08 +0000507class SS42FI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000508 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000509 : I<o, F, outs, ins, asm, pattern, itin>, T8XD, Requires<[HasSSE42]>;
Craig Topperb9109842012-01-01 19:51:58 +0000510
Eric Christopher9fe912d2009-08-18 22:50:32 +0000511// SS42AI = SSE 4.2 instructions with TA prefix
512class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000513 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000514 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Michael Liaobbd10792012-08-30 16:54:46 +0000515 Requires<[UseSSE42]>;
Eric Christopher9fe912d2009-08-18 22:50:32 +0000516
Bruno Cardoso Lopes14c5fd42010-07-20 00:11:13 +0000517// AVX Instruction Templates:
518// Instructions introduced in AVX (no SSE equivalent forms)
519//
520// AVX8I - AVX instructions with T8 and OpSize prefix.
Bruno Cardoso Lopes3b505842010-07-20 19:44:51 +0000521// AVXAIi8 - AVX instructions with TA, OpSize prefix and ImmT = Imm8.
Bruno Cardoso Lopes14c5fd42010-07-20 00:11:13 +0000522class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000523 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000524 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8, OpSize,
Bruno Cardoso Lopes14c5fd42010-07-20 00:11:13 +0000525 Requires<[HasAVX]>;
Bruno Cardoso Lopes3b505842010-07-20 19:44:51 +0000526class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000527 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000528 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA, OpSize,
Bruno Cardoso Lopes3b505842010-07-20 19:44:51 +0000529 Requires<[HasAVX]>;
Bruno Cardoso Lopes14c5fd42010-07-20 00:11:13 +0000530
Craig Topper05d1cb92011-11-06 06:12:20 +0000531// AVX2 Instruction Templates:
532// Instructions introduced in AVX2 (no SSE equivalent forms)
533//
534// AVX28I - AVX2 instructions with T8 and OpSize prefix.
535// AVX2AIi8 - AVX2 instructions with TA, OpSize prefix and ImmT = Imm8.
536class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000537 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000538 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8, OpSize,
Craig Topper05d1cb92011-11-06 06:12:20 +0000539 Requires<[HasAVX2]>;
Craig Topperf01f1b52011-11-06 23:04:08 +0000540class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000541 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000542 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA, OpSize,
Craig Topper05d1cb92011-11-06 06:12:20 +0000543 Requires<[HasAVX2]>;
544
Eric Christopher2ef63182010-04-02 21:54:27 +0000545// AES Instruction Templates:
546//
547// AES8I
Eric Christopher1290fa02010-04-05 21:14:32 +0000548// These use the same encoding as the SSE4.2 T8 and TA encodings.
Eric Christopher2ef63182010-04-02 21:54:27 +0000549class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000550 list<dag>pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000551 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, T8,
Craig Topperc0cef322012-05-01 05:35:02 +0000552 Requires<[HasAES]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000553
554class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000555 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000556 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Craig Topperc0cef322012-05-01 05:35:02 +0000557 Requires<[HasAES]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000558
Benjamin Kramera0396e42012-05-31 14:34:17 +0000559// PCLMUL Instruction Templates
560class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000561 list<dag>pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000562 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Benjamin Kramera0396e42012-05-31 14:34:17 +0000563 OpSize, Requires<[HasPCLMUL]>;
Eli Friedman415412e2011-07-05 18:21:20 +0000564
Benjamin Kramera0396e42012-05-31 14:34:17 +0000565class AVXPCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000566 list<dag>pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000567 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Benjamin Kramera0396e42012-05-31 14:34:17 +0000568 OpSize, VEX_4V, Requires<[HasAVX, HasPCLMUL]>;
Bruno Cardoso Lopesea0e05a2010-07-23 18:41:12 +0000569
Bruno Cardoso Lopesacd92302010-07-23 00:54:35 +0000570// FMA3 Instruction Templates
571class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000572 list<dag>pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000573 : I<o, F, outs, ins, asm, pattern, itin>, T8,
Nadav Rotemff8c4552013-03-28 22:54:45 +0000574 OpSize, VEX_4V, FMASC, Requires<[HasFMA]>;
Bruno Cardoso Lopesacd92302010-07-23 00:54:35 +0000575
Bruno Cardoso Lopes0f9a1f52011-11-25 19:33:42 +0000576// FMA4 Instruction Templates
577class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000578 list<dag>pattern, InstrItinClass itin = NoItinerary>
Benjamin Kramerfee7d212013-01-22 18:05:59 +0000579 : Ii8<o, F, outs, ins, asm, pattern, itin>, TA,
Nadav Rotemff8c4552013-03-28 22:54:45 +0000580 OpSize, VEX_4V, VEX_I8IMM, FMASC, Requires<[HasFMA4]>;
Bruno Cardoso Lopes0f9a1f52011-11-25 19:33:42 +0000581
Jan Sjödin7c0face2011-12-12 19:37:49 +0000582// XOP 2, 3 and 4 Operand Instruction Template
583class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000584 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000585 : I<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
Jan Sjödin7c0face2011-12-12 19:37:49 +0000586 XOP, XOP9, Requires<[HasXOP]>;
587
588// XOP 2, 3 and 4 Operand Instruction Templates with imm byte
589class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000590 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000591 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedDouble>,
Jan Sjödin7c0face2011-12-12 19:37:49 +0000592 XOP, XOP8, Requires<[HasXOP]>;
593
594// XOP 5 operand instruction (VEX encoding!)
595class IXOP5<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000596 list<dag>pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000597 : Ii8<o, F, outs, ins, asm, pattern, itin, SSEPackedInt>, TA,
Jan Sjödin7c0face2011-12-12 19:37:49 +0000598 OpSize, VEX_4V, VEX_I8IMM, Requires<[HasXOP]>;
599
Evan Cheng12c6be82007-07-31 08:04:03 +0000600// X86-64 Instruction templates...
601//
602
Andrew Trick8523b162012-02-01 23:20:51 +0000603class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000604 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000605 : I<o, F, outs, ins, asm, pattern, itin>, REX_W;
Evan Cheng12c6be82007-07-31 08:04:03 +0000606class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000607 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000608 : Ii8<o, F, outs, ins, asm, pattern, itin>, REX_W;
Evan Cheng12c6be82007-07-31 08:04:03 +0000609class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000610 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000611 : Ii32<o, F, outs, ins, asm, pattern, itin>, REX_W;
Evan Cheng12c6be82007-07-31 08:04:03 +0000612
613class RIi64<bits<8> o, Format f, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000614 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000615 : X86Inst<o, f, Imm64, outs, ins, asm, itin>, REX_W {
Evan Cheng12c6be82007-07-31 08:04:03 +0000616 let Pattern = pattern;
617 let CodeSize = 3;
618}
619
620class RSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000621 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000622 : SSI<o, F, outs, ins, asm, pattern, itin>, REX_W;
Evan Cheng12c6be82007-07-31 08:04:03 +0000623class RSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000624 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000625 : SDI<o, F, outs, ins, asm, pattern, itin>, REX_W;
Evan Cheng12c6be82007-07-31 08:04:03 +0000626class RPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000627 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000628 : PDI<o, F, outs, ins, asm, pattern, itin>, REX_W;
Bruno Cardoso Lopes123dff02011-07-25 23:05:25 +0000629class VRPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000630 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000631 : VPDI<o, F, outs, ins, asm, pattern, itin>, VEX_W;
Evan Cheng12c6be82007-07-31 08:04:03 +0000632
633// MMX Instruction templates
634//
635
636// MMXI - MMX instructions with TB prefix.
Anton Korobeynikov31099512008-08-23 15:53:19 +0000637// MMXI64 - MMX instructions with TB prefix valid only in 64 bit mode.
Evan Cheng12c6be82007-07-31 08:04:03 +0000638// MMX2I - MMX / SSE2 instructions with TB and OpSize prefixes.
639// MMXIi8 - MMX instructions with ImmT == Imm8 and TB prefix.
640// MMXIi8 - MMX instructions with ImmT == Imm8 and TB prefix.
641// MMXID - MMX instructions with XD prefix.
642// MMXIS - MMX instructions with XS prefix.
Sean Callanan04d8cb72009-12-18 00:01:26 +0000643class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000644 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000645 : I<o, F, outs, ins, asm, pattern, itin>, TB, Requires<[HasMMX]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000646class MMXI64<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000647 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000648 : I<o, F, outs, ins, asm, pattern, itin>, TB, Requires<[HasMMX,In64BitMode]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000649class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000650 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000651 : I<o, F, outs, ins, asm, pattern, itin>, TB, REX_W, Requires<[HasMMX]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000652class MMX2I<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000653 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000654 : I<o, F, outs, ins, asm, pattern, itin>, TB, OpSize, Requires<[HasMMX]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000655class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000656 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000657 : Ii8<o, F, outs, ins, asm, pattern, itin>, TB, Requires<[HasMMX]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000658class MMXID<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000659 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000660 : Ii8<o, F, outs, ins, asm, pattern, itin>, XD, Requires<[HasMMX]>;
Sean Callanan04d8cb72009-12-18 00:01:26 +0000661class MMXIS<bits<8> o, Format F, dag outs, dag ins, string asm,
Jakob Stoklund Olesen4d39e812013-03-25 23:12:41 +0000662 list<dag> pattern, InstrItinClass itin = NoItinerary>
Andrew Trick8523b162012-02-01 23:20:51 +0000663 : Ii8<o, F, outs, ins, asm, pattern, itin>, XS, Requires<[HasMMX]>;