1 //===-- X86Schedule.td - X86 Scheduling Definitions --------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
10 // InstrSchedModel annotations for out-of-order CPUs.
12 // Instructions with folded loads need to read the memory operand immediately,
13 // but other register operands don't have to be read until the load is ready.
14 // These operands are marked with ReadAfterLd.
15 def ReadAfterLd : SchedRead;
16 def ReadAfterVecLd : SchedRead;
17 def ReadAfterVecXLd : SchedRead;
18 def ReadAfterVecYLd : SchedRead;
20 // Instructions that move data between general purpose registers and vector
21 // registers may be subject to extra latency due to data bypass delays.
22 // This SchedRead describes a bypass delay caused by data being moved from the
23 // integer unit to the floating point unit.
24 def ReadInt2Fpu : SchedRead;
26 // Instructions with both a load and a store folded are modeled as a folded
28 def WriteRMW : SchedWrite;
30 // Helper to set SchedWrite ExePorts/Latency/ResourceCycles/NumMicroOps.
31 multiclass X86WriteRes<SchedWrite SchedRW,
32 list<ProcResourceKind> ExePorts,
33 int Lat, list<int> Res, int UOps> {
34 def : WriteRes<SchedRW, ExePorts> {
36 let ResourceCycles = Res;
37 let NumMicroOps = UOps;
41 // Most instructions can fold loads, so almost every SchedWrite comes in two
42 // variants: With and without a folded load.
43 // An X86FoldableSchedWrite holds a reference to the corresponding SchedWrite
44 // with a folded load.
45 class X86FoldableSchedWrite : SchedWrite {
46 // The SchedWrite to use when a load is folded into the instruction.
48 // The SchedRead to tag register operands than don't need to be ready
49 // until the folded load has completed.
50 SchedRead ReadAfterFold;
53 // Multiclass that produces a linked pair of SchedWrites.
54 multiclass X86SchedWritePair<SchedRead ReadAfter = ReadAfterLd> {
55 // Register-Memory operation.
57 // Register-Register operation.
58 def NAME : X86FoldableSchedWrite {
59 let Folded = !cast<SchedWrite>(NAME#"Ld");
60 let ReadAfterFold = ReadAfter;
64 // Helpers to mark SchedWrites as unsupported.
65 multiclass X86WriteResUnsupported<SchedWrite SchedRW> {
66 let Unsupported = 1 in {
67 def : WriteRes<SchedRW, []>;
70 multiclass X86WriteResPairUnsupported<X86FoldableSchedWrite SchedRW> {
71 let Unsupported = 1 in {
72 def : WriteRes<SchedRW, []>;
73 def : WriteRes<SchedRW.Folded, []>;
77 // Multiclass that wraps X86FoldableSchedWrite for each vector width.
78 class X86SchedWriteWidths<X86FoldableSchedWrite sScl,
79 X86FoldableSchedWrite s128,
80 X86FoldableSchedWrite s256,
81 X86FoldableSchedWrite s512> {
82 X86FoldableSchedWrite Scl = sScl; // Scalar float/double operations.
83 X86FoldableSchedWrite MMX = sScl; // MMX operations.
84 X86FoldableSchedWrite XMM = s128; // XMM operations.
85 X86FoldableSchedWrite YMM = s256; // YMM operations.
86 X86FoldableSchedWrite ZMM = s512; // ZMM operations.
89 // Multiclass that wraps X86SchedWriteWidths for each fp vector type.
90 class X86SchedWriteSizes<X86SchedWriteWidths sPS,
91 X86SchedWriteWidths sPD> {
92 X86SchedWriteWidths PS = sPS;
93 X86SchedWriteWidths PD = sPD;
96 // Multiclass that wraps move/load/store triple for a vector width.
97 class X86SchedWriteMoveLS<SchedWrite MoveRR,
100 SchedWrite RR = MoveRR;
101 SchedWrite RM = LoadRM;
102 SchedWrite MR = StoreMR;
105 // Multiclass that wraps masked load/store writes for a vector width.
106 class X86SchedWriteMaskMove<SchedWrite LoadRM, SchedWrite StoreMR> {
107 SchedWrite RM = LoadRM;
108 SchedWrite MR = StoreMR;
111 // Multiclass that wraps X86SchedWriteMoveLS for each vector width.
112 class X86SchedWriteMoveLSWidths<X86SchedWriteMoveLS sScl,
113 X86SchedWriteMoveLS s128,
114 X86SchedWriteMoveLS s256,
115 X86SchedWriteMoveLS s512> {
116 X86SchedWriteMoveLS Scl = sScl; // Scalar float/double operations.
117 X86SchedWriteMoveLS MMX = sScl; // MMX operations.
118 X86SchedWriteMoveLS XMM = s128; // XMM operations.
119 X86SchedWriteMoveLS YMM = s256; // YMM operations.
120 X86SchedWriteMoveLS ZMM = s512; // ZMM operations.
123 // Loads, stores, and moves, not folded with other operations.
124 def WriteLoad : SchedWrite;
125 def WriteStore : SchedWrite;
126 def WriteStoreNT : SchedWrite;
127 def WriteMove : SchedWrite;
128 def WriteCopy : WriteSequence<[WriteLoad, WriteStore]>; // mem->mem copy
131 defm WriteALU : X86SchedWritePair; // Simple integer ALU op.
132 defm WriteADC : X86SchedWritePair; // Integer ALU + flags op.
133 def WriteALURMW : WriteSequence<[WriteALULd, WriteRMW]>;
134 def WriteADCRMW : WriteSequence<[WriteADCLd, WriteRMW]>;
135 def WriteLEA : SchedWrite; // LEA instructions can't fold loads.
137 // Integer multiplication
138 defm WriteIMul8 : X86SchedWritePair; // Integer 8-bit multiplication.
139 defm WriteIMul16 : X86SchedWritePair; // Integer 16-bit multiplication.
140 defm WriteIMul16Imm : X86SchedWritePair; // Integer 16-bit multiplication by immediate.
141 defm WriteIMul16Reg : X86SchedWritePair; // Integer 16-bit multiplication by register.
142 defm WriteIMul32 : X86SchedWritePair; // Integer 32-bit multiplication.
143 defm WriteIMul32Imm : X86SchedWritePair; // Integer 32-bit multiplication by immediate.
144 defm WriteIMul32Reg : X86SchedWritePair; // Integer 32-bit multiplication by register.
145 defm WriteIMul64 : X86SchedWritePair; // Integer 64-bit multiplication.
146 defm WriteIMul64Imm : X86SchedWritePair; // Integer 64-bit multiplication by immediate.
147 defm WriteIMul64Reg : X86SchedWritePair; // Integer 64-bit multiplication by register.
148 def WriteIMulH : SchedWrite; // Integer multiplication, high part.
150 def WriteBSWAP32 : SchedWrite; // Byte Order (Endianness) 32-bit Swap.
151 def WriteBSWAP64 : SchedWrite; // Byte Order (Endianness) 64-bit Swap.
152 defm WriteCMPXCHG : X86SchedWritePair; // Compare and set, compare and swap.
153 def WriteCMPXCHGRMW : SchedWrite; // Compare and set, compare and swap.
154 def WriteXCHG : SchedWrite; // Compare+Exchange - TODO RMW support.
157 defm WriteDiv8 : X86SchedWritePair;
158 defm WriteDiv16 : X86SchedWritePair;
159 defm WriteDiv32 : X86SchedWritePair;
160 defm WriteDiv64 : X86SchedWritePair;
161 defm WriteIDiv8 : X86SchedWritePair;
162 defm WriteIDiv16 : X86SchedWritePair;
163 defm WriteIDiv32 : X86SchedWritePair;
164 defm WriteIDiv64 : X86SchedWritePair;
166 defm WriteBSF : X86SchedWritePair; // Bit scan forward.
167 defm WriteBSR : X86SchedWritePair; // Bit scan reverse.
168 defm WritePOPCNT : X86SchedWritePair; // Bit population count.
169 defm WriteLZCNT : X86SchedWritePair; // Leading zero count.
170 defm WriteTZCNT : X86SchedWritePair; // Trailing zero count.
171 defm WriteCMOV : X86SchedWritePair; // Conditional move.
172 def WriteFCMOV : SchedWrite; // X87 conditional move.
173 def WriteSETCC : SchedWrite; // Set register based on condition code.
174 def WriteSETCCStore : SchedWrite;
175 def WriteLAHFSAHF : SchedWrite; // Load/Store flags in AH.
177 def WriteBitTest : SchedWrite; // Bit Test
178 def WriteBitTestImmLd : SchedWrite;
179 def WriteBitTestRegLd : SchedWrite;
181 def WriteBitTestSet : SchedWrite; // Bit Test + Set
182 def WriteBitTestSetImmLd : SchedWrite;
183 def WriteBitTestSetRegLd : SchedWrite;
184 def WriteBitTestSetImmRMW : WriteSequence<[WriteBitTestSetImmLd, WriteRMW]>;
185 def WriteBitTestSetRegRMW : WriteSequence<[WriteBitTestSetRegLd, WriteRMW]>;
187 // Integer shifts and rotates.
188 defm WriteShift : X86SchedWritePair;
189 defm WriteShiftCL : X86SchedWritePair;
190 defm WriteRotate : X86SchedWritePair;
191 defm WriteRotateCL : X86SchedWritePair;
193 // Double shift instructions.
194 def WriteSHDrri : SchedWrite;
195 def WriteSHDrrcl : SchedWrite;
196 def WriteSHDmri : SchedWrite;
197 def WriteSHDmrcl : SchedWrite;
199 // BMI1 BEXTR/BLS, BMI2 BZHI
200 defm WriteBEXTR : X86SchedWritePair;
201 defm WriteBLS : X86SchedWritePair;
202 defm WriteBZHI : X86SchedWritePair;
204 // Idioms that clear a register, like xorps %xmm0, %xmm0.
205 // These can often bypass execution ports completely.
206 def WriteZero : SchedWrite;
208 // Branches don't produce values, so they have no latency, but they still
209 // consume resources. Indirect branches can fold loads.
210 defm WriteJump : X86SchedWritePair;
212 // Floating point. This covers both scalar and vector operations.
213 def WriteFLD0 : SchedWrite;
214 def WriteFLD1 : SchedWrite;
215 def WriteFLDC : SchedWrite;
216 def WriteFLoad : SchedWrite;
217 def WriteFLoadX : SchedWrite;
218 def WriteFLoadY : SchedWrite;
219 def WriteFMaskedLoad : SchedWrite;
220 def WriteFMaskedLoadY : SchedWrite;
221 def WriteFStore : SchedWrite;
222 def WriteFStoreX : SchedWrite;
223 def WriteFStoreY : SchedWrite;
224 def WriteFStoreNT : SchedWrite;
225 def WriteFStoreNTX : SchedWrite;
226 def WriteFStoreNTY : SchedWrite;
228 def WriteFMaskedStore32 : SchedWrite;
229 def WriteFMaskedStore64 : SchedWrite;
230 def WriteFMaskedStore32Y : SchedWrite;
231 def WriteFMaskedStore64Y : SchedWrite;
233 def WriteFMove : SchedWrite;
234 def WriteFMoveX : SchedWrite;
235 def WriteFMoveY : SchedWrite;
237 defm WriteFAdd : X86SchedWritePair<ReadAfterVecLd>; // Floating point add/sub.
238 defm WriteFAddX : X86SchedWritePair<ReadAfterVecXLd>; // Floating point add/sub (XMM).
239 defm WriteFAddY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point add/sub (YMM).
240 defm WriteFAddZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point add/sub (ZMM).
241 defm WriteFAdd64 : X86SchedWritePair<ReadAfterVecLd>; // Floating point double add/sub.
242 defm WriteFAdd64X : X86SchedWritePair<ReadAfterVecXLd>; // Floating point double add/sub (XMM).
243 defm WriteFAdd64Y : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double add/sub (YMM).
244 defm WriteFAdd64Z : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double add/sub (ZMM).
245 defm WriteFCmp : X86SchedWritePair<ReadAfterVecLd>; // Floating point compare.
246 defm WriteFCmpX : X86SchedWritePair<ReadAfterVecXLd>; // Floating point compare (XMM).
247 defm WriteFCmpY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point compare (YMM).
248 defm WriteFCmpZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point compare (ZMM).
249 defm WriteFCmp64 : X86SchedWritePair<ReadAfterVecLd>; // Floating point double compare.
250 defm WriteFCmp64X : X86SchedWritePair<ReadAfterVecXLd>; // Floating point double compare (XMM).
251 defm WriteFCmp64Y : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double compare (YMM).
252 defm WriteFCmp64Z : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double compare (ZMM).
253 defm WriteFCom : X86SchedWritePair<ReadAfterVecLd>; // Floating point compare to flags.
254 defm WriteFMul : X86SchedWritePair<ReadAfterVecLd>; // Floating point multiplication.
255 defm WriteFMulX : X86SchedWritePair<ReadAfterVecXLd>; // Floating point multiplication (XMM).
256 defm WriteFMulY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point multiplication (YMM).
257 defm WriteFMulZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point multiplication (YMM).
258 defm WriteFMul64 : X86SchedWritePair<ReadAfterVecLd>; // Floating point double multiplication.
259 defm WriteFMul64X : X86SchedWritePair<ReadAfterVecXLd>; // Floating point double multiplication (XMM).
260 defm WriteFMul64Y : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double multiplication (YMM).
261 defm WriteFMul64Z : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double multiplication (ZMM).
262 defm WriteFDiv : X86SchedWritePair<ReadAfterVecLd>; // Floating point division.
263 defm WriteFDivX : X86SchedWritePair<ReadAfterVecXLd>; // Floating point division (XMM).
264 defm WriteFDivY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point division (YMM).
265 defm WriteFDivZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point division (ZMM).
266 defm WriteFDiv64 : X86SchedWritePair<ReadAfterVecLd>; // Floating point double division.
267 defm WriteFDiv64X : X86SchedWritePair<ReadAfterVecXLd>; // Floating point double division (XMM).
268 defm WriteFDiv64Y : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double division (YMM).
269 defm WriteFDiv64Z : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double division (ZMM).
270 defm WriteFSqrt : X86SchedWritePair<ReadAfterVecLd>; // Floating point square root.
271 defm WriteFSqrtX : X86SchedWritePair<ReadAfterVecXLd>; // Floating point square root (XMM).
272 defm WriteFSqrtY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point square root (YMM).
273 defm WriteFSqrtZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point square root (ZMM).
274 defm WriteFSqrt64 : X86SchedWritePair<ReadAfterVecLd>; // Floating point double square root.
275 defm WriteFSqrt64X : X86SchedWritePair<ReadAfterVecXLd>; // Floating point double square root (XMM).
276 defm WriteFSqrt64Y : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double square root (YMM).
277 defm WriteFSqrt64Z : X86SchedWritePair<ReadAfterVecYLd>; // Floating point double square root (ZMM).
278 defm WriteFSqrt80 : X86SchedWritePair<ReadAfterVecLd>; // Floating point long double square root.
279 defm WriteFRcp : X86SchedWritePair<ReadAfterVecLd>; // Floating point reciprocal estimate.
280 defm WriteFRcpX : X86SchedWritePair<ReadAfterVecXLd>; // Floating point reciprocal estimate (XMM).
281 defm WriteFRcpY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point reciprocal estimate (YMM).
282 defm WriteFRcpZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point reciprocal estimate (ZMM).
283 defm WriteFRsqrt : X86SchedWritePair<ReadAfterVecLd>; // Floating point reciprocal square root estimate.
284 defm WriteFRsqrtX: X86SchedWritePair<ReadAfterVecXLd>; // Floating point reciprocal square root estimate (XMM).
285 defm WriteFRsqrtY: X86SchedWritePair<ReadAfterVecYLd>; // Floating point reciprocal square root estimate (YMM).
286 defm WriteFRsqrtZ: X86SchedWritePair<ReadAfterVecYLd>; // Floating point reciprocal square root estimate (ZMM).
287 defm WriteFMA : X86SchedWritePair<ReadAfterVecLd>; // Fused Multiply Add.
288 defm WriteFMAX : X86SchedWritePair<ReadAfterVecXLd>; // Fused Multiply Add (XMM).
289 defm WriteFMAY : X86SchedWritePair<ReadAfterVecYLd>; // Fused Multiply Add (YMM).
290 defm WriteFMAZ : X86SchedWritePair<ReadAfterVecYLd>; // Fused Multiply Add (ZMM).
291 defm WriteDPPD : X86SchedWritePair<ReadAfterVecXLd>; // Floating point double dot product.
292 defm WriteDPPS : X86SchedWritePair<ReadAfterVecXLd>; // Floating point single dot product.
293 defm WriteDPPSY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point single dot product (YMM).
294 defm WriteDPPSZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point single dot product (ZMM).
295 defm WriteFSign : X86SchedWritePair<ReadAfterVecLd>; // Floating point fabs/fchs.
296 defm WriteFRnd : X86SchedWritePair<ReadAfterVecXLd>; // Floating point rounding.
297 defm WriteFRndY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point rounding (YMM).
298 defm WriteFRndZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point rounding (ZMM).
299 defm WriteFLogic : X86SchedWritePair<ReadAfterVecXLd>; // Floating point and/or/xor logicals.
300 defm WriteFLogicY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point and/or/xor logicals (YMM).
301 defm WriteFLogicZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point and/or/xor logicals (ZMM).
302 defm WriteFTest : X86SchedWritePair<ReadAfterVecXLd>; // Floating point TEST instructions.
303 defm WriteFTestY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point TEST instructions (YMM).
304 defm WriteFTestZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point TEST instructions (ZMM).
305 defm WriteFShuffle : X86SchedWritePair<ReadAfterVecXLd>; // Floating point vector shuffles.
306 defm WriteFShuffleY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point vector shuffles (YMM).
307 defm WriteFShuffleZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point vector shuffles (ZMM).
308 defm WriteFVarShuffle : X86SchedWritePair<ReadAfterVecXLd>; // Floating point vector variable shuffles.
309 defm WriteFVarShuffleY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point vector variable shuffles (YMM).
310 defm WriteFVarShuffleZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point vector variable shuffles (ZMM).
311 defm WriteFBlend : X86SchedWritePair<ReadAfterVecXLd>; // Floating point vector blends.
312 defm WriteFBlendY : X86SchedWritePair<ReadAfterVecYLd>; // Floating point vector blends (YMM).
313 defm WriteFBlendZ : X86SchedWritePair<ReadAfterVecYLd>; // Floating point vector blends (ZMM).
314 defm WriteFVarBlend : X86SchedWritePair<ReadAfterVecXLd>; // Fp vector variable blends.
315 defm WriteFVarBlendY : X86SchedWritePair<ReadAfterVecYLd>; // Fp vector variable blends (YMM).
316 defm WriteFVarBlendZ : X86SchedWritePair<ReadAfterVecYLd>; // Fp vector variable blends (YMZMM).
318 // FMA Scheduling helper class.
319 class FMASC { X86FoldableSchedWrite Sched = WriteFAdd; }
321 // Horizontal Add/Sub (float and integer)
322 defm WriteFHAdd : X86SchedWritePair<ReadAfterVecXLd>;
323 defm WriteFHAddY : X86SchedWritePair<ReadAfterVecYLd>;
324 defm WriteFHAddZ : X86SchedWritePair<ReadAfterVecYLd>;
325 defm WritePHAdd : X86SchedWritePair<ReadAfterVecLd>;
326 defm WritePHAddX : X86SchedWritePair<ReadAfterVecXLd>;
327 defm WritePHAddY : X86SchedWritePair<ReadAfterVecYLd>;
328 defm WritePHAddZ : X86SchedWritePair<ReadAfterVecYLd>;
330 // Vector integer operations.
331 def WriteVecLoad : SchedWrite;
332 def WriteVecLoadX : SchedWrite;
333 def WriteVecLoadY : SchedWrite;
334 def WriteVecLoadNT : SchedWrite;
335 def WriteVecLoadNTY : SchedWrite;
336 def WriteVecMaskedLoad : SchedWrite;
337 def WriteVecMaskedLoadY : SchedWrite;
338 def WriteVecStore : SchedWrite;
339 def WriteVecStoreX : SchedWrite;
340 def WriteVecStoreY : SchedWrite;
341 def WriteVecStoreNT : SchedWrite;
342 def WriteVecStoreNTY : SchedWrite;
343 def WriteVecMaskedStore : SchedWrite;
344 def WriteVecMaskedStoreY : SchedWrite;
345 def WriteVecMove : SchedWrite;
346 def WriteVecMoveX : SchedWrite;
347 def WriteVecMoveY : SchedWrite;
348 def WriteVecMoveToGpr : SchedWrite;
349 def WriteVecMoveFromGpr : SchedWrite;
351 defm WriteVecALU : X86SchedWritePair<ReadAfterVecLd>; // Vector integer ALU op, no logicals.
352 defm WriteVecALUX : X86SchedWritePair<ReadAfterVecXLd>; // Vector integer ALU op, no logicals (XMM).
353 defm WriteVecALUY : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer ALU op, no logicals (YMM).
354 defm WriteVecALUZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer ALU op, no logicals (ZMM).
355 defm WriteVecLogic : X86SchedWritePair<ReadAfterVecLd>; // Vector integer and/or/xor logicals.
356 defm WriteVecLogicX : X86SchedWritePair<ReadAfterVecXLd>; // Vector integer and/or/xor logicals (XMM).
357 defm WriteVecLogicY : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer and/or/xor logicals (YMM).
358 defm WriteVecLogicZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer and/or/xor logicals (ZMM).
359 defm WriteVecTest : X86SchedWritePair<ReadAfterVecXLd>; // Vector integer TEST instructions.
360 defm WriteVecTestY : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer TEST instructions (YMM).
361 defm WriteVecTestZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer TEST instructions (ZMM).
362 defm WriteVecShift : X86SchedWritePair<ReadAfterVecLd>; // Vector integer shifts (default).
363 defm WriteVecShiftX : X86SchedWritePair<ReadAfterVecXLd>; // Vector integer shifts (XMM).
364 defm WriteVecShiftY : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer shifts (YMM).
365 defm WriteVecShiftZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer shifts (ZMM).
366 defm WriteVecShiftImm : X86SchedWritePair<ReadAfterVecLd>; // Vector integer immediate shifts (default).
367 defm WriteVecShiftImmX: X86SchedWritePair<ReadAfterVecXLd>; // Vector integer immediate shifts (XMM).
368 defm WriteVecShiftImmY: X86SchedWritePair<ReadAfterVecYLd>; // Vector integer immediate shifts (YMM).
369 defm WriteVecShiftImmZ: X86SchedWritePair<ReadAfterVecYLd>; // Vector integer immediate shifts (ZMM).
370 defm WriteVecIMul : X86SchedWritePair<ReadAfterVecLd>; // Vector integer multiply (default).
371 defm WriteVecIMulX : X86SchedWritePair<ReadAfterVecXLd>; // Vector integer multiply (XMM).
372 defm WriteVecIMulY : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer multiply (YMM).
373 defm WriteVecIMulZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector integer multiply (ZMM).
374 defm WritePMULLD : X86SchedWritePair<ReadAfterVecXLd>; // Vector PMULLD.
375 defm WritePMULLDY : X86SchedWritePair<ReadAfterVecYLd>; // Vector PMULLD (YMM).
376 defm WritePMULLDZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector PMULLD (ZMM).
377 defm WriteShuffle : X86SchedWritePair<ReadAfterVecLd>; // Vector shuffles.
378 defm WriteShuffleX : X86SchedWritePair<ReadAfterVecXLd>; // Vector shuffles (XMM).
379 defm WriteShuffleY : X86SchedWritePair<ReadAfterVecYLd>; // Vector shuffles (YMM).
380 defm WriteShuffleZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector shuffles (ZMM).
381 defm WriteVarShuffle : X86SchedWritePair<ReadAfterVecLd>; // Vector variable shuffles.
382 defm WriteVarShuffleX : X86SchedWritePair<ReadAfterVecXLd>; // Vector variable shuffles (XMM).
383 defm WriteVarShuffleY : X86SchedWritePair<ReadAfterVecYLd>; // Vector variable shuffles (YMM).
384 defm WriteVarShuffleZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector variable shuffles (ZMM).
385 defm WriteBlend : X86SchedWritePair<ReadAfterVecXLd>; // Vector blends.
386 defm WriteBlendY : X86SchedWritePair<ReadAfterVecYLd>; // Vector blends (YMM).
387 defm WriteBlendZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector blends (ZMM).
388 defm WriteVarBlend : X86SchedWritePair<ReadAfterVecXLd>; // Vector variable blends.
389 defm WriteVarBlendY : X86SchedWritePair<ReadAfterVecYLd>; // Vector variable blends (YMM).
390 defm WriteVarBlendZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector variable blends (ZMM).
391 defm WritePSADBW : X86SchedWritePair<ReadAfterVecLd>; // Vector PSADBW.
392 defm WritePSADBWX : X86SchedWritePair<ReadAfterVecXLd>; // Vector PSADBW (XMM).
393 defm WritePSADBWY : X86SchedWritePair<ReadAfterVecYLd>; // Vector PSADBW (YMM).
394 defm WritePSADBWZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector PSADBW (ZMM).
395 defm WriteMPSAD : X86SchedWritePair<ReadAfterVecXLd>; // Vector MPSAD.
396 defm WriteMPSADY : X86SchedWritePair<ReadAfterVecYLd>; // Vector MPSAD (YMM).
397 defm WriteMPSADZ : X86SchedWritePair<ReadAfterVecYLd>; // Vector MPSAD (ZMM).
398 defm WritePHMINPOS : X86SchedWritePair<ReadAfterVecXLd>; // Vector PHMINPOS.
400 // Vector insert/extract operations.
401 defm WriteVecInsert : X86SchedWritePair; // Insert gpr to vector element.
402 def WriteVecExtract : SchedWrite; // Extract vector element to gpr.
403 def WriteVecExtractSt : SchedWrite; // Extract vector element and store.
405 // MOVMSK operations.
406 def WriteFMOVMSK : SchedWrite;
407 def WriteVecMOVMSK : SchedWrite;
408 def WriteVecMOVMSKY : SchedWrite;
409 def WriteMMXMOVMSK : SchedWrite;
411 // Conversion between integer and float.
412 defm WriteCvtSD2I : X86SchedWritePair<ReadAfterVecLd>; // Double -> Integer.
413 defm WriteCvtPD2I : X86SchedWritePair<ReadAfterVecXLd>; // Double -> Integer (XMM).
414 defm WriteCvtPD2IY : X86SchedWritePair<ReadAfterVecYLd>; // Double -> Integer (YMM).
415 defm WriteCvtPD2IZ : X86SchedWritePair<ReadAfterVecYLd>; // Double -> Integer (ZMM).
417 defm WriteCvtSS2I : X86SchedWritePair<ReadAfterVecLd>; // Float -> Integer.
418 defm WriteCvtPS2I : X86SchedWritePair<ReadAfterVecXLd>; // Float -> Integer (XMM).
419 defm WriteCvtPS2IY : X86SchedWritePair<ReadAfterVecYLd>; // Float -> Integer (YMM).
420 defm WriteCvtPS2IZ : X86SchedWritePair<ReadAfterVecYLd>; // Float -> Integer (ZMM).
422 defm WriteCvtI2SD : X86SchedWritePair<ReadAfterVecLd>; // Integer -> Double.
423 defm WriteCvtI2PD : X86SchedWritePair<ReadAfterVecXLd>; // Integer -> Double (XMM).
424 defm WriteCvtI2PDY : X86SchedWritePair<ReadAfterVecYLd>; // Integer -> Double (YMM).
425 defm WriteCvtI2PDZ : X86SchedWritePair<ReadAfterVecYLd>; // Integer -> Double (ZMM).
427 defm WriteCvtI2SS : X86SchedWritePair<ReadAfterVecLd>; // Integer -> Float.
428 defm WriteCvtI2PS : X86SchedWritePair<ReadAfterVecXLd>; // Integer -> Float (XMM).
429 defm WriteCvtI2PSY : X86SchedWritePair<ReadAfterVecYLd>; // Integer -> Float (YMM).
430 defm WriteCvtI2PSZ : X86SchedWritePair<ReadAfterVecYLd>; // Integer -> Float (ZMM).
432 defm WriteCvtSS2SD : X86SchedWritePair<ReadAfterVecLd>; // Float -> Double size conversion.
433 defm WriteCvtPS2PD : X86SchedWritePair<ReadAfterVecXLd>; // Float -> Double size conversion (XMM).
434 defm WriteCvtPS2PDY : X86SchedWritePair<ReadAfterVecYLd>; // Float -> Double size conversion (YMM).
435 defm WriteCvtPS2PDZ : X86SchedWritePair<ReadAfterVecYLd>; // Float -> Double size conversion (ZMM).
437 defm WriteCvtSD2SS : X86SchedWritePair<ReadAfterVecLd>; // Double -> Float size conversion.
438 defm WriteCvtPD2PS : X86SchedWritePair<ReadAfterVecXLd>; // Double -> Float size conversion (XMM).
439 defm WriteCvtPD2PSY : X86SchedWritePair<ReadAfterVecYLd>; // Double -> Float size conversion (YMM).
440 defm WriteCvtPD2PSZ : X86SchedWritePair<ReadAfterVecYLd>; // Double -> Float size conversion (ZMM).
442 defm WriteCvtPH2PS : X86SchedWritePair<ReadAfterVecXLd>; // Half -> Float size conversion.
443 defm WriteCvtPH2PSY : X86SchedWritePair<ReadAfterVecYLd>; // Half -> Float size conversion (YMM).
444 defm WriteCvtPH2PSZ : X86SchedWritePair<ReadAfterVecYLd>; // Half -> Float size conversion (ZMM).
446 def WriteCvtPS2PH : SchedWrite; // // Float -> Half size conversion.
447 def WriteCvtPS2PHY : SchedWrite; // // Float -> Half size conversion (YMM).
448 def WriteCvtPS2PHZ : SchedWrite; // // Float -> Half size conversion (ZMM).
449 def WriteCvtPS2PHSt : SchedWrite; // // Float -> Half + store size conversion.
450 def WriteCvtPS2PHYSt : SchedWrite; // // Float -> Half + store size conversion (YMM).
451 def WriteCvtPS2PHZSt : SchedWrite; // // Float -> Half + store size conversion (ZMM).
453 // CRC32 instruction.
454 defm WriteCRC32 : X86SchedWritePair<ReadAfterLd>;
456 // Strings instructions.
457 // Packed Compare Implicit Length Strings, Return Mask
458 defm WritePCmpIStrM : X86SchedWritePair<ReadAfterVecXLd>;
459 // Packed Compare Explicit Length Strings, Return Mask
460 defm WritePCmpEStrM : X86SchedWritePair<ReadAfterVecXLd>;
461 // Packed Compare Implicit Length Strings, Return Index
462 defm WritePCmpIStrI : X86SchedWritePair<ReadAfterVecXLd>;
463 // Packed Compare Explicit Length Strings, Return Index
464 defm WritePCmpEStrI : X86SchedWritePair<ReadAfterVecXLd>;
467 defm WriteAESDecEnc : X86SchedWritePair<ReadAfterVecXLd>; // Decryption, encryption.
468 defm WriteAESIMC : X86SchedWritePair<ReadAfterVecXLd>; // InvMixColumn.
469 defm WriteAESKeyGen : X86SchedWritePair<ReadAfterVecXLd>; // Key Generation.
471 // Carry-less multiplication instructions.
472 defm WriteCLMul : X86SchedWritePair<ReadAfterVecXLd>;
475 def WriteEMMS : SchedWrite;
478 def WriteLDMXCSR : SchedWrite;
479 def WriteSTMXCSR : SchedWrite;
481 // Catch-all for expensive system instructions.
482 def WriteSystem : SchedWrite;
485 defm WriteFShuffle256 : X86SchedWritePair<ReadAfterVecYLd>; // Fp 256-bit width vector shuffles.
486 defm WriteFVarShuffle256 : X86SchedWritePair<ReadAfterVecYLd>; // Fp 256-bit width variable shuffles.
487 defm WriteShuffle256 : X86SchedWritePair<ReadAfterVecYLd>; // 256-bit width vector shuffles.
488 defm WriteVarShuffle256 : X86SchedWritePair<ReadAfterVecYLd>; // 256-bit width vector variable shuffles.
489 defm WriteVarVecShift : X86SchedWritePair<ReadAfterVecXLd>; // Variable vector shifts.
490 defm WriteVarVecShiftY : X86SchedWritePair<ReadAfterVecYLd>; // Variable vector shifts (YMM).
491 defm WriteVarVecShiftZ : X86SchedWritePair<ReadAfterVecYLd>; // Variable vector shifts (ZMM).
493 // Old microcoded instructions that nobody use.
494 def WriteMicrocoded : SchedWrite;
496 // Fence instructions.
497 def WriteFence : SchedWrite;
499 // Nop, not very useful expect it provides a model for nops!
500 def WriteNop : SchedWrite;
502 // Move/Load/Store wrappers.
504 : X86SchedWriteMoveLS<WriteFMove, WriteFLoad, WriteFStore>;
506 : X86SchedWriteMoveLS<WriteFMoveX, WriteFLoadX, WriteFStoreX>;
508 : X86SchedWriteMoveLS<WriteFMoveY, WriteFLoadY, WriteFStoreY>;
509 def SchedWriteFMoveLS
510 : X86SchedWriteMoveLSWidths<WriteFMoveLS, WriteFMoveLSX,
511 WriteFMoveLSY, WriteFMoveLSY>;
514 : X86SchedWriteMoveLS<WriteFMove, WriteFLoad, WriteFStoreNT>;
516 : X86SchedWriteMoveLS<WriteFMove, WriteFLoad, WriteFStoreNTX>;
518 : X86SchedWriteMoveLS<WriteFMoveY, WriteFLoadY, WriteFStoreNTY>;
519 def SchedWriteFMoveLSNT
520 : X86SchedWriteMoveLSWidths<WriteFMoveLSNT, WriteFMoveLSNTX,
521 WriteFMoveLSNTY, WriteFMoveLSNTY>;
524 : X86SchedWriteMoveLS<WriteVecMove, WriteVecLoad, WriteVecStore>;
526 : X86SchedWriteMoveLS<WriteVecMoveX, WriteVecLoadX, WriteVecStoreX>;
528 : X86SchedWriteMoveLS<WriteVecMoveY, WriteVecLoadY, WriteVecStoreY>;
529 def SchedWriteVecMoveLS
530 : X86SchedWriteMoveLSWidths<WriteVecMoveLS, WriteVecMoveLSX,
531 WriteVecMoveLSY, WriteVecMoveLSY>;
534 : X86SchedWriteMoveLS<WriteVecMove, WriteVecLoadNT, WriteVecStoreNT>;
535 def WriteVecMoveLSNTX
536 : X86SchedWriteMoveLS<WriteVecMoveX, WriteVecLoadNT, WriteVecStoreNT>;
537 def WriteVecMoveLSNTY
538 : X86SchedWriteMoveLS<WriteVecMoveY, WriteVecLoadNTY, WriteVecStoreNTY>;
539 def SchedWriteVecMoveLSNT
540 : X86SchedWriteMoveLSWidths<WriteVecMoveLSNT, WriteVecMoveLSNTX,
541 WriteVecMoveLSNTY, WriteVecMoveLSNTY>;
543 // Conditional SIMD Packed Loads and Stores wrappers.
545 : X86SchedWriteMaskMove<WriteFMaskedLoad, WriteFMaskedStore32>;
547 : X86SchedWriteMaskMove<WriteFMaskedLoad, WriteFMaskedStore64>;
548 def WriteFMaskMove32Y
549 : X86SchedWriteMaskMove<WriteFMaskedLoadY, WriteFMaskedStore32Y>;
550 def WriteFMaskMove64Y
551 : X86SchedWriteMaskMove<WriteFMaskedLoadY, WriteFMaskedStore64Y>;
553 // Vector width wrappers.
555 : X86SchedWriteWidths<WriteFAdd, WriteFAddX, WriteFAddY, WriteFAddZ>;
557 : X86SchedWriteWidths<WriteFAdd64, WriteFAdd64X, WriteFAdd64Y, WriteFAdd64Z>;
559 : X86SchedWriteWidths<WriteFHAdd, WriteFHAdd, WriteFHAddY, WriteFHAddZ>;
561 : X86SchedWriteWidths<WriteFCmp, WriteFCmpX, WriteFCmpY, WriteFCmpZ>;
563 : X86SchedWriteWidths<WriteFCmp64, WriteFCmp64X, WriteFCmp64Y, WriteFCmp64Z>;
565 : X86SchedWriteWidths<WriteFMul, WriteFMulX, WriteFMulY, WriteFMulZ>;
567 : X86SchedWriteWidths<WriteFMul64, WriteFMul64X, WriteFMul64Y, WriteFMul64Z>;
569 : X86SchedWriteWidths<WriteFMA, WriteFMAX, WriteFMAY, WriteFMAZ>;
571 : X86SchedWriteWidths<WriteDPPD, WriteDPPD, WriteDPPD, WriteDPPD>;
573 : X86SchedWriteWidths<WriteDPPS, WriteDPPS, WriteDPPSY, WriteDPPSZ>;
575 : X86SchedWriteWidths<WriteFDiv, WriteFDivX, WriteFDivY, WriteFDivZ>;
577 : X86SchedWriteWidths<WriteFDiv64, WriteFDiv64X, WriteFDiv64Y, WriteFDiv64Z>;
579 : X86SchedWriteWidths<WriteFSqrt, WriteFSqrtX,
580 WriteFSqrtY, WriteFSqrtZ>;
581 def SchedWriteFSqrt64
582 : X86SchedWriteWidths<WriteFSqrt64, WriteFSqrt64X,
583 WriteFSqrt64Y, WriteFSqrt64Z>;
585 : X86SchedWriteWidths<WriteFRcp, WriteFRcpX, WriteFRcpY, WriteFRcpZ>;
587 : X86SchedWriteWidths<WriteFRsqrt, WriteFRsqrtX, WriteFRsqrtY, WriteFRsqrtZ>;
589 : X86SchedWriteWidths<WriteFRnd, WriteFRnd, WriteFRndY, WriteFRndZ>;
591 : X86SchedWriteWidths<WriteFLogic, WriteFLogic, WriteFLogicY, WriteFLogicZ>;
593 : X86SchedWriteWidths<WriteFTest, WriteFTest, WriteFTestY, WriteFTestZ>;
595 def SchedWriteFShuffle
596 : X86SchedWriteWidths<WriteFShuffle, WriteFShuffle,
597 WriteFShuffleY, WriteFShuffleZ>;
598 def SchedWriteFVarShuffle
599 : X86SchedWriteWidths<WriteFVarShuffle, WriteFVarShuffle,
600 WriteFVarShuffleY, WriteFVarShuffleZ>;
602 : X86SchedWriteWidths<WriteFBlend, WriteFBlend, WriteFBlendY, WriteFBlendZ>;
603 def SchedWriteFVarBlend
604 : X86SchedWriteWidths<WriteFVarBlend, WriteFVarBlend,
605 WriteFVarBlendY, WriteFVarBlendZ>;
607 def SchedWriteCvtDQ2PD
608 : X86SchedWriteWidths<WriteCvtI2SD, WriteCvtI2PD,
609 WriteCvtI2PDY, WriteCvtI2PDZ>;
610 def SchedWriteCvtDQ2PS
611 : X86SchedWriteWidths<WriteCvtI2SS, WriteCvtI2PS,
612 WriteCvtI2PSY, WriteCvtI2PSZ>;
613 def SchedWriteCvtPD2DQ
614 : X86SchedWriteWidths<WriteCvtSD2I, WriteCvtPD2I,
615 WriteCvtPD2IY, WriteCvtPD2IZ>;
616 def SchedWriteCvtPS2DQ
617 : X86SchedWriteWidths<WriteCvtSS2I, WriteCvtPS2I,
618 WriteCvtPS2IY, WriteCvtPS2IZ>;
619 def SchedWriteCvtPS2PD
620 : X86SchedWriteWidths<WriteCvtSS2SD, WriteCvtPS2PD,
621 WriteCvtPS2PDY, WriteCvtPS2PDZ>;
622 def SchedWriteCvtPD2PS
623 : X86SchedWriteWidths<WriteCvtSD2SS, WriteCvtPD2PS,
624 WriteCvtPD2PSY, WriteCvtPD2PSZ>;
627 : X86SchedWriteWidths<WriteVecALU, WriteVecALUX, WriteVecALUY, WriteVecALUZ>;
629 : X86SchedWriteWidths<WritePHAdd, WritePHAddX, WritePHAddY, WritePHAddZ>;
630 def SchedWriteVecLogic
631 : X86SchedWriteWidths<WriteVecLogic, WriteVecLogicX,
632 WriteVecLogicY, WriteVecLogicZ>;
633 def SchedWriteVecTest
634 : X86SchedWriteWidths<WriteVecTest, WriteVecTest,
635 WriteVecTestY, WriteVecTestZ>;
636 def SchedWriteVecShift
637 : X86SchedWriteWidths<WriteVecShift, WriteVecShiftX,
638 WriteVecShiftY, WriteVecShiftZ>;
639 def SchedWriteVecShiftImm
640 : X86SchedWriteWidths<WriteVecShiftImm, WriteVecShiftImmX,
641 WriteVecShiftImmY, WriteVecShiftImmZ>;
642 def SchedWriteVarVecShift
643 : X86SchedWriteWidths<WriteVarVecShift, WriteVarVecShift,
644 WriteVarVecShiftY, WriteVarVecShiftZ>;
645 def SchedWriteVecIMul
646 : X86SchedWriteWidths<WriteVecIMul, WriteVecIMulX,
647 WriteVecIMulY, WriteVecIMulZ>;
649 : X86SchedWriteWidths<WritePMULLD, WritePMULLD,
650 WritePMULLDY, WritePMULLDZ>;
652 : X86SchedWriteWidths<WriteMPSAD, WriteMPSAD,
653 WriteMPSADY, WriteMPSADZ>;
655 : X86SchedWriteWidths<WritePSADBW, WritePSADBWX,
656 WritePSADBWY, WritePSADBWZ>;
658 def SchedWriteShuffle
659 : X86SchedWriteWidths<WriteShuffle, WriteShuffleX,
660 WriteShuffleY, WriteShuffleZ>;
661 def SchedWriteVarShuffle
662 : X86SchedWriteWidths<WriteVarShuffle, WriteVarShuffleX,
663 WriteVarShuffleY, WriteVarShuffleZ>;
665 : X86SchedWriteWidths<WriteBlend, WriteBlend, WriteBlendY, WriteBlendZ>;
666 def SchedWriteVarBlend
667 : X86SchedWriteWidths<WriteVarBlend, WriteVarBlend,
668 WriteVarBlendY, WriteVarBlendZ>;
670 // Vector size wrappers.
671 def SchedWriteFAddSizes
672 : X86SchedWriteSizes<SchedWriteFAdd, SchedWriteFAdd64>;
673 def SchedWriteFCmpSizes
674 : X86SchedWriteSizes<SchedWriteFCmp, SchedWriteFCmp64>;
675 def SchedWriteFMulSizes
676 : X86SchedWriteSizes<SchedWriteFMul, SchedWriteFMul64>;
677 def SchedWriteFDivSizes
678 : X86SchedWriteSizes<SchedWriteFDiv, SchedWriteFDiv64>;
679 def SchedWriteFSqrtSizes
680 : X86SchedWriteSizes<SchedWriteFSqrt, SchedWriteFSqrt64>;
681 def SchedWriteFLogicSizes
682 : X86SchedWriteSizes<SchedWriteFLogic, SchedWriteFLogic>;
683 def SchedWriteFShuffleSizes
684 : X86SchedWriteSizes<SchedWriteFShuffle, SchedWriteFShuffle>;
686 //===----------------------------------------------------------------------===//
687 // Generic Processor Scheduler Models.
689 // IssueWidth is analogous to the number of decode units. Core and its
690 // descendents, including Nehalem and SandyBridge have 4 decoders.
691 // Resources beyond the decoder operate on micro-ops and are bufferred
692 // so adjacent micro-ops don't directly compete.
694 // MicroOpBufferSize > 1 indicates that RAW dependencies can be
695 // decoded in the same cycle. The value 32 is a reasonably arbitrary
696 // number of in-flight instructions.
698 // HighLatency=10 is optimistic. X86InstrInfo::isHighLatencyDef
699 // indicates high latency opcodes. Alternatively, InstrItinData
700 // entries may be included here to define specific operand
701 // latencies. Since these latencies are not used for pipeline hazards,
702 // they do not need to be exact.
704 // The GenericX86Model contains no instruction schedules
705 // and disables PostRAScheduler.
706 class GenericX86Model : SchedMachineModel {
708 let MicroOpBufferSize = 32;
710 let HighLatency = 10;
711 let PostRAScheduler = 0;
712 let CompleteModel = 0;
715 def GenericModel : GenericX86Model;
717 // Define a model with the PostRAScheduler enabled.
718 def GenericPostRAModel : GenericX86Model {
719 let PostRAScheduler = 1;