1 //=- X86ScheduleZnver1.td - X86 Znver1 Scheduling -------------*- 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 // This file defines the machine model for Znver1 to support instruction
10 // scheduling and other instruction cost heuristics.
12 //===----------------------------------------------------------------------===//
14 def Znver1Model : SchedMachineModel {
15 // Zen can decode 4 instructions per cycle.
17 // Based on the reorder buffer we define MicroOpBufferSize
18 let MicroOpBufferSize = 192;
20 let MispredictPenalty = 17;
22 let PostRAScheduler = 1;
24 // FIXME: This variable is required for incomplete model.
25 // We haven't catered all instructions.
26 // So, we reset the value of this variable so as to
27 // say that the model is incomplete.
28 let CompleteModel = 0;
31 let SchedModel = Znver1Model in {
33 // Zen can issue micro-ops to 10 different units in one cycle.
35 // * Four integer ALU units (ZALU0, ZALU1, ZALU2, ZALU3)
36 // * Two AGU units (ZAGU0, ZAGU1)
37 // * Four FPU units (ZFPU0, ZFPU1, ZFPU2, ZFPU3)
38 // AGUs feed load store queues @two loads and 1 store per cycle.
40 // Four ALU units are defined below
41 def ZnALU0 : ProcResource<1>;
42 def ZnALU1 : ProcResource<1>;
43 def ZnALU2 : ProcResource<1>;
44 def ZnALU3 : ProcResource<1>;
46 // Two AGU units are defined below
47 def ZnAGU0 : ProcResource<1>;
48 def ZnAGU1 : ProcResource<1>;
50 // Four FPU units are defined below
51 def ZnFPU0 : ProcResource<1>;
52 def ZnFPU1 : ProcResource<1>;
53 def ZnFPU2 : ProcResource<1>;
54 def ZnFPU3 : ProcResource<1>;
57 def ZnFPU013 : ProcResGroup<[ZnFPU0, ZnFPU1, ZnFPU3]>;
58 def ZnFPU01 : ProcResGroup<[ZnFPU0, ZnFPU1]>;
59 def ZnFPU12 : ProcResGroup<[ZnFPU1, ZnFPU2]>;
60 def ZnFPU13 : ProcResGroup<[ZnFPU1, ZnFPU3]>;
61 def ZnFPU23 : ProcResGroup<[ZnFPU2, ZnFPU3]>;
62 def ZnFPU02 : ProcResGroup<[ZnFPU0, ZnFPU2]>;
63 def ZnFPU03 : ProcResGroup<[ZnFPU0, ZnFPU3]>;
65 // Below are the grouping of the units.
66 // Micro-ops to be issued to multiple units are tackled this way.
69 // ZnALU03 - 0,3 grouping
70 def ZnALU03: ProcResGroup<[ZnALU0, ZnALU3]>;
72 // 56 Entry (14x4 entries) Int Scheduler
73 def ZnALU : ProcResGroup<[ZnALU0, ZnALU1, ZnALU2, ZnALU3]> {
77 // 28 Entry (14x2) AGU group. AGUs can't be used for all ALU operations
78 // but are relevant for some instructions
79 def ZnAGU : ProcResGroup<[ZnAGU0, ZnAGU1]> {
83 // Integer Multiplication issued on ALU1.
84 def ZnMultiplier : ProcResource<1>;
86 // Integer division issued on ALU2.
87 def ZnDivider : ProcResource<1>;
89 // 4 Cycles integer load-to use Latency is captured
90 def : ReadAdvance<ReadAfterLd, 4>;
92 // 8 Cycles vector load-to use Latency is captured
93 def : ReadAdvance<ReadAfterVecLd, 8>;
94 def : ReadAdvance<ReadAfterVecXLd, 8>;
95 def : ReadAdvance<ReadAfterVecYLd, 8>;
97 def : ReadAdvance<ReadInt2Fpu, 0>;
99 // The Integer PRF for Zen is 168 entries, and it holds the architectural and
100 // speculative version of the 64-bit integer registers.
101 // Reference: "Software Optimization Guide for AMD Family 17h Processors"
102 def ZnIntegerPRF : RegisterFile<168, [GR64, CCR]>;
104 // 36 Entry (9x4 entries) floating-point Scheduler
105 def ZnFPU : ProcResGroup<[ZnFPU0, ZnFPU1, ZnFPU2, ZnFPU3]> {
109 // The Zen FP Retire Queue renames SIMD and FP uOps onto a pool of 160 128-bit
110 // registers. Operations on 256-bit data types are cracked into two COPs.
111 // Reference: "Software Optimization Guide for AMD Family 17h Processors"
112 def ZnFpuPRF: RegisterFile<160, [VR64, VR128, VR256], [1, 1, 2]>;
114 // The unit can track up to 192 macro ops in-flight.
115 // The retire unit handles in-order commit of up to 8 macro ops per cycle.
116 // Reference: "Software Optimization Guide for AMD Family 17h Processors"
117 // To be noted, the retire unit is shared between integer and FP ops.
118 // In SMT mode it is 96 entry per thread. But, we do not use the conservative
119 // value here because there is currently no way to fully mode the SMT mode,
120 // so there is no point in trying.
121 def ZnRCU : RetireControlUnit<192, 8>;
123 // FIXME: there are 72 read buffers and 44 write buffers.
125 // (a folded load is an instruction that loads and does some operation)
126 // Ex: ADDPD xmm,[mem]-> This instruction has two micro-ops
127 // Instructions with folded loads are usually micro-fused, so they only appear
131 // This multiclass is for folded loads for integer units.
132 multiclass ZnWriteResPair<X86FoldableSchedWrite SchedRW,
133 list<ProcResourceKind> ExePorts,
134 int Lat, list<int> Res = [], int UOps = 1,
135 int LoadLat = 4, int LoadUOps = 1> {
136 // Register variant takes 1-cycle on Execution Port.
137 def : WriteRes<SchedRW, ExePorts> {
139 let ReleaseAtCycles = Res;
140 let NumMicroOps = UOps;
143 // Memory variant also uses a cycle on ZnAGU
144 // adds LoadLat cycles to the latency (default = 4).
145 def : WriteRes<SchedRW.Folded, !listconcat([ZnAGU], ExePorts)> {
146 let Latency = !add(Lat, LoadLat);
147 let ReleaseAtCycles = !if(!empty(Res), [], !listconcat([1], Res));
148 let NumMicroOps = !add(UOps, LoadUOps);
152 // This multiclass is for folded loads for floating point units.
153 multiclass ZnWriteResFpuPair<X86FoldableSchedWrite SchedRW,
154 list<ProcResourceKind> ExePorts,
155 int Lat, list<int> Res = [], int UOps = 1,
156 int LoadLat = 7, int LoadUOps = 0> {
157 // Register variant takes 1-cycle on Execution Port.
158 def : WriteRes<SchedRW, ExePorts> {
160 let ReleaseAtCycles = Res;
161 let NumMicroOps = UOps;
164 // Memory variant also uses a cycle on ZnAGU
165 // adds LoadLat cycles to the latency (default = 7).
166 def : WriteRes<SchedRW.Folded, !listconcat([ZnAGU], ExePorts)> {
167 let Latency = !add(Lat, LoadLat);
168 let ReleaseAtCycles = !if(!empty(Res), [], !listconcat([1], Res));
169 let NumMicroOps = !add(UOps, LoadUOps);
173 // WriteRMW is set for instructions with Memory write
174 // operation in codegen
175 def : WriteRes<WriteRMW, [ZnAGU]>;
177 def : WriteRes<WriteStore, [ZnAGU]>;
178 def : WriteRes<WriteStoreNT, [ZnAGU]>;
179 def : WriteRes<WriteMove, [ZnALU]>;
180 def : WriteRes<WriteLoad, [ZnAGU]> { let Latency = 4; }
182 // Model the effect of clobbering the read-write mask operand of the GATHER operation.
183 // Does not cost anything by itself, only has latency, matching that of the WriteLoad,
184 def : WriteRes<WriteVecMaskedGatherWriteback, []> { let Latency = 8; let NumMicroOps = 0; }
186 def : WriteRes<WriteZero, []>;
187 def : WriteRes<WriteLEA, [ZnALU]>;
188 defm : ZnWriteResPair<WriteALU, [ZnALU], 1>;
189 defm : ZnWriteResPair<WriteADC, [ZnALU], 1>;
191 defm : ZnWriteResPair<WriteIMul8, [ZnALU1, ZnMultiplier], 4>;
193 defm : X86WriteRes<WriteBSWAP32, [ZnALU], 1, [4], 1>;
194 defm : X86WriteRes<WriteBSWAP64, [ZnALU], 1, [4], 1>;
195 defm : X86WriteRes<WriteCMPXCHG, [ZnALU], 1, [1], 1>;
196 defm : X86WriteRes<WriteCMPXCHGRMW,[ZnALU,ZnAGU], 8, [1,1], 5>;
197 defm : X86WriteRes<WriteXCHG, [ZnALU], 1, [2], 2>;
199 defm : ZnWriteResPair<WriteShift, [ZnALU], 1>;
200 defm : ZnWriteResPair<WriteShiftCL, [ZnALU], 1>;
201 defm : ZnWriteResPair<WriteRotate, [ZnALU], 1>;
202 defm : ZnWriteResPair<WriteRotateCL, [ZnALU], 1>;
204 defm : X86WriteRes<WriteSHDrri, [ZnALU], 1, [1], 1>;
205 defm : X86WriteResUnsupported<WriteSHDrrcl>;
206 defm : X86WriteResUnsupported<WriteSHDmri>;
207 defm : X86WriteResUnsupported<WriteSHDmrcl>;
209 defm : ZnWriteResPair<WriteJump, [ZnALU], 1>;
210 defm : ZnWriteResFpuPair<WriteCRC32, [ZnFPU0], 3>;
212 defm : ZnWriteResPair<WriteCMOV, [ZnALU], 1>;
213 def : WriteRes<WriteSETCC, [ZnALU]>;
214 def : WriteRes<WriteSETCCStore, [ZnALU, ZnAGU]>;
215 defm : X86WriteRes<WriteLAHFSAHF, [ZnALU], 2, [1], 2>;
217 defm : X86WriteRes<WriteBitTest, [ZnALU], 1, [1], 1>;
218 defm : X86WriteRes<WriteBitTestImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
219 defm : X86WriteRes<WriteBitTestRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
220 defm : X86WriteRes<WriteBitTestSet, [ZnALU], 2, [1], 2>;
223 defm : ZnWriteResPair<WriteBSF, [ZnALU], 3, [12], 6, 4, 2>;
224 defm : ZnWriteResPair<WriteBSR, [ZnALU], 4, [16], 6, 4, 2>;
225 defm : ZnWriteResPair<WriteLZCNT, [ZnALU], 2>;
226 defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2, [2], 2, 4, 0>;
227 defm : ZnWriteResPair<WritePOPCNT, [ZnALU], 1>;
229 // Treat misc copies as a move.
230 def : InstRW<[WriteMove], (instrs COPY)>;
232 // BMI1 BEXTR, BMI2 BZHI
233 defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1, [1], 1, 4, 1>;
234 defm : ZnWriteResPair<WriteBLS, [ZnALU], 2, [2], 2, 4, 1>;
235 defm : ZnWriteResPair<WriteBZHI, [ZnALU], 1>;
238 defm : ZnWriteResPair<WriteDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
239 defm : ZnWriteResPair<WriteDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
240 defm : ZnWriteResPair<WriteDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
241 defm : ZnWriteResPair<WriteDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
242 defm : ZnWriteResPair<WriteIDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
243 defm : ZnWriteResPair<WriteIDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
244 defm : ZnWriteResPair<WriteIDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
245 defm : ZnWriteResPair<WriteIDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
248 def ZnWriteIMulH : WriteRes<WriteIMulH, [ZnMultiplier]>{
252 def : WriteRes<WriteIMulHLd, [ZnMultiplier]> {
253 let Latency = !add(ZnWriteIMulH.Latency, Znver1Model.LoadLatency);
254 let NumMicroOps = ZnWriteIMulH.NumMicroOps;
257 // Floating point operations
258 defm : X86WriteRes<WriteFLoad, [ZnAGU], 8, [1], 1>;
259 defm : X86WriteRes<WriteFLoadX, [ZnAGU], 8, [1], 1>;
260 defm : X86WriteRes<WriteFLoadY, [ZnAGU], 8, [1], 1>;
261 defm : X86WriteRes<WriteFMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,1], 1>;
262 defm : X86WriteRes<WriteFMaskedLoadY, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
264 defm : X86WriteRes<WriteFStore, [ZnAGU], 1, [1], 1>;
265 defm : X86WriteRes<WriteFStoreX, [ZnAGU], 1, [1], 1>;
266 defm : X86WriteRes<WriteFStoreY, [ZnAGU], 1, [1], 1>;
267 defm : X86WriteRes<WriteFStoreNT, [ZnAGU,ZnFPU2], 8, [1,1], 1>;
268 defm : X86WriteRes<WriteFStoreNTX, [ZnAGU], 1, [1], 1>;
269 defm : X86WriteRes<WriteFStoreNTY, [ZnAGU], 1, [1], 1>;
270 defm : X86WriteRes<WriteFMaskedStore32, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
271 defm : X86WriteRes<WriteFMaskedStore32Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
272 defm : X86WriteRes<WriteFMaskedStore64, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
273 defm : X86WriteRes<WriteFMaskedStore64Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
275 defm : X86WriteRes<WriteFMove, [ZnFPU], 1, [1], 1>;
276 defm : X86WriteRes<WriteFMoveX, [ZnFPU], 1, [1], 1>;
277 defm : X86WriteRes<WriteFMoveY, [ZnFPU], 1, [1], 1>;
278 defm : X86WriteResUnsupported<WriteFMoveZ>;
280 defm : ZnWriteResFpuPair<WriteFAdd, [ZnFPU23], 3>;
281 defm : ZnWriteResFpuPair<WriteFAddX, [ZnFPU23], 3>;
282 defm : ZnWriteResFpuPair<WriteFAddY, [ZnFPU23], 3, [2], 2>;
283 defm : X86WriteResPairUnsupported<WriteFAddZ>;
284 defm : ZnWriteResFpuPair<WriteFAdd64, [ZnFPU23], 3>;
285 defm : ZnWriteResFpuPair<WriteFAdd64X, [ZnFPU23], 3>;
286 defm : ZnWriteResFpuPair<WriteFAdd64Y, [ZnFPU23], 3, [2], 2>;
287 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
288 defm : ZnWriteResFpuPair<WriteFCmp, [ZnFPU01], 1>;
289 defm : ZnWriteResFpuPair<WriteFCmpX, [ZnFPU01], 1>;
290 defm : ZnWriteResFpuPair<WriteFCmpY, [ZnFPU01], 1, [2], 2>;
291 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
292 defm : ZnWriteResFpuPair<WriteFCmp64, [ZnFPU01], 1>;
293 defm : ZnWriteResFpuPair<WriteFCmp64X, [ZnFPU01], 1>;
294 defm : ZnWriteResFpuPair<WriteFCmp64Y, [ZnFPU01], 1, [2], 2>;
295 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
296 defm : ZnWriteResFpuPair<WriteFCom, [ZnFPU01,ZnFPU2], 3, [1,1], 2>;
297 defm : ZnWriteResFpuPair<WriteFComX, [ZnFPU01,ZnFPU2], 3, [1,1], 2>;
298 defm : ZnWriteResFpuPair<WriteFBlend, [ZnFPU01], 1>;
299 defm : ZnWriteResFpuPair<WriteFBlendY, [ZnFPU01], 1>;
300 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
301 defm : ZnWriteResFpuPair<WriteFVarBlend, [ZnFPU01], 1>;
302 defm : ZnWriteResFpuPair<WriteFVarBlendY,[ZnFPU01], 1, [2], 2>;
303 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
304 defm : ZnWriteResFpuPair<WriteCvtSS2I, [ZnFPU3], 5>;
305 defm : ZnWriteResFpuPair<WriteCvtPS2I, [ZnFPU3], 5>;
306 defm : ZnWriteResFpuPair<WriteCvtPS2IY, [ZnFPU3], 5>;
307 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
308 defm : ZnWriteResFpuPair<WriteCvtSD2I, [ZnFPU3], 5>;
309 defm : ZnWriteResFpuPair<WriteCvtPD2I, [ZnFPU3], 5>;
310 defm : ZnWriteResFpuPair<WriteCvtPD2IY, [ZnFPU3], 5>;
311 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
312 defm : ZnWriteResFpuPair<WriteCvtI2SS, [ZnFPU3], 5>;
313 defm : ZnWriteResFpuPair<WriteCvtI2PS, [ZnFPU3], 5>;
314 defm : ZnWriteResFpuPair<WriteCvtI2PSY, [ZnFPU3], 5>;
315 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
316 defm : ZnWriteResFpuPair<WriteCvtI2SD, [ZnFPU3], 5>;
317 defm : ZnWriteResFpuPair<WriteCvtI2PD, [ZnFPU3], 5>;
318 defm : ZnWriteResFpuPair<WriteCvtI2PDY, [ZnFPU3], 5>;
319 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
320 defm : ZnWriteResFpuPair<WriteFDiv, [ZnFPU3], 10, [3]>;
321 defm : ZnWriteResFpuPair<WriteFDivX, [ZnFPU3], 10, [3]>;
322 defm : ZnWriteResFpuPair<WriteFDivY, [ZnFPU3], 10, [6], 2>;
323 defm : X86WriteResPairUnsupported<WriteFDivZ>;
324 defm : ZnWriteResFpuPair<WriteFDiv64, [ZnFPU3], 13, [5]>;
325 defm : ZnWriteResFpuPair<WriteFDiv64X, [ZnFPU3], 13, [5]>;
326 defm : ZnWriteResFpuPair<WriteFDiv64Y, [ZnFPU3], 15, [9], 2>;
327 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
328 defm : ZnWriteResFpuPair<WriteFSign, [ZnFPU3], 2>;
329 defm : ZnWriteResFpuPair<WriteFRnd, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
330 defm : ZnWriteResFpuPair<WriteFRndY, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
331 defm : X86WriteResPairUnsupported<WriteFRndZ>;
332 defm : ZnWriteResFpuPair<WriteFLogic, [ZnFPU], 1>;
333 defm : ZnWriteResFpuPair<WriteFLogicY, [ZnFPU], 1, [2], 2>;
334 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
335 defm : ZnWriteResFpuPair<WriteFTest, [ZnFPU12], 2, [2], 1, 7, 1>;
336 defm : ZnWriteResFpuPair<WriteFTestY, [ZnFPU12], 4, [4], 3, 7, 2>;
337 defm : X86WriteResPairUnsupported<WriteFTestZ>;
338 defm : ZnWriteResFpuPair<WriteFShuffle, [ZnFPU12], 1>;
339 defm : ZnWriteResFpuPair<WriteFShuffleY, [ZnFPU12], 1, [2], 2>;
340 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
341 defm : ZnWriteResFpuPair<WriteFVarShuffle, [ZnFPU12], 1>;
342 defm : ZnWriteResFpuPair<WriteFVarShuffleY,[ZnFPU12], 1, [2], 2>;
343 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
344 defm : ZnWriteResFpuPair<WriteFMul, [ZnFPU01], 3>;
345 defm : ZnWriteResFpuPair<WriteFMulX, [ZnFPU01], 3>;
346 defm : ZnWriteResFpuPair<WriteFMulY, [ZnFPU01], 3, [2], 2>;
347 defm : X86WriteResPairUnsupported<WriteFMulZ>;
348 defm : ZnWriteResFpuPair<WriteFMul64, [ZnFPU01], 4>;
349 defm : ZnWriteResFpuPair<WriteFMul64X, [ZnFPU01], 4>;
350 defm : ZnWriteResFpuPair<WriteFMul64Y, [ZnFPU01], 4, [2], 2>;
351 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
352 defm : ZnWriteResFpuPair<WriteFMA, [ZnFPU01], 5>;
353 defm : ZnWriteResFpuPair<WriteFMAX, [ZnFPU01], 5>;
354 defm : ZnWriteResFpuPair<WriteFMAY, [ZnFPU01], 5, [2], 2>;
355 defm : X86WriteResPairUnsupported<WriteFMAZ>;
356 defm : ZnWriteResFpuPair<WriteFRcp, [ZnFPU01], 5>;
357 defm : ZnWriteResFpuPair<WriteFRcpX, [ZnFPU01], 5>;
358 defm : ZnWriteResFpuPair<WriteFRcpY, [ZnFPU01], 5, [2], 2>;
359 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
360 defm : ZnWriteResFpuPair<WriteFRsqrt, [ZnFPU01], 5>;
361 defm : ZnWriteResFpuPair<WriteFRsqrtX, [ZnFPU01], 5>;
362 defm : ZnWriteResFpuPair<WriteFRsqrtY, [ZnFPU01], 5, [2], 2>;
363 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
364 defm : ZnWriteResFpuPair<WriteFSqrt, [ZnFPU3], 14, [5]>;
365 defm : ZnWriteResFpuPair<WriteFSqrtX, [ZnFPU3], 14, [5]>;
366 defm : ZnWriteResFpuPair<WriteFSqrtY, [ZnFPU3], 14, [10], 2>;
367 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
368 defm : ZnWriteResFpuPair<WriteFSqrt64, [ZnFPU3], 20, [8]>;
369 defm : ZnWriteResFpuPair<WriteFSqrt64X, [ZnFPU3], 20, [8]>;
370 defm : ZnWriteResFpuPair<WriteFSqrt64Y, [ZnFPU3], 20, [16], 2>;
371 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
372 defm : ZnWriteResFpuPair<WriteFSqrt80, [ZnFPU3], 20, [20]>;
373 defm : ZnWriteResFpuPair<WriteFShuffle256, [ZnFPU12], 2, [2], 2>;
374 defm : ZnWriteResFpuPair<WriteFVarShuffle256, [ZnFPU12], 2, [2], 2>;
376 // Vector integer operations which uses FPU units
377 defm : X86WriteRes<WriteVecLoad, [ZnAGU], 8, [1], 1>;
378 defm : X86WriteRes<WriteVecLoadX, [ZnAGU], 8, [1], 1>;
379 defm : X86WriteRes<WriteVecLoadY, [ZnAGU], 8, [1], 1>;
380 defm : X86WriteRes<WriteVecLoadNT, [ZnAGU], 8, [1], 1>;
381 defm : X86WriteRes<WriteVecLoadNTY, [ZnAGU], 8, [1], 1>;
382 defm : X86WriteRes<WriteVecMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
383 defm : X86WriteRes<WriteVecMaskedLoadY, [ZnAGU,ZnFPU01], 9, [1,3], 2>;
384 defm : X86WriteRes<WriteVecStore, [ZnAGU], 1, [1], 1>;
385 defm : X86WriteRes<WriteVecStoreX, [ZnAGU], 1, [1], 1>;
386 defm : X86WriteRes<WriteVecStoreY, [ZnAGU], 1, [1], 1>;
387 defm : X86WriteRes<WriteVecStoreNT, [ZnAGU], 1, [1], 1>;
388 defm : X86WriteRes<WriteVecStoreNTY, [ZnAGU], 1, [1], 1>;
389 defm : X86WriteRes<WriteVecMaskedStore32, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
390 defm : X86WriteRes<WriteVecMaskedStore32Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
391 defm : X86WriteRes<WriteVecMaskedStore64, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
392 defm : X86WriteRes<WriteVecMaskedStore64Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
393 defm : X86WriteRes<WriteVecMove, [ZnFPU], 1, [1], 1>;
394 defm : X86WriteRes<WriteVecMoveX, [ZnFPU], 1, [1], 1>;
395 defm : X86WriteRes<WriteVecMoveY, [ZnFPU], 2, [1], 2>;
396 defm : X86WriteResUnsupported<WriteVecMoveZ>;
397 defm : X86WriteRes<WriteVecMoveToGpr, [ZnFPU2], 2, [1], 1>;
398 defm : X86WriteRes<WriteVecMoveFromGpr, [ZnFPU2], 3, [1], 1>;
399 defm : X86WriteRes<WriteEMMS, [ZnFPU], 2, [1], 1>;
401 defm : ZnWriteResFpuPair<WriteVecShift, [ZnFPU2], 1>;
402 defm : ZnWriteResFpuPair<WriteVecShiftX, [ZnFPU2], 1>;
403 defm : ZnWriteResFpuPair<WriteVecShiftY, [ZnFPU2], 1, [2], 2>;
404 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
405 defm : ZnWriteResFpuPair<WriteVecShiftImm, [ZnFPU2], 1>;
406 defm : ZnWriteResFpuPair<WriteVecShiftImmX, [ZnFPU2], 1>;
407 defm : ZnWriteResFpuPair<WriteVecShiftImmY, [ZnFPU2], 1, [2], 2>;
408 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
409 defm : ZnWriteResFpuPair<WriteVarVecShift, [ZnFPU1], 3, [2], 1>;
410 defm : ZnWriteResFpuPair<WriteVarVecShiftY, [ZnFPU1], 3, [4], 2>;
411 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
412 defm : ZnWriteResFpuPair<WriteVecLogic, [ZnFPU], 1>;
413 defm : ZnWriteResFpuPair<WriteVecLogicX, [ZnFPU], 1>;
414 defm : ZnWriteResFpuPair<WriteVecLogicY, [ZnFPU], 1, [2], 2>;
415 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
416 defm : ZnWriteResFpuPair<WriteVecTest, [ZnFPU12], 2, [2], 1, 7, 1>;
417 defm : ZnWriteResFpuPair<WriteVecTestY, [ZnFPU12], 4, [4], 3, 7, 2>;
418 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
419 defm : ZnWriteResFpuPair<WriteVecALU, [ZnFPU013], 1>;
420 defm : ZnWriteResFpuPair<WriteVecALUX, [ZnFPU013], 1>;
421 defm : ZnWriteResFpuPair<WriteVecALUY, [ZnFPU013], 1, [2], 2>;
422 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
423 defm : ZnWriteResFpuPair<WriteVecIMul, [ZnFPU0], 4>;
424 defm : ZnWriteResFpuPair<WriteVecIMulX, [ZnFPU0], 4>;
425 defm : ZnWriteResFpuPair<WriteVecIMulY, [ZnFPU0], 4, [2], 2>;
426 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
427 defm : ZnWriteResFpuPair<WritePMULLD, [ZnFPU0], 4, [2]>;
428 defm : ZnWriteResFpuPair<WritePMULLDY, [ZnFPU0], 4, [4], 2>;
429 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
430 defm : ZnWriteResFpuPair<WriteShuffle, [ZnFPU12], 1>;
431 defm : ZnWriteResFpuPair<WriteShuffleX, [ZnFPU12], 1>;
432 defm : ZnWriteResFpuPair<WriteShuffleY, [ZnFPU12], 1, [2], 2>;
433 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
434 defm : ZnWriteResFpuPair<WriteVarShuffle, [ZnFPU12], 1>;
435 defm : ZnWriteResFpuPair<WriteVarShuffleX,[ZnFPU12], 1>;
436 defm : ZnWriteResFpuPair<WriteVarShuffleY,[ZnFPU12], 1, [2], 2>;
437 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
438 defm : ZnWriteResFpuPair<WriteBlend, [ZnFPU013], 1>;
439 defm : ZnWriteResFpuPair<WriteBlendY, [ZnFPU013], 1, [2], 2>;
440 defm : X86WriteResPairUnsupported<WriteBlendZ>;
441 defm : ZnWriteResFpuPair<WriteVarBlend, [ZnFPU0], 1>;
442 defm : ZnWriteResFpuPair<WriteVarBlendY, [ZnFPU0], 1, [2], 2>;
443 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
444 defm : ZnWriteResFpuPair<WriteShuffle256, [ZnFPU12], 2, [2], 2>;
445 defm : ZnWriteResFpuPair<WriteVPMOV256, [ZnFPU12], 1, [4], 3>;
446 defm : ZnWriteResFpuPair<WriteVarShuffle256, [ZnFPU12],2, [2], 2>;
447 defm : ZnWriteResFpuPair<WritePSADBW, [ZnFPU0], 3>;
448 defm : ZnWriteResFpuPair<WritePSADBWX, [ZnFPU0], 3>;
449 defm : ZnWriteResFpuPair<WritePSADBWY, [ZnFPU0], 3, [2], 2>;
450 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
451 defm : ZnWriteResFpuPair<WritePHMINPOS, [ZnFPU0], 4>;
453 // Vector insert/extract operations.
454 defm : ZnWriteResFpuPair<WriteVecInsert, [ZnFPU], 1>;
456 def : WriteRes<WriteVecExtract, [ZnFPU12, ZnFPU2]> {
458 let ReleaseAtCycles = [1, 2];
460 def : WriteRes<WriteVecExtractSt, [ZnAGU, ZnFPU12, ZnFPU2]> {
463 let ReleaseAtCycles = [1, 2, 3];
466 // MOVMSK Instructions.
467 def : WriteRes<WriteFMOVMSK, [ZnFPU2]>;
468 def : WriteRes<WriteMMXMOVMSK, [ZnFPU2]>;
469 def : WriteRes<WriteVecMOVMSK, [ZnFPU2]>;
471 def : WriteRes<WriteVecMOVMSKY, [ZnFPU2]> {
474 let ReleaseAtCycles = [2];
478 defm : ZnWriteResFpuPair<WriteAESDecEnc, [ZnFPU01], 4>;
479 defm : ZnWriteResFpuPair<WriteAESIMC, [ZnFPU01], 4>;
480 defm : ZnWriteResFpuPair<WriteAESKeyGen, [ZnFPU01], 4>;
482 def : WriteRes<WriteFence, [ZnAGU]>;
483 def : WriteRes<WriteNop, []>;
485 // Microcoded Instructions
486 def ZnWriteMicrocoded : SchedWriteRes<[]> {
490 def : SchedAlias<WriteMicrocoded, ZnWriteMicrocoded>;
491 def : SchedAlias<WriteFCMOV, ZnWriteMicrocoded>;
492 def : SchedAlias<WriteSystem, ZnWriteMicrocoded>;
493 def : SchedAlias<WriteMPSAD, ZnWriteMicrocoded>;
494 def : SchedAlias<WriteMPSADY, ZnWriteMicrocoded>;
495 def : SchedAlias<WriteMPSADLd, ZnWriteMicrocoded>;
496 def : SchedAlias<WriteMPSADYLd, ZnWriteMicrocoded>;
497 def : SchedAlias<WriteCLMul, ZnWriteMicrocoded>;
498 def : SchedAlias<WriteCLMulLd, ZnWriteMicrocoded>;
499 def : SchedAlias<WritePCmpIStrM, ZnWriteMicrocoded>;
500 def : SchedAlias<WritePCmpIStrMLd, ZnWriteMicrocoded>;
501 def : SchedAlias<WritePCmpEStrI, ZnWriteMicrocoded>;
502 def : SchedAlias<WritePCmpEStrILd, ZnWriteMicrocoded>;
503 def : SchedAlias<WritePCmpEStrM, ZnWriteMicrocoded>;
504 def : SchedAlias<WritePCmpEStrMLd, ZnWriteMicrocoded>;
505 def : SchedAlias<WritePCmpIStrI, ZnWriteMicrocoded>;
506 def : SchedAlias<WritePCmpIStrILd, ZnWriteMicrocoded>;
507 def : SchedAlias<WriteLDMXCSR, ZnWriteMicrocoded>;
508 def : SchedAlias<WriteSTMXCSR, ZnWriteMicrocoded>;
510 //=== Regex based InstRW ===//
515 // - mm: 64 bit mmx register.
516 // - x = 128 bit xmm register.
517 // - (x)mm = mmx or xmm register.
518 // - y = 256 bit ymm register.
519 // - v = any vector register.
521 //=== Integer Instructions ===//
522 //-- Move instructions --//
525 def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>;
529 def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> {
533 def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>;
535 def : InstRW<[WriteMicrocoded], (instrs XLAT)>;
539 def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{
543 def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>;
544 def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>;
545 def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>;
549 // r. Has default values.
551 def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{
554 def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>;
557 def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
560 def ZnWritePushA : SchedWriteRes<[ZnAGU]> {
563 def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>;
566 def : InstRW<[WriteMicrocoded], (instrs LAHF)>;
570 def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> {
573 def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>;
576 def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>;
578 //-- Arithmetic instructions --//
582 def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)",
583 "(ADD|SUB)(8|16|32|64)mi8",
588 def : InstRW<[WriteALULd],
589 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)",
590 "(ADC|SBB)(16|32|64)mi8",
595 def : InstRW<[WriteALULd],
596 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>;
600 def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
603 def : SchedAlias<WriteIMul16, ZnWriteMul16>;
604 def : SchedAlias<WriteIMul16Imm, ZnWriteMul16>; // TODO: is this right?
605 def : SchedAlias<WriteIMul16Reg, ZnWriteMul16>; // TODO: is this right?
608 def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
611 def : SchedAlias<WriteIMul16Ld, ZnWriteMul16Ld>;
612 def : SchedAlias<WriteIMul16ImmLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
613 def : SchedAlias<WriteIMul16RegLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
615 def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
618 def : SchedAlias<WriteIMul32, ZnWriteMul32>;
619 def : SchedAlias<WriteIMul32Imm, ZnWriteMul32>; // TODO: is this right?
620 def : SchedAlias<WriteIMul32Reg, ZnWriteMul32>; // TODO: is this right?
623 def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
626 def : SchedAlias<WriteIMul32Ld, ZnWriteMul32Ld>;
627 def : SchedAlias<WriteIMul32ImmLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
628 def : SchedAlias<WriteIMul32RegLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
631 def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
635 def : SchedAlias<WriteIMul64, ZnWriteMul64>;
636 def : SchedAlias<WriteIMul64Imm, ZnWriteMul64>; // TODO: is this right?
637 def : SchedAlias<WriteIMul64Reg, ZnWriteMul64>; // TODO: is this right?
640 def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
644 def : SchedAlias<WriteIMul64Ld, ZnWriteMul64Ld>;
645 def : SchedAlias<WriteIMul64ImmLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
646 def : SchedAlias<WriteIMul64RegLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
649 // Numbers are based on the AMD SOG for Family 17h - Instruction Latencies.
650 defm : ZnWriteResPair<WriteMULX32, [ZnALU1, ZnMultiplier], 3, [1, 1], 1, 5, 0>;
651 defm : ZnWriteResPair<WriteMULX64, [ZnALU1, ZnMultiplier], 3, [1, 1], 1, 5, 0>;
653 //-- Control transfer instructions --//
656 def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>;
657 def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>;
660 def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>;
661 def : InstRW<[ZnWriteLOOP], (instrs LOOP)>;
663 // LOOP(N)E, LOOP(N)Z
664 def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>;
665 def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>;
669 def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>;
670 def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>;
672 def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>;
675 def ZnWriteRET : SchedWriteRes<[ZnALU03]> {
678 def : InstRW<[ZnWriteRET], (instregex "RET(16|32|64)", "LRET(16|32|64)",
681 //-- Logic instructions --//
685 def : InstRW<[WriteALULd],
686 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)",
687 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>;
689 // Define ALU latency variants
690 def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> {
693 def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> {
699 def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> {
704 def : SchedAlias<WriteBitTestSetImmRMW, ZnWriteBTRSCm>;
705 def : SchedAlias<WriteBitTestSetRegRMW, ZnWriteBTRSCm>;
709 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>;
711 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>;
715 def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>;
719 def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>;
723 def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>;
726 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>;
729 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>;
731 //-- Misc instructions --//
733 def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> {
734 let NumMicroOps = 18;
736 def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>;
738 def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>;
741 def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> {
745 def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>;
748 def : InstRW<[WriteMicrocoded], (instrs PAUSE)>;
751 def ZnXADD : SchedWriteRes<[ZnALU]>;
752 def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>;
753 def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>;
755 //=== Floating Point x87 Instructions ===//
756 //-- Move instructions --//
758 def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ;
760 def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> {
767 def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>;
770 def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> {
773 def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>;
777 def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>;
780 def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> {
783 def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>;
785 def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>;
788 def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>;
791 def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> {
795 def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>;
798 def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> {
801 def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>;
803 def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> {
807 def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> {
812 def : SchedAlias<WriteFLD0, ZnWriteFPU13>;
815 def : SchedAlias<WriteFLD1, ZnWriteFPU3>;
818 def : SchedAlias<WriteFLDC, ZnWriteFPU3>;
822 def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>;
825 def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>;
828 def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>;
831 def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>;
834 def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>;
836 //-- Arithmetic instructions --//
838 def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ;
840 def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ;
842 def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> {
847 def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>;
851 def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>;
853 def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>;
857 def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>;
859 def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]>
864 // FCOMI(P) FUCOMI(P).
866 def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
868 def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]>
872 let ReleaseAtCycles = [1,3];
876 def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>;
879 def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>;
882 def : InstRW<[ZnWriteFPU3Lat1], (instrs XAM_F)>;
885 def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>;
888 def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>;
890 //=== Integer MMX and XMM Instructions ===//
892 def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ;
893 def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> {
898 def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ;
899 def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> {
905 def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>;
907 def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>;
910 def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> {
913 let ReleaseAtCycles = [1, 2];
915 def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> {
918 let ReleaseAtCycles = [1, 3];
920 def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>;
921 def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>;
924 def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>;
927 def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>;
931 def : InstRW<[WriteMicrocoded],
932 (instregex "VPMASKMOVD(Y?)rm")>;
934 def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>;
938 def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
941 let ReleaseAtCycles = [1, 2];
943 def : InstRW<[ZnWriteVPBROADCAST128Ld],
944 (instregex "VPBROADCAST(B|W)rm")>;
947 def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
950 let ReleaseAtCycles = [1, 2];
952 def : InstRW<[ZnWriteVPBROADCAST256Ld],
953 (instregex "VPBROADCAST(B|W)Yrm")>;
956 def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>;
958 //-- Arithmetic instructions --//
961 // PHADD|PHSUB (S) W/D.
962 defm : ZnWriteResFpuPair<WriteFHAdd, [], 7>;
963 defm : ZnWriteResFpuPair<WriteFHAddY, [], 7>;
964 defm : ZnWriteResFpuPair<WritePHAdd, [], 3>;
965 defm : ZnWriteResFpuPair<WritePHAddX, [], 3>;
966 defm : ZnWriteResFpuPair<WritePHAddY, [], 3>;
969 def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>;
970 def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>;
973 def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
977 def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
980 let ReleaseAtCycles = [1,2];
982 def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>;
983 def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>;
985 //=== Floating Point XMM and YMM Instructions ===//
986 //-- Move instructions --//
988 // VPERM2F128 / VPERM2I128.
989 def ZnWriteVPERM2r : SchedWriteRes<[ZnFPU0, ZnFPU12]> {
992 let ReleaseAtCycles = [3,3];
994 def : InstRW<[ZnWriteVPERM2r], (instrs VPERM2F128rri,
997 def ZnWriteVPERM2m : SchedWriteRes<[ZnAGU, ZnFPU0, ZnFPU12]> {
998 let NumMicroOps = 12;
1000 let ReleaseAtCycles = [1,3,3];
1002 def : InstRW<[ZnWriteVPERM2m], (instrs VPERM2F128rmi,
1005 def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> {
1006 let NumMicroOps = 2;
1009 // VBROADCASTF128 / VBROADCASTI128.
1010 def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128rm,
1015 def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1017 let NumMicroOps = 2;
1018 let ReleaseAtCycles = [1, 2];
1020 def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrri")>;
1022 def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> {
1024 let NumMicroOps = 2;
1025 let ReleaseAtCycles = [5, 1, 2];
1028 def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmri")>;
1030 // VEXTRACTF128 / VEXTRACTI128.
1032 def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rri,
1036 def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mri,
1039 def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> {
1041 let ReleaseAtCycles = [2];
1043 def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> {
1045 let NumMicroOps = 2;
1046 let ReleaseAtCycles = [1, 2];
1048 // VINSERTF128 / VINSERTI128.
1050 def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rri,
1052 def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rmi,
1056 def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>;
1058 //-- Conversion instructions --//
1059 def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> {
1062 def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> {
1064 let NumMicroOps = 2;
1065 let ReleaseAtCycles = [2];
1070 def : SchedAlias<WriteCvtPD2PS, ZnWriteCVTPD2PSr>;
1072 def : SchedAlias<WriteCvtPD2PSY, ZnWriteCVTPD2PSYr>;
1074 defm : X86WriteResUnsupported<WriteCvtPD2PSZ>;
1076 def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU3]> {
1080 def : SchedAlias<WriteCvtPD2PSLd, ZnWriteCVTPD2PSLd>;
1083 def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1085 let NumMicroOps = 2;
1086 let ReleaseAtCycles = [1,2];
1088 def : SchedAlias<WriteCvtPD2PSYLd, ZnWriteCVTPD2PSYLd>;
1090 defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>;
1094 // Same as WriteCVTPD2PSr
1095 def : SchedAlias<WriteCvtSD2SS, ZnWriteCVTPD2PSr>;
1098 def : SchedAlias<WriteCvtSD2SSLd, ZnWriteCVTPD2PSLd>;
1102 def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> {
1105 def : SchedAlias<WriteCvtPS2PD, ZnWriteCVTPS2PDr>;
1109 def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1111 let NumMicroOps = 2;
1113 def : SchedAlias<WriteCvtPS2PDLd, ZnWriteCVTPS2PDLd>;
1114 def : SchedAlias<WriteCvtPS2PDYLd, ZnWriteCVTPS2PDLd>;
1115 defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>;
1118 def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> {
1121 def : SchedAlias<WriteCvtPS2PDY, ZnWriteVCVTPS2PDY>;
1122 defm : X86WriteResUnsupported<WriteCvtPS2PDZ>;
1126 def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> {
1129 def : SchedAlias<WriteCvtSS2SD, ZnWriteCVTSS2SDr>;
1132 def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1134 let NumMicroOps = 2;
1135 let ReleaseAtCycles = [1, 2];
1137 def : SchedAlias<WriteCvtSS2SDLd, ZnWriteCVTSS2SDLd>;
1139 def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> {
1144 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>;
1148 def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>;
1150 def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> {
1155 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)PD2DQrr")>;
1157 def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> {
1159 let NumMicroOps = 2;
1162 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>;
1163 // same as xmm handling
1165 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>;
1167 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>;
1169 def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> {
1174 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIrr")>;
1178 def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDrr)>;
1182 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIrr")>;
1184 def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> {
1188 // same as CVTPD2DQr
1191 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>;
1192 // same as CVTPD2DQm
1194 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>;
1196 def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> {
1201 def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>;
1204 def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> {
1207 def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> {
1212 def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>;
1214 def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>;
1218 def : SchedAlias<WriteCvtPS2PH, ZnWriteMicrocoded>;
1219 def : SchedAlias<WriteCvtPS2PHY, ZnWriteMicrocoded>;
1220 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
1222 def : SchedAlias<WriteCvtPS2PHSt, ZnWriteMicrocoded>;
1223 def : SchedAlias<WriteCvtPS2PHYSt, ZnWriteMicrocoded>;
1224 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
1228 def : SchedAlias<WriteCvtPH2PS, ZnWriteMicrocoded>;
1229 def : SchedAlias<WriteCvtPH2PSY, ZnWriteMicrocoded>;
1230 defm : X86WriteResUnsupported<WriteCvtPH2PSZ>;
1232 def : SchedAlias<WriteCvtPH2PSLd, ZnWriteMicrocoded>;
1233 def : SchedAlias<WriteCvtPH2PSYLd, ZnWriteMicrocoded>;
1234 defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>;
1236 //-- SSE4A instructions --//
1238 def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1241 def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>;
1244 def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> {
1247 def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>;
1249 //-- SHA instructions --//
1251 def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>;
1253 // SHA1MSG1, SHA256MSG1
1255 def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> {
1257 let ReleaseAtCycles = [2];
1259 def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>;
1261 def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1263 let ReleaseAtCycles = [1,2];
1265 def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>;
1269 def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ;
1270 def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>;
1272 def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1275 def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>;
1279 def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ;
1280 def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>;
1282 def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1285 def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>;
1289 def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> {
1292 def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>;
1294 def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1297 def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>;
1301 def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> {
1304 def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>;
1306 def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1309 def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>;
1311 //-- Arithmetic instructions --//
1315 def : SchedAlias<WriteDPPS, ZnWriteMicrocoded>;
1316 def : SchedAlias<WriteDPPSY, ZnWriteMicrocoded>;
1319 def : SchedAlias<WriteDPPSLd, ZnWriteMicrocoded>;
1320 def : SchedAlias<WriteDPPSYLd,ZnWriteMicrocoded>;
1324 def : SchedAlias<WriteDPPD, ZnWriteMicrocoded>;
1327 def : SchedAlias<WriteDPPDLd, ZnWriteMicrocoded>;
1329 ///////////////////////////////////////////////////////////////////////////////
1330 // Dependency breaking instructions.
1331 ///////////////////////////////////////////////////////////////////////////////
1333 def : IsZeroIdiomFunction<[
1338 ], ZeroIdiomPredicate>,
1342 MMX_PXORrr, MMX_PANDNrr, MMX_PSUBBrr,
1343 MMX_PSUBDrr, MMX_PSUBQrr, MMX_PSUBWrr,
1344 MMX_PSUBSBrr, MMX_PSUBSWrr, MMX_PSUBUSBrr, MMX_PSUBUSWrr,
1345 MMX_PCMPGTBrr, MMX_PCMPGTDrr, MMX_PCMPGTWrr
1346 ], ZeroIdiomPredicate>,
1351 XORPSrr, XORPDrr, ANDNPSrr, ANDNPDrr,
1355 PSUBBrr, PSUBWrr, PSUBDrr, PSUBQrr,
1356 PCMPGTBrr, PCMPGTDrr, PCMPGTQrr, PCMPGTWrr
1357 ], ZeroIdiomPredicate>,
1359 // AVX XMM Zero-idioms.
1362 VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr,
1366 VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr,
1367 VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr
1368 ], ZeroIdiomPredicate>,
1370 // AVX YMM Zero-idioms.
1373 VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr,
1376 VPXORYrr, VPANDNYrr,
1377 VPSUBBYrr, VPSUBWYrr, VPSUBDYrr, VPSUBQYrr,
1378 VPCMPGTBYrr, VPCMPGTWYrr, VPCMPGTDYrr, VPCMPGTQYrr
1379 ], ZeroIdiomPredicate>
1382 def : IsDepBreakingFunction<[
1384 DepBreakingClass<[ SBB32rr, SBB64rr ], ZeroIdiomPredicate>,
1385 DepBreakingClass<[ CMP32rr, CMP64rr ], CheckSameRegOperand<0, 1> >,
1389 MMX_PCMPEQBrr, MMX_PCMPEQWrr, MMX_PCMPEQDrr
1390 ], ZeroIdiomPredicate>,
1394 PCMPEQBrr, PCMPEQWrr, PCMPEQDrr, PCMPEQQrr
1395 ], ZeroIdiomPredicate>,
1399 VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr, VPCMPEQQrr
1400 ], ZeroIdiomPredicate>,
1404 VPCMPEQBYrr, VPCMPEQWYrr, VPCMPEQDYrr, VPCMPEQQYrr
1405 ], ZeroIdiomPredicate>,