xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86InstrUtils.td (revision 1db9f3b21e39176dd5b67cf8ac378633b172463e)
1//===-- X86InstrUtils.td - X86 Instruction Utilities --------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides utilities for simplifying the instruction definitions.
10//
11//===----------------------------------------------------------------------===//
12
13//===----------------------------------------------------------------------===//
14// Classes for setting the fields of X86Inst
15//===----------------------------------------------------------------------===//
16
17// Prefix byte classes which are used to indicate to the ad-hoc machine code
18// emitter that various prefix bytes are required.
19class OpSize16 { OperandSize OpSize = OpSize16; }
20class OpSize32 { OperandSize OpSize = OpSize32; }
21class AdSize16 { AddressSize AdSize = AdSize16; }
22class AdSize32 { AddressSize AdSize = AdSize32; }
23class AdSize64 { AddressSize AdSize = AdSize64; }
24class REX_W  { bit hasREX_W = 1; }
25class LOCK   { bit hasLockPrefix = 1; }
26class REP    { bit hasREPPrefix = 1; }
27class TB     { Map OpMap = TB; }
28class T8     { Map OpMap = T8; }
29class TA     { Map OpMap = TA; }
30class T_MAP4 { Map OpMap = T_MAP4; }
31class T_MAP5 { Map OpMap = T_MAP5; }
32class T_MAP6 { Map OpMap = T_MAP6; }
33class T_MAP7 { Map OpMap = T_MAP7; }
34class XOP8   { Map OpMap = XOP8; }
35class XOP9   { Map OpMap = XOP9; }
36class XOPA   { Map OpMap = XOPA; }
37class ThreeDNow { Map OpMap = ThreeDNow; }
38class PS { Prefix OpPrefix = PS; }
39class PD { Prefix OpPrefix = PD; }
40class XD { Prefix OpPrefix = XD; }
41class XS { Prefix OpPrefix = XS; }
42class XOP { Encoding OpEnc = EncXOP; }
43class VEX { Encoding OpEnc = EncVEX; }
44class EVEX { Encoding OpEnc = EncEVEX; }
45class WIG  { bit IgnoresW = 1; }
46class VEX_L  { bit hasVEX_L = 1; }
47class VEX_LIG { bit ignoresVEX_L = 1; }
48class VVVV { bit hasVEX_4V = 1; }
49class EVEX_K { bit hasEVEX_K = 1; }
50class EVEX_KZ : EVEX_K { bit hasEVEX_Z = 1; }
51class EVEX_B { bit hasEVEX_B = 1; }
52class EVEX_NF { bit hasEVEX_NF = 1; }
53class EVEX_RC { bit hasEVEX_RC = 1; }
54class EVEX_V512 { bit hasEVEX_L2 = 1; bit hasVEX_L = 0; }
55class EVEX_V256 { bit hasEVEX_L2 = 0; bit hasVEX_L = 1; }
56class EVEX_V128 { bit hasEVEX_L2 = 0; bit hasVEX_L = 0; }
57class NOTRACK { bit hasNoTrackPrefix = 1; }
58class SIMD_EXC { list<Register> Uses = [MXCSR]; bit mayRaiseFPException = 1; }
59// Specify AVX512 8-bit compressed displacement encoding based on the vector
60// element size in bits (8, 16, 32, 64) and the CDisp8 form.
61class EVEX_CD8<int esize, CD8VForm form> {
62  int CD8_EltSize = !srl(esize, 3);
63  bits<3> CD8_Form = form.Value;
64}
65class NoCD8 { bits<7> CD8_Scale = 0; }
66
67class AVX512BIi8Base : TB, PD {
68  Domain ExeDomain = SSEPackedInt;
69  ImmType ImmT = Imm8;
70}
71class AVX512XSIi8Base : TB, XS {
72  Domain ExeDomain = SSEPackedInt;
73  ImmType ImmT = Imm8;
74}
75class AVX512XDIi8Base : TB, XD {
76  Domain ExeDomain = SSEPackedInt;
77  ImmType ImmT = Imm8;
78}
79class AVX512PSIi8Base : TB {
80  Domain ExeDomain = SSEPackedSingle;
81  ImmType ImmT = Imm8;
82}
83class AVX512PDIi8Base : TB, PD {
84  Domain ExeDomain = SSEPackedDouble;
85  ImmType ImmT = Imm8;
86}
87class ExplicitREX2Prefix { ExplicitOpPrefix explicitOpPrefix = ExplicitREX2; }
88class ExplicitVEXPrefix { ExplicitOpPrefix explicitOpPrefix = ExplicitVEX; }
89class ExplicitEVEXPrefix { ExplicitOpPrefix explicitOpPrefix = ExplicitEVEX; }
90class DefEFLAGS { list<Register> Defs = [EFLAGS]; }
91class UseEFLAGS { list<Register> Uses = [EFLAGS]; }
92class DisassembleOnly {
93  // The disassembler should know about this, but not the asmparser.
94  bit isCodeGenOnly = 1;
95  bit ForceDisassemble = 1;
96}
97
98defvar unaryop_args = "$src1";
99defvar unaryop_ndd_args = "{$src1, $dst|$dst, $src1}";
100defvar binop_args = "{$src2, $src1|$src1, $src2}";
101defvar binop_ndd_args = "{$src2, $src1, $dst|$dst, $src1, $src2}";
102defvar tie_dst_src1 = "$src1 = $dst";
103
104// NDD - Helper for new data destination instructions
105class NDD<bit ndd> {
106  string Constraints = !if(!eq(ndd, 0), tie_dst_src1, "");
107  Encoding OpEnc = !if(!eq(ndd, 0), EncNormal, EncEVEX);
108  bit hasEVEX_B = ndd;
109  bit hasVEX_4V = ndd;
110  Map OpMap = !if(!eq(ndd, 0), OB, T_MAP4);
111}
112// NF - Helper for NF (no flags update) instructions
113class NF: T_MAP4, EVEX, EVEX_NF, NoCD8;
114// PL - Helper for promoted legacy instructions
115class PL: T_MAP4, EVEX, NoCD8, ExplicitEVEXPrefix;
116
117//===----------------------------------------------------------------------===//
118// X86 Type infomation definitions
119//===----------------------------------------------------------------------===//
120
121/// X86TypeInfo - This is a bunch of information that describes relevant X86
122/// information about value types.  For example, it can tell you what the
123/// register class and preferred load to use.
124class X86TypeInfo<ValueType vt, string instrsuffix, RegisterClass regclass,
125                  PatFrag loadnode, X86MemOperand memoperand, ImmType immkind,
126                  Operand immoperand, SDPatternOperator immoperator,
127                  SDPatternOperator immnosuoperator, Operand imm8operand,
128                  SDPatternOperator imm8operator, SDPatternOperator imm8nosuoperator,
129                  bit hasEvenOpcode, bit hasREX_W> {
130  /// VT - This is the value type itself.
131  ValueType VT = vt;
132
133  /// InstrSuffix - This is the suffix used on instructions with this type.  For
134  /// example, i8 -> "b", i16 -> "w", i32 -> "l", i64 -> "q".
135  string InstrSuffix = instrsuffix;
136
137  /// RegClass - This is the register class associated with this type.  For
138  /// example, i8 -> GR8, i16 -> GR16, i32 -> GR32, i64 -> GR64.
139  RegisterClass RegClass = regclass;
140
141  /// LoadNode - This is the load node associated with this type.  For
142  /// example, i8 -> loadi8, i16 -> loadi16, i32 -> loadi32, i64 -> loadi64.
143  PatFrag LoadNode = loadnode;
144
145  /// MemOperand - This is the memory operand associated with this type.  For
146  /// example, i8 -> i8mem, i16 -> i16mem, i32 -> i32mem, i64 -> i64mem.
147  X86MemOperand MemOperand = memoperand;
148
149  /// ImmEncoding - This is the encoding of an immediate of this type.  For
150  /// example, i8 -> Imm8, i16 -> Imm16, i32 -> Imm32.  Note that i64 -> Imm32
151  /// since the immediate fields of i64 instructions is a 32-bit sign extended
152  /// value.
153  ImmType ImmEncoding = immkind;
154
155  /// ImmOperand - This is the operand kind of an immediate of this type.  For
156  /// example, i8 -> i8imm, i16 -> i16imm, i32 -> i32imm.  Note that i64 ->
157  /// i64i32imm since the immediate fields of i64 instructions is a 32-bit sign
158  /// extended value.
159  Operand ImmOperand = immoperand;
160
161  /// ImmOperator - This is the operator that should be used to match an
162  /// immediate of this kind in a pattern (e.g. imm, or i64immSExt32).
163  SDPatternOperator ImmOperator = immoperator;
164
165  SDPatternOperator ImmNoSuOperator = immnosuoperator;
166
167  /// Imm8Operand - This is the operand kind to use for an imm8 of this type.
168  /// For example, i8 -> <invalid>, i16 -> i16i8imm, i32 -> i32i8imm.  This is
169  /// only used for instructions that have a sign-extended imm8 field form.
170  Operand Imm8Operand = imm8operand;
171
172  /// Imm8Operator - This is the operator that should be used to match an 8-bit
173  /// sign extended immediate of this kind in a pattern (e.g. imm16immSExt8).
174  SDPatternOperator Imm8Operator = imm8operator;
175
176  SDPatternOperator Imm8NoSuOperator = imm8nosuoperator;
177
178  /// HasEvenOpcode - This bit is true if the instruction should have an even (as
179  /// opposed to odd) opcode.  Operations on i8 are even, operations on
180  /// other datatypes are usually odd.
181  bit HasEvenOpcode = hasEvenOpcode;
182
183  /// HasREX_W - This bit is set to true if the instruction should have
184  /// the 0x40 REX prefix.  This is set for i64 types.
185  bit HasREX_W = hasREX_W;
186}
187
188def invalid_node : SDNode<"<<invalid_node>>", SDTIntLeaf,[],"<<invalid_node>>">;
189
190def Xi8  : X86TypeInfo<i8, "b", GR8, loadi8, i8mem, Imm8, i8imm,
191                       imm_su, imm, i8imm, invalid_node, invalid_node,
192                       1, 0>;
193def Xi16 : X86TypeInfo<i16, "w", GR16, loadi16, i16mem, Imm16, i16imm,
194                       imm_su, imm, i16i8imm, i16immSExt8_su, i16immSExt8,
195                       0, 0>;
196def Xi32 : X86TypeInfo<i32, "l", GR32, loadi32, i32mem, Imm32, i32imm,
197                       imm_su, imm, i32i8imm, i32immSExt8_su, i32immSExt8,
198                       0, 0>;
199def Xi64 : X86TypeInfo<i64, "q", GR64, loadi64, i64mem, Imm32S, i64i32imm,
200                       i64immSExt32_su, i64immSExt32, i64i8imm, i64immSExt8_su,
201                       i64immSExt8, 0, 1>;
202
203// Group template arguments that can be derived from the vector type (EltNum x
204// EltVT).  These are things like the register class for the writemask, etc.
205// The idea is to pass one of these as the template argument rather than the
206// individual arguments.
207// The template is also used for scalar types, in this case numelts is 1.
208class X86VectorVTInfo<int numelts, ValueType eltvt, RegisterClass rc,
209                      string suffix = ""> {
210  RegisterClass RC = rc;
211  ValueType EltVT = eltvt;
212  int NumElts = numelts;
213
214  // Corresponding mask register class.
215  RegisterClass KRC = !cast<RegisterClass>("VK" # NumElts);
216
217  // Corresponding mask register pair class.
218  RegisterOperand KRPC = !if (!gt(NumElts, 16), ?,
219                              !cast<RegisterOperand>("VK" # NumElts # "Pair"));
220
221  // Corresponding write-mask register class.
222  RegisterClass KRCWM = !cast<RegisterClass>("VK" # NumElts # "WM");
223
224  // The mask VT.
225  ValueType KVT = !cast<ValueType>("v" # NumElts # "i1");
226
227  // Suffix used in the instruction mnemonic.
228  string Suffix = suffix;
229
230  // VTName is a string name for vector VT. For vector types it will be
231  // v # NumElts # EltVT, so for vector of 8 elements of i32 it will be v8i32
232  // It is a little bit complex for scalar types, where NumElts = 1.
233  // In this case we build v4f32 or v2f64
234  string VTName = "v" # !if (!eq (NumElts, 1),
235                        !if (!eq (EltVT.Size, 16), 8,
236                        !if (!eq (EltVT.Size, 32), 4,
237                        !if (!eq (EltVT.Size, 64), 2, NumElts))), NumElts) # EltVT;
238
239  // The vector VT.
240  ValueType VT = !cast<ValueType>(VTName);
241
242  string EltTypeName = !cast<string>(EltVT);
243  // Size of the element type in bits, e.g. 32 for v16i32.
244  string EltSizeName = !subst("i", "", !subst("f", "", !subst("b", "", EltTypeName)));
245  int EltSize = EltVT.Size;
246
247  // "i" for integer types and "f" for floating-point types
248  string TypeVariantName = !subst("b", "", !subst(EltSizeName, "", EltTypeName));
249
250  // Size of RC in bits, e.g. 512 for VR512.
251  int Size = VT.Size;
252
253  // The corresponding memory operand, e.g. i512mem for VR512.
254  X86MemOperand MemOp = !cast<X86MemOperand>(TypeVariantName # Size # "mem");
255  X86MemOperand ScalarMemOp = !cast<X86MemOperand>(!subst("b", "", EltTypeName) # "mem");
256  // FP scalar memory operand for intrinsics - ssmem/sdmem.
257  Operand IntScalarMemOp = !if (!eq (EltTypeName, "f16"), !cast<Operand>("shmem"),
258                           !if (!eq (EltTypeName, "bf16"), !cast<Operand>("shmem"),
259                           !if (!eq (EltTypeName, "f32"), !cast<Operand>("ssmem"),
260                           !if (!eq (EltTypeName, "f64"), !cast<Operand>("sdmem"), ?))));
261
262  // Load patterns
263  PatFrag LdFrag = !cast<PatFrag>("load" # VTName);
264
265  PatFrag AlignedLdFrag = !cast<PatFrag>("alignedload" # VTName);
266
267  PatFrag ScalarLdFrag = !cast<PatFrag>("load" # !subst("b", "", EltTypeName));
268  PatFrag BroadcastLdFrag = !cast<PatFrag>("X86VBroadcastld" # EltSizeName);
269
270  PatFrags ScalarIntMemFrags = !if (!eq (EltTypeName, "f16"), !cast<PatFrags>("sse_load_f16"),
271                               !if (!eq (EltTypeName, "bf16"), !cast<PatFrags>("sse_load_f16"),
272                               !if (!eq (EltTypeName, "f32"), !cast<PatFrags>("sse_load_f32"),
273                               !if (!eq (EltTypeName, "f64"), !cast<PatFrags>("sse_load_f64"), ?))));
274
275  // The string to specify embedded broadcast in assembly.
276  string BroadcastStr = "{1to" # NumElts # "}";
277
278  // 8-bit compressed displacement tuple/subvector format.  This is only
279  // defined for NumElts <= 8.
280  CD8VForm CD8TupleForm = !if (!eq (!srl(NumElts, 4), 0),
281                               !cast<CD8VForm>("CD8VT" # NumElts), ?);
282
283  SubRegIndex SubRegIdx = !if (!eq (Size, 128), sub_xmm,
284                          !if (!eq (Size, 256), sub_ymm, ?));
285
286  Domain ExeDomain = !if (!eq (EltTypeName, "f32"), SSEPackedSingle,
287                     !if (!eq (EltTypeName, "f64"), SSEPackedDouble,
288                     !if (!eq (EltTypeName, "f16"), SSEPackedSingle, // FIXME?
289                     !if (!eq (EltTypeName, "bf16"), SSEPackedSingle, // FIXME?
290                     SSEPackedInt))));
291
292  RegisterClass FRC = !if (!eq (EltTypeName, "f32"), FR32X,
293                      !if (!eq (EltTypeName, "f16"), FR16X,
294                      !if (!eq (EltTypeName, "bf16"), FR16X,
295                      FR64X)));
296
297  dag ImmAllZerosV = (VT immAllZerosV);
298
299  string ZSuffix = !if (!eq (Size, 128), "Z128",
300                   !if (!eq (Size, 256), "Z256", "Z"));
301}
302
303def v64i8_info  : X86VectorVTInfo<64,  i8, VR512, "b">;
304def v32i16_info : X86VectorVTInfo<32, i16, VR512, "w">;
305def v16i32_info : X86VectorVTInfo<16, i32, VR512, "d">;
306def v8i64_info  : X86VectorVTInfo<8,  i64, VR512, "q">;
307def v32f16_info : X86VectorVTInfo<32, f16, VR512, "ph">;
308def v32bf16_info: X86VectorVTInfo<32, bf16, VR512, "pbf">;
309def v16f32_info : X86VectorVTInfo<16, f32, VR512, "ps">;
310def v8f64_info  : X86VectorVTInfo<8,  f64, VR512, "pd">;
311
312// "x" in v32i8x_info means RC = VR256X
313def v32i8x_info  : X86VectorVTInfo<32,  i8, VR256X, "b">;
314def v16i16x_info : X86VectorVTInfo<16, i16, VR256X, "w">;
315def v8i32x_info  : X86VectorVTInfo<8,  i32, VR256X, "d">;
316def v4i64x_info  : X86VectorVTInfo<4,  i64, VR256X, "q">;
317def v16f16x_info : X86VectorVTInfo<16, f16, VR256X, "ph">;
318def v16bf16x_info: X86VectorVTInfo<16, bf16, VR256X, "pbf">;
319def v8f32x_info  : X86VectorVTInfo<8,  f32, VR256X, "ps">;
320def v4f64x_info  : X86VectorVTInfo<4,  f64, VR256X, "pd">;
321
322def v16i8x_info  : X86VectorVTInfo<16,  i8, VR128X, "b">;
323def v8i16x_info  : X86VectorVTInfo<8,  i16, VR128X, "w">;
324def v4i32x_info  : X86VectorVTInfo<4,  i32, VR128X, "d">;
325def v2i64x_info  : X86VectorVTInfo<2,  i64, VR128X, "q">;
326def v8f16x_info  : X86VectorVTInfo<8,  f16, VR128X, "ph">;
327def v8bf16x_info : X86VectorVTInfo<8,  bf16, VR128X, "pbf">;
328def v4f32x_info  : X86VectorVTInfo<4,  f32, VR128X, "ps">;
329def v2f64x_info  : X86VectorVTInfo<2,  f64, VR128X, "pd">;
330
331// We map scalar types to the smallest (128-bit) vector type
332// with the appropriate element type. This allows to use the same masking logic.
333def i32x_info    : X86VectorVTInfo<1,  i32, GR32, "si">;
334def i64x_info    : X86VectorVTInfo<1,  i64, GR64, "sq">;
335def f16x_info    : X86VectorVTInfo<1,  f16, VR128X, "sh">;
336def bf16x_info   : X86VectorVTInfo<1,  bf16, VR128X, "sbf">;
337def f32x_info    : X86VectorVTInfo<1,  f32, VR128X, "ss">;
338def f64x_info    : X86VectorVTInfo<1,  f64, VR128X, "sd">;
339
340class AVX512VLVectorVTInfo<X86VectorVTInfo i512, X86VectorVTInfo i256,
341                           X86VectorVTInfo i128> {
342  X86VectorVTInfo info512 = i512;
343  X86VectorVTInfo info256 = i256;
344  X86VectorVTInfo info128 = i128;
345}
346
347def avx512vl_i8_info  : AVX512VLVectorVTInfo<v64i8_info, v32i8x_info,
348                                             v16i8x_info>;
349def avx512vl_i16_info : AVX512VLVectorVTInfo<v32i16_info, v16i16x_info,
350                                             v8i16x_info>;
351def avx512vl_i32_info : AVX512VLVectorVTInfo<v16i32_info, v8i32x_info,
352                                             v4i32x_info>;
353def avx512vl_i64_info : AVX512VLVectorVTInfo<v8i64_info, v4i64x_info,
354                                             v2i64x_info>;
355def avx512vl_f16_info : AVX512VLVectorVTInfo<v32f16_info, v16f16x_info,
356                                             v8f16x_info>;
357def avx512vl_bf16_info : AVX512VLVectorVTInfo<v32bf16_info, v16bf16x_info,
358                                             v8bf16x_info>;
359def avx512vl_f32_info : AVX512VLVectorVTInfo<v16f32_info, v8f32x_info,
360                                             v4f32x_info>;
361def avx512vl_f64_info : AVX512VLVectorVTInfo<v8f64_info, v4f64x_info,
362                                             v2f64x_info>;
363
364class X86KVectorVTInfo<RegisterClass _krc, RegisterClass _krcwm,
365                       ValueType _vt> {
366  RegisterClass KRC = _krc;
367  RegisterClass KRCWM = _krcwm;
368  ValueType KVT = _vt;
369}
370
371def v1i1_info : X86KVectorVTInfo<VK1, VK1WM, v1i1>;
372def v2i1_info : X86KVectorVTInfo<VK2, VK2WM, v2i1>;
373def v4i1_info : X86KVectorVTInfo<VK4, VK4WM, v4i1>;
374def v8i1_info : X86KVectorVTInfo<VK8, VK8WM, v8i1>;
375def v16i1_info : X86KVectorVTInfo<VK16, VK16WM, v16i1>;
376def v32i1_info : X86KVectorVTInfo<VK32, VK32WM, v32i1>;
377def v64i1_info : X86KVectorVTInfo<VK64, VK64WM, v64i1>;
378
379// Subclasses of X86Inst
380class PseudoI<dag oops, dag iops, list<dag> pattern>
381  : X86Inst<0, Pseudo, NoImm, oops, iops, ""> {
382  let Pattern = pattern;
383}
384
385class I<bits<8> o, Format f, dag outs, dag ins, string asm,
386        list<dag> pattern, Domain d = GenericDomain>
387  : X86Inst<o, f, NoImm, outs, ins, asm, d> {
388  let Pattern = pattern;
389}
390class Ii8<bits<8> o, Format f, dag outs, dag ins, string asm,
391          list<dag> pattern, Domain d = GenericDomain>
392  : X86Inst<o, f, Imm8, outs, ins, asm, d> {
393  let Pattern = pattern;
394}
395class Ii8Reg<bits<8> o, Format f, dag outs, dag ins, string asm,
396             list<dag> pattern, Domain d = GenericDomain>
397  : X86Inst<o, f, Imm8Reg, outs, ins, asm, d> {
398  let Pattern = pattern;
399}
400class Ii8PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
401               list<dag> pattern>
402  : X86Inst<o, f, Imm8PCRel, outs, ins, asm> {
403  let Pattern = pattern;
404}
405class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm,
406           list<dag> pattern>
407  : X86Inst<o, f, Imm16, outs, ins, asm> {
408  let Pattern = pattern;
409}
410class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm,
411           list<dag> pattern>
412  : X86Inst<o, f, Imm32, outs, ins, asm> {
413  let Pattern = pattern;
414}
415class Ii32S<bits<8> o, Format f, dag outs, dag ins, string asm,
416            list<dag> pattern>
417  : X86Inst<o, f, Imm32S, outs, ins, asm> {
418  let Pattern = pattern;
419}
420
421class Ii64<bits<8> o, Format f, dag outs, dag ins, string asm,
422           list<dag> pattern>
423  : X86Inst<o, f, Imm64, outs, ins, asm> {
424  let Pattern = pattern;
425}
426
427class Ii16PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
428           list<dag> pattern>
429           : X86Inst<o, f, Imm16PCRel, outs, ins, asm> {
430  let Pattern = pattern;
431}
432
433class Ii32PCRel<bits<8> o, Format f, dag outs, dag ins, string asm,
434           list<dag> pattern>
435  : X86Inst<o, f, Imm32PCRel, outs, ins, asm> {
436  let Pattern = pattern;
437}
438
439// FPStack Instruction Templates:
440// FPI - Floating Point Instruction template.
441class FPI<bits<8> o, Format F, dag outs, dag ins, string asm>
442  : I<o, F, outs, ins, asm, []> {
443  let Defs = [FPSW];
444  let Predicates = [HasX87];
445}
446
447// FpI_ - Floating Point Pseudo Instruction template.
448class FpI_<dag outs, dag ins, FPFormat fp, list<dag> pattern>
449  : PseudoI<outs, ins, pattern> {
450  let FPForm = fp;
451  let Defs = [FPSW];
452  let Predicates = [HasX87];
453}
454
455// Templates for instructions that use a 16- or 32-bit segmented address as
456//  their only operand: lcall (FAR CALL) and ljmp (FAR JMP)
457//
458//   Iseg16 - 16-bit segment selector, 16-bit offset
459//   Iseg32 - 16-bit segment selector, 32-bit offset
460
461class Iseg16 <bits<8> o, Format f, dag outs, dag ins, string asm,
462              list<dag> pattern>
463      : X86Inst<o, f, Imm16, outs, ins, asm> {
464  let Pattern = pattern;
465}
466
467class Iseg32 <bits<8> o, Format f, dag outs, dag ins, string asm,
468              list<dag> pattern>
469      : X86Inst<o, f, Imm32, outs, ins, asm> {
470  let Pattern = pattern;
471}
472
473// SI - SSE 1 & 2 scalar instructions
474class SI<bits<8> o, Format F, dag outs, dag ins, string asm,
475         list<dag> pattern, Domain d = GenericDomain>
476      : I<o, F, outs, ins, asm, pattern, d> {
477  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
478                   !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
479                   !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
480                   !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
481                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
482                   [UseSSE1])))));
483
484  // AVX instructions have a 'v' prefix in the mnemonic
485  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
486                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
487                  asm));
488}
489
490// SI - SSE 1 & 2 scalar intrinsics - vex form available on AVX512
491class SI_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
492         list<dag> pattern, Domain d = GenericDomain>
493      : I<o, F, outs, ins, asm, pattern, d> {
494  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
495                   !if(!eq(OpEnc.Value, EncVEX.Value), [UseAVX],
496                   !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
497                   !if(!eq(OpPrefix.Value, XD.Value), [UseSSE2],
498                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
499                   [UseSSE1])))));
500
501  // AVX instructions have a 'v' prefix in the mnemonic
502  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
503                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
504                  asm));
505}
506// SIi8 - SSE 1 & 2 scalar instructions - vex form available on AVX512
507class SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
508           list<dag> pattern>
509      : Ii8<o, F, outs, ins, asm, pattern> {
510  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
511                   !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
512                   !if(!eq(OpPrefix.Value, XS.Value), [UseSSE1],
513                   [UseSSE2])));
514
515  // AVX instructions have a 'v' prefix in the mnemonic
516  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
517                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
518                  asm));
519}
520
521// PI - SSE 1 & 2 packed instructions
522class PI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
523         Domain d>
524      : I<o, F, outs, ins, asm, pattern, d> {
525  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
526                   !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
527                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
528                   [UseSSE1])));
529
530  // AVX instructions have a 'v' prefix in the mnemonic
531  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
532                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
533                  asm));
534}
535
536// MMXPI - SSE 1 & 2 packed instructions with MMX operands
537class MMXPI<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pattern,
538            Domain d>
539      : I<o, F, outs, ins, asm, pattern, d> {
540  let Predicates = !if(!eq(OpPrefix.Value, PD.Value), [HasMMX, HasSSE2],
541                       [HasMMX, HasSSE1]);
542}
543
544// PIi8 - SSE 1 & 2 packed instructions with immediate
545class PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
546           list<dag> pattern, Domain d>
547      : Ii8<o, F, outs, ins, asm, pattern, d> {
548  let Predicates = !if(!eq(OpEnc.Value, EncEVEX.Value), [HasAVX512],
549                   !if(!eq(OpEnc.Value, EncVEX.Value), [HasAVX],
550                   !if(!eq(OpPrefix.Value, PD.Value), [UseSSE2],
551                   [UseSSE1])));
552
553  // AVX instructions have a 'v' prefix in the mnemonic
554  let AsmString = !if(!eq(OpEnc.Value, EncEVEX.Value), !strconcat("v", asm),
555                  !if(!eq(OpEnc.Value, EncVEX.Value), !strconcat("v", asm),
556                  asm));
557}
558
559// SSE1 Instruction Templates:
560//
561//   SSI   - SSE1 instructions with XS prefix.
562//   PSI   - SSE1 instructions with PS prefix.
563//   PSIi8 - SSE1 instructions with ImmT == Imm8 and PS prefix.
564//   VSSI  - SSE1 instructions with XS prefix in AVX form.
565//   VPSI  - SSE1 instructions with PS prefix in AVX form, packed single.
566
567class SSI<bits<8> o, Format F, dag outs, dag ins, string asm,
568          list<dag> pattern>
569      : I<o, F, outs, ins, asm, pattern>, TB, XS, Requires<[UseSSE1]>;
570class SSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
571            list<dag> pattern>
572      : Ii8<o, F, outs, ins, asm, pattern>, TB, XS, Requires<[UseSSE1]>;
573class PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
574          list<dag> pattern>
575      : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, TB,
576        Requires<[UseSSE1]>;
577class PSIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
578            list<dag> pattern>
579      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedSingle>, TB,
580        Requires<[UseSSE1]>;
581class VSSI<bits<8> o, Format F, dag outs, dag ins, string asm,
582           list<dag> pattern>
583      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, TB, XS,
584        Requires<[HasAVX]>;
585class VPSI<bits<8> o, Format F, dag outs, dag ins, string asm,
586           list<dag> pattern>
587      : I<o, F, outs, ins, !strconcat("v", asm), pattern, SSEPackedSingle>,
588        TB, Requires<[HasAVX]>;
589
590// SSE2 Instruction Templates:
591//
592//   SDI    - SSE2 instructions with XD prefix.
593//   SDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix.
594//   S2SI   - SSE2 instructions with XS prefix.
595//   SSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix.
596//   PDI    - SSE2 instructions with PD prefix, packed double domain.
597//   PDIi8  - SSE2 instructions with ImmT == Imm8 and PD prefix.
598//   VSDI   - SSE2 scalar instructions with XD prefix in AVX form.
599//   VPDI   - SSE2 vector instructions with PD prefix in AVX form,
600//                 packed double domain.
601//   VS2I   - SSE2 scalar instructions with PD prefix in AVX form.
602//   S2I    - SSE2 scalar instructions with PD prefix.
603//   MMXSDIi8  - SSE2 instructions with ImmT == Imm8 and XD prefix as well as
604//               MMX operands.
605//   MMXSSDIi8 - SSE2 instructions with ImmT == Imm8 and XS prefix as well as
606//               MMX operands.
607
608class SDI<bits<8> o, Format F, dag outs, dag ins, string asm,
609          list<dag> pattern>
610      : I<o, F, outs, ins, asm, pattern>, TB, XD, Requires<[UseSSE2]>;
611class SDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
612            list<dag> pattern>
613      : Ii8<o, F, outs, ins, asm, pattern>, TB, XD, Requires<[UseSSE2]>;
614class S2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
615           list<dag> pattern>
616      : I<o, F, outs, ins, asm, pattern>, TB, XS, Requires<[UseSSE2]>;
617class S2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
618             list<dag> pattern>
619      : Ii8<o, F, outs, ins, asm, pattern>, TB, XS, Requires<[UseSSE2]>;
620class PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
621          list<dag> pattern>
622      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, TB, PD,
623        Requires<[UseSSE2]>;
624class PDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
625            list<dag> pattern>
626      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedDouble>, TB, PD,
627        Requires<[UseSSE2]>;
628class VSDI<bits<8> o, Format F, dag outs, dag ins, string asm,
629           list<dag> pattern>
630      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, TB, XD,
631        Requires<[UseAVX]>;
632class VS2SI<bits<8> o, Format F, dag outs, dag ins, string asm,
633            list<dag> pattern>
634      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, TB, XS,
635        Requires<[HasAVX]>;
636class VPDI<bits<8> o, Format F, dag outs, dag ins, string asm,
637           list<dag> pattern>
638      : I<o, F, outs, ins, !strconcat("v", asm), pattern, SSEPackedDouble>,
639        TB, PD, Requires<[HasAVX]>;
640class VS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
641           list<dag> pattern>
642      : I<o, F, outs, ins, !strconcat("v", asm), pattern>, TB, PD,
643        Requires<[UseAVX]>;
644class S2I<bits<8> o, Format F, dag outs, dag ins, string asm,
645           list<dag> pattern>
646      : I<o, F, outs, ins, asm, pattern>, TB, PD, Requires<[UseSSE2]>;
647class MMXSDIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
648               list<dag> pattern>
649      : Ii8<o, F, outs, ins, asm, pattern>, TB, XD, Requires<[HasMMX, HasSSE2]>;
650class MMXS2SIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
651                list<dag> pattern>
652      : Ii8<o, F, outs, ins, asm, pattern>, TB, XS, Requires<[HasMMX, HasSSE2]>;
653
654// SSE3 Instruction Templates:
655//
656//   S3I   - SSE3 instructions with PD prefixes.
657//   S3SI  - SSE3 instructions with XS prefix.
658//   S3DI  - SSE3 instructions with XD prefix.
659
660class S3SI<bits<8> o, Format F, dag outs, dag ins, string asm,
661           list<dag> pattern>
662      : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, TB, XS,
663        Requires<[UseSSE3]>;
664class S3DI<bits<8> o, Format F, dag outs, dag ins, string asm,
665           list<dag> pattern>
666      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, TB, XD,
667        Requires<[UseSSE3]>;
668class S3I<bits<8> o, Format F, dag outs, dag ins, string asm,
669          list<dag> pattern>
670      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, TB, PD,
671        Requires<[UseSSE3]>;
672
673
674// SSSE3 Instruction Templates:
675//
676//   SS38I - SSSE3 instructions with T8 prefix.
677//   SS3AI - SSSE3 instructions with TA prefix.
678//   MMXSS38I - SSSE3 instructions with T8 prefix and MMX operands.
679//   MMXSS3AI - SSSE3 instructions with TA prefix and MMX operands.
680//
681// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version
682// uses the MMX registers. The 64-bit versions are grouped with the MMX
683// classes. They need to be enabled even if AVX is enabled.
684
685class SS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
686            list<dag> pattern>
687      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
688        Requires<[UseSSSE3]>;
689class SS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
690            list<dag> pattern>
691      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
692        Requires<[UseSSSE3]>;
693class MMXSS38I<bits<8> o, Format F, dag outs, dag ins, string asm,
694               list<dag> pattern>
695      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8,
696        Requires<[HasMMX, HasSSSE3]>;
697class MMXSS3AI<bits<8> o, Format F, dag outs, dag ins, string asm,
698               list<dag> pattern>
699      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA,
700        Requires<[HasMMX, HasSSSE3]>;
701
702// SSE4.1 Instruction Templates:
703//
704//   SS48I - SSE 4.1 instructions with T8 prefix.
705//   SS41AIi8 - SSE 4.1 instructions with TA prefix and ImmT == Imm8.
706//
707class SS48I<bits<8> o, Format F, dag outs, dag ins, string asm,
708            list<dag> pattern>
709      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
710        Requires<[UseSSE41]>;
711class SS4AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
712            list<dag> pattern>
713      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
714        Requires<[UseSSE41]>;
715
716// SSE4.2 Instruction Templates:
717//
718//   SS428I - SSE 4.2 instructions with T8 prefix.
719class SS428I<bits<8> o, Format F, dag outs, dag ins, string asm,
720             list<dag> pattern>
721      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
722        Requires<[UseSSE42]>;
723
724//   SS42AI = SSE 4.2 instructions with TA prefix
725class SS42AI<bits<8> o, Format F, dag outs, dag ins, string asm,
726             list<dag> pattern>
727      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
728        Requires<[UseSSE42]>;
729
730// AVX Instruction Templates:
731//   Instructions introduced in AVX (no SSE equivalent forms)
732//
733//   AVX8I - AVX instructions with T8, PD prefix.
734//   AVXAIi8 - AVX instructions with TA, PD prefix and ImmT = Imm8.
735class AVX8I<bits<8> o, Format F, dag outs, dag ins, string asm,
736            list<dag> pattern>
737      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
738        Requires<[HasAVX]>;
739class AVXAIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
740              list<dag> pattern>
741      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
742        Requires<[HasAVX]>;
743
744// AVX2 Instruction Templates:
745//   Instructions introduced in AVX2 (no SSE equivalent forms)
746//
747//   AVX28I - AVX2 instructions with T8, PD prefix.
748//   AVX2AIi8 - AVX2 instructions with TA, PD prefix and ImmT = Imm8.
749class AVX28I<bits<8> o, Format F, dag outs, dag ins, string asm,
750            list<dag> pattern>
751      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
752        Requires<[HasAVX2]>;
753class AVX2AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
754              list<dag> pattern>
755      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
756        Requires<[HasAVX2]>;
757
758
759// AVX-512 Instruction Templates:
760//   Instructions introduced in AVX-512 (no SSE equivalent forms)
761//
762//   AVX5128I - AVX-512 instructions with T8, PD prefix.
763//   AVX512AIi8 - AVX-512 instructions with TA, PD prefix and ImmT = Imm8.
764//   AVX512PDI  - AVX-512 instructions with PD, double packed.
765//   AVX512PSI  - AVX-512 instructions with PS, single packed.
766//   AVX512XS8I - AVX-512 instructions with T8 and XS prefixes.
767//   AVX512XSI  - AVX-512 instructions with XS prefix, generic domain.
768//   AVX512BI   - AVX-512 instructions with PD, int packed domain.
769//   AVX512SI   - AVX-512 scalar instructions with PD prefix.
770
771class AVX5128I<bits<8> o, Format F, dag outs, dag ins, string asm,
772            list<dag> pattern>
773      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
774        Requires<[HasAVX512]>;
775class AVX5128IBase : T8, PD {
776  Domain ExeDomain = SSEPackedInt;
777}
778class AVX512XS8I<bits<8> o, Format F, dag outs, dag ins, string asm,
779            list<dag> pattern>
780      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, XS,
781        Requires<[HasAVX512]>;
782class AVX512XSI<bits<8> o, Format F, dag outs, dag ins, string asm,
783            list<dag> pattern>
784      : I<o, F, outs, ins, asm, pattern>, TB, XS,
785        Requires<[HasAVX512]>;
786class AVX512XDI<bits<8> o, Format F, dag outs, dag ins, string asm,
787            list<dag> pattern>
788      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, TB, XD,
789        Requires<[HasAVX512]>;
790class AVX512BI<bits<8> o, Format F, dag outs, dag ins, string asm,
791            list<dag> pattern>
792      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, TB, PD,
793        Requires<[HasAVX512]>;
794class AVX512BIBase : TB, PD {
795  Domain ExeDomain = SSEPackedInt;
796}
797class AVX512BIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
798              list<dag> pattern>
799      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TB, PD,
800        Requires<[HasAVX512]>;
801class AVX512AIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
802              list<dag> pattern>
803      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
804        Requires<[HasAVX512]>;
805class AVX512AIi8Base : TA, PD {
806  ImmType ImmT = Imm8;
807}
808class AVX512Ii8<bits<8> o, Format F, dag outs, dag ins, string asm,
809              list<dag> pattern>
810      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>,
811        Requires<[HasAVX512]>;
812class AVX512PDI<bits<8> o, Format F, dag outs, dag ins, string asm,
813           list<dag> pattern>
814      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>, TB, PD,
815        Requires<[HasAVX512]>;
816class AVX512PSI<bits<8> o, Format F, dag outs, dag ins, string asm,
817           list<dag> pattern>
818      : I<o, F, outs, ins, asm, pattern, SSEPackedSingle>, TB,
819        Requires<[HasAVX512]>;
820class AVX512PIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
821              list<dag> pattern, Domain d>
822      : Ii8<o, F, outs, ins, asm, pattern, d>, Requires<[HasAVX512]>;
823class AVX512PI<bits<8> o, Format F, dag outs, dag ins, string asm,
824              list<dag> pattern, Domain d>
825      : I<o, F, outs, ins, asm, pattern, d>, Requires<[HasAVX512]>;
826class AVX512FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
827           list<dag>pattern>
828      : I<o, F, outs, ins, asm, pattern>, T8, PD,
829        EVEX, VVVV, Requires<[HasAVX512]>;
830
831class AVX512<bits<8> o, Format F, dag outs, dag ins, string asm,
832           list<dag>pattern>
833      : I<o, F, outs, ins, asm, pattern>, Requires<[HasAVX512]>;
834
835// AES Instruction Templates:
836//
837// AES8I
838// These use the same encoding as the SSE4.2 T8 and TA encodings.
839class AES8I<bits<8> o, Format F, dag outs, dag ins, string asm,
840            list<dag>pattern>
841      : I<o, F, outs, ins, asm, pattern, SSEPackedInt>, T8, PD,
842        Requires<[NoAVX, HasAES]>;
843
844class AESAI<bits<8> o, Format F, dag outs, dag ins, string asm,
845            list<dag> pattern>
846      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
847        Requires<[NoAVX, HasAES]>;
848
849// PCLMUL Instruction Templates
850class PCLMULIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
851               list<dag>pattern>
852      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD;
853
854// FMA3 Instruction Templates
855class FMA3<bits<8> o, Format F, dag outs, dag ins, string asm,
856           list<dag>pattern>
857      : I<o, F, outs, ins, asm, pattern>, T8, PD,
858        VEX, VVVV, FMASC, Requires<[HasFMA, NoFMA4, NoVLX]>;
859class FMA3S<bits<8> o, Format F, dag outs, dag ins, string asm,
860            list<dag>pattern>
861      : I<o, F, outs, ins, asm, pattern>, T8, PD,
862        VEX, VVVV, FMASC, Requires<[HasFMA, NoFMA4, NoAVX512]>;
863class FMA3S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
864                list<dag>pattern>
865      : I<o, F, outs, ins, asm, pattern>, T8, PD,
866        VEX, VVVV, FMASC, Requires<[HasFMA, NoAVX512]>;
867
868// FMA4 Instruction Templates
869class FMA4<bits<8> o, Format F, dag outs, dag ins, string asm,
870           list<dag>pattern>
871      : Ii8Reg<o, F, outs, ins, asm, pattern>, TA, PD,
872        VEX, VVVV, FMASC, Requires<[HasFMA4, NoVLX]>;
873class FMA4S<bits<8> o, Format F, dag outs, dag ins, string asm,
874            list<dag>pattern>
875      : Ii8Reg<o, F, outs, ins, asm, pattern>, TA, PD,
876        VEX, VVVV, FMASC, Requires<[HasFMA4, NoAVX512]>;
877class FMA4S_Int<bits<8> o, Format F, dag outs, dag ins, string asm,
878                list<dag>pattern>
879      : Ii8Reg<o, F, outs, ins, asm, pattern>, TA, PD,
880        VEX, VVVV, FMASC, Requires<[HasFMA4]>;
881
882// XOP 2, 3 and 4 Operand Instruction Template
883class IXOP<bits<8> o, Format F, dag outs, dag ins, string asm,
884           list<dag> pattern>
885      : I<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
886         XOP9, Requires<[HasXOP]>;
887
888// XOP 2 and 3 Operand Instruction Templates with imm byte
889class IXOPi8<bits<8> o, Format F, dag outs, dag ins, string asm,
890           list<dag> pattern>
891      : Ii8<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
892         XOP8, Requires<[HasXOP]>;
893// XOP 4 Operand Instruction Templates with imm byte
894class IXOPi8Reg<bits<8> o, Format F, dag outs, dag ins, string asm,
895           list<dag> pattern>
896      : Ii8Reg<o, F, outs, ins, asm, pattern, SSEPackedDouble>,
897         XOP8, Requires<[HasXOP]>;
898
899//  XOP 5 operand instruction (VEX encoding!)
900class IXOP5<bits<8> o, Format F, dag outs, dag ins, string asm,
901           list<dag>pattern>
902      : Ii8Reg<o, F, outs, ins, asm, pattern, SSEPackedInt>, TA, PD,
903        VEX, VVVV, Requires<[HasXOP]>;
904
905// X86-64 Instruction templates...
906//
907
908class RI<bits<8> o, Format F, dag outs, dag ins, string asm,
909         list<dag> pattern>
910      : I<o, F, outs, ins, asm, pattern>, REX_W;
911class RIi8 <bits<8> o, Format F, dag outs, dag ins, string asm,
912            list<dag> pattern>
913      : Ii8<o, F, outs, ins, asm, pattern>, REX_W;
914class RIi16 <bits<8> o, Format F, dag outs, dag ins, string asm,
915            list<dag> pattern>
916      : Ii16<o, F, outs, ins, asm, pattern>, REX_W;
917class RIi32 <bits<8> o, Format F, dag outs, dag ins, string asm,
918             list<dag> pattern>
919      : Ii32<o, F, outs, ins, asm, pattern>, REX_W;
920class RIi32S <bits<8> o, Format F, dag outs, dag ins, string asm,
921              list<dag> pattern>
922      : Ii32S<o, F, outs, ins, asm, pattern>, REX_W;
923class RIi64<bits<8> o, Format F, dag outs, dag ins, string asm,
924            list<dag> pattern>
925      : Ii64<o, F, outs, ins, asm, pattern>, REX_W;
926
927class RS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
928           list<dag> pattern>
929      : S2I<o, F, outs, ins, asm, pattern>, REX_W;
930class VRS2I<bits<8> o, Format F, dag outs, dag ins, string asm,
931           list<dag> pattern>
932      : VS2I<o, F, outs, ins, asm, pattern>, REX_W;
933
934// MMX Instruction templates
935//
936// MMXI   - MMX instructions with TB prefix.
937// MMXRI  - MMX instructions with TB prefix and REX.W.
938// MMXIi8 - MMX instructions with ImmT == Imm8 and PS prefix.
939class MMXI<bits<8> o, Format F, dag outs, dag ins, string asm,
940           list<dag> pattern>
941      : I<o, F, outs, ins, asm, pattern>, TB, Requires<[HasMMX]>;
942class MMXRI<bits<8> o, Format F, dag outs, dag ins, string asm,
943            list<dag> pattern>
944      : I<o, F, outs, ins, asm, pattern>, TB, REX_W,
945        Requires<[HasMMX,In64BitMode]>;
946class MMXIi8<bits<8> o, Format F, dag outs, dag ins, string asm,
947             list<dag> pattern>
948      : Ii8<o, F, outs, ins, asm, pattern>, TB, Requires<[HasMMX]>;
949
950/// ITy - This instruction base class takes the type info for the instruction.
951/// Using this, it:
952/// 1. Concatenates together the instruction mnemonic with the appropriate
953///    suffix letter, a tab, and the arguments.
954/// 2. Infers whether the instruction should have a 0x40 REX_W prefix.
955/// 3. Infers whether the low bit of the opcode should be 0 (for i8 operations)
956///    or 1 (for i16,i32,i64 operations).
957class ITy<bits<8> o, Format f, X86TypeInfo t, dag outs, dag ins, string m,
958          string args, list<dag> p>
959  : I<{o{7}, o{6}, o{5}, o{4}, o{3}, o{2}, o{1},
960       !if(!eq(t.HasEvenOpcode, 1), 0, o{0})}, f, outs, ins,
961      !strconcat(m, "{", t.InstrSuffix, "}\t", args), p> {
962  let hasSideEffects = 0;
963  let hasREX_W  = t.HasREX_W;
964}
965
966// BinOpRR - Instructions that read "reg, reg".
967class BinOpRR<bits<8> o, string m, string args, X86TypeInfo t, dag out, list<dag> p>
968  : ITy<o, MRMDestReg, t, out, (ins t.RegClass:$src1, t.RegClass:$src2), m,
969        args, p>, Sched<[WriteALU]>;
970// BinOpRR_F - Instructions that read "reg, reg" and write EFLAGS only.
971class BinOpRR_F<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
972  : BinOpRR<o, m, binop_args, t, (outs),
973            [(set EFLAGS, (node t.RegClass:$src1, t.RegClass:$src2))]>,
974    DefEFLAGS;
975// BinOpRR_F_Rev - Reversed encoding of BinOpRR_F
976class BinOpRR_F_Rev<bits<8> o, string m, X86TypeInfo t>
977  : BinOpRR_F<o, m, t, null_frag>, DisassembleOnly {
978  let Form = MRMSrcReg;
979}
980// BinOpRR_R - Instructions that read "reg, reg" and write "reg".
981class BinOpRR_R<bits<8> o, string m, X86TypeInfo t, bit ndd = 0>
982  : BinOpRR<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t,
983            (outs t.RegClass:$dst), []>, NDD<ndd>;
984// BinOpRR_R_Rev - Reversed encoding of BinOpRR_R
985class BinOpRR_R_Rev<bits<8> o, string m, X86TypeInfo t, bit ndd = 0>
986  : BinOpRR_R<o, m, t, ndd>, DisassembleOnly {
987  let Form = MRMSrcReg;
988}
989// BinOpRR_RF - Instructions that read "reg, reg", and write "reg", EFLAGS.
990class BinOpRR_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node, bit ndd = 0>
991  : BinOpRR<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t,
992            (outs t.RegClass:$dst),
993            [(set t.RegClass:$dst, EFLAGS,
994             (node t.RegClass:$src1, t.RegClass:$src2))]>, DefEFLAGS, NDD<ndd>;
995// BinOpRR_RF_Rev - Reversed encoding of BinOpRR_RF.
996class BinOpRR_RF_Rev<bits<8> o, string m, X86TypeInfo t, bit ndd = 0>
997  : BinOpRR_RF<o, m, t, null_frag, ndd>, DisassembleOnly {
998  let Form = MRMSrcReg;
999}
1000// BinOpRRF_RF - Instructions that read "reg, reg", write "reg" and read/write
1001// EFLAGS.
1002class BinOpRRF_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node = null_frag, bit ndd = 0>
1003  : BinOpRR<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, (outs t.RegClass:$dst),
1004            [(set t.RegClass:$dst, EFLAGS,
1005             (node t.RegClass:$src1, t.RegClass:$src2,
1006             EFLAGS))]>, DefEFLAGS, UseEFLAGS, NDD<ndd> {
1007  let SchedRW = [WriteADC];
1008}
1009// BinOpRRF_RF_Rev - Reversed encoding of BinOpRRF_RF
1010class BinOpRRF_RF_Rev<bits<8> o, string m, X86TypeInfo t, bit ndd = 0>
1011  : BinOpRRF_RF<o, m, t, null_frag, ndd>, DisassembleOnly {
1012  let Form = MRMSrcReg;
1013}
1014
1015// BinOpRM - Instructions that read "reg, [mem]".
1016class BinOpRM<bits<8> o, string m, string args, X86TypeInfo t, dag out, list<dag> p>
1017  : ITy<o, MRMSrcMem, t, out, (ins t.RegClass:$src1, t.MemOperand:$src2), m,
1018        args, p>,
1019    Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]> {
1020  let mayLoad = 1;
1021}
1022// BinOpRM_F - Instructions that read "reg, [mem]" and write EFLAGS only.
1023class BinOpRM_F<bits<8> o, string m, X86TypeInfo t, SDNode node>
1024  : BinOpRM<o, m, binop_args, t, (outs),
1025            [(set EFLAGS, (node t.RegClass:$src1,
1026             (t.LoadNode addr:$src2)))]>, DefEFLAGS;
1027// BinOpRM_R - Instructions that read "reg, [mem]", and write "reg".
1028class BinOpRM_R<bits<8> o, string m, X86TypeInfo t, bit ndd = 0>
1029  : BinOpRM<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, (outs t.RegClass:$dst),
1030            []>, NDD<ndd>;
1031// BinOpRM_RF - Instructions that read "reg, [mem]", and write "reg", EFLAGS.
1032class BinOpRM_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node, bit ndd = 0>
1033  : BinOpRM<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, (outs t.RegClass:$dst),
1034            [(set t.RegClass:$dst, EFLAGS, (node t.RegClass:$src1,
1035             (t.LoadNode addr:$src2)))]>, DefEFLAGS, NDD<ndd>;
1036// BinOpRMF_RF - Instructions that read "reg, [mem]", write "reg" and read/write
1037// EFLAGS.
1038class BinOpRMF_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node = null_frag, bit ndd = 0>
1039  : BinOpRM<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, (outs t.RegClass:$dst),
1040            [(set t.RegClass:$dst, EFLAGS,
1041             (node t.RegClass:$src1, (t.LoadNode addr:$src2), EFLAGS))]>,
1042    DefEFLAGS, UseEFLAGS, NDD<ndd> {
1043  let SchedRW = [WriteADC.Folded, WriteADC.ReadAfterFold,
1044                 // base, scale, index, offset, segment.
1045                 ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
1046                 // implicit register read.
1047                 WriteADC.ReadAfterFold];
1048}
1049
1050// BinOpRI - Instructions that read "reg, imm".
1051class BinOpRI<bits<8> o, string m, string args, X86TypeInfo t, Format f, dag out, list<dag> p>
1052  : ITy<o, f, t, out, (ins t.RegClass:$src1, t.ImmOperand:$src2), m,
1053        args, p>, Sched<[WriteALU]> {
1054  let ImmT = t.ImmEncoding;
1055}
1056// BinOpRI_F - Instructions that read "reg, imm" and write EFLAGS only.
1057class BinOpRI_F<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node,
1058                Format f>
1059  : BinOpRI<o, m, binop_args, t, f, (outs),
1060            [(set EFLAGS, (node t.RegClass:$src1,
1061             t.ImmOperator:$src2))]>, DefEFLAGS;
1062// BinOpRI_R - Instructions that read "reg, imm" and write "reg".
1063class BinOpRI_R<bits<8> o, string m, X86TypeInfo t, Format f, bit ndd = 0>
1064  : BinOpRI<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst),
1065            []>, NDD<ndd>;
1066// BinOpRI_RF - Instructions that read "reg, imm" and write "reg", EFLAGS.
1067class BinOpRI_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node, Format f, bit ndd = 0>
1068  : BinOpRI<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst),
1069            [(set t.RegClass:$dst, EFLAGS,
1070             (node t.RegClass:$src1, t.ImmOperator:$src2))]>, DefEFLAGS, NDD<ndd>;
1071// BinOpRIF_RF - Instructions that read "reg, imm", write "reg" and read/write
1072// EFLAGS.
1073class BinOpRIF_RF<bits<8> o, string m, X86TypeInfo t, SDNode node, Format f, bit ndd = 0>
1074  : BinOpRI<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst),
1075            [(set t.RegClass:$dst, EFLAGS,
1076             (node t.RegClass:$src1, t.ImmOperator:$src2,
1077             EFLAGS))]>, DefEFLAGS, UseEFLAGS, NDD<ndd> {
1078  let SchedRW = [WriteADC];
1079}
1080// BinOpRI8 - Instructions that read "reg, imm8".
1081class BinOpRI8<bits<8> o, string m, string args, X86TypeInfo t, Format f, dag out>
1082  : ITy<o, f, t, out, (ins t.RegClass:$src1, t.Imm8Operand:$src2), m,
1083        args, []>, Sched<[WriteALU]> {
1084  let ImmT = Imm8;
1085}
1086// BinOpRI8_F - Instructions that read "reg, imm8" and write EFLAGS only.
1087class BinOpRI8_F<bits<8> o, string m, X86TypeInfo t, Format f>
1088  : BinOpRI8<o, m, binop_args, t, f, (outs)>, DefEFLAGS;
1089// BinOpRI8_R - Instructions that read "reg, imm8" and write "reg".
1090class BinOpRI8_R<bits<8> o, string m, X86TypeInfo t, Format f, bit ndd = 0>
1091  : BinOpRI8<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst)>, NDD<ndd>;
1092// BinOpRI8_RF - Instructions that read "reg, imm8" and write "reg", EFLAGS.
1093class BinOpRI8_RF<bits<8> o, string m, X86TypeInfo t, Format f, bit ndd = 0>
1094  : BinOpRI8<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst)>, DefEFLAGS, NDD<ndd>;
1095// BinOpRI8F_RF - Instructions that read "reg, imm", write "reg" and read/write
1096// EFLAGS.
1097class BinOpRI8F_RF<bits<8> o, string m, X86TypeInfo t, Format f, bit ndd = 0>
1098  : BinOpRI8<o, m, !if(!eq(ndd, 0), binop_args, binop_ndd_args), t, f, (outs t.RegClass:$dst)>, DefEFLAGS, UseEFLAGS, NDD<ndd> {
1099  let SchedRW = [WriteADC];
1100}
1101
1102// BinOpMR - Instructions that read "[mem], reg".
1103class BinOpMR<bits<8> o, string m, string args, X86TypeInfo t, dag out, list<dag> p>
1104  : ITy<o, MRMDestMem, t, out, (ins t.MemOperand:$src1, t.RegClass:$src2), m,
1105        args, p> {
1106  let mayLoad = 1;
1107  let SchedRW = [WriteALU.Folded, WriteALU.ReadAfterFold];
1108}
1109// BinOpMR_R - Instructions that read "[mem], reg", and write "reg".
1110class BinOpMR_R<bits<8> o, string m, X86TypeInfo t>
1111  : BinOpMR<o, m, binop_ndd_args, t, (outs t.RegClass:$dst), []>, NDD<1>;
1112// BinOpMR_RF - Instructions that read "[mem], reg", and write "reg", EFLAGS.
1113class BinOpMR_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
1114  : BinOpMR<o, m, binop_ndd_args, t, (outs t.RegClass:$dst),
1115            [(set t.RegClass:$dst, EFLAGS, (node (t.LoadNode addr:$src1),
1116             t.RegClass:$src2))]>, DefEFLAGS, NDD<1>;
1117// BinOpMR_F - Instructions that read "[mem], imm8" and write EFLAGS only.
1118class BinOpMR_F<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
1119  : BinOpMR<o, m, binop_args, t, (outs),
1120            [(set EFLAGS, (node (t.LoadNode addr:$src1), t.RegClass:$src2))]>,
1121    Sched<[WriteALU.Folded, ReadDefault, ReadDefault, ReadDefault,
1122            ReadDefault, ReadDefault, WriteALU.ReadAfterFold]>, DefEFLAGS;
1123// BinOpMR_M - Instructions that read "[mem], reg" and write "[mem]".
1124class BinOpMR_M<bits<8> o, string m, X86TypeInfo t>
1125  : BinOpMR<o, m, binop_args, t, (outs), []>,
1126    Sched<[WriteALURMW,
1127           // base, scale, index, offset, segment
1128           ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault]> {
1129  let mayStore = 1;
1130}
1131// BinOpMR_MF - Instructions that read "[mem], reg" and write "[mem]", EFLAGS.
1132class BinOpMR_MF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
1133  : BinOpMR<o, m, binop_args, t, (outs),
1134            [(store (node (load addr:$src1), t.RegClass:$src2), addr:$src1),
1135             (implicit EFLAGS)]>,
1136    Sched<[WriteALURMW,
1137           // base, scale, index, offset, segment
1138           ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
1139           WriteALU.ReadAfterFold]>, // reg
1140    DefEFLAGS {
1141  let mayStore = 1;
1142}
1143// BinOpMRF_RF - Instructions that read "[mem], reg", write "reg" and
1144// read/write EFLAGS.
1145class BinOpMRF_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
1146  : BinOpMR<o, m, binop_ndd_args, t, (outs t.RegClass:$dst),
1147            [(set t.RegClass:$dst, EFLAGS, (node (load addr:$src1),
1148             t.RegClass:$src2, EFLAGS))]>, DefEFLAGS, UseEFLAGS, NDD<1>,
1149    Sched<[WriteADC.Folded, WriteADC.ReadAfterFold]>;
1150// BinOpMRF_MF - Instructions that read "[mem], reg", write "[mem]" and
1151// read/write EFLAGS.
1152class BinOpMRF_MF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node>
1153  : BinOpMR<o, m, binop_args, t, (outs),
1154            [(store (node (load addr:$src1), t.RegClass:$src2, EFLAGS),
1155             addr:$src1), (implicit EFLAGS)]>,
1156    Sched<[WriteADCRMW,
1157          // base, scale, index, offset, segment
1158          ReadDefault, ReadDefault, ReadDefault,
1159          ReadDefault, ReadDefault,
1160          WriteALU.ReadAfterFold,    // reg
1161          WriteALU.ReadAfterFold]>,  // EFLAGS
1162    DefEFLAGS, UseEFLAGS {
1163  let mayStore = 1;
1164}
1165
1166// BinOpMI - Instructions that read "[mem], imm".
1167class BinOpMI<bits<8> o, string m, string args, X86TypeInfo t, Format f, dag out, list<dag> p>
1168  : ITy<o, f, t, out, (ins t.MemOperand:$src1, t.ImmOperand:$src2), m,
1169        args, p> {
1170  let ImmT = t.ImmEncoding;
1171  let mayLoad = 1;
1172}
1173// BinOpMI_F - Instructions that read "[mem], imm" and write EFLAGS only.
1174class BinOpMI_F<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node,
1175                Format f>
1176  : BinOpMI<o, m, binop_args, t, f, (outs),
1177            [(set EFLAGS, (node (t.LoadNode addr:$src1), t.ImmOperator:$src2))]>,
1178    Sched<[WriteALU.Folded]>, DefEFLAGS;
1179// BinOpMI_R - Instructions that read "[mem], imm" and write "reg".
1180class BinOpMI_R<bits<8> o, string m, X86TypeInfo t, Format f>
1181  : BinOpMI<o, m, binop_ndd_args, t, f, (outs t.RegClass:$dst), []>,
1182    Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, NDD<1>;
1183// BinOpMI_R - Instructions that read "[mem], imm" and write "reg", EFLAGS.
1184class BinOpMI_RF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node,
1185                Format f>
1186  : BinOpMI<o, m, binop_ndd_args, t, f, (outs t.RegClass:$dst),
1187            [(set t.RegClass:$dst, EFLAGS, (node (t.LoadNode addr:$src1), t.ImmOperator:$src2))]>,
1188    Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, DefEFLAGS, NDD<1>;
1189// BinOpMI_M - Instructions that read "[mem], imm" and write "[mem]".
1190class BinOpMI_M<bits<8> o, string m, X86TypeInfo t, Format f>
1191  : BinOpMI<o, m, binop_args, t, f, (outs), []>, Sched<[WriteALURMW]> {
1192  let mayStore = 1;
1193}
1194// BinOpMI_MF - Instructions that read "[mem], imm" and write "[mem]", EFLAGS.
1195class BinOpMI_MF<bits<8> o, string m, X86TypeInfo t, SDPatternOperator node, Format f>
1196  : BinOpMI<o, m, binop_args, t, f, (outs),
1197            [(store (node (t.VT (load addr:$src1)),
1198             t.ImmOperator:$src2), addr:$src1), (implicit EFLAGS)]>,
1199    Sched<[WriteALURMW]>, DefEFLAGS {
1200  let mayStore = 1;
1201}
1202// BinOpMIF_RF - Instructions that read "[mem], imm", write "reg" and
1203// read/write EFLAGS.
1204class BinOpMIF_RF<bits<8> o, string m, X86TypeInfo t, SDNode node, Format f>
1205  : BinOpMI<o, m, binop_ndd_args, t, f, (outs t.RegClass:$dst),
1206            [(set t.RegClass:$dst, EFLAGS, (node (t.VT (load addr:$src1)),
1207             t.ImmOperator:$src2, EFLAGS))]>,
1208    Sched<[WriteADC.Folded, WriteADC.ReadAfterFold]>, DefEFLAGS, UseEFLAGS, NDD<1>;
1209// BinOpMIF_MF - Instructions that read "[mem], imm", write "[mem]" and
1210// read/write EFLAGS.
1211class BinOpMIF_MF<bits<8> o, string m, X86TypeInfo t, SDNode node, Format f>
1212  : BinOpMI<o, m, binop_args, t, f, (outs),
1213            [(store (node (t.VT (load addr:$src1)),
1214             t.ImmOperator:$src2, EFLAGS), addr:$src1), (implicit EFLAGS)]>,
1215    Sched<[WriteADCRMW]>, DefEFLAGS, UseEFLAGS {
1216  let mayStore = 1;
1217}
1218
1219// BinOpMI8 - Instructions that read "[mem], imm8".
1220class BinOpMI8<string m, string args, X86TypeInfo t, Format f, dag out>
1221  : ITy<0x83, f, t, out, (ins t.MemOperand:$src1, t.Imm8Operand:$src2), m,
1222        args, []> {
1223  let ImmT = Imm8;
1224  let mayLoad = 1;
1225}
1226// BinOpMI8_F - Instructions that read "[mem], imm8" and write EFLAGS only.
1227class BinOpMI8_F<string m, X86TypeInfo t, Format f>
1228  : BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteALU.Folded]>, DefEFLAGS;
1229// BinOpMI8_R - Instructions that read "[mem], imm8" and write "reg".
1230class BinOpMI8_R<string m, X86TypeInfo t, Format f>
1231  : BinOpMI8<m, binop_ndd_args, t, f, (outs t.RegClass:$dst)>, Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, NDD<1>;
1232// BinOpMI8_RF - Instructions that read "[mem], imm8" and write "reg"/EFLAGS.
1233class BinOpMI8_RF<string m, X86TypeInfo t, Format f>
1234  : BinOpMI8<m, binop_ndd_args, t, f, (outs t.RegClass:$dst)>, Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, DefEFLAGS, NDD<1>;
1235// BinOpMI8_M - Instructions that read "[mem], imm8" and write "[mem]".
1236class BinOpMI8_M<string m, X86TypeInfo t, Format f>
1237  : BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteALURMW]> {
1238  let mayStore = 1;
1239}
1240// BinOpMI8_MF - Instructions that read "[mem], imm8" and write "[mem]", EFLAGS.
1241class BinOpMI8_MF<string m, X86TypeInfo t, Format f>
1242  : BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteALURMW]>, DefEFLAGS {
1243  let mayStore = 1;
1244}
1245// BinOpMI8F_RF - Instructions that read "[mem], imm8", write "reg" and
1246// read/write EFLAGS.
1247class BinOpMI8F_RF<string m, X86TypeInfo t, Format f>
1248  : BinOpMI8<m, binop_ndd_args, t, f, (outs t.RegClass:$dst)>,
1249    Sched<[WriteADC.Folded, WriteADC.ReadAfterFold]>, DefEFLAGS, UseEFLAGS, NDD<1>;
1250// BinOpMI8F_MF - Instructions that read "[mem], imm8", write "[mem]" and
1251// read/write EFLAGS.
1252class BinOpMI8F_MF<string m, X86TypeInfo t, Format f>
1253  : BinOpMI8<m, binop_args, t, f, (outs)>, Sched<[WriteADCRMW]>, DefEFLAGS, UseEFLAGS {
1254  let mayStore = 1;
1255}
1256
1257// BinOpAI - Instructions that read "a-reg imm" (Accumulator register).
1258class BinOpAI<bits<8> o, string m, X86TypeInfo t, Register areg, string args>
1259  : ITy<o, RawFrm, t, (outs), (ins t.ImmOperand:$src), m, args, []>,
1260    Sched<[WriteALU]> {
1261  let ImmT = t.ImmEncoding;
1262  let Uses = [areg];
1263}
1264// BinOpAI_F - Instructions that read "a-reg imm" and write EFLAGS only.
1265class BinOpAI_F<bits<8> o, string m, X86TypeInfo t, Register areg, string args>
1266  : BinOpAI<o, m, t, areg, args>, DefEFLAGS;
1267
1268// BinOpAI_AF - Instructions that read "a-reg imm" and write a-reg/EFLAGS.
1269class BinOpAI_AF<bits<8> o, string m, X86TypeInfo t, Register areg,
1270                 string args> : BinOpAI<o, m, t, areg, args> {
1271  let Defs = [areg, EFLAGS];
1272}
1273// BinOpAIF_AF - Instructions that read "a-reg imm", write a-reg and read/write
1274// EFLAGS.
1275class BinOpAIF_AF<bits<8> o, string m, X86TypeInfo t, Register areg,
1276                  string args> : BinOpAI<o, m, t, areg, args> {
1277  let Uses = [areg, EFLAGS];
1278  let Defs = [areg, EFLAGS];
1279  let SchedRW = [WriteADC];
1280}
1281
1282// UnaryOpR - Instructions that read "reg".
1283class UnaryOpR<bits<8> o, Format f, string m, string args, X86TypeInfo t,
1284               dag out, list<dag> p>
1285  : ITy<o, f, t, out, (ins t.RegClass:$src1), m, args, p>, Sched<[WriteALU]>;
1286// UnaryOpR_R - Instructions that read "reg" and write "reg".
1287class UnaryOpR_R<bits<8> o, Format f, string m, X86TypeInfo t,
1288                  SDPatternOperator node, bit ndd = 0>
1289  : UnaryOpR<o, f, m, !if(!eq(ndd, 0), unaryop_args, unaryop_ndd_args), t,
1290             (outs t.RegClass:$dst),
1291             [(set t.RegClass:$dst, (node t.RegClass:$src1))]>, NDD<ndd>;
1292// UnaryOpR_RF - Instructions that read "reg" and write "reg"/EFLAGS.
1293class UnaryOpR_RF<bits<8> o, Format f, string m, X86TypeInfo t,
1294                  SDPatternOperator node, bit ndd = 0>
1295  : UnaryOpR<o, f, m, !if(!eq(ndd, 0), unaryop_args, unaryop_ndd_args), t,
1296             (outs t.RegClass:$dst),
1297             [(set t.RegClass:$dst, (node t.RegClass:$src1)),
1298              (implicit EFLAGS)]>, DefEFLAGS, NDD<ndd>;
1299
1300// UnaryOpM - Instructions that read "[mem]".
1301class UnaryOpM<bits<8> o, Format f, string m, string args, X86TypeInfo t,
1302               dag out, list<dag> p>
1303  : ITy<o, f, t, out, (ins t.MemOperand:$src1), m, args, p> {
1304  let mayLoad = 1;
1305}
1306// UnaryOpM_R - Instructions that read "[mem]" and writes "reg".
1307class UnaryOpM_R<bits<8> o, Format f, string m, X86TypeInfo t,
1308                  SDPatternOperator node>
1309  : UnaryOpM<o, f, m, unaryop_ndd_args, t, (outs t.RegClass:$dst),
1310             [(set t.RegClass:$dst, (node (t.LoadNode addr:$src1)))]>,
1311    Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, NDD<1>;
1312// UnaryOpM_RF - Instructions that read "[mem]" and writes "reg"/EFLAGS.
1313class UnaryOpM_RF<bits<8> o, Format f, string m, X86TypeInfo t,
1314                  SDPatternOperator node>
1315  : UnaryOpM<o, f, m, unaryop_ndd_args, t, (outs t.RegClass:$dst),
1316             [(set t.RegClass:$dst, EFLAGS, (node (t.LoadNode addr:$src1)))]>,
1317    Sched<[WriteALU.Folded, WriteALU.ReadAfterFold]>, DefEFLAGS, NDD<1>;
1318// UnaryOpM_M - Instructions that read "[mem]" and writes "[mem]".
1319class UnaryOpM_M<bits<8> o, Format f, string m, X86TypeInfo t,
1320                  SDPatternOperator node>
1321  : UnaryOpM<o, f, m, unaryop_args, t, (outs),
1322             [(store (node (t.LoadNode addr:$src1)), addr:$src1)]>,
1323    Sched<[WriteALURMW]>{
1324  let mayStore = 1;
1325}
1326// UnaryOpM_MF - Instructions that read "[mem]" and writes "[mem]"/EFLAGS.
1327class UnaryOpM_MF<bits<8> o, Format f, string m, X86TypeInfo t,
1328                  SDPatternOperator node>
1329  : UnaryOpM<o, f, m, unaryop_args, t, (outs),
1330             [(store (node (t.LoadNode addr:$src1)), addr:$src1),
1331              (implicit EFLAGS)]>, Sched<[WriteALURMW]>, DefEFLAGS {
1332  let mayStore = 1;
1333}
1334