1 //=- X86ScheduleZnver2.td - X86 Znver2 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 Znver2 to support instruction
10 // scheduling and other instruction cost heuristics.
12 //===----------------------------------------------------------------------===//
14 def Znver2Model : SchedMachineModel {
15 // Zen can decode 4 instructions per cycle.
17 // Based on the reorder buffer we define MicroOpBufferSize
18 let MicroOpBufferSize = 224;
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 = Znver2Model in {
33 // Zen can issue micro-ops to 10 different units in one cycle.
35 // * Four integer ALU units (ZALU0, ZALU1, ZALU2, ZALU3)
36 // * Three AGU units (ZAGU0, ZAGU1, ZAGU2)
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 Zn2ALU0 : ProcResource<1>;
42 def Zn2ALU1 : ProcResource<1>;
43 def Zn2ALU2 : ProcResource<1>;
44 def Zn2ALU3 : ProcResource<1>;
46 // Three AGU units are defined below
47 def Zn2AGU0 : ProcResource<1>;
48 def Zn2AGU1 : ProcResource<1>;
49 def Zn2AGU2 : ProcResource<1>;
51 // Four FPU units are defined below
52 def Zn2FPU0 : ProcResource<1>;
53 def Zn2FPU1 : ProcResource<1>;
54 def Zn2FPU2 : ProcResource<1>;
55 def Zn2FPU3 : ProcResource<1>;
58 def Zn2FPU013 : ProcResGroup<[Zn2FPU0, Zn2FPU1, Zn2FPU3]>;
59 def Zn2FPU01 : ProcResGroup<[Zn2FPU0, Zn2FPU1]>;
60 def Zn2FPU12 : ProcResGroup<[Zn2FPU1, Zn2FPU2]>;
61 def Zn2FPU13 : ProcResGroup<[Zn2FPU1, Zn2FPU3]>;
62 def Zn2FPU23 : ProcResGroup<[Zn2FPU2, Zn2FPU3]>;
63 def Zn2FPU02 : ProcResGroup<[Zn2FPU0, Zn2FPU2]>;
64 def Zn2FPU03 : ProcResGroup<[Zn2FPU0, Zn2FPU3]>;
66 // Below are the grouping of the units.
67 // Micro-ops to be issued to multiple units are tackled this way.
70 // Zn2ALU03 - 0,3 grouping
71 def Zn2ALU03: ProcResGroup<[Zn2ALU0, Zn2ALU3]>;
73 // 64 Entry (16x4 entries) Int Scheduler
74 def Zn2ALU : ProcResGroup<[Zn2ALU0, Zn2ALU1, Zn2ALU2, Zn2ALU3]> {
78 // 28 Entry (14x2) AGU group. AGUs can't be used for all ALU operations
79 // but are relevant for some instructions
80 def Zn2AGU : ProcResGroup<[Zn2AGU0, Zn2AGU1, Zn2AGU2]> {
84 // Integer Multiplication issued on ALU1.
85 def Zn2Multiplier : ProcResource<1>;
87 // Integer division issued on ALU2.
88 def Zn2Divider : ProcResource<1>;
90 // 4 Cycles load-to use Latency is captured
91 def : ReadAdvance<ReadAfterLd, 4>;
93 // 7 Cycles vector load-to use Latency is captured
94 def : ReadAdvance<ReadAfterVecLd, 7>;
95 def : ReadAdvance<ReadAfterVecXLd, 7>;
96 def : ReadAdvance<ReadAfterVecYLd, 7>;
98 def : ReadAdvance<ReadInt2Fpu, 0>;
100 // The Integer PRF for Zen is 168 entries, and it holds the architectural and
101 // speculative version of the 64-bit integer registers.
102 // Reference: "Software Optimization Guide for AMD Family 17h Processors"
103 def Zn2IntegerPRF : RegisterFile<168, [GR64, CCR]>;
105 // 36 Entry (9x4 entries) floating-point Scheduler
106 def Zn2FPU : ProcResGroup<[Zn2FPU0, Zn2FPU1, Zn2FPU2, Zn2FPU3]> {
110 // The Zen FP Retire Queue renames SIMD and FP uOps onto a pool of 160 128-bit
111 // registers. Operations on 256-bit data types are cracked into two COPs.
112 // Reference: "Software Optimization Guide for AMD Family 17h Processors"
113 def Zn2FpuPRF: RegisterFile<160, [VR64, VR128, VR256], [1, 1, 2]>;
115 // The unit can track up to 192 macro ops in-flight.
116 // The retire unit handles in-order commit of up to 8 macro ops per cycle.
117 // Reference: "Software Optimization Guide for AMD Family 17h Processors"
118 // To be noted, the retire unit is shared between integer and FP ops.
119 // In SMT mode it is 96 entry per thread. But, we do not use the conservative
120 // value here because there is currently no way to fully mode the SMT mode,
121 // so there is no point in trying.
122 def Zn2RCU : RetireControlUnit<192, 8>;
124 // (a folded load is an instruction that loads and does some operation)
125 // Ex: ADDPD xmm,[mem]-> This instruction has two micro-ops
126 // Instructions with folded loads are usually micro-fused, so they only appear
130 // This multiclass is for folded loads for integer units.
131 multiclass Zn2WriteResPair<X86FoldableSchedWrite SchedRW,
132 list<ProcResourceKind> ExePorts,
133 int Lat, list<int> Res = [], int UOps = 1,
134 int LoadLat = 4, int LoadUOps = 1> {
135 // Register variant takes 1-cycle on Execution Port.
136 def : WriteRes<SchedRW, ExePorts> {
138 let ReleaseAtCycles = Res;
139 let NumMicroOps = UOps;
142 // Memory variant also uses a cycle on Zn2AGU
143 // adds LoadLat cycles to the latency (default = 4).
144 def : WriteRes<SchedRW.Folded, !listconcat([Zn2AGU], ExePorts)> {
145 let Latency = !add(Lat, LoadLat);
146 let ReleaseAtCycles = !if(!empty(Res), [], !listconcat([1], Res));
147 let NumMicroOps = !add(UOps, LoadUOps);
151 // This multiclass is for folded loads for floating point units.
152 multiclass Zn2WriteResFpuPair<X86FoldableSchedWrite SchedRW,
153 list<ProcResourceKind> ExePorts,
154 int Lat, list<int> Res = [], int UOps = 1,
155 int LoadLat = 7, int LoadUOps = 0> {
156 // Register variant takes 1-cycle on Execution Port.
157 def : WriteRes<SchedRW, ExePorts> {
159 let ReleaseAtCycles = Res;
160 let NumMicroOps = UOps;
163 // Memory variant also uses a cycle on Zn2AGU
164 // adds LoadLat cycles to the latency (default = 7).
165 def : WriteRes<SchedRW.Folded, !listconcat([Zn2AGU], ExePorts)> {
166 let Latency = !add(Lat, LoadLat);
167 let ReleaseAtCycles = !if(!empty(Res), [], !listconcat([1], Res));
168 let NumMicroOps = !add(UOps, LoadUOps);
172 // WriteRMW is set for instructions with Memory write
173 // operation in codegen
174 def : WriteRes<WriteRMW, [Zn2AGU]>;
176 def : WriteRes<WriteStore, [Zn2AGU]>;
177 def : WriteRes<WriteStoreNT, [Zn2AGU]>;
178 def : WriteRes<WriteMove, [Zn2ALU]>;
179 def : WriteRes<WriteLoad, [Zn2AGU]> { let Latency = 4; }
181 // Model the effect of clobbering the read-write mask operand of the GATHER operation.
182 // Does not cost anything by itself, only has latency, matching that of the WriteLoad,
183 def : WriteRes<WriteVecMaskedGatherWriteback, []> { let Latency = 8; let NumMicroOps = 0; }
185 def : WriteRes<WriteZero, []>;
186 def : WriteRes<WriteLEA, [Zn2ALU]>;
187 defm : Zn2WriteResPair<WriteALU, [Zn2ALU], 1>;
188 defm : Zn2WriteResPair<WriteADC, [Zn2ALU], 1>;
190 defm : Zn2WriteResPair<WriteIMul8, [Zn2ALU1, Zn2Multiplier], 4>;
192 defm : X86WriteRes<WriteBSWAP32, [Zn2ALU], 1, [4], 1>;
193 defm : X86WriteRes<WriteBSWAP64, [Zn2ALU], 1, [4], 1>;
194 defm : X86WriteRes<WriteCMPXCHG, [Zn2ALU], 3, [1], 1>;
195 defm : X86WriteRes<WriteCMPXCHGRMW,[Zn2ALU,Zn2AGU], 8, [1,1], 5>;
196 defm : X86WriteRes<WriteXCHG, [Zn2ALU], 1, [2], 2>;
198 defm : Zn2WriteResPair<WriteShift, [Zn2ALU], 1>;
199 defm : Zn2WriteResPair<WriteShiftCL, [Zn2ALU], 1>;
200 defm : Zn2WriteResPair<WriteRotate, [Zn2ALU], 1>;
201 defm : Zn2WriteResPair<WriteRotateCL, [Zn2ALU], 1>;
203 defm : X86WriteRes<WriteSHDrri, [Zn2ALU], 1, [1], 1>;
204 defm : X86WriteResUnsupported<WriteSHDrrcl>;
205 defm : X86WriteResUnsupported<WriteSHDmri>;
206 defm : X86WriteResUnsupported<WriteSHDmrcl>;
208 defm : Zn2WriteResPair<WriteJump, [Zn2ALU], 1>;
209 defm : Zn2WriteResFpuPair<WriteCRC32, [Zn2FPU0], 3>;
211 defm : Zn2WriteResPair<WriteCMOV, [Zn2ALU], 1>;
212 def : WriteRes<WriteSETCC, [Zn2ALU]>;
213 def : WriteRes<WriteSETCCStore, [Zn2ALU, Zn2AGU]>;
214 defm : X86WriteRes<WriteLAHFSAHF, [Zn2ALU], 2, [1], 2>;
216 defm : X86WriteRes<WriteBitTest, [Zn2ALU], 1, [1], 1>;
217 defm : X86WriteRes<WriteBitTestImmLd, [Zn2ALU,Zn2AGU], 5, [1,1], 2>;
218 defm : X86WriteRes<WriteBitTestRegLd, [Zn2ALU,Zn2AGU], 5, [1,1], 2>;
219 defm : X86WriteRes<WriteBitTestSet, [Zn2ALU], 2, [1], 2>;
222 defm : Zn2WriteResPair<WriteBSF, [Zn2ALU], 3, [12], 6, 4, 2>;
223 defm : Zn2WriteResPair<WriteBSR, [Zn2ALU], 4, [16], 6, 4, 2>;
224 defm : Zn2WriteResPair<WriteLZCNT, [Zn2ALU], 1>;
225 defm : Zn2WriteResPair<WriteTZCNT, [Zn2ALU], 2, [2], 2, 4, 0>;
226 defm : Zn2WriteResPair<WritePOPCNT, [Zn2ALU], 1>;
228 // Treat misc copies as a move.
229 def : InstRW<[WriteMove], (instrs COPY)>;
231 // BMI1 BEXTR, BMI2 BZHI
232 defm : Zn2WriteResPair<WriteBEXTR, [Zn2ALU], 1, [1], 1, 4, 1>;
233 defm : Zn2WriteResPair<WriteBLS, [Zn2ALU], 2, [2], 2, 4, 1>;
234 defm : Zn2WriteResPair<WriteBZHI, [Zn2ALU], 1>;
237 defm : Zn2WriteResPair<WriteDiv8, [Zn2ALU2, Zn2Divider], 15, [1,15], 1>;
238 defm : Zn2WriteResPair<WriteDiv16, [Zn2ALU2, Zn2Divider], 17, [1,17], 2>;
239 defm : Zn2WriteResPair<WriteDiv32, [Zn2ALU2, Zn2Divider], 25, [1,25], 2>;
240 defm : Zn2WriteResPair<WriteDiv64, [Zn2ALU2, Zn2Divider], 41, [1,41], 2>;
241 defm : Zn2WriteResPair<WriteIDiv8, [Zn2ALU2, Zn2Divider], 15, [1,15], 1>;
242 defm : Zn2WriteResPair<WriteIDiv16, [Zn2ALU2, Zn2Divider], 17, [1,17], 2>;
243 defm : Zn2WriteResPair<WriteIDiv32, [Zn2ALU2, Zn2Divider], 25, [1,25], 2>;
244 defm : Zn2WriteResPair<WriteIDiv64, [Zn2ALU2, Zn2Divider], 41, [1,41], 2>;
247 def Zn2WriteIMulH : WriteRes<WriteIMulH, [Zn2Multiplier]>{
251 def : WriteRes<WriteIMulHLd, [Zn2Multiplier]>{
252 let Latency = !add(Zn2WriteIMulH.Latency, Znver2Model.LoadLatency);
253 let NumMicroOps = Zn2WriteIMulH.NumMicroOps;
256 // Floating point operations
257 defm : X86WriteRes<WriteFLoad, [Zn2AGU], 8, [1], 1>;
258 defm : X86WriteRes<WriteFLoadX, [Zn2AGU], 8, [1], 1>;
259 defm : X86WriteRes<WriteFLoadY, [Zn2AGU], 8, [1], 1>;
260 defm : X86WriteRes<WriteFMaskedLoad, [Zn2AGU,Zn2FPU01], 8, [1,1], 1>;
261 defm : X86WriteRes<WriteFMaskedLoadY, [Zn2AGU,Zn2FPU01], 8, [1,1], 2>;
263 defm : X86WriteRes<WriteFStore, [Zn2AGU], 1, [1], 1>;
264 defm : X86WriteRes<WriteFStoreX, [Zn2AGU], 1, [1], 1>;
265 defm : X86WriteRes<WriteFStoreY, [Zn2AGU], 1, [1], 1>;
266 defm : X86WriteRes<WriteFStoreNT, [Zn2AGU,Zn2FPU2], 8, [1,1], 1>;
267 defm : X86WriteRes<WriteFStoreNTX, [Zn2AGU], 1, [1], 1>;
268 defm : X86WriteRes<WriteFStoreNTY, [Zn2AGU], 1, [1], 1>;
269 defm : X86WriteRes<WriteFMaskedStore32, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
270 defm : X86WriteRes<WriteFMaskedStore32Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
271 defm : X86WriteRes<WriteFMaskedStore64, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
272 defm : X86WriteRes<WriteFMaskedStore64Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
274 defm : X86WriteRes<WriteFMove, [Zn2FPU], 1, [1], 1>;
275 defm : X86WriteRes<WriteFMoveX, [Zn2FPU], 1, [1], 1>;
276 defm : X86WriteRes<WriteFMoveY, [Zn2FPU], 1, [1], 1>;
277 defm : X86WriteResUnsupported<WriteFMoveZ>;
279 defm : Zn2WriteResFpuPair<WriteFAdd, [Zn2FPU23], 3>;
280 defm : Zn2WriteResFpuPair<WriteFAddX, [Zn2FPU23], 3>;
281 defm : Zn2WriteResFpuPair<WriteFAddY, [Zn2FPU23], 3>;
282 defm : X86WriteResPairUnsupported<WriteFAddZ>;
283 defm : Zn2WriteResFpuPair<WriteFAdd64, [Zn2FPU23], 3>;
284 defm : Zn2WriteResFpuPair<WriteFAdd64X, [Zn2FPU23], 3>;
285 defm : Zn2WriteResFpuPair<WriteFAdd64Y, [Zn2FPU23], 3>;
286 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
287 defm : Zn2WriteResFpuPair<WriteFCmp, [Zn2FPU01], 1>;
288 defm : Zn2WriteResFpuPair<WriteFCmpX, [Zn2FPU01], 1>;
289 defm : Zn2WriteResFpuPair<WriteFCmpY, [Zn2FPU01], 1>;
290 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
291 defm : Zn2WriteResFpuPair<WriteFCmp64, [Zn2FPU01], 1>;
292 defm : Zn2WriteResFpuPair<WriteFCmp64X, [Zn2FPU01], 1>;
293 defm : Zn2WriteResFpuPair<WriteFCmp64Y, [Zn2FPU01], 1>;
294 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
295 defm : Zn2WriteResFpuPair<WriteFCom, [Zn2FPU01,Zn2FPU2], 3, [1,1], 2>;
296 defm : Zn2WriteResFpuPair<WriteFComX, [Zn2FPU01,Zn2FPU2], 3, [1,1], 2>;
297 defm : Zn2WriteResFpuPair<WriteFBlend, [Zn2FPU01], 1>;
298 defm : Zn2WriteResFpuPair<WriteFBlendY, [Zn2FPU01], 1>;
299 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
300 defm : Zn2WriteResFpuPair<WriteFVarBlend, [Zn2FPU01], 1>;
301 defm : Zn2WriteResFpuPair<WriteFVarBlendY,[Zn2FPU01], 1>;
302 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
303 defm : Zn2WriteResFpuPair<WriteCvtSS2I, [Zn2FPU3], 5>;
304 defm : Zn2WriteResFpuPair<WriteCvtPS2I, [Zn2FPU3], 5>;
305 defm : Zn2WriteResFpuPair<WriteCvtPS2IY, [Zn2FPU3], 5>;
306 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
307 defm : Zn2WriteResFpuPair<WriteCvtSD2I, [Zn2FPU3], 5>;
308 defm : Zn2WriteResFpuPair<WriteCvtPD2I, [Zn2FPU3], 5>;
309 defm : Zn2WriteResFpuPair<WriteCvtPD2IY, [Zn2FPU3], 5>;
310 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
311 defm : Zn2WriteResFpuPair<WriteCvtI2SS, [Zn2FPU3], 5>;
312 defm : Zn2WriteResFpuPair<WriteCvtI2PS, [Zn2FPU3], 5>;
313 defm : Zn2WriteResFpuPair<WriteCvtI2PSY, [Zn2FPU3], 5>;
314 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
315 defm : Zn2WriteResFpuPair<WriteCvtI2SD, [Zn2FPU3], 5>;
316 defm : Zn2WriteResFpuPair<WriteCvtI2PD, [Zn2FPU3], 5>;
317 defm : Zn2WriteResFpuPair<WriteCvtI2PDY, [Zn2FPU3], 5>;
318 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
319 defm : Zn2WriteResFpuPair<WriteFDiv, [Zn2FPU3], 10, [5]>;
320 defm : Zn2WriteResFpuPair<WriteFDivX, [Zn2FPU3], 10, [5]>;
321 defm : Zn2WriteResFpuPair<WriteFDivY, [Zn2FPU3], 10, [5]>;
322 defm : X86WriteResPairUnsupported<WriteFDivZ>;
323 defm : Zn2WriteResFpuPair<WriteFDiv64, [Zn2FPU3], 13, [6]>;
324 defm : Zn2WriteResFpuPair<WriteFDiv64X, [Zn2FPU3], 13, [6]>;
325 defm : Zn2WriteResFpuPair<WriteFDiv64Y, [Zn2FPU3], 13, [6]>;
326 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
327 defm : Zn2WriteResFpuPair<WriteFSign, [Zn2FPU3], 2>;
328 defm : Zn2WriteResFpuPair<WriteFRnd, [Zn2FPU3], 3, [1], 1, 7, 0>;
329 defm : Zn2WriteResFpuPair<WriteFRndY, [Zn2FPU3], 3, [1], 1, 7, 0>;
330 defm : X86WriteResPairUnsupported<WriteFRndZ>;
331 defm : Zn2WriteResFpuPair<WriteFLogic, [Zn2FPU], 1>;
332 defm : Zn2WriteResFpuPair<WriteFLogicY, [Zn2FPU], 1>;
333 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
334 defm : Zn2WriteResFpuPair<WriteFTest, [Zn2FPU12], 3, [2], 1, 7, 1>;
335 defm : Zn2WriteResFpuPair<WriteFTestY, [Zn2FPU12], 3, [2], 1, 7, 1>;
336 defm : X86WriteResPairUnsupported<WriteFTestZ>;
337 defm : Zn2WriteResFpuPair<WriteFShuffle, [Zn2FPU12], 1>;
338 defm : Zn2WriteResFpuPair<WriteFShuffleY, [Zn2FPU12], 1>;
339 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
340 defm : Zn2WriteResFpuPair<WriteFVarShuffle, [Zn2FPU12], 3>;
341 defm : Zn2WriteResFpuPair<WriteFVarShuffleY,[Zn2FPU12], 3>;
342 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
343 defm : Zn2WriteResFpuPair<WriteFMul, [Zn2FPU01], 3>;
344 defm : Zn2WriteResFpuPair<WriteFMulX, [Zn2FPU01], 3>;
345 defm : Zn2WriteResFpuPair<WriteFMulY, [Zn2FPU01], 3>;
346 defm : X86WriteResPairUnsupported<WriteFMulZ>;
347 defm : Zn2WriteResFpuPair<WriteFMul64, [Zn2FPU01], 3>;
348 defm : Zn2WriteResFpuPair<WriteFMul64X, [Zn2FPU01], 3>;
349 defm : Zn2WriteResFpuPair<WriteFMul64Y, [Zn2FPU01], 3>;
350 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
351 defm : Zn2WriteResFpuPair<WriteFMA, [Zn2FPU01], 5>;
352 defm : Zn2WriteResFpuPair<WriteFMAX, [Zn2FPU01], 5>;
353 defm : Zn2WriteResFpuPair<WriteFMAY, [Zn2FPU01], 5>;
354 defm : X86WriteResPairUnsupported<WriteFMAZ>;
355 defm : Zn2WriteResFpuPair<WriteFRcp, [Zn2FPU01], 5>;
356 defm : Zn2WriteResFpuPair<WriteFRcpX, [Zn2FPU01], 5>;
357 defm : Zn2WriteResFpuPair<WriteFRcpY, [Zn2FPU01], 5>;
358 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
359 defm : Zn2WriteResFpuPair<WriteFRsqrt, [Zn2FPU01], 5>;
360 defm : Zn2WriteResFpuPair<WriteFRsqrtX, [Zn2FPU01], 5>;
361 defm : Zn2WriteResFpuPair<WriteFRsqrtY, [Zn2FPU01], 5>;
362 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
363 defm : Zn2WriteResFpuPair<WriteFSqrt, [Zn2FPU3], 14, [7]>;
364 defm : Zn2WriteResFpuPair<WriteFSqrtX, [Zn2FPU3], 14, [7]>;
365 defm : Zn2WriteResFpuPair<WriteFSqrtY, [Zn2FPU3], 14, [7]>;
366 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
367 defm : Zn2WriteResFpuPair<WriteFSqrt64, [Zn2FPU3], 20, [10]>;
368 defm : Zn2WriteResFpuPair<WriteFSqrt64X, [Zn2FPU3], 20, [10]>;
369 defm : Zn2WriteResFpuPair<WriteFSqrt64Y, [Zn2FPU3], 20, [10]>;
370 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
371 defm : Zn2WriteResFpuPair<WriteFSqrt80, [Zn2FPU3], 20, [20]>;
372 defm : Zn2WriteResFpuPair<WriteFShuffle256, [Zn2FPU12], 2>;
373 defm : Zn2WriteResFpuPair<WriteFVarShuffle256, [Zn2FPU12], 2>;
375 // Vector integer operations which uses FPU units
376 defm : X86WriteRes<WriteVecLoad, [Zn2AGU], 8, [1], 1>;
377 defm : X86WriteRes<WriteVecLoadX, [Zn2AGU], 8, [1], 1>;
378 defm : X86WriteRes<WriteVecLoadY, [Zn2AGU], 8, [1], 1>;
379 defm : X86WriteRes<WriteVecLoadNT, [Zn2AGU], 8, [1], 1>;
380 defm : X86WriteRes<WriteVecLoadNTY, [Zn2AGU], 8, [1], 1>;
381 defm : X86WriteRes<WriteVecMaskedLoad, [Zn2AGU,Zn2FPU01], 8, [1,2], 2>;
382 defm : X86WriteRes<WriteVecMaskedLoadY, [Zn2AGU,Zn2FPU01], 8, [1,2], 2>;
383 defm : X86WriteRes<WriteVecStore, [Zn2AGU], 1, [1], 1>;
384 defm : X86WriteRes<WriteVecStoreX, [Zn2AGU], 1, [1], 1>;
385 defm : X86WriteRes<WriteVecStoreY, [Zn2AGU], 1, [1], 1>;
386 defm : X86WriteRes<WriteVecStoreNT, [Zn2AGU], 1, [1], 1>;
387 defm : X86WriteRes<WriteVecStoreNTY, [Zn2AGU], 1, [1], 1>;
388 defm : X86WriteRes<WriteVecMaskedStore32, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
389 defm : X86WriteRes<WriteVecMaskedStore32Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
390 defm : X86WriteRes<WriteVecMaskedStore64, [Zn2AGU,Zn2FPU01], 4, [1,1], 1>;
391 defm : X86WriteRes<WriteVecMaskedStore64Y, [Zn2AGU,Zn2FPU01], 5, [1,2], 2>;
392 defm : X86WriteRes<WriteVecMove, [Zn2FPU], 1, [1], 1>;
393 defm : X86WriteRes<WriteVecMoveX, [Zn2FPU], 1, [1], 1>;
394 defm : X86WriteRes<WriteVecMoveY, [Zn2FPU], 2, [1], 2>;
395 defm : X86WriteResUnsupported<WriteVecMoveZ>;
396 defm : X86WriteRes<WriteVecMoveToGpr, [Zn2FPU2], 2, [1], 1>;
397 defm : X86WriteRes<WriteVecMoveFromGpr, [Zn2FPU2], 3, [1], 1>;
398 defm : X86WriteRes<WriteEMMS, [Zn2FPU], 2, [1], 1>;
400 defm : Zn2WriteResFpuPair<WriteVecShift, [Zn2FPU2], 1>;
401 defm : Zn2WriteResFpuPair<WriteVecShiftX, [Zn2FPU2], 1>;
402 defm : Zn2WriteResFpuPair<WriteVecShiftY, [Zn2FPU2], 1>;
403 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
404 defm : Zn2WriteResFpuPair<WriteVecShiftImm, [Zn2FPU2], 1>;
405 defm : Zn2WriteResFpuPair<WriteVecShiftImmX, [Zn2FPU2], 1>;
406 defm : Zn2WriteResFpuPair<WriteVecShiftImmY, [Zn2FPU2], 1>;
407 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
408 defm : Zn2WriteResFpuPair<WriteVarVecShift, [Zn2FPU1], 3, [2], 1>;
409 defm : Zn2WriteResFpuPair<WriteVarVecShiftY, [Zn2FPU1], 3, [2], 1>;
410 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
411 defm : Zn2WriteResFpuPair<WriteVecLogic, [Zn2FPU], 1>;
412 defm : Zn2WriteResFpuPair<WriteVecLogicX, [Zn2FPU], 1>;
413 defm : Zn2WriteResFpuPair<WriteVecLogicY, [Zn2FPU], 1>;
414 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
415 defm : Zn2WriteResFpuPair<WriteVecTest, [Zn2FPU12], 3, [2], 1, 7, 1>;
416 defm : Zn2WriteResFpuPair<WriteVecTestY, [Zn2FPU12], 3, [2], 1, 7, 1>;
417 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
418 defm : Zn2WriteResFpuPair<WriteVecALU, [Zn2FPU013], 1>;
419 defm : Zn2WriteResFpuPair<WriteVecALUX, [Zn2FPU013], 1>;
420 defm : Zn2WriteResFpuPair<WriteVecALUY, [Zn2FPU013], 1>;
421 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
422 defm : Zn2WriteResFpuPair<WriteVecIMul, [Zn2FPU0], 4>;
423 defm : Zn2WriteResFpuPair<WriteVecIMulX, [Zn2FPU0], 4>;
424 defm : Zn2WriteResFpuPair<WriteVecIMulY, [Zn2FPU0], 4>;
425 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
426 defm : Zn2WriteResFpuPair<WritePMULLD, [Zn2FPU0], 4, [2]>;
427 defm : Zn2WriteResFpuPair<WritePMULLDY, [Zn2FPU0], 4, [2]>;
428 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
429 defm : Zn2WriteResFpuPair<WriteShuffle, [Zn2FPU12], 1>;
430 defm : Zn2WriteResFpuPair<WriteShuffleX, [Zn2FPU12], 1>;
431 defm : Zn2WriteResFpuPair<WriteShuffleY, [Zn2FPU12], 1>;
432 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
433 defm : Zn2WriteResFpuPair<WriteVarShuffle, [Zn2FPU12], 1>;
434 defm : Zn2WriteResFpuPair<WriteVarShuffleX,[Zn2FPU12], 1>;
435 defm : Zn2WriteResFpuPair<WriteVarShuffleY,[Zn2FPU12], 1>;
436 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
437 defm : Zn2WriteResFpuPair<WriteBlend, [Zn2FPU013], 1>;
438 defm : Zn2WriteResFpuPair<WriteBlendY, [Zn2FPU013], 1>;
439 defm : X86WriteResPairUnsupported<WriteBlendZ>;
440 defm : Zn2WriteResFpuPair<WriteVarBlend, [Zn2FPU0], 1>;
441 defm : Zn2WriteResFpuPair<WriteVarBlendY, [Zn2FPU0], 1>;
442 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
443 defm : Zn2WriteResFpuPair<WriteShuffle256, [Zn2FPU12], 2>;
444 defm : Zn2WriteResFpuPair<WriteVPMOV256, [Zn2FPU12], 4, [1], 2, 4>;
445 defm : Zn2WriteResFpuPair<WriteVarShuffle256, [Zn2FPU12], 2>;
446 defm : Zn2WriteResFpuPair<WritePSADBW, [Zn2FPU0], 3>;
447 defm : Zn2WriteResFpuPair<WritePSADBWX, [Zn2FPU0], 3>;
448 defm : Zn2WriteResFpuPair<WritePSADBWY, [Zn2FPU0], 3>;
449 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
450 defm : Zn2WriteResFpuPair<WritePHMINPOS, [Zn2FPU0], 4>;
452 // Vector insert/extract operations.
453 defm : Zn2WriteResFpuPair<WriteVecInsert, [Zn2FPU], 1>;
455 def : WriteRes<WriteVecExtract, [Zn2FPU12, Zn2FPU2]> {
457 let ReleaseAtCycles = [1, 2];
459 def : WriteRes<WriteVecExtractSt, [Zn2AGU, Zn2FPU12, Zn2FPU2]> {
462 let ReleaseAtCycles = [1, 2, 3];
465 // MOVMSK Instructions.
466 def : WriteRes<WriteFMOVMSK, [Zn2FPU2]>;
467 def : WriteRes<WriteMMXMOVMSK, [Zn2FPU2]>;
468 def : WriteRes<WriteVecMOVMSK, [Zn2FPU2]>;
470 def : WriteRes<WriteVecMOVMSKY, [Zn2FPU2]> {
473 let ReleaseAtCycles = [2];
477 defm : Zn2WriteResFpuPair<WriteAESDecEnc, [Zn2FPU01], 4>;
478 defm : Zn2WriteResFpuPair<WriteAESIMC, [Zn2FPU01], 4>;
479 defm : Zn2WriteResFpuPair<WriteAESKeyGen, [Zn2FPU01], 4>;
481 def : WriteRes<WriteFence, [Zn2AGU]>;
482 def : WriteRes<WriteNop, []>;
484 // Microcoded Instructions
485 def Zn2WriteMicrocoded : SchedWriteRes<[]> {
489 def : SchedAlias<WriteMicrocoded, Zn2WriteMicrocoded>;
490 def : SchedAlias<WriteFCMOV, Zn2WriteMicrocoded>;
491 def : SchedAlias<WriteSystem, Zn2WriteMicrocoded>;
492 def : SchedAlias<WriteMPSAD, Zn2WriteMicrocoded>;
493 def : SchedAlias<WriteMPSADY, Zn2WriteMicrocoded>;
494 def : SchedAlias<WriteMPSADLd, Zn2WriteMicrocoded>;
495 def : SchedAlias<WriteMPSADYLd, Zn2WriteMicrocoded>;
496 def : SchedAlias<WriteCLMul, Zn2WriteMicrocoded>;
497 def : SchedAlias<WriteCLMulLd, Zn2WriteMicrocoded>;
498 def : SchedAlias<WritePCmpIStrM, Zn2WriteMicrocoded>;
499 def : SchedAlias<WritePCmpIStrMLd, Zn2WriteMicrocoded>;
500 def : SchedAlias<WritePCmpEStrI, Zn2WriteMicrocoded>;
501 def : SchedAlias<WritePCmpEStrILd, Zn2WriteMicrocoded>;
502 def : SchedAlias<WritePCmpEStrM, Zn2WriteMicrocoded>;
503 def : SchedAlias<WritePCmpEStrMLd, Zn2WriteMicrocoded>;
504 def : SchedAlias<WritePCmpIStrI, Zn2WriteMicrocoded>;
505 def : SchedAlias<WritePCmpIStrILd, Zn2WriteMicrocoded>;
506 def : SchedAlias<WriteLDMXCSR, Zn2WriteMicrocoded>;
507 def : SchedAlias<WriteSTMXCSR, Zn2WriteMicrocoded>;
509 //=== Regex based InstRW ===//
514 // - mm: 64 bit mmx register.
515 // - x = 128 bit xmm register.
516 // - (x)mm = mmx or xmm register.
517 // - y = 256 bit ymm register.
518 // - v = any vector register.
520 //=== Integer Instructions ===//
521 //-- Move instructions --//
524 def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>;
528 def Zn2WriteXCHG : SchedWriteRes<[Zn2ALU]> {
532 def : InstRW<[Zn2WriteXCHG], (instregex "^XCHG(8|16|32|64)rr", "^XCHG(16|32|64)ar")>;
535 def Zn2WriteXCHGrm : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
539 def : InstRW<[Zn2WriteXCHGrm, ReadAfterLd], (instregex "^XCHG(8|16|32|64)rm")>;
541 def : InstRW<[WriteMicrocoded], (instrs XLAT)>;
545 def Zn2WritePop16r : SchedWriteRes<[Zn2AGU]>{
549 def : InstRW<[Zn2WritePop16r], (instrs POP16rmm)>;
550 def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>;
551 def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>;
555 // r. Has default values.
557 def Zn2WritePUSH : SchedWriteRes<[Zn2AGU]>{
560 def : InstRW<[Zn2WritePUSH], (instregex "PUSH(16|32)rmm")>;
563 def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>;
566 def Zn2WritePushA : SchedWriteRes<[Zn2AGU]> {
569 def : InstRW<[Zn2WritePushA], (instregex "PUSHA(16|32)")>;
572 def : InstRW<[WriteMicrocoded], (instrs LAHF)>;
576 def Zn2WriteMOVBE : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
579 def : InstRW<[Zn2WriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>;
582 def : InstRW<[Zn2WriteMOVBE], (instregex "MOVBE(16|32|64)mr")>;
584 //-- Arithmetic instructions --//
588 def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)",
589 "(ADD|SUB)(8|16|32|64)mi8",
594 def : InstRW<[WriteALULd],
595 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)",
596 "(ADC|SBB)(16|32|64)mi8",
601 def : InstRW<[WriteALULd],
602 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>;
606 def Zn2WriteMul16 : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
609 def Zn2WriteMul16Imm : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
612 def : SchedAlias<WriteIMul16, Zn2WriteMul16>;
613 def : SchedAlias<WriteIMul16Imm, Zn2WriteMul16Imm>;
614 def : SchedAlias<WriteIMul16Reg, Zn2WriteMul16>;
617 def Zn2WriteMul16Ld : SchedWriteRes<[Zn2AGU, Zn2ALU1, Zn2Multiplier]> {
620 def : SchedAlias<WriteIMul16Ld, Zn2WriteMul16Ld>;
621 def : SchedAlias<WriteIMul16ImmLd, Zn2WriteMul16Ld>;
622 def : SchedAlias<WriteIMul16RegLd, Zn2WriteMul16Ld>;
625 def Zn2WriteMul32 : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
628 def : SchedAlias<WriteIMul32, Zn2WriteMul32>;
629 def : SchedAlias<WriteIMul32Imm, Zn2WriteMul32>;
630 def : SchedAlias<WriteIMul32Reg, Zn2WriteMul32>;
633 def Zn2WriteMul32Ld : SchedWriteRes<[Zn2AGU, Zn2ALU1, Zn2Multiplier]> {
636 def : SchedAlias<WriteIMul32Ld, Zn2WriteMul32Ld>;
637 def : SchedAlias<WriteIMul32ImmLd, Zn2WriteMul32Ld>;
638 def : SchedAlias<WriteIMul32RegLd, Zn2WriteMul32Ld>;
641 def Zn2WriteMul64 : SchedWriteRes<[Zn2ALU1, Zn2Multiplier]> {
645 def : SchedAlias<WriteIMul64, Zn2WriteMul64>;
646 def : SchedAlias<WriteIMul64Imm, Zn2WriteMul64>;
647 def : SchedAlias<WriteIMul64Reg, Zn2WriteMul64>;
650 def Zn2WriteMul64Ld : SchedWriteRes<[Zn2AGU, Zn2ALU1, Zn2Multiplier]> {
654 def : SchedAlias<WriteIMul64Ld, Zn2WriteMul64Ld>;
655 def : SchedAlias<WriteIMul64ImmLd, Zn2WriteMul64Ld>;
656 def : SchedAlias<WriteIMul64RegLd, Zn2WriteMul64Ld>;
659 // Numbers are based on the AMD SOG for Family 17h - Instruction Latencies.
660 defm : Zn2WriteResPair<WriteMULX32, [Zn2ALU1, Zn2Multiplier], 3, [1, 1], 1, 4, 0>;
661 defm : Zn2WriteResPair<WriteMULX64, [Zn2ALU1, Zn2Multiplier], 3, [1, 1], 1, 4, 0>;
663 //-- Control transfer instructions --//
666 def Zn2WriteJCXZ : SchedWriteRes<[Zn2ALU03]>;
667 def : InstRW<[Zn2WriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>;
670 def Zn2WriteLOOP : SchedWriteRes<[Zn2ALU03]>;
671 def : InstRW<[Zn2WriteLOOP], (instrs LOOP)>;
673 // LOOP(N)E, LOOP(N)Z
674 def Zn2WriteLOOPE : SchedWriteRes<[Zn2ALU03]>;
675 def : InstRW<[Zn2WriteLOOPE], (instrs LOOPE, LOOPNE)>;
679 def Zn2WriteCALLr : SchedWriteRes<[Zn2AGU, Zn2ALU03]>;
680 def : InstRW<[Zn2WriteCALLr], (instregex "CALL(16|32)r")>;
682 def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>;
685 def Zn2WriteRET : SchedWriteRes<[Zn2ALU03]> {
688 def : InstRW<[Zn2WriteRET], (instregex "RET(16|32|64)", "LRET(16|32|64)",
691 //-- Logic instructions --//
695 def : InstRW<[WriteALULd],
696 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)",
697 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>;
699 // Define ALU latency variants
700 def Zn2WriteALULat2 : SchedWriteRes<[Zn2ALU]> {
703 def Zn2WriteALULat2Ld : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
709 def Zn2WriteBTRSCm : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
714 def : SchedAlias<WriteBitTestSetImmRMW, Zn2WriteBTRSCm>;
715 def : SchedAlias<WriteBitTestSetRegRMW, Zn2WriteBTRSCm>;
719 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>;
721 def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>;
725 def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>;
729 def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>;
733 def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>;
736 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>;
739 def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>;
741 //-- Misc instructions --//
743 def Zn2WriteCMPXCHG8B : SchedWriteRes<[Zn2AGU, Zn2ALU]> {
744 let NumMicroOps = 18;
746 def : InstRW<[Zn2WriteCMPXCHG8B], (instrs CMPXCHG8B)>;
748 def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>;
751 def Zn2WriteLEAVE : SchedWriteRes<[Zn2ALU, Zn2AGU]> {
755 def : InstRW<[Zn2WriteLEAVE], (instregex "LEAVE")>;
758 def : InstRW<[WriteMicrocoded], (instrs PAUSE)>;
761 def Zn2XADD : SchedWriteRes<[Zn2ALU]>;
762 def : InstRW<[Zn2XADD], (instregex "XADD(8|16|32|64)rr")>;
763 def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>;
765 //=== Floating Point x87 Instructions ===//
766 //-- Move instructions --//
768 def Zn2WriteFLDr : SchedWriteRes<[Zn2FPU13]> ;
770 def Zn2WriteSTr: SchedWriteRes<[Zn2FPU23]> {
777 def : InstRW<[Zn2WriteFLDr], (instrs LD_Frr)>;
780 def Zn2WriteLD_F80m : SchedWriteRes<[Zn2AGU, Zn2FPU13]> {
783 def : InstRW<[Zn2WriteLD_F80m], (instrs LD_F80m)>;
787 def : InstRW<[Zn2WriteSTr], (instregex "ST_(F|FP)rr")>;
790 def Zn2WriteST_FP80m : SchedWriteRes<[Zn2AGU, Zn2FPU23]> {
793 def : InstRW<[Zn2WriteST_FP80m], (instrs ST_FP80m)>;
795 def Zn2WriteFXCH : SchedWriteRes<[Zn2FPU]>;
798 def : InstRW<[Zn2WriteFXCH], (instrs XCH_F)>;
801 def Zn2WriteFILD : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
805 def : InstRW<[Zn2WriteFILD], (instregex "ILD_F(16|32|64)m")>;
808 def Zn2WriteFIST : SchedWriteRes<[Zn2AGU, Zn2FPU23]> {
811 def : InstRW<[Zn2WriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>;
813 def Zn2WriteFPU13 : SchedWriteRes<[Zn2AGU, Zn2FPU13]> {
817 def Zn2WriteFPU3 : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
822 def : SchedAlias<WriteFLD0, Zn2WriteFPU13>;
825 def : SchedAlias<WriteFLD1, Zn2WriteFPU3>;
828 def : SchedAlias<WriteFLDC, Zn2WriteFPU3>;
832 def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>;
835 def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>;
838 def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>;
841 def : InstRW<[Zn2WriteFPU3], (instrs FINCSTP, FDECSTP)>;
844 def : InstRW<[Zn2WriteFPU3], (instregex "FFREE")>;
846 //-- Arithmetic instructions --//
848 def Zn2WriteFPU3Lat1 : SchedWriteRes<[Zn2FPU3]> ;
850 def Zn2WriteFPU0Lat1 : SchedWriteRes<[Zn2FPU0]> ;
852 def Zn2WriteFPU0Lat1Ld : SchedWriteRes<[Zn2AGU, Zn2FPU0]> {
857 def : InstRW<[Zn2WriteFPU3Lat1], (instregex "CHS_F")>;
861 def : InstRW<[Zn2WriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>;
863 def : InstRW<[Zn2WriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>;
867 def : InstRW<[Zn2WriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>;
869 def Zn2WriteFPU02 : SchedWriteRes<[Zn2AGU, Zn2FPU02]>
874 // FCOMI(P) FUCOMI(P).
876 def : InstRW<[Zn2WriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
878 def Zn2WriteFPU03 : SchedWriteRes<[Zn2AGU, Zn2FPU03]>
882 let ReleaseAtCycles = [1,3];
886 def : InstRW<[Zn2WriteFPU03], (instregex "FICOM(P?)(16|32)m")>;
889 def : InstRW<[Zn2WriteFPU0Lat1], (instregex "TST_F")>;
892 def : InstRW<[Zn2WriteFPU3Lat1], (instrs XAM_F)>;
895 def : InstRW<[Zn2WriteFPU0Lat1], (instrs FNOP)>;
898 def : InstRW<[Zn2WriteFPU0Lat1], (instrs WAIT)>;
900 //=== Integer MMX and XMM Instructions ===//
902 def Zn2WriteFPU013 : SchedWriteRes<[Zn2FPU013]> ;
903 def Zn2WriteFPU013m : SchedWriteRes<[Zn2AGU, Zn2FPU013]> {
908 def Zn2WriteFPU01 : SchedWriteRes<[Zn2FPU01]> ;
909 def Zn2WriteFPU01Y : SchedWriteRes<[Zn2FPU01]> {
915 def : InstRW<[Zn2WriteFPU01], (instrs VPBLENDDrri)>;
917 def : InstRW<[Zn2WriteFPU01Y], (instrs VPBLENDDYrri)>;
920 def Zn2WriteFPU01Op2 : SchedWriteRes<[Zn2AGU, Zn2FPU01]> {
923 let ReleaseAtCycles = [1, 2];
925 def Zn2WriteFPU01Op2Y : SchedWriteRes<[Zn2AGU, Zn2FPU01]> {
928 let ReleaseAtCycles = [1, 3];
930 def : InstRW<[Zn2WriteFPU01Op2], (instrs VPBLENDDrmi)>;
931 def : InstRW<[Zn2WriteFPU01Op2Y], (instrs VPBLENDDYrmi)>;
934 def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>;
937 def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>;
941 def : InstRW<[WriteMicrocoded],
942 (instregex "VPMASKMOVD(Y?)rm")>;
944 def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>;
948 def Zn2WriteVPBROADCAST128Ld : SchedWriteRes<[Zn2AGU, Zn2FPU12]> {
951 let ReleaseAtCycles = [1, 2];
953 def : InstRW<[Zn2WriteVPBROADCAST128Ld],
954 (instregex "VPBROADCAST(B|W)rm")>;
957 def Zn2WriteVPBROADCAST256Ld : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
960 let ReleaseAtCycles = [1, 2];
962 def : InstRW<[Zn2WriteVPBROADCAST256Ld],
963 (instregex "VPBROADCAST(B|W)Yrm")>;
966 def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>;
968 //-- Arithmetic instructions --//
971 // PHADD|PHSUB (S) W/D.
972 defm : Zn2WriteResFpuPair<WriteFHAdd, [], 7>;
973 defm : Zn2WriteResFpuPair<WriteFHAddY, [], 7>;
974 defm : Zn2WriteResFpuPair<WritePHAdd, [], 3>;
975 defm : Zn2WriteResFpuPair<WritePHAddX, [], 3>;
976 defm : Zn2WriteResFpuPair<WritePHAddY, [], 3>;
979 def Zn2WritePCMPGTQr : SchedWriteRes<[Zn2FPU03]>;
980 def : InstRW<[Zn2WritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>;
983 def Zn2WritePCMPGTQm : SchedWriteRes<[Zn2AGU, Zn2FPU03]> {
987 def Zn2WritePCMPGTQYm : SchedWriteRes<[Zn2AGU, Zn2FPU03]> {
990 def : InstRW<[Zn2WritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>;
991 def : InstRW<[Zn2WritePCMPGTQYm], (instrs VPCMPGTQYrm)>;
993 //=== Floating Point XMM and YMM Instructions ===//
994 //-- Move instructions --//
996 // VPERM2F128 / VPERM2I128.
997 def Zn2WriteVPERM2r : SchedWriteRes<[Zn2FPU2]> {
1001 def : InstRW<[Zn2WriteVPERM2r], (instrs VPERM2F128rri,
1004 def Zn2WriteVPERM2m : SchedWriteRes<[Zn2AGU, Zn2FPU2]> {
1005 let NumMicroOps = 1;
1008 def : InstRW<[Zn2WriteVPERM2m], (instrs VPERM2F128rmi,
1011 def Zn2WriteBROADCAST : SchedWriteRes<[Zn2AGU, Zn2FPU13]> {
1012 let NumMicroOps = 2;
1015 // VBROADCASTF128 / VBROADCASTI128.
1016 def : InstRW<[Zn2WriteBROADCAST], (instrs VBROADCASTF128rm,
1021 def Zn2WriteEXTRACTPSr : SchedWriteRes<[Zn2FPU12, Zn2FPU2]> {
1023 let NumMicroOps = 2;
1024 let ReleaseAtCycles = [1, 2];
1026 def : InstRW<[Zn2WriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrri")>;
1028 def Zn2WriteEXTRACTPSm : SchedWriteRes<[Zn2AGU,Zn2FPU12, Zn2FPU2]> {
1030 let NumMicroOps = 2;
1031 let ReleaseAtCycles = [5, 1, 2];
1034 def : InstRW<[Zn2WriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmri")>;
1036 // VEXTRACTF128 / VEXTRACTI128.
1038 def : InstRW<[Zn2WriteFPU013], (instrs VEXTRACTF128rri,
1042 def : InstRW<[Zn2WriteFPU013m], (instrs VEXTRACTF128mri,
1045 def Zn2WriteVINSERT128r: SchedWriteRes<[Zn2FPU013]> {
1047 // let ReleaseAtCycles = [2];
1049 def Zn2WriteVINSERT128Ld: SchedWriteRes<[Zn2AGU,Zn2FPU013]> {
1051 let NumMicroOps = 2;
1053 // VINSERTF128 / VINSERTI128.
1055 def : InstRW<[Zn2WriteVINSERT128r], (instrs VINSERTF128rri,
1057 def : InstRW<[Zn2WriteVINSERT128Ld], (instrs VINSERTF128rmi,
1061 def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>;
1063 //-- Conversion instructions --//
1064 def Zn2WriteCVTPD2PSr: SchedWriteRes<[Zn2FPU3]> {
1067 def Zn2WriteCVTPD2PSYr: SchedWriteRes<[Zn2FPU3]> {
1073 def : SchedAlias<WriteCvtPD2PS, Zn2WriteCVTPD2PSr>;
1075 def : SchedAlias<WriteCvtPD2PSY, Zn2WriteCVTPD2PSYr>;
1077 defm : X86WriteResUnsupported<WriteCvtPD2PSZ>;
1079 def Zn2WriteCVTPD2PSLd: SchedWriteRes<[Zn2AGU,Zn2FPU3]> {
1083 def : SchedAlias<WriteCvtPD2PSLd, Zn2WriteCVTPD2PSLd>;
1086 def Zn2WriteCVTPD2PSYLd : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
1089 def : SchedAlias<WriteCvtPD2PSYLd, Zn2WriteCVTPD2PSYLd>;
1091 defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>;
1095 // Same as WriteCVTPD2PSr
1096 def : SchedAlias<WriteCvtSD2SS, Zn2WriteCVTPD2PSr>;
1099 def : SchedAlias<WriteCvtSD2SSLd, Zn2WriteCVTPD2PSLd>;
1103 def Zn2WriteCVTPS2PDr : SchedWriteRes<[Zn2FPU3]> {
1106 def : SchedAlias<WriteCvtPS2PD, Zn2WriteCVTPS2PDr>;
1110 def Zn2WriteCVTPS2PDLd : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
1112 let NumMicroOps = 2;
1114 def : SchedAlias<WriteCvtPS2PDLd, Zn2WriteCVTPS2PDLd>;
1115 def : SchedAlias<WriteCvtPS2PDYLd, Zn2WriteCVTPS2PDLd>;
1116 defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>;
1119 def Zn2WriteVCVTPS2PDY : SchedWriteRes<[Zn2FPU3]> {
1122 def : SchedAlias<WriteCvtPS2PDY, Zn2WriteVCVTPS2PDY>;
1123 defm : X86WriteResUnsupported<WriteCvtPS2PDZ>;
1127 def Zn2WriteCVTSS2SDr : SchedWriteRes<[Zn2FPU3]> {
1130 def : SchedAlias<WriteCvtSS2SD, Zn2WriteCVTSS2SDr>;
1133 def Zn2WriteCVTSS2SDLd : SchedWriteRes<[Zn2AGU, Zn2FPU3]> {
1135 let NumMicroOps = 2;
1136 let ReleaseAtCycles = [1, 2];
1138 def : SchedAlias<WriteCvtSS2SDLd, Zn2WriteCVTSS2SDLd>;
1140 def Zn2WriteCVTDQ2PDr: SchedWriteRes<[Zn2FPU12,Zn2FPU3]> {
1145 def : InstRW<[Zn2WriteCVTDQ2PDr], (instregex "(V)?CVTDQ2P(D|S)rr")>;
1149 def : InstRW<[Zn2WriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>;
1150 def : InstRW<[Zn2WriteCVTDQ2PDr], (instrs VCVTDQ2PSYrr)>;
1152 def Zn2WriteCVTPD2DQr: SchedWriteRes<[Zn2FPU12, Zn2FPU3]> {
1157 def : InstRW<[Zn2WriteCVTPD2DQr], (instregex "(V?)CVT(T?)P(D|S)2DQrr")>;
1159 def Zn2WriteCVTPD2DQLd: SchedWriteRes<[Zn2AGU,Zn2FPU12,Zn2FPU3]> {
1161 let NumMicroOps = 2;
1164 def : InstRW<[Zn2WriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>;
1165 // same as xmm handling
1167 def : InstRW<[Zn2WriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>;
1169 def : InstRW<[Zn2WriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>;
1171 def Zn2WriteCVTPS2PIr: SchedWriteRes<[Zn2FPU3]> {
1176 def : InstRW<[Zn2WriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIrr")>;
1180 def : InstRW<[Zn2WriteCVTPS2PDr], (instrs MMX_CVTPI2PDrr)>;
1184 def : InstRW<[Zn2WriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIrr")>;
1186 def Zn2WriteCVSTSI2SSr: SchedWriteRes<[Zn2FPU3]> {
1190 // same as CVTPD2DQr
1193 def : InstRW<[Zn2WriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>;
1194 // same as CVTPD2DQm
1196 def : InstRW<[Zn2WriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>;
1198 def Zn2WriteCVSTSI2SDr: SchedWriteRes<[Zn2FPU013, Zn2FPU3]> {
1203 def : InstRW<[Zn2WriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>;
1206 def Zn2WriteCVSTSI2SIr: SchedWriteRes<[Zn2FPU3, Zn2FPU2]> {
1209 def Zn2WriteCVSTSI2SILd: SchedWriteRes<[Zn2AGU, Zn2FPU3, Zn2FPU2]> {
1214 def : InstRW<[Zn2WriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>;
1216 def : InstRW<[Zn2WriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>;
1220 def : SchedAlias<WriteCvtPS2PH, Zn2WriteMicrocoded>;
1221 def : SchedAlias<WriteCvtPS2PHY, Zn2WriteMicrocoded>;
1222 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
1224 def : SchedAlias<WriteCvtPS2PHSt, Zn2WriteMicrocoded>;
1225 def : SchedAlias<WriteCvtPS2PHYSt, Zn2WriteMicrocoded>;
1226 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
1230 def : SchedAlias<WriteCvtPH2PS, Zn2WriteMicrocoded>;
1231 def : SchedAlias<WriteCvtPH2PSY, Zn2WriteMicrocoded>;
1232 defm : X86WriteResUnsupported<WriteCvtPH2PSZ>;
1234 def : SchedAlias<WriteCvtPH2PSLd, Zn2WriteMicrocoded>;
1235 def : SchedAlias<WriteCvtPH2PSYLd, Zn2WriteMicrocoded>;
1236 defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>;
1238 //-- SSE4A instructions --//
1240 def Zn2WriteEXTRQ: SchedWriteRes<[Zn2FPU12, Zn2FPU2]> {
1243 def : InstRW<[Zn2WriteEXTRQ], (instregex "EXTRQ")>;
1246 def Zn2WriteINSERTQ: SchedWriteRes<[Zn2FPU03,Zn2FPU1]> {
1249 def : InstRW<[Zn2WriteINSERTQ], (instregex "INSERTQ")>;
1251 //-- SHA instructions --//
1253 def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>;
1255 // SHA1MSG1, SHA256MSG1
1257 def Zn2WriteSHA1MSG1r : SchedWriteRes<[Zn2FPU12]> {
1260 def : InstRW<[Zn2WriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>;
1262 def Zn2WriteSHA1MSG1Ld : SchedWriteRes<[Zn2AGU, Zn2FPU12]> {
1265 def : InstRW<[Zn2WriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>;
1269 def Zn2WriteSHA1MSG2r : SchedWriteRes<[Zn2FPU12]> ;
1270 def : InstRW<[Zn2WriteSHA1MSG2r], (instrs SHA1MSG2rr)>;
1272 def Zn2WriteSHA1MSG2Ld : SchedWriteRes<[Zn2AGU, Zn2FPU12]> {
1275 def : InstRW<[Zn2WriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>;
1279 def Zn2WriteSHA1NEXTEr : SchedWriteRes<[Zn2FPU1]> ;
1280 def : InstRW<[Zn2WriteSHA1NEXTEr], (instrs SHA1NEXTErr)>;
1282 def Zn2WriteSHA1NEXTELd : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
1285 def : InstRW<[Zn2WriteSHA1NEXTELd], (instrs SHA1NEXTErm)>;
1289 def Zn2WriteSHA1RNDS4r : SchedWriteRes<[Zn2FPU1]> {
1292 def : InstRW<[Zn2WriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>;
1294 def Zn2WriteSHA1RNDS4Ld : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
1297 def : InstRW<[Zn2WriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>;
1301 def Zn2WriteSHA256RNDS2r : SchedWriteRes<[Zn2FPU1]> {
1304 def : InstRW<[Zn2WriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>;
1306 def Zn2WriteSHA256RNDS2Ld : SchedWriteRes<[Zn2AGU, Zn2FPU1]> {
1309 def : InstRW<[Zn2WriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>;
1311 //-- Arithmetic instructions --//
1315 defm : Zn2WriteResPair<WriteDPPS, [], 15>;
1316 def : SchedAlias<WriteDPPSY, Zn2WriteMicrocoded>;
1319 def : SchedAlias<WriteDPPSYLd,Zn2WriteMicrocoded>;
1323 def : SchedAlias<WriteDPPD, Zn2WriteMicrocoded>;
1326 def : SchedAlias<WriteDPPDLd, Zn2WriteMicrocoded>;
1328 //-- Other instructions --//
1331 def : InstRW<[WriteALU], (instrs VZEROUPPER)>;
1333 ///////////////////////////////////////////////////////////////////////////////
1334 // Dependency breaking instructions.
1335 ///////////////////////////////////////////////////////////////////////////////
1337 def : IsZeroIdiomFunction<[
1342 ], ZeroIdiomPredicate>,
1346 MMX_PXORrr, MMX_PANDNrr, MMX_PSUBBrr,
1347 MMX_PSUBDrr, MMX_PSUBQrr, MMX_PSUBWrr,
1348 MMX_PSUBSBrr, MMX_PSUBSWrr, MMX_PSUBUSBrr, MMX_PSUBUSWrr,
1349 MMX_PCMPGTBrr, MMX_PCMPGTDrr, MMX_PCMPGTWrr
1350 ], ZeroIdiomPredicate>,
1355 XORPSrr, XORPDrr, ANDNPSrr, ANDNPDrr,
1359 PSUBBrr, PSUBWrr, PSUBDrr, PSUBQrr,
1360 PCMPGTBrr, PCMPGTDrr, PCMPGTQrr, PCMPGTWrr
1361 ], ZeroIdiomPredicate>,
1363 // AVX XMM Zero-idioms.
1366 VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr,
1370 VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr,
1371 VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr
1372 ], ZeroIdiomPredicate>,
1374 // AVX YMM Zero-idioms.
1377 VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr,
1380 VPXORYrr, VPANDNYrr,
1381 VPSUBBYrr, VPSUBWYrr, VPSUBDYrr, VPSUBQYrr,
1382 VPCMPGTBYrr, VPCMPGTWYrr, VPCMPGTDYrr, VPCMPGTQYrr
1383 ], ZeroIdiomPredicate>
1386 def : IsDepBreakingFunction<[
1388 DepBreakingClass<[ SBB32rr, SBB64rr ], ZeroIdiomPredicate>,
1389 DepBreakingClass<[ CMP32rr, CMP64rr ], CheckSameRegOperand<0, 1> >,
1393 MMX_PCMPEQBrr, MMX_PCMPEQWrr, MMX_PCMPEQDrr
1394 ], ZeroIdiomPredicate>,
1398 PCMPEQBrr, PCMPEQWrr, PCMPEQDrr, PCMPEQQrr
1399 ], ZeroIdiomPredicate>,
1403 VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr, VPCMPEQQrr
1404 ], ZeroIdiomPredicate>,
1408 VPCMPEQBYrr, VPCMPEQWYrr, VPCMPEQDYrr, VPCMPEQQYrr
1409 ], ZeroIdiomPredicate>,