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 def : WriteRes<WriteZero, []>;
183 def : WriteRes<WriteLEA, [ZnALU]>;
184 defm : ZnWriteResPair<WriteALU, [ZnALU], 1>;
185 defm : ZnWriteResPair<WriteADC, [ZnALU], 1>;
187 defm : ZnWriteResPair<WriteIMul8, [ZnALU1, ZnMultiplier], 4>;
188 //defm : ZnWriteResPair<WriteIMul16, [ZnALU1, ZnMultiplier], 4>;
189 //defm : ZnWriteResPair<WriteIMul16Imm, [ZnALU1, ZnMultiplier], 4>;
190 //defm : ZnWriteResPair<WriteIMul16Reg, [ZnALU1, ZnMultiplier], 4>;
191 //defm : ZnWriteResPair<WriteIMul32, [ZnALU1, ZnMultiplier], 4>;
192 //defm : ZnWriteResPair<WriteIMul32Imm, [ZnALU1, ZnMultiplier], 4>;
193 //defm : ZnWriteResPair<WriteIMul32Reg, [ZnALU1, ZnMultiplier], 4>;
194 //defm : ZnWriteResPair<WriteIMul64, [ZnALU1, ZnMultiplier], 4, [1,1], 2>;
195 //defm : ZnWriteResPair<WriteIMul64Imm, [ZnALU1, ZnMultiplier], 4, [1,1], 2>;
196 //defm : ZnWriteResPair<WriteIMul64Reg, [ZnALU1, ZnMultiplier], 4, [1,1], 2>;
198 defm : X86WriteRes<WriteBSWAP32, [ZnALU], 1, [4], 1>;
199 defm : X86WriteRes<WriteBSWAP64, [ZnALU], 1, [4], 1>;
200 defm : X86WriteRes<WriteCMPXCHG, [ZnALU], 1, [1], 1>;
201 defm : X86WriteRes<WriteCMPXCHGRMW,[ZnALU,ZnAGU], 8, [1,1], 5>;
202 defm : X86WriteRes<WriteXCHG, [ZnALU], 1, [2], 2>;
204 defm : ZnWriteResPair<WriteShift, [ZnALU], 1>;
205 defm : ZnWriteResPair<WriteShiftCL, [ZnALU], 1>;
206 defm : ZnWriteResPair<WriteRotate, [ZnALU], 1>;
207 defm : ZnWriteResPair<WriteRotateCL, [ZnALU], 1>;
209 defm : X86WriteRes<WriteSHDrri, [ZnALU], 1, [1], 1>;
210 defm : X86WriteResUnsupported<WriteSHDrrcl>;
211 defm : X86WriteResUnsupported<WriteSHDmri>;
212 defm : X86WriteResUnsupported<WriteSHDmrcl>;
214 defm : ZnWriteResPair<WriteJump, [ZnALU], 1>;
215 defm : ZnWriteResFpuPair<WriteCRC32, [ZnFPU0], 3>;
217 defm : ZnWriteResPair<WriteCMOV, [ZnALU], 1>;
218 def : WriteRes<WriteSETCC, [ZnALU]>;
219 def : WriteRes<WriteSETCCStore, [ZnALU, ZnAGU]>;
220 defm : X86WriteRes<WriteLAHFSAHF, [ZnALU], 2, [1], 2>;
222 defm : X86WriteRes<WriteBitTest, [ZnALU], 1, [1], 1>;
223 defm : X86WriteRes<WriteBitTestImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
224 defm : X86WriteRes<WriteBitTestRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
225 defm : X86WriteRes<WriteBitTestSet, [ZnALU], 2, [1], 2>;
226 //defm : X86WriteRes<WriteBitTestSetImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
227 //defm : X86WriteRes<WriteBitTestSetRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
230 defm : ZnWriteResPair<WriteBSF, [ZnALU], 3>;
231 defm : ZnWriteResPair<WriteBSR, [ZnALU], 3>;
232 defm : ZnWriteResPair<WriteLZCNT, [ZnALU], 2>;
233 defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2>;
234 defm : ZnWriteResPair<WritePOPCNT, [ZnALU], 1>;
236 // Treat misc copies as a move.
237 def : InstRW<[WriteMove], (instrs COPY)>;
239 // BMI1 BEXTR/BLS, BMI2 BZHI
240 defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1>;
241 //defm : ZnWriteResPair<WriteBLS, [ZnALU], 2>;
242 defm : ZnWriteResPair<WriteBZHI, [ZnALU], 1>;
245 defm : ZnWriteResPair<WriteDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
246 defm : ZnWriteResPair<WriteDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
247 defm : ZnWriteResPair<WriteDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
248 defm : ZnWriteResPair<WriteDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
249 defm : ZnWriteResPair<WriteIDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
250 defm : ZnWriteResPair<WriteIDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
251 defm : ZnWriteResPair<WriteIDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
252 defm : ZnWriteResPair<WriteIDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
255 def : WriteRes<WriteIMulH, [ZnALU1, ZnMultiplier]>{
259 // Floating point operations
260 defm : X86WriteRes<WriteFLoad, [ZnAGU], 8, [1], 1>;
261 defm : X86WriteRes<WriteFLoadX, [ZnAGU], 8, [1], 1>;
262 defm : X86WriteRes<WriteFLoadY, [ZnAGU], 8, [1], 1>;
263 defm : X86WriteRes<WriteFMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,1], 1>;
264 defm : X86WriteRes<WriteFMaskedLoadY, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
265 defm : X86WriteRes<WriteFStore, [ZnAGU], 1, [1], 1>;
266 defm : X86WriteRes<WriteFStoreX, [ZnAGU], 1, [1], 1>;
267 defm : X86WriteRes<WriteFStoreY, [ZnAGU], 1, [1], 1>;
268 defm : X86WriteRes<WriteFStoreNT, [ZnAGU,ZnFPU2], 8, [1,1], 1>;
269 defm : X86WriteRes<WriteFStoreNTX, [ZnAGU], 1, [1], 1>;
270 defm : X86WriteRes<WriteFStoreNTY, [ZnAGU], 1, [1], 1>;
271 defm : X86WriteRes<WriteFMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
272 defm : X86WriteRes<WriteFMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
273 defm : X86WriteRes<WriteFMove, [ZnFPU], 1, [1], 1>;
274 defm : X86WriteRes<WriteFMoveX, [ZnFPU], 1, [1], 1>;
275 defm : X86WriteRes<WriteFMoveY, [ZnFPU], 1, [1], 1>;
277 defm : ZnWriteResFpuPair<WriteFAdd, [ZnFPU0], 3>;
278 defm : ZnWriteResFpuPair<WriteFAddX, [ZnFPU0], 3>;
279 defm : ZnWriteResFpuPair<WriteFAddY, [ZnFPU0], 3>;
280 defm : X86WriteResPairUnsupported<WriteFAddZ>;
281 defm : ZnWriteResFpuPair<WriteFAdd64, [ZnFPU0], 3>;
282 defm : ZnWriteResFpuPair<WriteFAdd64X, [ZnFPU0], 3>;
283 defm : ZnWriteResFpuPair<WriteFAdd64Y, [ZnFPU0], 3>;
284 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
285 defm : ZnWriteResFpuPair<WriteFCmp, [ZnFPU0], 3>;
286 defm : ZnWriteResFpuPair<WriteFCmpX, [ZnFPU0], 3>;
287 defm : ZnWriteResFpuPair<WriteFCmpY, [ZnFPU0], 3>;
288 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
289 defm : ZnWriteResFpuPair<WriteFCmp64, [ZnFPU0], 3>;
290 defm : ZnWriteResFpuPair<WriteFCmp64X, [ZnFPU0], 3>;
291 defm : ZnWriteResFpuPair<WriteFCmp64Y, [ZnFPU0], 3>;
292 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
293 defm : ZnWriteResFpuPair<WriteFCom, [ZnFPU0], 3>;
294 defm : ZnWriteResFpuPair<WriteFBlend, [ZnFPU01], 1>;
295 defm : ZnWriteResFpuPair<WriteFBlendY, [ZnFPU01], 1>;
296 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
297 defm : ZnWriteResFpuPair<WriteFVarBlend, [ZnFPU01], 1>;
298 defm : ZnWriteResFpuPair<WriteFVarBlendY,[ZnFPU01], 1>;
299 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
300 defm : ZnWriteResFpuPair<WriteVarBlend, [ZnFPU0], 1>;
301 defm : ZnWriteResFpuPair<WriteVarBlendY, [ZnFPU0], 1>;
302 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
303 defm : ZnWriteResFpuPair<WriteCvtSS2I, [ZnFPU3], 5>;
304 defm : ZnWriteResFpuPair<WriteCvtPS2I, [ZnFPU3], 5>;
305 defm : ZnWriteResFpuPair<WriteCvtPS2IY, [ZnFPU3], 5>;
306 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
307 defm : ZnWriteResFpuPair<WriteCvtSD2I, [ZnFPU3], 5>;
308 defm : ZnWriteResFpuPair<WriteCvtPD2I, [ZnFPU3], 5>;
309 defm : ZnWriteResFpuPair<WriteCvtPD2IY, [ZnFPU3], 5>;
310 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
311 defm : ZnWriteResFpuPair<WriteCvtI2SS, [ZnFPU3], 5>;
312 defm : ZnWriteResFpuPair<WriteCvtI2PS, [ZnFPU3], 5>;
313 defm : ZnWriteResFpuPair<WriteCvtI2PSY, [ZnFPU3], 5>;
314 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
315 defm : ZnWriteResFpuPair<WriteCvtI2SD, [ZnFPU3], 5>;
316 defm : ZnWriteResFpuPair<WriteCvtI2PD, [ZnFPU3], 5>;
317 defm : ZnWriteResFpuPair<WriteCvtI2PDY, [ZnFPU3], 5>;
318 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
319 defm : ZnWriteResFpuPair<WriteFDiv, [ZnFPU3], 15>;
320 defm : ZnWriteResFpuPair<WriteFDivX, [ZnFPU3], 15>;
321 //defm : ZnWriteResFpuPair<WriteFDivY, [ZnFPU3], 15>;
322 defm : X86WriteResPairUnsupported<WriteFDivZ>;
323 defm : ZnWriteResFpuPair<WriteFDiv64, [ZnFPU3], 15>;
324 defm : ZnWriteResFpuPair<WriteFDiv64X, [ZnFPU3], 15>;
325 //defm : ZnWriteResFpuPair<WriteFDiv64Y, [ZnFPU3], 15>;
326 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
327 defm : ZnWriteResFpuPair<WriteFSign, [ZnFPU3], 2>;
328 defm : ZnWriteResFpuPair<WriteFRnd, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
329 defm : ZnWriteResFpuPair<WriteFRndY, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
330 defm : X86WriteResPairUnsupported<WriteFRndZ>;
331 defm : ZnWriteResFpuPair<WriteFLogic, [ZnFPU], 1>;
332 defm : ZnWriteResFpuPair<WriteFLogicY, [ZnFPU], 1>;
333 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
334 defm : ZnWriteResFpuPair<WriteFTest, [ZnFPU], 1>;
335 defm : ZnWriteResFpuPair<WriteFTestY, [ZnFPU], 1>;
336 defm : X86WriteResPairUnsupported<WriteFTestZ>;
337 defm : ZnWriteResFpuPair<WriteFShuffle, [ZnFPU12], 1>;
338 defm : ZnWriteResFpuPair<WriteFShuffleY, [ZnFPU12], 1>;
339 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
340 defm : ZnWriteResFpuPair<WriteFVarShuffle, [ZnFPU12], 1>;
341 defm : ZnWriteResFpuPair<WriteFVarShuffleY,[ZnFPU12], 1>;
342 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
343 defm : ZnWriteResFpuPair<WriteFMul, [ZnFPU01], 3, [1], 1, 7, 1>;
344 defm : ZnWriteResFpuPair<WriteFMulX, [ZnFPU01], 3, [1], 1, 7, 1>;
345 defm : ZnWriteResFpuPair<WriteFMulY, [ZnFPU01], 4, [1], 1, 7, 1>;
346 defm : X86WriteResPairUnsupported<WriteFMulZ>;
347 defm : ZnWriteResFpuPair<WriteFMul64, [ZnFPU01], 3, [1], 1, 7, 1>;
348 defm : ZnWriteResFpuPair<WriteFMul64X, [ZnFPU01], 3, [1], 1, 7, 1>;
349 defm : ZnWriteResFpuPair<WriteFMul64Y, [ZnFPU01], 4, [1], 1, 7, 1>;
350 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
351 defm : ZnWriteResFpuPair<WriteFMA, [ZnFPU03], 5>;
352 defm : ZnWriteResFpuPair<WriteFMAX, [ZnFPU03], 5>;
353 defm : ZnWriteResFpuPair<WriteFMAY, [ZnFPU03], 5>;
354 defm : X86WriteResPairUnsupported<WriteFMAZ>;
355 defm : ZnWriteResFpuPair<WriteFRcp, [ZnFPU01], 5>;
356 defm : ZnWriteResFpuPair<WriteFRcpX, [ZnFPU01], 5>;
357 defm : ZnWriteResFpuPair<WriteFRcpY, [ZnFPU01], 5, [1], 1, 7, 2>;
358 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
359 //defm : ZnWriteResFpuPair<WriteFRsqrt, [ZnFPU02], 5>;
360 defm : ZnWriteResFpuPair<WriteFRsqrtX, [ZnFPU01], 5, [1], 1, 7, 1>;
361 //defm : ZnWriteResFpuPair<WriteFRsqrtY, [ZnFPU01], 5, [2], 2>;
362 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
363 defm : ZnWriteResFpuPair<WriteFSqrt, [ZnFPU3], 20, [20]>;
364 defm : ZnWriteResFpuPair<WriteFSqrtX, [ZnFPU3], 20, [20]>;
365 defm : ZnWriteResFpuPair<WriteFSqrtY, [ZnFPU3], 28, [28], 1, 7, 1>;
366 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
367 defm : ZnWriteResFpuPair<WriteFSqrt64, [ZnFPU3], 20, [20]>;
368 defm : ZnWriteResFpuPair<WriteFSqrt64X, [ZnFPU3], 20, [20]>;
369 defm : ZnWriteResFpuPair<WriteFSqrt64Y, [ZnFPU3], 40, [40], 1, 7, 1>;
370 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
371 defm : ZnWriteResFpuPair<WriteFSqrt80, [ZnFPU3], 20, [20]>;
373 // Vector integer operations which uses FPU units
374 defm : X86WriteRes<WriteVecLoad, [ZnAGU], 8, [1], 1>;
375 defm : X86WriteRes<WriteVecLoadX, [ZnAGU], 8, [1], 1>;
376 defm : X86WriteRes<WriteVecLoadY, [ZnAGU], 8, [1], 1>;
377 defm : X86WriteRes<WriteVecLoadNT, [ZnAGU], 8, [1], 1>;
378 defm : X86WriteRes<WriteVecLoadNTY, [ZnAGU], 8, [1], 1>;
379 defm : X86WriteRes<WriteVecMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
380 defm : X86WriteRes<WriteVecMaskedLoadY, [ZnAGU,ZnFPU01], 9, [1,3], 2>;
381 defm : X86WriteRes<WriteVecStore, [ZnAGU], 1, [1], 1>;
382 defm : X86WriteRes<WriteVecStoreX, [ZnAGU], 1, [1], 1>;
383 defm : X86WriteRes<WriteVecStoreY, [ZnAGU], 1, [1], 1>;
384 defm : X86WriteRes<WriteVecStoreNT, [ZnAGU], 1, [1], 1>;
385 defm : X86WriteRes<WriteVecStoreNTY, [ZnAGU], 1, [1], 1>;
386 defm : X86WriteRes<WriteVecMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
387 defm : X86WriteRes<WriteVecMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
388 defm : X86WriteRes<WriteVecMove, [ZnFPU], 1, [1], 1>;
389 defm : X86WriteRes<WriteVecMoveX, [ZnFPU], 1, [1], 1>;
390 defm : X86WriteRes<WriteVecMoveY, [ZnFPU], 2, [1], 2>;
391 defm : X86WriteRes<WriteVecMoveToGpr, [ZnFPU2], 2, [1], 1>;
392 defm : X86WriteRes<WriteVecMoveFromGpr, [ZnFPU2], 3, [1], 1>;
393 defm : X86WriteRes<WriteEMMS, [ZnFPU], 2, [1], 1>;
395 defm : ZnWriteResFpuPair<WriteVecShift, [ZnFPU], 1>;
396 defm : ZnWriteResFpuPair<WriteVecShiftX, [ZnFPU2], 1>;
397 defm : ZnWriteResFpuPair<WriteVecShiftY, [ZnFPU2], 2>;
398 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
399 defm : ZnWriteResFpuPair<WriteVecShiftImm, [ZnFPU], 1>;
400 defm : ZnWriteResFpuPair<WriteVecShiftImmX, [ZnFPU], 1>;
401 defm : ZnWriteResFpuPair<WriteVecShiftImmY, [ZnFPU], 1>;
402 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
403 defm : ZnWriteResFpuPair<WriteVecLogic, [ZnFPU], 1>;
404 defm : ZnWriteResFpuPair<WriteVecLogicX, [ZnFPU], 1>;
405 defm : ZnWriteResFpuPair<WriteVecLogicY, [ZnFPU], 1>;
406 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
407 defm : ZnWriteResFpuPair<WriteVecTest, [ZnFPU12], 1, [2], 1, 7, 1>;
408 defm : ZnWriteResFpuPair<WriteVecTestY, [ZnFPU12], 1, [2], 1, 7, 1>;
409 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
410 defm : ZnWriteResFpuPair<WriteVecALU, [ZnFPU], 1>;
411 defm : ZnWriteResFpuPair<WriteVecALUX, [ZnFPU], 1>;
412 defm : ZnWriteResFpuPair<WriteVecALUY, [ZnFPU], 1>;
413 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
414 defm : ZnWriteResFpuPair<WriteVecIMul, [ZnFPU0], 4>;
415 defm : ZnWriteResFpuPair<WriteVecIMulX, [ZnFPU0], 4>;
416 defm : ZnWriteResFpuPair<WriteVecIMulY, [ZnFPU0], 4>;
417 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
418 defm : ZnWriteResFpuPair<WritePMULLD, [ZnFPU0], 4, [1], 1, 7, 1>; // FIXME
419 defm : ZnWriteResFpuPair<WritePMULLDY, [ZnFPU0], 5, [2], 1, 7, 1>; // FIXME
420 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
421 defm : ZnWriteResFpuPair<WriteShuffle, [ZnFPU], 1>;
422 defm : ZnWriteResFpuPair<WriteShuffleX, [ZnFPU], 1>;
423 defm : ZnWriteResFpuPair<WriteShuffleY, [ZnFPU], 1>;
424 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
425 defm : ZnWriteResFpuPair<WriteVarShuffle, [ZnFPU], 1>;
426 defm : ZnWriteResFpuPair<WriteVarShuffleX,[ZnFPU], 1>;
427 defm : ZnWriteResFpuPair<WriteVarShuffleY,[ZnFPU], 1>;
428 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
429 defm : ZnWriteResFpuPair<WriteBlend, [ZnFPU01], 1>;
430 defm : ZnWriteResFpuPair<WriteBlendY, [ZnFPU01], 1>;
431 defm : X86WriteResPairUnsupported<WriteBlendZ>;
432 defm : ZnWriteResFpuPair<WriteShuffle256, [ZnFPU], 2>;
433 defm : ZnWriteResFpuPair<WriteVarShuffle256, [ZnFPU], 2>;
434 defm : ZnWriteResFpuPair<WritePSADBW, [ZnFPU0], 3>;
435 defm : ZnWriteResFpuPair<WritePSADBWX, [ZnFPU0], 3>;
436 defm : ZnWriteResFpuPair<WritePSADBWY, [ZnFPU0], 3>;
437 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
438 defm : ZnWriteResFpuPair<WritePHMINPOS, [ZnFPU0], 4>;
440 // Vector Shift Operations
441 defm : ZnWriteResFpuPair<WriteVarVecShift, [ZnFPU12], 1>;
442 defm : ZnWriteResFpuPair<WriteVarVecShiftY, [ZnFPU12], 1>;
443 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
445 // Vector insert/extract operations.
446 defm : ZnWriteResFpuPair<WriteVecInsert, [ZnFPU], 1>;
448 def : WriteRes<WriteVecExtract, [ZnFPU12, ZnFPU2]> {
450 let ResourceCycles = [1, 2];
452 def : WriteRes<WriteVecExtractSt, [ZnAGU, ZnFPU12, ZnFPU2]> {
455 let ResourceCycles = [1, 2, 3];
458 // MOVMSK Instructions.
459 def : WriteRes<WriteFMOVMSK, [ZnFPU2]>;
460 def : WriteRes<WriteMMXMOVMSK, [ZnFPU2]>;
461 def : WriteRes<WriteVecMOVMSK, [ZnFPU2]>;
463 def : WriteRes<WriteVecMOVMSKY, [ZnFPU2]> {
466 let ResourceCycles = [2];
470 defm : ZnWriteResFpuPair<WriteAESDecEnc, [ZnFPU01], 4>;
471 defm : ZnWriteResFpuPair<WriteAESIMC, [ZnFPU01], 4>;
472 defm : ZnWriteResFpuPair<WriteAESKeyGen, [ZnFPU01], 4>;
474 def : WriteRes<WriteFence, [ZnAGU]>;
475 def : WriteRes<WriteNop, []>;
477 // Following instructions with latency=100 are microcoded.
478 // We set long latency so as to block the entire pipeline.
479 defm : ZnWriteResFpuPair<WriteFShuffle256, [ZnFPU], 100>;
480 defm : ZnWriteResFpuPair<WriteFVarShuffle256, [ZnFPU], 100>;
482 // Microcoded Instructions
483 def ZnWriteMicrocoded : SchedWriteRes<[]> {
487 def : SchedAlias<WriteMicrocoded, ZnWriteMicrocoded>;
488 def : SchedAlias<WriteFCMOV, ZnWriteMicrocoded>;
489 def : SchedAlias<WriteSystem, ZnWriteMicrocoded>;
490 def : SchedAlias<WriteMPSAD, ZnWriteMicrocoded>;
491 def : SchedAlias<WriteMPSADY, ZnWriteMicrocoded>;
492 def : SchedAlias<WriteMPSADLd, ZnWriteMicrocoded>;
493 def : SchedAlias<WriteMPSADYLd, ZnWriteMicrocoded>;
494 def : SchedAlias<WriteCLMul, ZnWriteMicrocoded>;
495 def : SchedAlias<WriteCLMulLd, ZnWriteMicrocoded>;
496 def : SchedAlias<WritePCmpIStrM, ZnWriteMicrocoded>;
497 def : SchedAlias<WritePCmpIStrMLd, ZnWriteMicrocoded>;
498 def : SchedAlias<WritePCmpEStrI, ZnWriteMicrocoded>;
499 def : SchedAlias<WritePCmpEStrILd, ZnWriteMicrocoded>;
500 def : SchedAlias<WritePCmpEStrM, ZnWriteMicrocoded>;
501 def : SchedAlias<WritePCmpEStrMLd, ZnWriteMicrocoded>;
502 def : SchedAlias<WritePCmpIStrI, ZnWriteMicrocoded>;
503 def : SchedAlias<WritePCmpIStrILd, ZnWriteMicrocoded>;
504 def : SchedAlias<WriteLDMXCSR, ZnWriteMicrocoded>;
505 def : SchedAlias<WriteSTMXCSR, ZnWriteMicrocoded>;
507 //=== Regex based InstRW ===//
512 // - mm: 64 bit mmx register.
513 // - x = 128 bit xmm register.
514 // - (x)mm = mmx or xmm register.
515 // - y = 256 bit ymm register.
516 // - v = any vector register.
518 //=== Integer Instructions ===//
519 //-- Move instructions --//
522 def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>;
526 def : InstRW<[WriteLoad], (instregex "MOV(S|Z)X32rm(8|16)")>;
530 def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> {
534 def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>;
536 def : InstRW<[WriteMicrocoded], (instrs XLAT)>;
540 def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{
544 def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>;
545 def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>;
546 def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>;
550 // r. Has default values.
552 def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{
555 def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>;
558 def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
561 def ZnWritePushA : SchedWriteRes<[ZnAGU]> {
564 def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>;
567 def : InstRW<[WriteMicrocoded], (instrs LAHF)>;
571 def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> {
574 def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>;
577 def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>;
579 //-- Arithmetic instructions --//
583 def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)",
584 "(ADD|SUB)(8|16|32|64)mi8",
589 def : InstRW<[WriteALULd],
590 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)",
591 "(ADC|SBB)(16|32|64)mi8",
596 def : InstRW<[WriteALULd],
597 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>;
601 def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
604 def : SchedAlias<WriteIMul16, ZnWriteMul16>;
605 def : SchedAlias<WriteIMul16Imm, ZnWriteMul16>; // TODO: is this right?
606 def : SchedAlias<WriteIMul16Reg, ZnWriteMul16>; // TODO: is this right?
607 def : SchedAlias<WriteIMul16ImmLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
608 def : SchedAlias<WriteIMul16RegLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
611 def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
614 def : SchedAlias<WriteIMul16Ld, ZnWriteMul16Ld>;
617 def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
620 def : SchedAlias<WriteIMul32, ZnWriteMul32>;
621 def : SchedAlias<WriteIMul32Imm, ZnWriteMul32>; // TODO: is this right?
622 def : SchedAlias<WriteIMul32Reg, ZnWriteMul32>; // TODO: is this right?
623 def : SchedAlias<WriteIMul32ImmLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
624 def : SchedAlias<WriteIMul32RegLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
627 def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
630 def : SchedAlias<WriteIMul32Ld, ZnWriteMul32Ld>;
633 def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
637 def : SchedAlias<WriteIMul64, ZnWriteMul64>;
638 def : SchedAlias<WriteIMul64Imm, ZnWriteMul64>; // TODO: is this right?
639 def : SchedAlias<WriteIMul64Reg, ZnWriteMul64>; // TODO: is this right?
640 def : SchedAlias<WriteIMul64ImmLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
641 def : SchedAlias<WriteIMul64RegLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
644 def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
648 def : SchedAlias<WriteIMul64Ld, ZnWriteMul64Ld>;
652 def ZnWriteMulX32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
654 let ResourceCycles = [1, 2];
656 def : InstRW<[ZnWriteMulX32], (instrs MULX32rr)>;
659 def ZnWriteMulX32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
661 let ResourceCycles = [1, 2, 2];
663 def : InstRW<[ZnWriteMulX32Ld, ReadAfterLd], (instrs MULX32rm)>;
666 def ZnWriteMulX64 : SchedWriteRes<[ZnALU1]> {
669 def : InstRW<[ZnWriteMulX64], (instrs MULX64rr)>;
672 def ZnWriteMulX64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
675 def : InstRW<[ZnWriteMulX64Ld, ReadAfterLd], (instrs MULX64rm)>;
677 //-- Control transfer instructions --//
680 def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>;
681 def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>;
684 def : InstRW<[WriteMicrocoded], (instrs INTO)>;
687 def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>;
688 def : InstRW<[ZnWriteLOOP], (instrs LOOP)>;
690 // LOOP(N)E, LOOP(N)Z
691 def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>;
692 def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>;
696 def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>;
697 def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>;
699 def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>;
702 def ZnWriteRET : SchedWriteRes<[ZnALU03]> {
705 def : InstRW<[ZnWriteRET], (instregex "RET(L|Q|W)", "LRET(L|Q|W)",
708 //-- Logic instructions --//
712 def : InstRW<[WriteALULd],
713 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)",
714 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>;
716 // Define ALU latency variants
717 def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> {
720 def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> {
726 def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> {
731 def : SchedAlias<WriteBitTestSetImmRMW, ZnWriteBTRSCm>;
732 def : SchedAlias<WriteBitTestSetRegRMW, ZnWriteBTRSCm>;
736 def : SchedAlias<WriteBLS, ZnWriteALULat2>;
738 def : SchedAlias<WriteBLSLd, ZnWriteALULat2Ld>;
741 def : InstRW<[WriteALU], (instrs STD, CLD)>;
745 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>;
747 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>;
751 def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>;
755 def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>;
759 def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>;
762 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>;
765 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>;
767 //-- Misc instructions --//
769 def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> {
770 let NumMicroOps = 18;
772 def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>;
774 def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>;
777 def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> {
781 def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>;
784 def : InstRW<[WriteMicrocoded], (instrs PAUSE)>;
787 def : InstRW<[WriteMicrocoded], (instregex "RDTSC")>;
790 def : InstRW<[WriteMicrocoded], (instrs RDPMC)>;
793 def : InstRW<[WriteMicrocoded], (instrs RDRAND16r, RDRAND32r, RDRAND64r)>;
796 def : InstRW<[WriteMicrocoded], (instrs XGETBV)>;
798 //-- String instructions --//
800 def : InstRW<[WriteMicrocoded], (instregex "CMPS(B|L|Q|W)")>;
803 def : InstRW<[WriteMicrocoded], (instregex "LODS(B|W)")>;
806 def : InstRW<[WriteMicrocoded], (instregex "LODS(L|Q)")>;
809 def : InstRW<[WriteMicrocoded], (instregex "MOVS(B|L|Q|W)")>;
812 def : InstRW<[WriteMicrocoded], (instregex "SCAS(B|W|L|Q)")>;
815 def : InstRW<[WriteMicrocoded], (instregex "STOS(B|L|Q|W)")>;
818 def ZnXADD : SchedWriteRes<[ZnALU]>;
819 def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>;
820 def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>;
822 //=== Floating Point x87 Instructions ===//
823 //-- Move instructions --//
825 def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ;
827 def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> {
834 def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>;
837 def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> {
840 def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>;
843 def : InstRW<[WriteMicrocoded], (instrs FBLDm)>;
847 def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>;
850 def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> {
853 def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>;
857 def : InstRW<[WriteMicrocoded], (instrs FBSTPm)>;
859 def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>;
862 def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>;
865 def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> {
869 def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>;
872 def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> {
875 def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>;
877 def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> {
881 def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> {
886 def : SchedAlias<WriteFLD0, ZnWriteFPU13>;
889 def : SchedAlias<WriteFLD1, ZnWriteFPU3>;
892 def : SchedAlias<WriteFLDC, ZnWriteFPU3>;
896 def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>;
899 def : InstRW<[WriteMicrocoded], (instrs FNSTSWm)>;
902 def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>;
905 def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>;
908 def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>;
911 def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>;
914 def : InstRW<[WriteMicrocoded], (instrs FSAVEm)>;
917 def : InstRW<[WriteMicrocoded], (instrs FRSTORm)>;
919 //-- Arithmetic instructions --//
921 def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ;
923 def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ;
925 def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> {
930 def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>;
934 def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>;
936 def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>;
940 def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>;
942 def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]>
947 // FCOMI(P) FUCOMI(P).
949 def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
951 def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]>
955 let ResourceCycles = [1,3];
959 def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>;
962 def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>;
965 def : InstRW<[ZnWriteFPU3Lat1], (instrs FXAM)>;
968 def : InstRW<[WriteMicrocoded], (instrs FPREM)>;
971 def : InstRW<[WriteMicrocoded], (instrs FPREM1)>;
974 def : InstRW<[WriteMicrocoded], (instrs FRNDINT)>;
977 def : InstRW<[WriteMicrocoded], (instrs FSCALE)>;
980 def : InstRW<[WriteMicrocoded], (instrs FXTRACT)>;
983 def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>;
986 def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>;
989 def : InstRW<[WriteMicrocoded], (instrs FNCLEX)>;
992 def : InstRW<[WriteMicrocoded], (instrs FNINIT)>;
994 //=== Integer MMX and XMM Instructions ===//
998 def ZnWriteFPU12 : SchedWriteRes<[ZnFPU12]> ;
999 def ZnWriteFPU12Y : SchedWriteRes<[ZnFPU12]> {
1000 let NumMicroOps = 2;
1002 def ZnWriteFPU12m : SchedWriteRes<[ZnAGU, ZnFPU12]> ;
1003 def ZnWriteFPU12Ym : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1005 let NumMicroOps = 2;
1008 def : InstRW<[ZnWriteFPU12], (instrs MMX_PACKSSDWirr,
1011 def : InstRW<[ZnWriteFPU12m], (instrs MMX_PACKSSDWirm,
1015 // VPMOVSX/ZX BW BD BQ WD WQ DQ.
1017 def : InstRW<[ZnWriteFPU12Y], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrr")>;
1018 def : InstRW<[ZnWriteFPU12Ym], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrm")>;
1020 def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ;
1021 def ZnWriteFPU013Y : SchedWriteRes<[ZnFPU013]> {
1024 def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1026 let NumMicroOps = 2;
1028 def ZnWriteFPU013Ld : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1030 let NumMicroOps = 2;
1032 def ZnWriteFPU013LdY : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1034 let NumMicroOps = 2;
1039 def : InstRW<[ZnWriteFPU013], (instregex "(V?)PBLENDWrri")>;
1041 def : InstRW<[ZnWriteFPU013Y], (instrs VPBLENDWYrri)>;
1044 def : InstRW<[ZnWriteFPU013Ld], (instregex "(V?)PBLENDWrmi")>;
1046 def : InstRW<[ZnWriteFPU013LdY], (instrs VPBLENDWYrmi)>;
1048 def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ;
1049 def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> {
1050 let NumMicroOps = 2;
1055 def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>;
1057 def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>;
1060 def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1061 let NumMicroOps = 2;
1063 let ResourceCycles = [1, 2];
1065 def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1066 let NumMicroOps = 2;
1068 let ResourceCycles = [1, 3];
1070 def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>;
1071 def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>;
1074 def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>;
1077 def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>;
1081 def : InstRW<[WriteMicrocoded],
1082 (instregex "VPMASKMOVD(Y?)rm")>;
1084 def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>;
1088 def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1090 let NumMicroOps = 2;
1091 let ResourceCycles = [1, 2];
1093 def : InstRW<[ZnWriteVPBROADCAST128Ld],
1094 (instregex "VPBROADCAST(B|W)rm")>;
1097 def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1099 let NumMicroOps = 2;
1100 let ResourceCycles = [1, 2];
1102 def : InstRW<[ZnWriteVPBROADCAST256Ld],
1103 (instregex "VPBROADCAST(B|W)Yrm")>;
1106 def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>;
1108 //-- Arithmetic instructions --//
1111 // PHADD|PHSUB (S) W/D.
1112 def : SchedAlias<WritePHAdd, ZnWriteMicrocoded>;
1113 def : SchedAlias<WritePHAddLd, ZnWriteMicrocoded>;
1114 def : SchedAlias<WritePHAddX, ZnWriteMicrocoded>;
1115 def : SchedAlias<WritePHAddXLd, ZnWriteMicrocoded>;
1116 def : SchedAlias<WritePHAddY, ZnWriteMicrocoded>;
1117 def : SchedAlias<WritePHAddYLd, ZnWriteMicrocoded>;
1120 def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>;
1121 def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>;
1124 def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
1128 def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
1130 let NumMicroOps = 2;
1131 let ResourceCycles = [1,2];
1133 def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>;
1134 def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>;
1136 //-- Logic instructions --//
1138 // PSLL,PSRL,PSRA W/D/Q.
1140 def ZnWritePShift : SchedWriteRes<[ZnFPU2]> ;
1141 def ZnWritePShiftY : SchedWriteRes<[ZnFPU2]> {
1146 def : InstRW<[ZnWritePShift], (instregex "(V?)PS(R|L)LDQri")>;
1147 def : InstRW<[ZnWritePShiftY], (instregex "(V?)PS(R|L)LDQYri")>;
1149 //=== Floating Point XMM and YMM Instructions ===//
1150 //-- Move instructions --//
1153 def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr)>;
1154 def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm)>;
1156 def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> {
1157 let NumMicroOps = 2;
1161 def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128)>;
1165 def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1167 let NumMicroOps = 2;
1168 let ResourceCycles = [1, 2];
1170 def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>;
1172 def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> {
1174 let NumMicroOps = 2;
1175 let ResourceCycles = [5, 1, 2];
1178 def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>;
1182 def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rr)>;
1185 def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mr)>;
1187 def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> {
1189 let ResourceCycles = [2];
1191 def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> {
1193 let NumMicroOps = 2;
1194 let ResourceCycles = [1, 2];
1198 def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rr)>;
1199 def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rm)>;
1202 def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>;
1204 //-- Conversion instructions --//
1205 def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> {
1208 def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> {
1214 def : SchedAlias<WriteCvtPD2PS, ZnWriteCVTPD2PSr>;
1216 def : SchedAlias<WriteCvtPD2PSY, ZnWriteCVTPD2PSYr>;
1218 defm : X86WriteResUnsupported<WriteCvtPD2PSZ>;
1220 def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU03]> {
1222 let NumMicroOps = 2;
1223 let ResourceCycles = [1,2];
1226 def : SchedAlias<WriteCvtPD2PSLd, ZnWriteCVTPD2PSLd>;
1229 def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1232 def : SchedAlias<WriteCvtPD2PSYLd, ZnWriteCVTPD2PSYLd>;
1234 defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>;
1238 // Same as WriteCVTPD2PSr
1239 def : SchedAlias<WriteCvtSD2SS, ZnWriteCVTPD2PSr>;
1242 def : SchedAlias<WriteCvtSD2SSLd, ZnWriteCVTPD2PSLd>;
1246 def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> {
1249 def : SchedAlias<WriteCvtPS2PD, ZnWriteCVTPS2PDr>;
1253 def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1255 let NumMicroOps = 2;
1257 def : SchedAlias<WriteCvtPS2PDLd, ZnWriteCVTPS2PDLd>;
1258 def : SchedAlias<WriteCvtPS2PDYLd, ZnWriteCVTPS2PDLd>;
1259 defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>;
1262 def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> {
1265 def : SchedAlias<WriteCvtPS2PDY, ZnWriteVCVTPS2PDY>;
1266 defm : X86WriteResUnsupported<WriteCvtPS2PDZ>;
1270 def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> {
1273 def : SchedAlias<WriteCvtSS2SD, ZnWriteCVTSS2SDr>;
1276 def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1278 let NumMicroOps = 2;
1279 let ResourceCycles = [1, 2];
1281 def : SchedAlias<WriteCvtSS2SDLd, ZnWriteCVTSS2SDLd>;
1283 def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> {
1288 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>;
1292 def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>;
1294 def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> {
1299 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V?)CVT(T?)PD2DQrr")>;
1301 def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> {
1303 let NumMicroOps = 2;
1306 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>;
1307 // same as xmm handling
1309 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>;
1311 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>;
1313 def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> {
1318 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIirr")>;
1322 def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDirr)>;
1326 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIirr")>;
1328 def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> {
1332 // same as CVTPD2DQr
1335 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>;
1336 // same as CVTPD2DQm
1338 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>;
1340 def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> {
1345 def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>;
1348 def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> {
1351 def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> {
1356 def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>;
1358 def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>;
1362 def : SchedAlias<WriteCvtPS2PH, ZnWriteMicrocoded>;
1363 def : SchedAlias<WriteCvtPS2PHY, ZnWriteMicrocoded>;
1364 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
1366 def : SchedAlias<WriteCvtPS2PHSt, ZnWriteMicrocoded>;
1367 def : SchedAlias<WriteCvtPS2PHYSt, ZnWriteMicrocoded>;
1368 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
1372 def : SchedAlias<WriteCvtPH2PS, ZnWriteMicrocoded>;
1373 def : SchedAlias<WriteCvtPH2PSY, ZnWriteMicrocoded>;
1374 defm : X86WriteResUnsupported<WriteCvtPH2PSZ>;
1376 def : SchedAlias<WriteCvtPH2PSLd, ZnWriteMicrocoded>;
1377 def : SchedAlias<WriteCvtPH2PSYLd, ZnWriteMicrocoded>;
1378 defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>;
1380 //-- SSE4A instructions --//
1382 def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1385 def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>;
1388 def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> {
1391 def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>;
1393 //-- SHA instructions --//
1395 def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>;
1397 // SHA1MSG1, SHA256MSG1
1399 def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> {
1401 let ResourceCycles = [2];
1403 def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>;
1405 def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1407 let ResourceCycles = [1,2];
1409 def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>;
1413 def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ;
1414 def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>;
1416 def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1419 def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>;
1423 def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ;
1424 def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>;
1426 def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1429 def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>;
1433 def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> {
1436 def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>;
1438 def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1441 def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>;
1445 def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> {
1448 def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>;
1450 def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1453 def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>;
1455 //-- Arithmetic instructions --//
1458 def : SchedAlias<WriteFHAdd, ZnWriteMicrocoded>;
1459 def : SchedAlias<WriteFHAddLd, ZnWriteMicrocoded>;
1460 def : SchedAlias<WriteFHAddY, ZnWriteMicrocoded>;
1461 def : SchedAlias<WriteFHAddYLd, ZnWriteMicrocoded>;
1464 // TODO - convert to ZnWriteResFpuPair
1466 def ZnWriteVDIVPSYr : SchedWriteRes<[ZnFPU3]> {
1468 let ResourceCycles = [12];
1470 def : SchedAlias<WriteFDivY, ZnWriteVDIVPSYr>;
1473 def ZnWriteVDIVPSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1475 let NumMicroOps = 2;
1476 let ResourceCycles = [1, 19];
1478 def : SchedAlias<WriteFDivYLd, ZnWriteVDIVPSYLd>;
1481 // TODO - convert to ZnWriteResFpuPair
1483 def ZnWriteVDIVPDY : SchedWriteRes<[ZnFPU3]> {
1485 let ResourceCycles = [15];
1487 def : SchedAlias<WriteFDiv64Y, ZnWriteVDIVPDY>;
1490 def ZnWriteVDIVPDYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1492 let NumMicroOps = 2;
1493 let ResourceCycles = [1,22];
1495 def : SchedAlias<WriteFDiv64YLd, ZnWriteVDIVPDYLd>;
1499 def : SchedAlias<WriteDPPS, ZnWriteMicrocoded>;
1500 def : SchedAlias<WriteDPPSY, ZnWriteMicrocoded>;
1503 def : SchedAlias<WriteDPPSLd, ZnWriteMicrocoded>;
1504 def : SchedAlias<WriteDPPSYLd,ZnWriteMicrocoded>;
1508 def : SchedAlias<WriteDPPD, ZnWriteMicrocoded>;
1511 def : SchedAlias<WriteDPPDLd, ZnWriteMicrocoded>;
1514 // TODO - convert to ZnWriteResFpuPair
1516 def ZnWriteRSQRTSSr : SchedWriteRes<[ZnFPU02]> {
1519 def : SchedAlias<WriteFRsqrt, ZnWriteRSQRTSSr>;
1522 def ZnWriteRSQRTSSLd: SchedWriteRes<[ZnAGU, ZnFPU02]> {
1524 let NumMicroOps = 2;
1525 let ResourceCycles = [1,2]; // FIXME: Is this right?
1527 def : SchedAlias<WriteFRsqrtLd, ZnWriteRSQRTSSLd>;
1530 // TODO - convert to ZnWriteResFpuPair
1532 def ZnWriteRSQRTPSYr : SchedWriteRes<[ZnFPU01]> {
1534 let NumMicroOps = 2;
1535 let ResourceCycles = [2];
1537 def : SchedAlias<WriteFRsqrtY, ZnWriteRSQRTPSYr>;
1540 def ZnWriteRSQRTPSYLd : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1542 let NumMicroOps = 2;
1544 def : SchedAlias<WriteFRsqrtYLd, ZnWriteRSQRTPSYLd>;
1546 //-- Other instructions --//
1549 def : InstRW<[WriteMicrocoded], (instrs VZEROUPPER)>;
1552 def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>;