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 defm : ZnWriteResPair<WriteCMOV2, [ZnALU], 1>;
219 def : WriteRes<WriteSETCC, [ZnALU]>;
220 def : WriteRes<WriteSETCCStore, [ZnALU, ZnAGU]>;
221 defm : X86WriteRes<WriteLAHFSAHF, [ZnALU], 2, [1], 2>;
223 defm : X86WriteRes<WriteBitTest, [ZnALU], 1, [1], 1>;
224 defm : X86WriteRes<WriteBitTestImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
225 defm : X86WriteRes<WriteBitTestRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
226 defm : X86WriteRes<WriteBitTestSet, [ZnALU], 2, [1], 2>;
227 //defm : X86WriteRes<WriteBitTestSetImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
228 //defm : X86WriteRes<WriteBitTestSetRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>;
231 defm : ZnWriteResPair<WriteBSF, [ZnALU], 3>;
232 defm : ZnWriteResPair<WriteBSR, [ZnALU], 3>;
233 defm : ZnWriteResPair<WriteLZCNT, [ZnALU], 2>;
234 defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2>;
235 defm : ZnWriteResPair<WritePOPCNT, [ZnALU], 1>;
237 // Treat misc copies as a move.
238 def : InstRW<[WriteMove], (instrs COPY)>;
240 // BMI1 BEXTR/BLS, BMI2 BZHI
241 defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1>;
242 //defm : ZnWriteResPair<WriteBLS, [ZnALU], 2>;
243 defm : ZnWriteResPair<WriteBZHI, [ZnALU], 1>;
246 defm : ZnWriteResPair<WriteDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
247 defm : ZnWriteResPair<WriteDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
248 defm : ZnWriteResPair<WriteDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
249 defm : ZnWriteResPair<WriteDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
250 defm : ZnWriteResPair<WriteIDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>;
251 defm : ZnWriteResPair<WriteIDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>;
252 defm : ZnWriteResPair<WriteIDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>;
253 defm : ZnWriteResPair<WriteIDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>;
256 def : WriteRes<WriteIMulH, [ZnALU1, ZnMultiplier]>{
260 // Floating point operations
261 defm : X86WriteRes<WriteFLoad, [ZnAGU], 8, [1], 1>;
262 defm : X86WriteRes<WriteFLoadX, [ZnAGU], 8, [1], 1>;
263 defm : X86WriteRes<WriteFLoadY, [ZnAGU], 8, [1], 1>;
264 defm : X86WriteRes<WriteFMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,1], 1>;
265 defm : X86WriteRes<WriteFMaskedLoadY, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
266 defm : X86WriteRes<WriteFStore, [ZnAGU], 1, [1], 1>;
267 defm : X86WriteRes<WriteFStoreX, [ZnAGU], 1, [1], 1>;
268 defm : X86WriteRes<WriteFStoreY, [ZnAGU], 1, [1], 1>;
269 defm : X86WriteRes<WriteFStoreNT, [ZnAGU,ZnFPU2], 8, [1,1], 1>;
270 defm : X86WriteRes<WriteFStoreNTX, [ZnAGU], 1, [1], 1>;
271 defm : X86WriteRes<WriteFStoreNTY, [ZnAGU], 1, [1], 1>;
272 defm : X86WriteRes<WriteFMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
273 defm : X86WriteRes<WriteFMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
274 defm : X86WriteRes<WriteFMove, [ZnFPU], 1, [1], 1>;
275 defm : X86WriteRes<WriteFMoveX, [ZnFPU], 1, [1], 1>;
276 defm : X86WriteRes<WriteFMoveY, [ZnFPU], 1, [1], 1>;
278 defm : ZnWriteResFpuPair<WriteFAdd, [ZnFPU0], 3>;
279 defm : ZnWriteResFpuPair<WriteFAddX, [ZnFPU0], 3>;
280 defm : ZnWriteResFpuPair<WriteFAddY, [ZnFPU0], 3>;
281 defm : X86WriteResPairUnsupported<WriteFAddZ>;
282 defm : ZnWriteResFpuPair<WriteFAdd64, [ZnFPU0], 3>;
283 defm : ZnWriteResFpuPair<WriteFAdd64X, [ZnFPU0], 3>;
284 defm : ZnWriteResFpuPair<WriteFAdd64Y, [ZnFPU0], 3>;
285 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
286 defm : ZnWriteResFpuPair<WriteFCmp, [ZnFPU0], 3>;
287 defm : ZnWriteResFpuPair<WriteFCmpX, [ZnFPU0], 3>;
288 defm : ZnWriteResFpuPair<WriteFCmpY, [ZnFPU0], 3>;
289 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
290 defm : ZnWriteResFpuPair<WriteFCmp64, [ZnFPU0], 3>;
291 defm : ZnWriteResFpuPair<WriteFCmp64X, [ZnFPU0], 3>;
292 defm : ZnWriteResFpuPair<WriteFCmp64Y, [ZnFPU0], 3>;
293 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
294 defm : ZnWriteResFpuPair<WriteFCom, [ZnFPU0], 3>;
295 defm : ZnWriteResFpuPair<WriteFBlend, [ZnFPU01], 1>;
296 defm : ZnWriteResFpuPair<WriteFBlendY, [ZnFPU01], 1>;
297 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
298 defm : ZnWriteResFpuPair<WriteFVarBlend, [ZnFPU01], 1>;
299 defm : ZnWriteResFpuPair<WriteFVarBlendY,[ZnFPU01], 1>;
300 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
301 defm : ZnWriteResFpuPair<WriteVarBlend, [ZnFPU0], 1>;
302 defm : ZnWriteResFpuPair<WriteVarBlendY, [ZnFPU0], 1>;
303 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
304 defm : ZnWriteResFpuPair<WriteCvtSS2I, [ZnFPU3], 5>;
305 defm : ZnWriteResFpuPair<WriteCvtPS2I, [ZnFPU3], 5>;
306 defm : ZnWriteResFpuPair<WriteCvtPS2IY, [ZnFPU3], 5>;
307 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
308 defm : ZnWriteResFpuPair<WriteCvtSD2I, [ZnFPU3], 5>;
309 defm : ZnWriteResFpuPair<WriteCvtPD2I, [ZnFPU3], 5>;
310 defm : ZnWriteResFpuPair<WriteCvtPD2IY, [ZnFPU3], 5>;
311 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
312 defm : ZnWriteResFpuPair<WriteCvtI2SS, [ZnFPU3], 5>;
313 defm : ZnWriteResFpuPair<WriteCvtI2PS, [ZnFPU3], 5>;
314 defm : ZnWriteResFpuPair<WriteCvtI2PSY, [ZnFPU3], 5>;
315 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
316 defm : ZnWriteResFpuPair<WriteCvtI2SD, [ZnFPU3], 5>;
317 defm : ZnWriteResFpuPair<WriteCvtI2PD, [ZnFPU3], 5>;
318 defm : ZnWriteResFpuPair<WriteCvtI2PDY, [ZnFPU3], 5>;
319 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
320 defm : ZnWriteResFpuPair<WriteFDiv, [ZnFPU3], 15>;
321 defm : ZnWriteResFpuPair<WriteFDivX, [ZnFPU3], 15>;
322 //defm : ZnWriteResFpuPair<WriteFDivY, [ZnFPU3], 15>;
323 defm : X86WriteResPairUnsupported<WriteFDivZ>;
324 defm : ZnWriteResFpuPair<WriteFDiv64, [ZnFPU3], 15>;
325 defm : ZnWriteResFpuPair<WriteFDiv64X, [ZnFPU3], 15>;
326 //defm : ZnWriteResFpuPair<WriteFDiv64Y, [ZnFPU3], 15>;
327 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
328 defm : ZnWriteResFpuPair<WriteFSign, [ZnFPU3], 2>;
329 defm : ZnWriteResFpuPair<WriteFRnd, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
330 defm : ZnWriteResFpuPair<WriteFRndY, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops?
331 defm : X86WriteResPairUnsupported<WriteFRndZ>;
332 defm : ZnWriteResFpuPair<WriteFLogic, [ZnFPU], 1>;
333 defm : ZnWriteResFpuPair<WriteFLogicY, [ZnFPU], 1>;
334 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
335 defm : ZnWriteResFpuPair<WriteFTest, [ZnFPU], 1>;
336 defm : ZnWriteResFpuPair<WriteFTestY, [ZnFPU], 1>;
337 defm : X86WriteResPairUnsupported<WriteFTestZ>;
338 defm : ZnWriteResFpuPair<WriteFShuffle, [ZnFPU12], 1>;
339 defm : ZnWriteResFpuPair<WriteFShuffleY, [ZnFPU12], 1>;
340 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
341 defm : ZnWriteResFpuPair<WriteFVarShuffle, [ZnFPU12], 1>;
342 defm : ZnWriteResFpuPair<WriteFVarShuffleY,[ZnFPU12], 1>;
343 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
344 defm : ZnWriteResFpuPair<WriteFMul, [ZnFPU01], 3, [1], 1, 7, 1>;
345 defm : ZnWriteResFpuPair<WriteFMulX, [ZnFPU01], 3, [1], 1, 7, 1>;
346 defm : ZnWriteResFpuPair<WriteFMulY, [ZnFPU01], 4, [1], 1, 7, 1>;
347 defm : X86WriteResPairUnsupported<WriteFMulZ>;
348 defm : ZnWriteResFpuPair<WriteFMul64, [ZnFPU01], 3, [1], 1, 7, 1>;
349 defm : ZnWriteResFpuPair<WriteFMul64X, [ZnFPU01], 3, [1], 1, 7, 1>;
350 defm : ZnWriteResFpuPair<WriteFMul64Y, [ZnFPU01], 4, [1], 1, 7, 1>;
351 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
352 defm : ZnWriteResFpuPair<WriteFMA, [ZnFPU03], 5>;
353 defm : ZnWriteResFpuPair<WriteFMAX, [ZnFPU03], 5>;
354 defm : ZnWriteResFpuPair<WriteFMAY, [ZnFPU03], 5>;
355 defm : X86WriteResPairUnsupported<WriteFMAZ>;
356 defm : ZnWriteResFpuPair<WriteFRcp, [ZnFPU01], 5>;
357 defm : ZnWriteResFpuPair<WriteFRcpX, [ZnFPU01], 5>;
358 defm : ZnWriteResFpuPair<WriteFRcpY, [ZnFPU01], 5, [1], 1, 7, 2>;
359 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
360 //defm : ZnWriteResFpuPair<WriteFRsqrt, [ZnFPU02], 5>;
361 defm : ZnWriteResFpuPair<WriteFRsqrtX, [ZnFPU01], 5, [1], 1, 7, 1>;
362 //defm : ZnWriteResFpuPair<WriteFRsqrtY, [ZnFPU01], 5, [2], 2>;
363 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
364 defm : ZnWriteResFpuPair<WriteFSqrt, [ZnFPU3], 20, [20]>;
365 defm : ZnWriteResFpuPair<WriteFSqrtX, [ZnFPU3], 20, [20]>;
366 defm : ZnWriteResFpuPair<WriteFSqrtY, [ZnFPU3], 28, [28], 1, 7, 1>;
367 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
368 defm : ZnWriteResFpuPair<WriteFSqrt64, [ZnFPU3], 20, [20]>;
369 defm : ZnWriteResFpuPair<WriteFSqrt64X, [ZnFPU3], 20, [20]>;
370 defm : ZnWriteResFpuPair<WriteFSqrt64Y, [ZnFPU3], 40, [40], 1, 7, 1>;
371 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
372 defm : ZnWriteResFpuPair<WriteFSqrt80, [ZnFPU3], 20, [20]>;
374 // Vector integer operations which uses FPU units
375 defm : X86WriteRes<WriteVecLoad, [ZnAGU], 8, [1], 1>;
376 defm : X86WriteRes<WriteVecLoadX, [ZnAGU], 8, [1], 1>;
377 defm : X86WriteRes<WriteVecLoadY, [ZnAGU], 8, [1], 1>;
378 defm : X86WriteRes<WriteVecLoadNT, [ZnAGU], 8, [1], 1>;
379 defm : X86WriteRes<WriteVecLoadNTY, [ZnAGU], 8, [1], 1>;
380 defm : X86WriteRes<WriteVecMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,2], 2>;
381 defm : X86WriteRes<WriteVecMaskedLoadY, [ZnAGU,ZnFPU01], 9, [1,3], 2>;
382 defm : X86WriteRes<WriteVecStore, [ZnAGU], 1, [1], 1>;
383 defm : X86WriteRes<WriteVecStoreX, [ZnAGU], 1, [1], 1>;
384 defm : X86WriteRes<WriteVecStoreY, [ZnAGU], 1, [1], 1>;
385 defm : X86WriteRes<WriteVecStoreNT, [ZnAGU], 1, [1], 1>;
386 defm : X86WriteRes<WriteVecStoreNTY, [ZnAGU], 1, [1], 1>;
387 defm : X86WriteRes<WriteVecMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>;
388 defm : X86WriteRes<WriteVecMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>;
389 defm : X86WriteRes<WriteVecMove, [ZnFPU], 1, [1], 1>;
390 defm : X86WriteRes<WriteVecMoveX, [ZnFPU], 1, [1], 1>;
391 defm : X86WriteRes<WriteVecMoveY, [ZnFPU], 2, [1], 2>;
392 defm : X86WriteRes<WriteVecMoveToGpr, [ZnFPU2], 2, [1], 1>;
393 defm : X86WriteRes<WriteVecMoveFromGpr, [ZnFPU2], 3, [1], 1>;
394 defm : X86WriteRes<WriteEMMS, [ZnFPU], 2, [1], 1>;
396 defm : ZnWriteResFpuPair<WriteVecShift, [ZnFPU], 1>;
397 defm : ZnWriteResFpuPair<WriteVecShiftX, [ZnFPU2], 1>;
398 defm : ZnWriteResFpuPair<WriteVecShiftY, [ZnFPU2], 2>;
399 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
400 defm : ZnWriteResFpuPair<WriteVecShiftImm, [ZnFPU], 1>;
401 defm : ZnWriteResFpuPair<WriteVecShiftImmX, [ZnFPU], 1>;
402 defm : ZnWriteResFpuPair<WriteVecShiftImmY, [ZnFPU], 1>;
403 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
404 defm : ZnWriteResFpuPair<WriteVecLogic, [ZnFPU], 1>;
405 defm : ZnWriteResFpuPair<WriteVecLogicX, [ZnFPU], 1>;
406 defm : ZnWriteResFpuPair<WriteVecLogicY, [ZnFPU], 1>;
407 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
408 defm : ZnWriteResFpuPair<WriteVecTest, [ZnFPU12], 1, [2], 1, 7, 1>;
409 defm : ZnWriteResFpuPair<WriteVecTestY, [ZnFPU12], 1, [2], 1, 7, 1>;
410 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
411 defm : ZnWriteResFpuPair<WriteVecALU, [ZnFPU], 1>;
412 defm : ZnWriteResFpuPair<WriteVecALUX, [ZnFPU], 1>;
413 defm : ZnWriteResFpuPair<WriteVecALUY, [ZnFPU], 1>;
414 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
415 defm : ZnWriteResFpuPair<WriteVecIMul, [ZnFPU0], 4>;
416 defm : ZnWriteResFpuPair<WriteVecIMulX, [ZnFPU0], 4>;
417 defm : ZnWriteResFpuPair<WriteVecIMulY, [ZnFPU0], 4>;
418 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
419 defm : ZnWriteResFpuPair<WritePMULLD, [ZnFPU0], 4, [1], 1, 7, 1>; // FIXME
420 defm : ZnWriteResFpuPair<WritePMULLDY, [ZnFPU0], 5, [2], 1, 7, 1>; // FIXME
421 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
422 defm : ZnWriteResFpuPair<WriteShuffle, [ZnFPU], 1>;
423 defm : ZnWriteResFpuPair<WriteShuffleX, [ZnFPU], 1>;
424 defm : ZnWriteResFpuPair<WriteShuffleY, [ZnFPU], 1>;
425 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
426 defm : ZnWriteResFpuPair<WriteVarShuffle, [ZnFPU], 1>;
427 defm : ZnWriteResFpuPair<WriteVarShuffleX,[ZnFPU], 1>;
428 defm : ZnWriteResFpuPair<WriteVarShuffleY,[ZnFPU], 1>;
429 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
430 defm : ZnWriteResFpuPair<WriteBlend, [ZnFPU01], 1>;
431 defm : ZnWriteResFpuPair<WriteBlendY, [ZnFPU01], 1>;
432 defm : X86WriteResPairUnsupported<WriteBlendZ>;
433 defm : ZnWriteResFpuPair<WriteShuffle256, [ZnFPU], 2>;
434 defm : ZnWriteResFpuPair<WriteVarShuffle256, [ZnFPU], 2>;
435 defm : ZnWriteResFpuPair<WritePSADBW, [ZnFPU0], 3>;
436 defm : ZnWriteResFpuPair<WritePSADBWX, [ZnFPU0], 3>;
437 defm : ZnWriteResFpuPair<WritePSADBWY, [ZnFPU0], 3>;
438 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
439 defm : ZnWriteResFpuPair<WritePHMINPOS, [ZnFPU0], 4>;
441 // Vector Shift Operations
442 defm : ZnWriteResFpuPair<WriteVarVecShift, [ZnFPU12], 1>;
443 defm : ZnWriteResFpuPair<WriteVarVecShiftY, [ZnFPU12], 1>;
444 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
446 // Vector insert/extract operations.
447 defm : ZnWriteResFpuPair<WriteVecInsert, [ZnFPU], 1>;
449 def : WriteRes<WriteVecExtract, [ZnFPU12, ZnFPU2]> {
451 let ResourceCycles = [1, 2];
453 def : WriteRes<WriteVecExtractSt, [ZnAGU, ZnFPU12, ZnFPU2]> {
456 let ResourceCycles = [1, 2, 3];
459 // MOVMSK Instructions.
460 def : WriteRes<WriteFMOVMSK, [ZnFPU2]>;
461 def : WriteRes<WriteMMXMOVMSK, [ZnFPU2]>;
462 def : WriteRes<WriteVecMOVMSK, [ZnFPU2]>;
464 def : WriteRes<WriteVecMOVMSKY, [ZnFPU2]> {
467 let ResourceCycles = [2];
471 defm : ZnWriteResFpuPair<WriteAESDecEnc, [ZnFPU01], 4>;
472 defm : ZnWriteResFpuPair<WriteAESIMC, [ZnFPU01], 4>;
473 defm : ZnWriteResFpuPair<WriteAESKeyGen, [ZnFPU01], 4>;
475 def : WriteRes<WriteFence, [ZnAGU]>;
476 def : WriteRes<WriteNop, []>;
478 // Following instructions with latency=100 are microcoded.
479 // We set long latency so as to block the entire pipeline.
480 defm : ZnWriteResFpuPair<WriteFShuffle256, [ZnFPU], 100>;
481 defm : ZnWriteResFpuPair<WriteFVarShuffle256, [ZnFPU], 100>;
483 // Microcoded Instructions
484 def ZnWriteMicrocoded : SchedWriteRes<[]> {
488 def : SchedAlias<WriteMicrocoded, ZnWriteMicrocoded>;
489 def : SchedAlias<WriteFCMOV, ZnWriteMicrocoded>;
490 def : SchedAlias<WriteSystem, ZnWriteMicrocoded>;
491 def : SchedAlias<WriteMPSAD, ZnWriteMicrocoded>;
492 def : SchedAlias<WriteMPSADY, ZnWriteMicrocoded>;
493 def : SchedAlias<WriteMPSADLd, ZnWriteMicrocoded>;
494 def : SchedAlias<WriteMPSADYLd, ZnWriteMicrocoded>;
495 def : SchedAlias<WriteCLMul, ZnWriteMicrocoded>;
496 def : SchedAlias<WriteCLMulLd, ZnWriteMicrocoded>;
497 def : SchedAlias<WritePCmpIStrM, ZnWriteMicrocoded>;
498 def : SchedAlias<WritePCmpIStrMLd, ZnWriteMicrocoded>;
499 def : SchedAlias<WritePCmpEStrI, ZnWriteMicrocoded>;
500 def : SchedAlias<WritePCmpEStrILd, ZnWriteMicrocoded>;
501 def : SchedAlias<WritePCmpEStrM, ZnWriteMicrocoded>;
502 def : SchedAlias<WritePCmpEStrMLd, ZnWriteMicrocoded>;
503 def : SchedAlias<WritePCmpIStrI, ZnWriteMicrocoded>;
504 def : SchedAlias<WritePCmpIStrILd, ZnWriteMicrocoded>;
505 def : SchedAlias<WriteLDMXCSR, ZnWriteMicrocoded>;
506 def : SchedAlias<WriteSTMXCSR, ZnWriteMicrocoded>;
508 //=== Regex based InstRW ===//
513 // - mm: 64 bit mmx register.
514 // - x = 128 bit xmm register.
515 // - (x)mm = mmx or xmm register.
516 // - y = 256 bit ymm register.
517 // - v = any vector register.
519 //=== Integer Instructions ===//
520 //-- Move instructions --//
523 def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>;
527 def : InstRW<[WriteLoad], (instregex "MOV(S|Z)X32rm(8|16)")>;
531 def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> {
535 def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>;
537 def : InstRW<[WriteMicrocoded], (instrs XLAT)>;
541 def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{
545 def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>;
546 def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>;
547 def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>;
551 // r. Has default values.
553 def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{
556 def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>;
559 def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
562 def ZnWritePushA : SchedWriteRes<[ZnAGU]> {
565 def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>;
568 def : InstRW<[WriteMicrocoded], (instrs LAHF)>;
572 def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> {
575 def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>;
578 def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>;
580 //-- Arithmetic instructions --//
584 def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)",
585 "(ADD|SUB)(8|16|32|64)mi8",
590 def : InstRW<[WriteALULd],
591 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)",
592 "(ADC|SBB)(16|32|64)mi8",
597 def : InstRW<[WriteALULd],
598 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>;
602 def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
605 def : SchedAlias<WriteIMul16, ZnWriteMul16>;
606 def : SchedAlias<WriteIMul16Imm, ZnWriteMul16>; // TODO: is this right?
607 def : SchedAlias<WriteIMul16Reg, ZnWriteMul16>; // TODO: is this right?
608 def : SchedAlias<WriteIMul16ImmLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
609 def : SchedAlias<WriteIMul16RegLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did.
612 def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
615 def : SchedAlias<WriteIMul16Ld, ZnWriteMul16Ld>;
618 def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
621 def : SchedAlias<WriteIMul32, ZnWriteMul32>;
622 def : SchedAlias<WriteIMul32Imm, ZnWriteMul32>; // TODO: is this right?
623 def : SchedAlias<WriteIMul32Reg, ZnWriteMul32>; // TODO: is this right?
624 def : SchedAlias<WriteIMul32ImmLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
625 def : SchedAlias<WriteIMul32RegLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did.
628 def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
631 def : SchedAlias<WriteIMul32Ld, ZnWriteMul32Ld>;
634 def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
638 def : SchedAlias<WriteIMul64, ZnWriteMul64>;
639 def : SchedAlias<WriteIMul64Imm, ZnWriteMul64>; // TODO: is this right?
640 def : SchedAlias<WriteIMul64Reg, ZnWriteMul64>; // TODO: is this right?
641 def : SchedAlias<WriteIMul64ImmLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
642 def : SchedAlias<WriteIMul64RegLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did.
645 def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
649 def : SchedAlias<WriteIMul64Ld, ZnWriteMul64Ld>;
653 def ZnWriteMulX32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> {
655 let ResourceCycles = [1, 2];
657 def : InstRW<[ZnWriteMulX32], (instrs MULX32rr)>;
660 def ZnWriteMulX32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
662 let ResourceCycles = [1, 2, 2];
664 def : InstRW<[ZnWriteMulX32Ld, ReadAfterLd], (instrs MULX32rm)>;
667 def ZnWriteMulX64 : SchedWriteRes<[ZnALU1]> {
670 def : InstRW<[ZnWriteMulX64], (instrs MULX64rr)>;
673 def ZnWriteMulX64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> {
676 def : InstRW<[ZnWriteMulX64Ld, ReadAfterLd], (instrs MULX64rm)>;
678 //-- Control transfer instructions --//
681 def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>;
682 def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>;
685 def : InstRW<[WriteMicrocoded], (instrs INTO)>;
688 def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>;
689 def : InstRW<[ZnWriteLOOP], (instrs LOOP)>;
691 // LOOP(N)E, LOOP(N)Z
692 def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>;
693 def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>;
697 def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>;
698 def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>;
700 def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>;
703 def ZnWriteRET : SchedWriteRes<[ZnALU03]> {
706 def : InstRW<[ZnWriteRET], (instregex "RET(L|Q|W)", "LRET(L|Q|W)",
709 //-- Logic instructions --//
713 def : InstRW<[WriteALULd],
714 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)",
715 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>;
717 // Define ALU latency variants
718 def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> {
721 def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> {
727 def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> {
732 def : SchedAlias<WriteBitTestSetImmRMW, ZnWriteBTRSCm>;
733 def : SchedAlias<WriteBitTestSetRegRMW, ZnWriteBTRSCm>;
737 def : SchedAlias<WriteBLS, ZnWriteALULat2>;
739 def : SchedAlias<WriteBLSLd, ZnWriteALULat2Ld>;
742 def : InstRW<[WriteALU], (instrs STD, CLD)>;
746 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>;
748 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>;
752 def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>;
756 def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>;
760 def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>;
763 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>;
766 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>;
768 //-- Misc instructions --//
770 def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> {
771 let NumMicroOps = 18;
773 def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>;
775 def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>;
778 def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> {
782 def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>;
785 def : InstRW<[WriteMicrocoded], (instrs PAUSE)>;
788 def : InstRW<[WriteMicrocoded], (instregex "RDTSC")>;
791 def : InstRW<[WriteMicrocoded], (instrs RDPMC)>;
794 def : InstRW<[WriteMicrocoded], (instrs RDRAND16r, RDRAND32r, RDRAND64r)>;
797 def : InstRW<[WriteMicrocoded], (instrs XGETBV)>;
799 //-- String instructions --//
801 def : InstRW<[WriteMicrocoded], (instregex "CMPS(B|L|Q|W)")>;
804 def : InstRW<[WriteMicrocoded], (instregex "LODS(B|W)")>;
807 def : InstRW<[WriteMicrocoded], (instregex "LODS(L|Q)")>;
810 def : InstRW<[WriteMicrocoded], (instregex "MOVS(B|L|Q|W)")>;
813 def : InstRW<[WriteMicrocoded], (instregex "SCAS(B|W|L|Q)")>;
816 def : InstRW<[WriteMicrocoded], (instregex "STOS(B|L|Q|W)")>;
819 def ZnXADD : SchedWriteRes<[ZnALU]>;
820 def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>;
821 def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>;
823 //=== Floating Point x87 Instructions ===//
824 //-- Move instructions --//
826 def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ;
828 def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> {
835 def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>;
838 def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> {
841 def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>;
844 def : InstRW<[WriteMicrocoded], (instrs FBLDm)>;
848 def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>;
851 def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> {
854 def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>;
858 def : InstRW<[WriteMicrocoded], (instrs FBSTPm)>;
860 def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>;
863 def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>;
866 def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> {
870 def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>;
873 def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> {
876 def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>;
878 def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> {
882 def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> {
887 def : SchedAlias<WriteFLD0, ZnWriteFPU13>;
890 def : SchedAlias<WriteFLD1, ZnWriteFPU3>;
893 def : SchedAlias<WriteFLDC, ZnWriteFPU3>;
897 def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>;
900 def : InstRW<[WriteMicrocoded], (instrs FNSTSWm)>;
903 def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>;
906 def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>;
909 def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>;
912 def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>;
915 def : InstRW<[WriteMicrocoded], (instrs FSAVEm)>;
918 def : InstRW<[WriteMicrocoded], (instrs FRSTORm)>;
920 //-- Arithmetic instructions --//
922 def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ;
924 def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ;
926 def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> {
931 def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>;
935 def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>;
937 def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>;
941 def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>;
943 def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]>
948 // FCOMI(P) FUCOMI(P).
950 def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
952 def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]>
956 let ResourceCycles = [1,3];
960 def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>;
963 def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>;
966 def : InstRW<[ZnWriteFPU3Lat1], (instrs FXAM)>;
969 def : InstRW<[WriteMicrocoded], (instrs FPREM)>;
972 def : InstRW<[WriteMicrocoded], (instrs FPREM1)>;
975 def : InstRW<[WriteMicrocoded], (instrs FRNDINT)>;
978 def : InstRW<[WriteMicrocoded], (instrs FSCALE)>;
981 def : InstRW<[WriteMicrocoded], (instrs FXTRACT)>;
984 def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>;
987 def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>;
990 def : InstRW<[WriteMicrocoded], (instrs FNCLEX)>;
993 def : InstRW<[WriteMicrocoded], (instrs FNINIT)>;
995 //=== Integer MMX and XMM Instructions ===//
999 def ZnWriteFPU12 : SchedWriteRes<[ZnFPU12]> ;
1000 def ZnWriteFPU12Y : SchedWriteRes<[ZnFPU12]> {
1001 let NumMicroOps = 2;
1003 def ZnWriteFPU12m : SchedWriteRes<[ZnAGU, ZnFPU12]> ;
1004 def ZnWriteFPU12Ym : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1006 let NumMicroOps = 2;
1009 def : InstRW<[ZnWriteFPU12], (instrs MMX_PACKSSDWirr,
1012 def : InstRW<[ZnWriteFPU12m], (instrs MMX_PACKSSDWirm,
1016 // VPMOVSX/ZX BW BD BQ WD WQ DQ.
1018 def : InstRW<[ZnWriteFPU12Y], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrr")>;
1019 def : InstRW<[ZnWriteFPU12Ym], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrm")>;
1021 def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ;
1022 def ZnWriteFPU013Y : SchedWriteRes<[ZnFPU013]> {
1025 def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1027 let NumMicroOps = 2;
1029 def ZnWriteFPU013Ld : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1031 let NumMicroOps = 2;
1033 def ZnWriteFPU013LdY : SchedWriteRes<[ZnAGU, ZnFPU013]> {
1035 let NumMicroOps = 2;
1040 def : InstRW<[ZnWriteFPU013], (instregex "(V?)PBLENDWrri")>;
1042 def : InstRW<[ZnWriteFPU013Y], (instrs VPBLENDWYrri)>;
1045 def : InstRW<[ZnWriteFPU013Ld], (instregex "(V?)PBLENDWrmi")>;
1047 def : InstRW<[ZnWriteFPU013LdY], (instrs VPBLENDWYrmi)>;
1049 def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ;
1050 def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> {
1051 let NumMicroOps = 2;
1056 def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>;
1058 def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>;
1061 def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1062 let NumMicroOps = 2;
1064 let ResourceCycles = [1, 2];
1066 def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1067 let NumMicroOps = 2;
1069 let ResourceCycles = [1, 3];
1071 def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>;
1072 def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>;
1075 def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>;
1078 def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>;
1082 def : InstRW<[WriteMicrocoded],
1083 (instregex "VPMASKMOVD(Y?)rm")>;
1085 def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>;
1089 def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1091 let NumMicroOps = 2;
1092 let ResourceCycles = [1, 2];
1094 def : InstRW<[ZnWriteVPBROADCAST128Ld],
1095 (instregex "VPBROADCAST(B|W)rm")>;
1098 def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1100 let NumMicroOps = 2;
1101 let ResourceCycles = [1, 2];
1103 def : InstRW<[ZnWriteVPBROADCAST256Ld],
1104 (instregex "VPBROADCAST(B|W)Yrm")>;
1107 def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>;
1109 //-- Arithmetic instructions --//
1112 // PHADD|PHSUB (S) W/D.
1113 def : SchedAlias<WritePHAdd, ZnWriteMicrocoded>;
1114 def : SchedAlias<WritePHAddLd, ZnWriteMicrocoded>;
1115 def : SchedAlias<WritePHAddX, ZnWriteMicrocoded>;
1116 def : SchedAlias<WritePHAddXLd, ZnWriteMicrocoded>;
1117 def : SchedAlias<WritePHAddY, ZnWriteMicrocoded>;
1118 def : SchedAlias<WritePHAddYLd, ZnWriteMicrocoded>;
1121 def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>;
1122 def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>;
1125 def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
1129 def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> {
1131 let NumMicroOps = 2;
1132 let ResourceCycles = [1,2];
1134 def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>;
1135 def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>;
1137 //-- Logic instructions --//
1139 // PSLL,PSRL,PSRA W/D/Q.
1141 def ZnWritePShift : SchedWriteRes<[ZnFPU2]> ;
1142 def ZnWritePShiftY : SchedWriteRes<[ZnFPU2]> {
1147 def : InstRW<[ZnWritePShift], (instregex "(V?)PS(R|L)LDQri")>;
1148 def : InstRW<[ZnWritePShiftY], (instregex "(V?)PS(R|L)LDQYri")>;
1150 //=== Floating Point XMM and YMM Instructions ===//
1151 //-- Move instructions --//
1154 def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr)>;
1155 def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm)>;
1157 def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> {
1158 let NumMicroOps = 2;
1162 def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128)>;
1166 def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1168 let NumMicroOps = 2;
1169 let ResourceCycles = [1, 2];
1171 def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>;
1173 def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> {
1175 let NumMicroOps = 2;
1176 let ResourceCycles = [5, 1, 2];
1179 def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>;
1183 def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rr)>;
1186 def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mr)>;
1188 def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> {
1190 let ResourceCycles = [2];
1192 def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> {
1194 let NumMicroOps = 2;
1195 let ResourceCycles = [1, 2];
1199 def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rr)>;
1200 def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rm)>;
1203 def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>;
1205 //-- Conversion instructions --//
1206 def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> {
1209 def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> {
1215 def : SchedAlias<WriteCvtPD2PS, ZnWriteCVTPD2PSr>;
1217 def : SchedAlias<WriteCvtPD2PSY, ZnWriteCVTPD2PSYr>;
1219 defm : X86WriteResUnsupported<WriteCvtPD2PSZ>;
1221 def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU03]> {
1223 let NumMicroOps = 2;
1224 let ResourceCycles = [1,2];
1227 def : SchedAlias<WriteCvtPD2PSLd, ZnWriteCVTPD2PSLd>;
1230 def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1233 def : SchedAlias<WriteCvtPD2PSYLd, ZnWriteCVTPD2PSYLd>;
1235 defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>;
1239 // Same as WriteCVTPD2PSr
1240 def : SchedAlias<WriteCvtSD2SS, ZnWriteCVTPD2PSr>;
1243 def : SchedAlias<WriteCvtSD2SSLd, ZnWriteCVTPD2PSLd>;
1247 def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> {
1250 def : SchedAlias<WriteCvtPS2PD, ZnWriteCVTPS2PDr>;
1254 def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1256 let NumMicroOps = 2;
1258 def : SchedAlias<WriteCvtPS2PDLd, ZnWriteCVTPS2PDLd>;
1259 def : SchedAlias<WriteCvtPS2PDYLd, ZnWriteCVTPS2PDLd>;
1260 defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>;
1263 def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> {
1266 def : SchedAlias<WriteCvtPS2PDY, ZnWriteVCVTPS2PDY>;
1267 defm : X86WriteResUnsupported<WriteCvtPS2PDZ>;
1271 def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> {
1274 def : SchedAlias<WriteCvtSS2SD, ZnWriteCVTSS2SDr>;
1277 def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1279 let NumMicroOps = 2;
1280 let ResourceCycles = [1, 2];
1282 def : SchedAlias<WriteCvtSS2SDLd, ZnWriteCVTSS2SDLd>;
1284 def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> {
1289 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>;
1293 def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>;
1295 def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> {
1300 def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V?)CVT(T?)PD2DQrr")>;
1302 def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> {
1304 let NumMicroOps = 2;
1307 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>;
1308 // same as xmm handling
1310 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>;
1312 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>;
1314 def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> {
1319 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIirr")>;
1323 def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDirr)>;
1327 def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIirr")>;
1329 def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> {
1333 // same as CVTPD2DQr
1336 def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>;
1337 // same as CVTPD2DQm
1339 def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>;
1341 def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> {
1346 def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>;
1349 def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> {
1352 def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> {
1357 def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>;
1359 def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>;
1363 def : SchedAlias<WriteCvtPS2PH, ZnWriteMicrocoded>;
1364 def : SchedAlias<WriteCvtPS2PHY, ZnWriteMicrocoded>;
1365 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
1367 def : SchedAlias<WriteCvtPS2PHSt, ZnWriteMicrocoded>;
1368 def : SchedAlias<WriteCvtPS2PHYSt, ZnWriteMicrocoded>;
1369 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
1373 def : SchedAlias<WriteCvtPH2PS, ZnWriteMicrocoded>;
1374 def : SchedAlias<WriteCvtPH2PSY, ZnWriteMicrocoded>;
1375 defm : X86WriteResUnsupported<WriteCvtPH2PSZ>;
1377 def : SchedAlias<WriteCvtPH2PSLd, ZnWriteMicrocoded>;
1378 def : SchedAlias<WriteCvtPH2PSYLd, ZnWriteMicrocoded>;
1379 defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>;
1381 //-- SSE4A instructions --//
1383 def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> {
1386 def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>;
1389 def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> {
1392 def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>;
1394 //-- SHA instructions --//
1396 def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>;
1398 // SHA1MSG1, SHA256MSG1
1400 def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> {
1402 let ResourceCycles = [2];
1404 def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>;
1406 def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1408 let ResourceCycles = [1,2];
1410 def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>;
1414 def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ;
1415 def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>;
1417 def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> {
1420 def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>;
1424 def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ;
1425 def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>;
1427 def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1430 def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>;
1434 def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> {
1437 def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>;
1439 def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1442 def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>;
1446 def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> {
1449 def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>;
1451 def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> {
1454 def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>;
1456 //-- Arithmetic instructions --//
1459 def : SchedAlias<WriteFHAdd, ZnWriteMicrocoded>;
1460 def : SchedAlias<WriteFHAddLd, ZnWriteMicrocoded>;
1461 def : SchedAlias<WriteFHAddY, ZnWriteMicrocoded>;
1462 def : SchedAlias<WriteFHAddYLd, ZnWriteMicrocoded>;
1465 // TODO - convert to ZnWriteResFpuPair
1467 def ZnWriteVDIVPSYr : SchedWriteRes<[ZnFPU3]> {
1469 let ResourceCycles = [12];
1471 def : SchedAlias<WriteFDivY, ZnWriteVDIVPSYr>;
1474 def ZnWriteVDIVPSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1476 let NumMicroOps = 2;
1477 let ResourceCycles = [1, 19];
1479 def : SchedAlias<WriteFDivYLd, ZnWriteVDIVPSYLd>;
1482 // TODO - convert to ZnWriteResFpuPair
1484 def ZnWriteVDIVPDY : SchedWriteRes<[ZnFPU3]> {
1486 let ResourceCycles = [15];
1488 def : SchedAlias<WriteFDiv64Y, ZnWriteVDIVPDY>;
1491 def ZnWriteVDIVPDYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> {
1493 let NumMicroOps = 2;
1494 let ResourceCycles = [1,22];
1496 def : SchedAlias<WriteFDiv64YLd, ZnWriteVDIVPDYLd>;
1500 def : SchedAlias<WriteDPPS, ZnWriteMicrocoded>;
1501 def : SchedAlias<WriteDPPSY, ZnWriteMicrocoded>;
1504 def : SchedAlias<WriteDPPSLd, ZnWriteMicrocoded>;
1505 def : SchedAlias<WriteDPPSYLd,ZnWriteMicrocoded>;
1509 def : SchedAlias<WriteDPPD, ZnWriteMicrocoded>;
1512 def : SchedAlias<WriteDPPDLd, ZnWriteMicrocoded>;
1515 // TODO - convert to ZnWriteResFpuPair
1517 def ZnWriteRSQRTSSr : SchedWriteRes<[ZnFPU02]> {
1520 def : SchedAlias<WriteFRsqrt, ZnWriteRSQRTSSr>;
1523 def ZnWriteRSQRTSSLd: SchedWriteRes<[ZnAGU, ZnFPU02]> {
1525 let NumMicroOps = 2;
1526 let ResourceCycles = [1,2]; // FIXME: Is this right?
1528 def : SchedAlias<WriteFRsqrtLd, ZnWriteRSQRTSSLd>;
1531 // TODO - convert to ZnWriteResFpuPair
1533 def ZnWriteRSQRTPSYr : SchedWriteRes<[ZnFPU01]> {
1535 let NumMicroOps = 2;
1536 let ResourceCycles = [2];
1538 def : SchedAlias<WriteFRsqrtY, ZnWriteRSQRTPSYr>;
1541 def ZnWriteRSQRTPSYLd : SchedWriteRes<[ZnAGU, ZnFPU01]> {
1543 let NumMicroOps = 2;
1545 def : SchedAlias<WriteFRsqrtYLd, ZnWriteRSQRTPSYLd>;
1547 //-- Other instructions --//
1550 def : InstRW<[WriteMicrocoded], (instrs VZEROUPPER)>;
1553 def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>;