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 ResourceCycles = 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 ResourceCycles = !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 ResourceCycles = 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 ResourceCycles = !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 = 8; }
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>;
192 //defm : ZnWriteResPair<WriteIMul16, [ZnALU1, ZnMultiplier], 4>;
193 //defm : ZnWriteResPair<WriteIMul16Imm, [ZnALU1, ZnMultiplier], 4>;
194 //defm : ZnWriteResPair<WriteIMul16Reg, [ZnALU1, ZnMultiplier], 4>;
195 //defm : ZnWriteResPair<WriteIMul32, [ZnALU1, ZnMultiplier], 4>;
196 //defm : ZnWriteResPair<WriteIMul32Imm, [ZnALU1, ZnMultiplier], 4>;
197 //defm : ZnWriteResPair<WriteIMul32Reg, [ZnALU1, ZnMultiplier], 4>;
198 //defm : ZnWriteResPair<WriteIMul64, [ZnALU1, ZnMultiplier], 4, [1,1], 2>;
199 //defm : ZnWriteResPair<WriteIMul64Imm, [ZnALU1, ZnMultiplier], 4, [1,1], 2>;
200 //defm : ZnWriteResPair<WriteIMul64Reg, [ZnALU1, ZnMultiplier], 4, [1,1], 2>;
202 defm : X86WriteRes<WriteBSWAP32, [ZnALU], 1, [4], 1>;
203 defm : X86WriteRes<WriteBSWAP64, [ZnALU], 1, [4], 1>;
204 defm : X86WriteRes<WriteCMPXCHG, [ZnALU], 1, [1], 1>;
205 defm : X86WriteRes<WriteCMPXCHGRMW,[ZnALU,ZnAGU], 8, [1,1], 5>;
206 defm : X86WriteRes<WriteXCHG, [ZnALU], 1, [2], 2>;
208 defm : ZnWriteResPair<WriteShift, [ZnALU], 1>;
209 defm : ZnWriteResPair<WriteShiftCL, [ZnALU], 1>;
210 defm : ZnWriteResPair<WriteRotate, [ZnALU], 1>;
211 defm : ZnWriteResPair<WriteRotateCL, [ZnALU], 1>;
213 defm : X86WriteRes<WriteSHDrri, [ZnALU], 1, [1], 1>;
214 defm : X86WriteResUnsupported<WriteSHDrrcl>;
215 defm : X86WriteResUnsupported<WriteSHDmri>;
216 defm : X86WriteResUnsupported<WriteSHDmrcl>;
218 defm : ZnWriteResPair<WriteJump, [ZnALU], 1>;
219 defm : ZnWriteResFpuPair<WriteCRC32, [ZnFPU0], 3>;
221 defm : ZnWriteResPair<WriteCMOV, [ZnALU], 1>;
222 def : WriteRes<WriteSETCC, [ZnALU]>;
223 def : WriteRes<WriteSETCCStore, [ZnALU, ZnAGU]>;
224 defm : X86WriteRes<WriteLAHFSAHF, [ZnALU], 2, [1], 2>;
226 defm : X86WriteRes<WriteBitTest, [ZnALU], 1, [1], 1>;
227 defm : X86WriteRes<WriteBitTestImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
228 defm : X86WriteRes<WriteBitTestRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
229 defm : X86WriteRes<WriteBitTestSet, [ZnALU], 2, [1], 2>;
230 //defm : X86WriteRes<WriteBitTestSetImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
231 //defm : X86WriteRes<WriteBitTestSetRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
234 defm : ZnWriteResPair<WriteBSF, [ZnALU], 3>;
235 defm : ZnWriteResPair<WriteBSR, [ZnALU], 3>;
236 defm : ZnWriteResPair<WriteLZCNT, [ZnALU], 2>;
237 defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2>;
238 defm : ZnWriteResPair<WritePOPCNT, [ZnALU], 1>;
240 // Treat misc copies as a move.
241 def : InstRW<[WriteMove], (instrs COPY)>;
243 // BMI1 BEXTR/BLS, BMI2 BZHI
244 defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1>;
245 //defm : ZnWriteResPair<WriteBLS, [ZnALU], 2>;
246 defm : ZnWriteResPair<WriteBZHI, [ZnALU], 1>;
249 defm : ZnWriteResPair<WriteDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
250 defm : ZnWriteResPair<WriteDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
251 defm : ZnWriteResPair<WriteDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
252 defm : ZnWriteResPair<WriteDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
253 defm : ZnWriteResPair<WriteIDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
254 defm : ZnWriteResPair<WriteIDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
255 defm : ZnWriteResPair<WriteIDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
256 defm : ZnWriteResPair<WriteIDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
259 def : WriteRes<WriteIMulH, [ZnMultiplier]>{
264 // Floating point operations
265 defm : X86WriteRes<WriteFLoad, [ZnAGU], 8, [1], 1>;
266 defm : X86WriteRes<WriteFLoadX, [ZnAGU], 8, [1], 1>;
267 defm : X86WriteRes<WriteFLoadY, [ZnAGU], 8, [1], 1>;
268 defm : X86WriteRes<WriteFMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,1], 1>;
269 defm : X86WriteRes<WriteFMaskedLoadY, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
270 defm : X86WriteRes<WriteFStore, [ZnAGU], 1, [1], 1>;
271 defm : X86WriteRes<WriteFStoreX, [ZnAGU], 1, [1], 1>;
272 defm : X86WriteRes<WriteFStoreY, [ZnAGU], 1, [1], 1>;
273 defm : X86WriteRes<WriteFStoreNT, [ZnAGU,ZnFPU2], 8, [1,1], 1>;
274 defm : X86WriteRes<WriteFStoreNTX, [ZnAGU], 1, [1], 1>;
275 defm : X86WriteRes<WriteFStoreNTY, [ZnAGU], 1, [1], 1>;
277 defm : X86WriteRes<WriteFMaskedStore32, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
278 defm : X86WriteRes<WriteFMaskedStore32Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
279 defm : X86WriteRes<WriteFMaskedStore64, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
280 defm : X86WriteRes<WriteFMaskedStore64Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
282 defm : X86WriteRes<WriteFMove, [ZnFPU], 1, [1], 1>;
283 defm : X86WriteRes<WriteFMoveX, [ZnFPU], 1, [1], 1>;
284 defm : X86WriteRes<WriteFMoveY, [ZnFPU], 1, [1], 1>;
286 defm : ZnWriteResFpuPair<WriteFAdd, [ZnFPU0], 3>;
287 defm : ZnWriteResFpuPair<WriteFAddX, [ZnFPU0], 3>;
288 defm : ZnWriteResFpuPair<WriteFAddY, [ZnFPU0], 3>;
289 defm : X86WriteResPairUnsupported<WriteFAddZ>;
290 defm : ZnWriteResFpuPair<WriteFAdd64, [ZnFPU0], 3>;
291 defm : ZnWriteResFpuPair<WriteFAdd64X, [ZnFPU0], 3>;
292 defm : ZnWriteResFpuPair<WriteFAdd64Y, [ZnFPU0], 3>;
293 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
294 defm : ZnWriteResFpuPair<WriteFCmp, [ZnFPU0], 3>;
295 defm : ZnWriteResFpuPair<WriteFCmpX, [ZnFPU0], 3>;
296 defm : ZnWriteResFpuPair<WriteFCmpY, [ZnFPU0], 3>;
297 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
298 defm : ZnWriteResFpuPair<WriteFCmp64, [ZnFPU0], 3>;
299 defm : ZnWriteResFpuPair<WriteFCmp64X, [ZnFPU0], 3>;
300 defm : ZnWriteResFpuPair<WriteFCmp64Y, [ZnFPU0], 3>;
301 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
302 defm : ZnWriteResFpuPair<WriteFCom, [ZnFPU0], 3>;
303 defm : ZnWriteResFpuPair<WriteFComX, [ZnFPU0], 3>;
304 defm : ZnWriteResFpuPair<WriteFBlend, [ZnFPU01], 1>;
305 defm : ZnWriteResFpuPair<WriteFBlendY, [ZnFPU01], 1>;
306 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
307 defm : ZnWriteResFpuPair<WriteFVarBlend, [ZnFPU01], 1>;
308 defm : ZnWriteResFpuPair<WriteFVarBlendY,[ZnFPU01], 1>;
309 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
310 defm : ZnWriteResFpuPair<WriteVarBlend, [ZnFPU0], 1>;
311 defm : ZnWriteResFpuPair<WriteVarBlendY, [ZnFPU0], 1>;
312 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
313 defm : ZnWriteResFpuPair<WriteCvtSS2I, [ZnFPU3], 5>;
314 defm : ZnWriteResFpuPair<WriteCvtPS2I, [ZnFPU3], 5>;
315 defm : ZnWriteResFpuPair<WriteCvtPS2IY, [ZnFPU3], 5>;
316 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
317 defm : ZnWriteResFpuPair<WriteCvtSD2I, [ZnFPU3], 5>;
318 defm : ZnWriteResFpuPair<WriteCvtPD2I, [ZnFPU3], 5>;
319 defm : ZnWriteResFpuPair<WriteCvtPD2IY, [ZnFPU3], 5>;
320 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
321 defm : ZnWriteResFpuPair<WriteCvtI2SS, [ZnFPU3], 5>;
322 defm : ZnWriteResFpuPair<WriteCvtI2PS, [ZnFPU3], 5>;
323 defm : ZnWriteResFpuPair<WriteCvtI2PSY, [ZnFPU3], 5>;
324 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
325 defm : ZnWriteResFpuPair<WriteCvtI2SD, [ZnFPU3], 5>;
326 defm : ZnWriteResFpuPair<WriteCvtI2PD, [ZnFPU3], 5>;
327 defm : ZnWriteResFpuPair<WriteCvtI2PDY, [ZnFPU3], 5>;
328 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
329 defm : ZnWriteResFpuPair<WriteFDiv, [ZnFPU3], 15>;
330 defm : ZnWriteResFpuPair<WriteFDivX, [ZnFPU3], 15>;
331 //defm : ZnWriteResFpuPair<WriteFDivY, [ZnFPU3], 15>;
332 defm : X86WriteResPairUnsupported<WriteFDivZ>;
333 defm : ZnWriteResFpuPair<WriteFDiv64, [ZnFPU3], 15>;
334 defm : ZnWriteResFpuPair<WriteFDiv64X, [ZnFPU3], 15>;
335 //defm : ZnWriteResFpuPair<WriteFDiv64Y, [ZnFPU3], 15>;
336 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
337 defm : ZnWriteResFpuPair<WriteFSign, [ZnFPU3], 2>;
338 defm : ZnWriteResFpuPair<WriteFRnd, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
339 defm : ZnWriteResFpuPair<WriteFRndY, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
340 defm : X86WriteResPairUnsupported<WriteFRndZ>;
341 defm : ZnWriteResFpuPair<WriteFLogic, [ZnFPU], 1>;
342 defm : ZnWriteResFpuPair<WriteFLogicY, [ZnFPU], 1>;
343 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
344 defm : ZnWriteResFpuPair<WriteFTest, [ZnFPU], 1>;
345 defm : ZnWriteResFpuPair<WriteFTestY, [ZnFPU], 1>;
346 defm : X86WriteResPairUnsupported<WriteFTestZ>;
347 defm : ZnWriteResFpuPair<WriteFShuffle, [ZnFPU12], 1>;
348 defm : ZnWriteResFpuPair<WriteFShuffleY, [ZnFPU12], 1>;
349 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
350 defm : ZnWriteResFpuPair<WriteFVarShuffle, [ZnFPU12], 1>;
351 defm : ZnWriteResFpuPair<WriteFVarShuffleY,[ZnFPU12], 1>;
352 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
353 defm : ZnWriteResFpuPair<WriteFMul, [ZnFPU01], 3, [1], 1, 7, 1>;
354 defm : ZnWriteResFpuPair<WriteFMulX, [ZnFPU01], 3, [1], 1, 7, 1>;
355 defm : ZnWriteResFpuPair<WriteFMulY, [ZnFPU01], 4, [1], 1, 7, 1>;
356 defm : X86WriteResPairUnsupported<WriteFMulZ>;
357 defm : ZnWriteResFpuPair<WriteFMul64, [ZnFPU01], 3, [1], 1, 7, 1>;
358 defm : ZnWriteResFpuPair<WriteFMul64X, [ZnFPU01], 3, [1], 1, 7, 1>;
359 defm : ZnWriteResFpuPair<WriteFMul64Y, [ZnFPU01], 4, [1], 1, 7, 1>;
360 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
361 defm : ZnWriteResFpuPair<WriteFMA, [ZnFPU03], 5>;
362 defm : ZnWriteResFpuPair<WriteFMAX, [ZnFPU03], 5>;
363 defm : ZnWriteResFpuPair<WriteFMAY, [ZnFPU03], 5>;
364 defm : X86WriteResPairUnsupported<WriteFMAZ>;
365 defm : ZnWriteResFpuPair<WriteFRcp, [ZnFPU01], 5>;
366 defm : ZnWriteResFpuPair<WriteFRcpX, [ZnFPU01], 5>;
367 defm : ZnWriteResFpuPair<WriteFRcpY, [ZnFPU01], 5, [1], 1, 7, 2>;
368 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
369 //defm : ZnWriteResFpuPair<WriteFRsqrt, [ZnFPU02], 5>;
370 defm : ZnWriteResFpuPair<WriteFRsqrtX, [ZnFPU01], 5, [1], 1, 7, 1>;
371 //defm : ZnWriteResFpuPair<WriteFRsqrtY, [ZnFPU01], 5, [2], 2>;
372 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
373 defm : ZnWriteResFpuPair<WriteFSqrt, [ZnFPU3], 20, [20]>;
374 defm : ZnWriteResFpuPair<WriteFSqrtX, [ZnFPU3], 20, [20]>;
375 defm : ZnWriteResFpuPair<WriteFSqrtY, [ZnFPU3], 28, [28], 1, 7, 1>;
376 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
377 defm : ZnWriteResFpuPair<WriteFSqrt64, [ZnFPU3], 20, [20]>;
378 defm : ZnWriteResFpuPair<WriteFSqrt64X, [ZnFPU3], 20, [20]>;
379 defm : ZnWriteResFpuPair<WriteFSqrt64Y, [ZnFPU3], 40, [40], 1, 7, 1>;
380 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
381 defm : ZnWriteResFpuPair<WriteFSqrt80, [ZnFPU3], 20, [20]>;
383 // Vector integer operations which uses FPU units
384 defm : X86WriteRes<WriteVecLoad, [ZnAGU], 8, [1], 1>;
385 defm : X86WriteRes<WriteVecLoadX, [ZnAGU], 8, [1], 1>;
386 defm : X86WriteRes<WriteVecLoadY, [ZnAGU], 8, [1], 1>;
387 defm : X86WriteRes<WriteVecLoadNT, [ZnAGU], 8, [1], 1>;
388 defm : X86WriteRes<WriteVecLoadNTY, [ZnAGU], 8, [1], 1>;
389 defm : X86WriteRes<WriteVecMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
390 defm : X86WriteRes<WriteVecMaskedLoadY, [ZnAGU,ZnFPU01], 9, [1,3], 2>;
391 defm : X86WriteRes<WriteVecStore, [ZnAGU], 1, [1], 1>;
392 defm : X86WriteRes<WriteVecStoreX, [ZnAGU], 1, [1], 1>;
393 defm : X86WriteRes<WriteVecStoreY, [ZnAGU], 1, [1], 1>;
394 defm : X86WriteRes<WriteVecStoreNT, [ZnAGU], 1, [1], 1>;
395 defm : X86WriteRes<WriteVecStoreNTY, [ZnAGU], 1, [1], 1>;
396 defm : X86WriteRes<WriteVecMaskedStore32, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
397 defm : X86WriteRes<WriteVecMaskedStore32Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
398 defm : X86WriteRes<WriteVecMaskedStore64, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
399 defm : X86WriteRes<WriteVecMaskedStore64Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
400 defm : X86WriteRes<WriteVecMove, [ZnFPU], 1, [1], 1>;
401 defm : X86WriteRes<WriteVecMoveX, [ZnFPU], 1, [1], 1>;
402 defm : X86WriteRes<WriteVecMoveY, [ZnFPU], 2, [1], 2>;
403 defm : X86WriteRes<WriteVecMoveToGpr, [ZnFPU2], 2, [1], 1>;
404 defm : X86WriteRes<WriteVecMoveFromGpr, [ZnFPU2], 3, [1], 1>;
405 defm : X86WriteRes<WriteEMMS, [ZnFPU], 2, [1], 1>;
407 defm : ZnWriteResFpuPair<WriteVecShift, [ZnFPU], 1>;
408 defm : ZnWriteResFpuPair<WriteVecShiftX, [ZnFPU2], 1>;
409 defm : ZnWriteResFpuPair<WriteVecShiftY, [ZnFPU2], 2>;
410 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
411 defm : ZnWriteResFpuPair<WriteVecShiftImm, [ZnFPU], 1>;
412 defm : ZnWriteResFpuPair<WriteVecShiftImmX, [ZnFPU], 1>;
413 defm : ZnWriteResFpuPair<WriteVecShiftImmY, [ZnFPU], 1>;
414 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
415 defm : ZnWriteResFpuPair<WriteVecLogic, [ZnFPU], 1>;
416 defm : ZnWriteResFpuPair<WriteVecLogicX, [ZnFPU], 1>;
417 defm : ZnWriteResFpuPair<WriteVecLogicY, [ZnFPU], 1>;
418 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
419 defm : ZnWriteResFpuPair<WriteVecTest, [ZnFPU12], 1, [2], 1, 7, 1>;
420 defm : ZnWriteResFpuPair<WriteVecTestY, [ZnFPU12], 1, [2], 1, 7, 1>;
421 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
422 defm : ZnWriteResFpuPair<WriteVecALU, [ZnFPU], 1>;
423 defm : ZnWriteResFpuPair<WriteVecALUX, [ZnFPU], 1>;
424 defm : ZnWriteResFpuPair<WriteVecALUY, [ZnFPU], 1>;
425 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
426 defm : ZnWriteResFpuPair<WriteVecIMul, [ZnFPU0], 4>;
427 defm : ZnWriteResFpuPair<WriteVecIMulX, [ZnFPU0], 4>;
428 defm : ZnWriteResFpuPair<WriteVecIMulY, [ZnFPU0], 4>;
429 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
430 defm : ZnWriteResFpuPair<WritePMULLD, [ZnFPU0], 4, [1], 1, 7, 1>; // FIXME
431 defm : ZnWriteResFpuPair<WritePMULLDY, [ZnFPU0], 5, [2], 1, 7, 1>; // FIXME
432 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
433 defm : ZnWriteResFpuPair<WriteShuffle, [ZnFPU], 1>;
434 defm : ZnWriteResFpuPair<WriteShuffleX, [ZnFPU], 1>;
435 defm : ZnWriteResFpuPair<WriteShuffleY, [ZnFPU], 1>;
436 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
437 defm : ZnWriteResFpuPair<WriteVarShuffle, [ZnFPU], 1>;
438 defm : ZnWriteResFpuPair<WriteVarShuffleX,[ZnFPU], 1>;
439 defm : ZnWriteResFpuPair<WriteVarShuffleY,[ZnFPU], 1>;
440 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
441 defm : ZnWriteResFpuPair<WriteBlend, [ZnFPU01], 1>;
442 defm : ZnWriteResFpuPair<WriteBlendY, [ZnFPU01], 1>;
443 defm : X86WriteResPairUnsupported<WriteBlendZ>;
444 defm : ZnWriteResFpuPair<WriteShuffle256, [ZnFPU], 2>;
445 defm : ZnWriteResFpuPair<WriteVPMOV256, [ZnFPU12], 1, [1], 2>;
446 defm : ZnWriteResFpuPair<WriteVarShuffle256, [ZnFPU], 2>;
447 defm : ZnWriteResFpuPair<WritePSADBW, [ZnFPU0], 3>;
448 defm : ZnWriteResFpuPair<WritePSADBWX, [ZnFPU0], 3>;
449 defm : ZnWriteResFpuPair<WritePSADBWY, [ZnFPU0], 3>;
450 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
451 defm : ZnWriteResFpuPair<WritePHMINPOS, [ZnFPU0], 4>;
453 // Vector Shift Operations
454 defm : ZnWriteResFpuPair<WriteVarVecShift, [ZnFPU12], 1>;
455 defm : ZnWriteResFpuPair<WriteVarVecShiftY, [ZnFPU12], 1>;
456 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
458 // Vector insert/extract operations.
459 defm : ZnWriteResFpuPair<WriteVecInsert, [ZnFPU], 1>;
461 def : WriteRes<WriteVecExtract, [ZnFPU12, ZnFPU2]> {
463 let ResourceCycles = [1, 2];
465 def : WriteRes<WriteVecExtractSt, [ZnAGU, ZnFPU12, ZnFPU2]> {
468 let ResourceCycles = [1, 2, 3];
471 // MOVMSK Instructions.
472 def : WriteRes<WriteFMOVMSK, [ZnFPU2]>;
473 def : WriteRes<WriteMMXMOVMSK, [ZnFPU2]>;
474 def : WriteRes<WriteVecMOVMSK, [ZnFPU2]>;
476 def : WriteRes<WriteVecMOVMSKY, [ZnFPU2]> {
479 let ResourceCycles = [2];
483 defm : ZnWriteResFpuPair<WriteAESDecEnc, [ZnFPU01], 4>;
484 defm : ZnWriteResFpuPair<WriteAESIMC, [ZnFPU01], 4>;
485 defm : ZnWriteResFpuPair<WriteAESKeyGen, [ZnFPU01], 4>;
487 def : WriteRes<WriteFence, [ZnAGU]>;
488 def : WriteRes<WriteNop, []>;
490 // Following instructions with latency=100 are microcoded.
491 // We set long latency so as to block the entire pipeline.
492 defm : ZnWriteResFpuPair<WriteFShuffle256, [ZnFPU], 100>;
493 defm : ZnWriteResFpuPair<WriteFVarShuffle256, [ZnFPU], 100>;
495 // Microcoded Instructions
496 def ZnWriteMicrocoded : SchedWriteRes<[]> {
500 def : SchedAlias<WriteMicrocoded, ZnWriteMicrocoded>;
501 def : SchedAlias<WriteFCMOV, ZnWriteMicrocoded>;
502 def : SchedAlias<WriteSystem, ZnWriteMicrocoded>;
503 def : SchedAlias<WriteMPSAD, ZnWriteMicrocoded>;
504 def : SchedAlias<WriteMPSADY, ZnWriteMicrocoded>;
505 def : SchedAlias<WriteMPSADLd, ZnWriteMicrocoded>;
506 def : SchedAlias<WriteMPSADYLd, ZnWriteMicrocoded>;
507 def : SchedAlias<WriteCLMul, ZnWriteMicrocoded>;
508 def : SchedAlias<WriteCLMulLd, ZnWriteMicrocoded>;
509 def : SchedAlias<WritePCmpIStrM, ZnWriteMicrocoded>;
510 def : SchedAlias<WritePCmpIStrMLd, ZnWriteMicrocoded>;
511 def : SchedAlias<WritePCmpEStrI, ZnWriteMicrocoded>;
512 def : SchedAlias<WritePCmpEStrILd, ZnWriteMicrocoded>;
513 def : SchedAlias<WritePCmpEStrM, ZnWriteMicrocoded>;
514 def : SchedAlias<WritePCmpEStrMLd, ZnWriteMicrocoded>;
515 def : SchedAlias<WritePCmpIStrI, ZnWriteMicrocoded>;
516 def : SchedAlias<WritePCmpIStrILd, ZnWriteMicrocoded>;
517 def : SchedAlias<WriteLDMXCSR, ZnWriteMicrocoded>;
518 def : SchedAlias<WriteSTMXCSR, ZnWriteMicrocoded>;
520 //=== Regex based InstRW ===//
525 // - mm: 64 bit mmx register.
526 // - x = 128 bit xmm register.
527 // - (x)mm = mmx or xmm register.
528 // - y = 256 bit ymm register.
529 // - v = any vector register.
531 //=== Integer Instructions ===//
532 //-- Move instructions --//
535 def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>;
539 def : InstRW<[WriteLoad], (instregex "MOV(S|Z)X32rm(8|16)")>;
543 def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> {
547 def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>;
549 def : InstRW<[WriteMicrocoded], (instrs XLAT)>;
553 def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{
557 def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>;
558 def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>;
559 def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>;
563 // r. Has default values.
565 def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{
568 def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>;
571 def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
574 def ZnWritePushA : SchedWriteRes<[ZnAGU]> {
577 def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>;
580 def : InstRW<[WriteMicrocoded], (instrs LAHF)>;
584 def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> {
587 def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>;
590 def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>;
592 //-- Arithmetic instructions --//
596 def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)",
597 "(ADD|SUB)(8|16|32|64)mi8",
602 def : InstRW<[WriteALULd],
603 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)",
604 "(ADC|SBB)(16|32|64)mi8",
609 def : InstRW<[WriteALULd],
610 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>;
614 def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
617 def : SchedAlias<WriteIMul16, ZnWriteMul16>;
618 def : SchedAlias<WriteIMul16Imm, ZnWriteMul16>; // TODO: is this right?
619 def : SchedAlias<WriteIMul16Reg, ZnWriteMul16>; // TODO: is this right?
620 def : SchedAlias<WriteIMul16ImmLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
621 def : SchedAlias<WriteIMul16RegLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
624 def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
627 def : SchedAlias<WriteIMul16Ld, ZnWriteMul16Ld>;
630 def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
633 def : SchedAlias<WriteIMul32, ZnWriteMul32>;
634 def : SchedAlias<WriteIMul32Imm, ZnWriteMul32>; // TODO: is this right?
635 def : SchedAlias<WriteIMul32Reg, ZnWriteMul32>; // TODO: is this right?
636 def : SchedAlias<WriteIMul32ImmLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
637 def : SchedAlias<WriteIMul32RegLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
640 def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
643 def : SchedAlias<WriteIMul32Ld, ZnWriteMul32Ld>;
646 def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
650 def : SchedAlias<WriteIMul64, ZnWriteMul64>;
651 def : SchedAlias<WriteIMul64Imm, ZnWriteMul64>; // TODO: is this right?
652 def : SchedAlias<WriteIMul64Reg, ZnWriteMul64>; // TODO: is this right?
653 def : SchedAlias<WriteIMul64ImmLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
654 def : SchedAlias<WriteIMul64RegLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
657 def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
661 def : SchedAlias<WriteIMul64Ld, ZnWriteMul64Ld>;
664 // Numbers are based on the AMD SOG for Family 17h - Instruction Latencies.
665 defm : ZnWriteResPair<WriteMULX32, [ZnALU1, ZnMultiplier], 3, [1, 1], 1, 5, 0>;
666 defm : ZnWriteResPair<WriteMULX64, [ZnALU1, ZnMultiplier], 3, [1, 1], 1, 5, 0>;
668 //-- Control transfer instructions --//
671 def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>;
672 def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>;
675 def : InstRW<[WriteMicrocoded], (instrs INTO)>;
678 def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>;
679 def : InstRW<[ZnWriteLOOP], (instrs LOOP)>;
681 // LOOP(N)E, LOOP(N)Z
682 def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>;
683 def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>;
687 def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>;
688 def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>;
690 def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>;
693 def ZnWriteRET : SchedWriteRes<[ZnALU03]> {
696 def : InstRW<[ZnWriteRET], (instregex "RET(L|Q|W)", "LRET(L|Q|W)",
699 //-- Logic instructions --//
703 def : InstRW<[WriteALULd],
704 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)",
705 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>;
707 // Define ALU latency variants
708 def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> {
711 def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> {
717 def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> {
722 def : SchedAlias<WriteBitTestSetImmRMW, ZnWriteBTRSCm>;
723 def : SchedAlias<WriteBitTestSetRegRMW, ZnWriteBTRSCm>;
727 def : SchedAlias<WriteBLS, ZnWriteALULat2>;
729 def : SchedAlias<WriteBLSLd, ZnWriteALULat2Ld>;
732 def : InstRW<[WriteALU], (instrs STD, CLD)>;
736 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>;
738 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>;
742 def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>;
746 def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>;
750 def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>;
753 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>;
756 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>;
758 //-- Misc instructions --//
760 def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> {
761 let NumMicroOps = 18;
763 def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>;
765 def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>;
768 def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> {
772 def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>;
775 def : InstRW<[WriteMicrocoded], (instrs PAUSE)>;
778 def : InstRW<[WriteMicrocoded], (instregex "RDTSC")>;
781 def : InstRW<[WriteMicrocoded], (instrs RDPMC)>;
784 def : InstRW<[WriteMicrocoded], (instrs RDRAND16r, RDRAND32r, RDRAND64r)>;
787 def : InstRW<[WriteMicrocoded], (instrs XGETBV)>;
789 //-- String instructions --//
791 def : InstRW<[WriteMicrocoded], (instregex "CMPS(B|L|Q|W)")>;
794 def : InstRW<[WriteMicrocoded], (instregex "LODS(B|W)")>;
797 def : InstRW<[WriteMicrocoded], (instregex "LODS(L|Q)")>;
800 def : InstRW<[WriteMicrocoded], (instregex "MOVS(B|L|Q|W)")>;
803 def : InstRW<[WriteMicrocoded], (instregex "SCAS(B|W|L|Q)")>;
806 def : InstRW<[WriteMicrocoded], (instregex "STOS(B|L|Q|W)")>;
809 def ZnXADD : SchedWriteRes<[ZnALU]>;
810 def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>;
811 def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>;
813 //=== Floating Point x87 Instructions ===//
814 //-- Move instructions --//
816 def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ;
818 def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> {
825 def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>;
828 def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> {
831 def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>;
834 def : InstRW<[WriteMicrocoded], (instrs FBLDm)>;
838 def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>;
841 def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> {
844 def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>;
848 def : InstRW<[WriteMicrocoded], (instrs FBSTPm)>;
850 def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>;
853 def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>;
856 def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> {
860 def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>;
863 def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> {
866 def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>;
868 def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> {
872 def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> {
877 def : SchedAlias<WriteFLD0, ZnWriteFPU13>;
880 def : SchedAlias<WriteFLD1, ZnWriteFPU3>;
883 def : SchedAlias<WriteFLDC, ZnWriteFPU3>;
887 def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>;
890 def : InstRW<[WriteMicrocoded], (instrs FNSTSWm)>;
893 def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>;
896 def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>;
899 def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>;
902 def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>;
905 def : InstRW<[WriteMicrocoded], (instrs FSAVEm)>;
908 def : InstRW<[WriteMicrocoded], (instrs FRSTORm)>;
910 //-- Arithmetic instructions --//
912 def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ;
914 def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ;
916 def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> {
921 def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>;
925 def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>;
927 def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>;
931 def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>;
933 def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]>
938 // FCOMI(P) FUCOMI(P).
940 def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
942 def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]>
946 let ResourceCycles = [1,3];
950 def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>;
953 def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>;
956 def : InstRW<[ZnWriteFPU3Lat1], (instrs XAM_F)>;
959 def : InstRW<[WriteMicrocoded], (instrs FPREM)>;
962 def : InstRW<[WriteMicrocoded], (instrs FPREM1)>;
965 def : InstRW<[WriteMicrocoded], (instrs FRNDINT)>;
968 def : InstRW<[WriteMicrocoded], (instrs FSCALE)>;
971 def : InstRW<[WriteMicrocoded], (instrs FXTRACT)>;
974 def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>;
977 def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>;
980 def : InstRW<[WriteMicrocoded], (instrs FNCLEX)>;
983 def : InstRW<[WriteMicrocoded], (instrs FNINIT)>;
985 //=== Integer MMX and XMM Instructions ===//
989 def ZnWriteFPU12 : SchedWriteRes<[ZnFPU12]> ;
990 def ZnWriteFPU12Y : SchedWriteRes<[ZnFPU12]> {
993 def ZnWriteFPU12m : SchedWriteRes<[ZnAGU, ZnFPU12]> ;
994 def ZnWriteFPU12Ym : SchedWriteRes<[ZnAGU, ZnFPU12]> {
999 def : InstRW<[ZnWriteFPU12], (instrs MMX_PACKSSDWirr,
1002 def : InstRW<[ZnWriteFPU12m], (instrs MMX_PACKSSDWirm,
1006 def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ;
1007 def ZnWriteFPU013Y : SchedWriteRes<[ZnFPU013]> {
1010 def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1012 let NumMicroOps = 2;
1014 def ZnWriteFPU013Ld : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1016 let NumMicroOps = 2;
1018 def ZnWriteFPU013LdY : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1020 let NumMicroOps = 2;
1025 def : InstRW<[ZnWriteFPU013], (instregex "(V?)PBLENDWrri")>;
1027 def : InstRW<[ZnWriteFPU013Y], (instrs VPBLENDWYrri)>;
1030 def : InstRW<[ZnWriteFPU013Ld], (instregex "(V?)PBLENDWrmi")>;
1032 def : InstRW<[ZnWriteFPU013LdY], (instrs VPBLENDWYrmi)>;
1034 def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ;
1035 def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> {
1036 let NumMicroOps = 2;
1041 def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>;
1043 def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>;
1046 def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1047 let NumMicroOps = 2;
1049 let ResourceCycles = [1, 2];
1051 def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1052 let NumMicroOps = 2;
1054 let ResourceCycles = [1, 3];
1056 def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>;
1057 def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>;
1060 def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>;
1063 def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>;
1067 def : InstRW<[WriteMicrocoded],
1068 (instregex "VPMASKMOVD(Y?)rm")>;
1070 def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>;
1074 def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1076 let NumMicroOps = 2;
1077 let ResourceCycles = [1, 2];
1079 def : InstRW<[ZnWriteVPBROADCAST128Ld],
1080 (instregex "VPBROADCAST(B|W)rm")>;
1083 def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1085 let NumMicroOps = 2;
1086 let ResourceCycles = [1, 2];
1088 def : InstRW<[ZnWriteVPBROADCAST256Ld],
1089 (instregex "VPBROADCAST(B|W)Yrm")>;
1092 def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>;
1094 //-- Arithmetic instructions --//
1097 // PHADD|PHSUB (S) W/D.
1098 def : SchedAlias<WritePHAdd, ZnWriteMicrocoded>;
1099 def : SchedAlias<WritePHAddLd, ZnWriteMicrocoded>;
1100 def : SchedAlias<WritePHAddX, ZnWriteMicrocoded>;
1101 def : SchedAlias<WritePHAddXLd, ZnWriteMicrocoded>;
1102 def : SchedAlias<WritePHAddY, ZnWriteMicrocoded>;
1103 def : SchedAlias<WritePHAddYLd, ZnWriteMicrocoded>;
1106 def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>;
1107 def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>;
1110 def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
1114 def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
1116 let NumMicroOps = 2;
1117 let ResourceCycles = [1,2];
1119 def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>;
1120 def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>;
1122 //-- Logic instructions --//
1124 // PSLL,PSRL,PSRA W/D/Q.
1126 def ZnWritePShift : SchedWriteRes<[ZnFPU2]> ;
1127 def ZnWritePShiftY : SchedWriteRes<[ZnFPU2]> {
1132 def : InstRW<[ZnWritePShift], (instregex "(V?)PS(R|L)LDQri")>;
1133 def : InstRW<[ZnWritePShiftY], (instregex "(V?)PS(R|L)LDQYri")>;
1135 //=== Floating Point XMM and YMM Instructions ===//
1136 //-- Move instructions --//
1139 def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr)>;
1140 def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm)>;
1142 def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> {
1143 let NumMicroOps = 2;
1147 def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128)>;
1151 def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1153 let NumMicroOps = 2;
1154 let ResourceCycles = [1, 2];
1156 def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>;
1158 def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> {
1160 let NumMicroOps = 2;
1161 let ResourceCycles = [5, 1, 2];
1164 def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>;
1168 def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rr)>;
1171 def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mr)>;
1173 def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> {
1175 let ResourceCycles = [2];
1177 def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> {
1179 let NumMicroOps = 2;
1180 let ResourceCycles = [1, 2];
1184 def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rr)>;
1185 def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rm)>;
1188 def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>;
1190 //-- Conversion instructions --//
1191 def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> {
1194 def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> {
1200 def : SchedAlias<WriteCvtPD2PS, ZnWriteCVTPD2PSr>;
1202 def : SchedAlias<WriteCvtPD2PSY, ZnWriteCVTPD2PSYr>;
1204 defm : X86WriteResUnsupported<WriteCvtPD2PSZ>;
1206 def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU03]> {
1208 let NumMicroOps = 2;
1209 let ResourceCycles = [1,2];
1212 def : SchedAlias<WriteCvtPD2PSLd, ZnWriteCVTPD2PSLd>;
1215 def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1218 def : SchedAlias<WriteCvtPD2PSYLd, ZnWriteCVTPD2PSYLd>;
1220 defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>;
1224 // Same as WriteCVTPD2PSr
1225 def : SchedAlias<WriteCvtSD2SS, ZnWriteCVTPD2PSr>;
1228 def : SchedAlias<WriteCvtSD2SSLd, ZnWriteCVTPD2PSLd>;
1232 def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> {
1235 def : SchedAlias<WriteCvtPS2PD, ZnWriteCVTPS2PDr>;
1239 def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1241 let NumMicroOps = 2;
1243 def : SchedAlias<WriteCvtPS2PDLd, ZnWriteCVTPS2PDLd>;
1244 def : SchedAlias<WriteCvtPS2PDYLd, ZnWriteCVTPS2PDLd>;
1245 defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>;
1248 def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> {
1251 def : SchedAlias<WriteCvtPS2PDY, ZnWriteVCVTPS2PDY>;
1252 defm : X86WriteResUnsupported<WriteCvtPS2PDZ>;
1256 def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> {
1259 def : SchedAlias<WriteCvtSS2SD, ZnWriteCVTSS2SDr>;
1262 def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1264 let NumMicroOps = 2;
1265 let ResourceCycles = [1, 2];
1267 def : SchedAlias<WriteCvtSS2SDLd, ZnWriteCVTSS2SDLd>;
1269 def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> {
1274 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>;
1278 def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>;
1280 def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> {
1285 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V?)CVT(T?)PD2DQrr")>;
1287 def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> {
1289 let NumMicroOps = 2;
1292 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>;
1293 // same as xmm handling
1295 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>;
1297 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>;
1299 def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> {
1304 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIirr")>;
1308 def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDirr)>;
1312 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIirr")>;
1314 def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> {
1318 // same as CVTPD2DQr
1321 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>;
1322 // same as CVTPD2DQm
1324 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>;
1326 def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> {
1331 def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>;
1334 def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> {
1337 def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> {
1342 def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>;
1344 def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>;
1348 def : SchedAlias<WriteCvtPS2PH, ZnWriteMicrocoded>;
1349 def : SchedAlias<WriteCvtPS2PHY, ZnWriteMicrocoded>;
1350 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
1352 def : SchedAlias<WriteCvtPS2PHSt, ZnWriteMicrocoded>;
1353 def : SchedAlias<WriteCvtPS2PHYSt, ZnWriteMicrocoded>;
1354 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
1358 def : SchedAlias<WriteCvtPH2PS, ZnWriteMicrocoded>;
1359 def : SchedAlias<WriteCvtPH2PSY, ZnWriteMicrocoded>;
1360 defm : X86WriteResUnsupported<WriteCvtPH2PSZ>;
1362 def : SchedAlias<WriteCvtPH2PSLd, ZnWriteMicrocoded>;
1363 def : SchedAlias<WriteCvtPH2PSYLd, ZnWriteMicrocoded>;
1364 defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>;
1366 //-- SSE4A instructions --//
1368 def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1371 def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>;
1374 def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> {
1377 def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>;
1379 //-- SHA instructions --//
1381 def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>;
1383 // SHA1MSG1, SHA256MSG1
1385 def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> {
1387 let ResourceCycles = [2];
1389 def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>;
1391 def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1393 let ResourceCycles = [1,2];
1395 def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>;
1399 def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ;
1400 def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>;
1402 def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1405 def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>;
1409 def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ;
1410 def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>;
1412 def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1415 def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>;
1419 def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> {
1422 def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>;
1424 def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1427 def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>;
1431 def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> {
1434 def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>;
1436 def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1439 def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>;
1441 //-- Arithmetic instructions --//
1444 def : SchedAlias<WriteFHAdd, ZnWriteMicrocoded>;
1445 def : SchedAlias<WriteFHAddLd, ZnWriteMicrocoded>;
1446 def : SchedAlias<WriteFHAddY, ZnWriteMicrocoded>;
1447 def : SchedAlias<WriteFHAddYLd, ZnWriteMicrocoded>;
1450 // TODO - convert to ZnWriteResFpuPair
1452 def ZnWriteVDIVPSYr : SchedWriteRes<[ZnFPU3]> {
1454 let ResourceCycles = [12];
1456 def : SchedAlias<WriteFDivY, ZnWriteVDIVPSYr>;
1459 def ZnWriteVDIVPSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1461 let NumMicroOps = 2;
1462 let ResourceCycles = [1, 19];
1464 def : SchedAlias<WriteFDivYLd, ZnWriteVDIVPSYLd>;
1467 // TODO - convert to ZnWriteResFpuPair
1469 def ZnWriteVDIVPDY : SchedWriteRes<[ZnFPU3]> {
1471 let ResourceCycles = [15];
1473 def : SchedAlias<WriteFDiv64Y, ZnWriteVDIVPDY>;
1476 def ZnWriteVDIVPDYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1478 let NumMicroOps = 2;
1479 let ResourceCycles = [1,22];
1481 def : SchedAlias<WriteFDiv64YLd, ZnWriteVDIVPDYLd>;
1485 def : SchedAlias<WriteDPPS, ZnWriteMicrocoded>;
1486 def : SchedAlias<WriteDPPSY, ZnWriteMicrocoded>;
1489 def : SchedAlias<WriteDPPSLd, ZnWriteMicrocoded>;
1490 def : SchedAlias<WriteDPPSYLd,ZnWriteMicrocoded>;
1494 def : SchedAlias<WriteDPPD, ZnWriteMicrocoded>;
1497 def : SchedAlias<WriteDPPDLd, ZnWriteMicrocoded>;
1500 // TODO - convert to ZnWriteResFpuPair
1502 def ZnWriteRSQRTSSr : SchedWriteRes<[ZnFPU02]> {
1505 def : SchedAlias<WriteFRsqrt, ZnWriteRSQRTSSr>;
1508 def ZnWriteRSQRTSSLd: SchedWriteRes<[ZnAGU, ZnFPU02]> {
1510 let NumMicroOps = 2;
1511 let ResourceCycles = [1,2]; // FIXME: Is this right?
1513 def : SchedAlias<WriteFRsqrtLd, ZnWriteRSQRTSSLd>;
1516 // TODO - convert to ZnWriteResFpuPair
1518 def ZnWriteRSQRTPSYr : SchedWriteRes<[ZnFPU01]> {
1520 let NumMicroOps = 2;
1521 let ResourceCycles = [2];
1523 def : SchedAlias<WriteFRsqrtY, ZnWriteRSQRTPSYr>;
1526 def ZnWriteRSQRTPSYLd : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1528 let NumMicroOps = 2;
1530 def : SchedAlias<WriteFRsqrtYLd, ZnWriteRSQRTPSYLd>;
1532 //-- Other instructions --//
1535 def : InstRW<[WriteMicrocoded], (instrs VZEROUPPER)>;
1538 def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>;