1 //=- X86ScheduleBdVer2.td - X86 BdVer2 (Piledriver) 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 AMD bdver2 (Piledriver) to support
10 // instruction scheduling and other instruction cost heuristics.
12 // * AMD Software Optimization Guide for AMD Family 15h Processors.
13 // https://support.amd.com/TechDocs/47414_15h_sw_opt_guide.pdf
14 // * The microarchitecture of Intel, AMD and VIA CPUs, By Agner Fog
15 // http://www.agner.org/optimize/microarchitecture.pdf
16 // * https://www.realworldtech.com/bulldozer/
17 // Yes, that is for Bulldozer aka bdver1, not Piledriver aka bdver2.
19 //===----------------------------------------------------------------------===//
21 def BdVer2Model : SchedMachineModel {
22 let IssueWidth = 4; // Up to 4 IPC can be decoded, issued, retired.
23 let MicroOpBufferSize = 128; // RCU reorder buffer size, which is unconfirmed.
24 let LoopMicroOpBufferSize = -1; // There does not seem to be a loop buffer.
25 let LoadLatency = 4; // L1 data cache has a 4-cycle load-to-use latency.
26 let HighLatency = 25; // FIXME: any better choice?
27 let MispredictPenalty = 20; // Minimum branch misdirection penalty.
29 let PostRAScheduler = 1; // Enable Post RegAlloc Scheduler pass.
31 // FIXME: Incomplete. This flag is set to allow the scheduler to assign
32 // a default model to unrecognized opcodes.
33 let CompleteModel = 0;
34 } // SchedMachineModel
36 let SchedModel = BdVer2Model in {
39 //===----------------------------------------------------------------------===//
41 //===----------------------------------------------------------------------===//
43 // There are total of eight pipes.
45 //===----------------------------------------------------------------------===//
46 // Integer execution pipes
49 // Two EX (ALU) pipes.
50 def PdEX0 : ProcResource<1>; // ALU, Integer Pipe0
51 def PdEX1 : ProcResource<1>; // ALU, Integer Pipe1
52 def PdEX01 : ProcResGroup<[PdEX0, PdEX1]>;
54 // Two AGLU pipes, identical.
55 def PdAGLU01 : ProcResource<2>; // AGU, Integer Pipe[23]
57 //===----------------------------------------------------------------------===//
58 // Floating point execution pipes
63 def PdFPU0 : ProcResource<1>; // Vector/FPU Pipe0
64 def PdFPU1 : ProcResource<1>; // Vector/FPU Pipe1
65 def PdFPU2 : ProcResource<1>; // Vector/FPU Pipe2
66 def PdFPU3 : ProcResource<1>; // Vector/FPU Pipe3
69 def PdFPU01 : ProcResGroup<[PdFPU0, PdFPU1]>;
70 def PdFPU23 : ProcResGroup<[PdFPU2, PdFPU3]>;
73 //===----------------------------------------------------------------------===//
75 //===----------------------------------------------------------------------===//
77 // The Retire Control Unit on Piledriver can retire up to 4 macro-ops per cycle.
78 // On the other hand, the RCU reorder buffer size for Piledriver does not
79 // seem be specified in any trustworthy source.
80 // But as per https://www.realworldtech.com/bulldozer/6/ the Bulldozer had
81 // RCU reorder buffer size of 128. So that is a good guess for now.
82 def PdRCU : RetireControlUnit<128, 4>;
85 //===----------------------------------------------------------------------===//
87 //===----------------------------------------------------------------------===//
89 // There are total of two pipelines, each one with it's own scheduler.
91 //===----------------------------------------------------------------------===//
92 // Integer Pipeline Scheduling
95 // There is one Integer Scheduler per core.
97 // Integer physical register file has 96 registers of 64-bit.
98 def PdIntegerPRF : RegisterFile<96, [GR64, CCR]>;
100 // Unified Integer, Memory Scheduler has 40 entries.
101 def PdEX : ProcResGroup<[PdEX0, PdEX1, PdAGLU01]> {
102 // Up to 4 IPC can be decoded, issued, retired.
107 //===----------------------------------------------------------------------===//
108 // FPU Pipeline Scheduling
111 // The FPU unit is shared between the two cores.
113 // FP physical register file has 160 registers of 128-bit.
114 // Operations on 256-bit data types are cracked into two COPs.
115 def PdFpuPRF : RegisterFile<160, [VR64, VR128, VR256], [1, 1, 2]>;
117 // Unified FP Scheduler has 64 entries,
118 def PdFPU : ProcResGroup<[PdFPU0, PdFPU1, PdFPU2, PdFPU3]> {
119 // Up to 4 IPC can be decoded, issued, retired.
124 //===----------------------------------------------------------------------===//
126 //===----------------------------------------------------------------------===//
128 //===----------------------------------------------------------------------===//
132 let Super = PdAGLU01 in
133 def PdLoad : ProcResource<2> {
134 // For Piledriver, the load queue is 40 entries deep.
138 def PdLoadQueue : LoadQueue<PdLoad>;
140 let Super = PdAGLU01 in
141 def PdStore : ProcResource<1> {
142 // For Piledriver, the store queue is 24 entries deep.
146 def PdStoreQueue : StoreQueue<PdStore>;
148 //===----------------------------------------------------------------------===//
149 // Integer Execution Units
152 def PdDiv : ProcResource<1>; // PdEX0; unpipelined integer division
153 def PdCount : ProcResource<1>; // PdEX0; POPCNT, LZCOUNT
155 def PdMul : ProcResource<1>; // PdEX1; integer multiplication
156 def PdBranch : ProcResource<1>; // PdEX1; JMP, fused branches
158 //===----------------------------------------------------------------------===//
159 // Floating-Point Units
162 // Two FMAC/FPFMA units.
163 def PdFPFMA : ProcResource<2>; // PdFPU0, PdFPU1
165 // One 128-bit integer multiply-accumulate unit.
166 def PdFPMMA : ProcResource<1>; // PdFPU0
168 // One fp conversion unit.
169 def PdFPCVT : ProcResource<1>; // PdFPU0
171 // One unit for shuffles, packs, permutes, shifts.
172 def PdFPXBR : ProcResource<1>; // PdFPU1
174 // Two 128-bit packed integer units.
175 def PdFPMAL : ProcResource<2>; // PdFPU2, PdFPU3
177 // One FP store unit.
178 def PdFPSTO : ProcResource<1>; // PdFPU3
181 //===----------------------------------------------------------------------===//
182 // Basic helper classes.
183 //===----------------------------------------------------------------------===//
185 // Many SchedWrites are defined in pairs with and without a folded load.
186 // Instructions with folded loads are usually micro-fused, so they only appear
187 // as two micro-ops when dispatched by the schedulers.
188 // This multiclass defines the resource usage for variants with and without
190 multiclass PdWriteRes<SchedWrite SchedRW,
191 list<ProcResourceKind> ExePorts, int Lat = 1,
192 list<int> Res = [], int UOps = 1> {
193 def : WriteRes<SchedRW, ExePorts> {
195 let ResourceCycles = Res;
196 let NumMicroOps = UOps;
200 multiclass __pdWriteResPair<X86FoldableSchedWrite SchedRW,
201 list<ProcResourceKind> ExePorts, int Lat,
202 list<int> Res, int UOps,
203 int LoadLat, int LoadRes, int LoadUOps> {
204 defm : PdWriteRes<SchedRW, ExePorts, Lat, Res, UOps>;
206 defm : PdWriteRes<SchedRW.Folded,
207 !listconcat([PdLoad], ExePorts),
209 !if(!and(!empty(Res), !eq(LoadRes, 1)),
211 !listconcat([LoadRes], Res)),
212 !add(UOps, LoadUOps)>;
215 multiclass PdWriteResExPair<X86FoldableSchedWrite SchedRW,
216 list<ProcResourceKind> ExePorts, int Lat = 1,
217 list<int> Res = [], int UOps = 1,
219 defm : __pdWriteResPair<SchedRW, ExePorts, Lat, Res, UOps,
220 /*LoadLat*/4, /*LoadRes*/1, LoadUOps>;
223 multiclass PdWriteResXMMPair<X86FoldableSchedWrite SchedRW,
224 list<ProcResourceKind> ExePorts, int Lat = 1,
225 list<int> Res = [], int UOps = 1,
227 defm : __pdWriteResPair<SchedRW, ExePorts, Lat, Res, UOps,
228 /*LoadLat*/5, /*LoadRes*/1, LoadUOps>;
231 multiclass PdWriteResYMMPair<X86FoldableSchedWrite SchedRW,
232 list<ProcResourceKind> ExePorts, int Lat,
233 list<int> Res, int UOps = 2,
235 defm : __pdWriteResPair<SchedRW, ExePorts, Lat, Res, UOps,
236 /*LoadLat*/5, /*LoadRes*/2, LoadUOps>;
239 //===----------------------------------------------------------------------===//
241 //===----------------------------------------------------------------------===//
243 // L1 data cache has a 4-cycle load-to-use latency, so ReadAfterLd registers
244 // needn't be available until 4 cycles after the memory operand.
245 def : ReadAdvance<ReadAfterLd, 4>;
247 // Vector loads are 5 cycles, so ReadAfterVec*Ld registers needn't be available
248 // until 5 cycles after the memory operand.
249 def : ReadAdvance<ReadAfterVecLd, 5>;
250 def : ReadAdvance<ReadAfterVecXLd, 5>;
251 def : ReadAdvance<ReadAfterVecYLd, 5>;
253 // Transfer from int domain to ivec domain incurs additional latency of 8..10cy
254 // Reference: Agner, Microarchitecture, "AMD Bulldozer, Piledriver, Steamroller
255 // and Excavator pipeline", "Data delay between different execution domains"
256 def : ReadAdvance<ReadInt2Fpu, -10>;
258 // A folded store needs a cycle on the PdStore for the store data.
259 def : WriteRes<WriteRMW, [PdStore]>;
261 ////////////////////////////////////////////////////////////////////////////////
262 // Loads, stores, and moves, not folded with other operations.
263 ////////////////////////////////////////////////////////////////////////////////
265 def : WriteRes<WriteLoad, [PdLoad]> { let Latency = 5; }
266 def : WriteRes<WriteStore, [PdStore]>;
267 def : WriteRes<WriteStoreNT, [PdStore]>;
268 def : WriteRes<WriteMove, [PdEX01]>;
271 // FIXME: These are copy and pasted from WriteLoad/Store.
272 def : WriteRes<WriteLDMXCSR, [PdLoad]> { let Latency = 5; }
273 def : WriteRes<WriteSTMXCSR, [PdStore]> { let NumMicroOps = 2; }
275 // Treat misc copies as a move.
276 def : InstRW<[WriteMove], (instrs COPY)>;
278 ////////////////////////////////////////////////////////////////////////////////
279 // Idioms that clear a register, like xorps %xmm0, %xmm0.
280 // These can often bypass execution ports completely.
281 ////////////////////////////////////////////////////////////////////////////////
283 def : WriteRes<WriteZero, [/*No ExePorts*/]>;
285 ////////////////////////////////////////////////////////////////////////////////
286 // Branches don't produce values, so they have no latency, but they still
287 // consume resources. Indirect branches can fold loads.
288 ////////////////////////////////////////////////////////////////////////////////
290 defm : PdWriteResExPair<WriteJump, [PdEX1, PdBranch]>;
292 ////////////////////////////////////////////////////////////////////////////////
293 // Special case scheduling classes.
294 ////////////////////////////////////////////////////////////////////////////////
296 def : WriteRes<WriteSystem, [PdEX01]> { let Latency = 100; }
297 def : WriteRes<WriteMicrocoded, [PdEX01]> { let Latency = 100; }
298 def : WriteRes<WriteFence, [PdStore]>;
300 def PdWriteXLAT : SchedWriteRes<[PdEX01]> {
303 def : InstRW<[PdWriteXLAT], (instrs XLAT)>;
305 def PdWriteLARrr : SchedWriteRes<[PdEX01]> {
307 let NumMicroOps = 45;
309 def : InstRW<[PdWriteLARrr], (instregex "LAR(16|32|64)rr",
312 // Nops don't have dependencies, so there's no actual latency, but we set this
313 // to '1' to tell the scheduler that the nop uses an ALU slot for a cycle.
314 def : WriteRes<WriteNop, [PdEX01]>;
316 ////////////////////////////////////////////////////////////////////////////////
318 ////////////////////////////////////////////////////////////////////////////////
320 defm : PdWriteResExPair<WriteALU, [PdEX01]>;
322 def PdWriteLXADD : SchedWriteRes<[PdEX01]> {
326 def : InstRW<[PdWriteLXADD], (instrs LXADD8, LXADD16, LXADD32, LXADD64)>;
328 def PdWriteBMI1 : SchedWriteRes<[PdEX01]> {
332 def : InstRW<[PdWriteBMI1],
333 (instrs BLCFILL32rr, BLCFILL64rr, BLCI32rr, BLCI64rr,
334 BLCIC32rr, BLCIC64rr, BLCMSK32rr, BLCMSK64rr,
335 BLCS32rr, BLCS64rr, BLSFILL32rr, BLSFILL64rr,
336 BLSIC32rr, BLSIC64rr, T1MSKC32rr, T1MSKC64rr,
337 TZMSK32rr, TZMSK64rr)>;
339 def PdWriteBMI1m : SchedWriteRes<[PdEX01]> {
343 def : InstRW<[PdWriteBMI1m],
344 (instrs BLCFILL32rm, BLCFILL64rm, BLCI32rm, BLCI64rm,
345 BLCIC32rm, BLCIC64rm, BLCMSK32rm, BLCMSK64rm,
346 BLCS32rm, BLCS64rm, BLSFILL32rm, BLSFILL64rm,
347 BLSIC32rm, BLSIC64rm, T1MSKC32rm, T1MSKC64rm,
348 TZMSK32rm, TZMSK64rm)>;
350 defm : PdWriteResExPair<WriteADC, [PdEX01], 1, [2]>;
352 defm : PdWriteRes<WriteBSWAP32, [PdEX1]>;
353 defm : PdWriteRes<WriteBSWAP64, [PdEX1]>;
354 defm : PdWriteRes<WriteCMPXCHG, [PdEX1], 3, [], 5>;
355 defm : PdWriteRes<WriteCMPXCHGRMW, [PdEX1, PdStore, PdLoad], 3, [], 2>;
356 defm : PdWriteRes<WriteXCHG, [PdEX1], 1, [], 2>;
358 def PdWriteCMPXCHG8rr : SchedWriteRes<[PdEX1]> {
362 def : InstRW<[PdWriteCMPXCHG8rr], (instrs CMPXCHG8rr)>;
364 def PdWriteCMPXCHG8rm : SchedWriteRes<[PdEX1]> {
368 def : InstRW<[PdWriteCMPXCHG8rm], (instrs CMPXCHG8rm)>;
370 def PdWriteCMPXCHG16rm_CMPXCHG32rm_CMPXCHG64rm : SchedWriteRes<[PdEX1]> {
374 def : InstRW<[PdWriteCMPXCHG16rm_CMPXCHG32rm_CMPXCHG64rm],
375 (instrs CMPXCHG16rm, CMPXCHG32rm, CMPXCHG64rm)>;
377 def PdWriteCMPXCHG8B : SchedWriteRes<[PdEX1]> {
379 let NumMicroOps = 18;
381 def : InstRW<[PdWriteCMPXCHG8B], (instrs CMPXCHG8B)>;
383 def PdWriteCMPXCHG16B : SchedWriteRes<[PdEX1]> {
385 let NumMicroOps = 22;
387 def : InstRW<[PdWriteCMPXCHG16B], (instrs CMPXCHG16B)>;
389 def PdWriteXCHG16rr : SchedWriteRes<[PdEX1]> {
393 def : InstRW<[PdWriteXCHG16rr], (instrs XCHG16rr)>;
395 def PdWriteXADD : SchedWriteRes<[PdEX1]> {
399 def : InstRW<[PdWriteXADD], (instrs XADD8rr, XADD16rr, XADD32rr, XADD64rr)>;
401 def PdWriteXADDm : SchedWriteRes<[PdEX1]> {
405 def : InstRW<[PdWriteXADDm], (instrs XADD8rm, XADD16rm, XADD32rm, XADD64rm)>;
407 defm : PdWriteResExPair<WriteIMul8, [PdEX1, PdMul], 4>;
408 defm : PdWriteResExPair<WriteIMul16, [PdEX1, PdMul], 4, [], 2>;
409 defm : PdWriteResExPair<WriteIMul16Imm, [PdEX1, PdMul], 5, [], 2>;
410 defm : PdWriteResExPair<WriteIMul16Reg, [PdEX1, PdMul], 4>;
411 defm : PdWriteResExPair<WriteIMul32, [PdEX1, PdMul], 4>;
412 defm : PdWriteResExPair<WriteIMul32Imm, [PdEX1, PdMul], 4, [], 1, 1>;
413 defm : PdWriteResExPair<WriteIMul32Reg, [PdEX1, PdMul], 4>;
414 defm : PdWriteResExPair<WriteIMul64, [PdEX1, PdMul], 6, [1, 4]>;
415 defm : PdWriteResExPair<WriteIMul64Imm, [PdEX1, PdMul], 6, [1, 4],1, 1>;
416 defm : PdWriteResExPair<WriteIMul64Reg, [PdEX1, PdMul], 6, [1, 4]>;
417 defm : X86WriteResUnsupported<WriteIMulH>; // BMI2 MULX
419 defm : PdWriteResExPair<WriteDiv8, [PdEX1, PdDiv], 12, [1, 12]>;
420 defm : PdWriteResExPair<WriteDiv16, [PdEX1, PdDiv], 15, [1, 15], 2>;
421 defm : PdWriteResExPair<WriteDiv32, [PdEX1, PdDiv], 14, [1, 14], 2>;
422 defm : PdWriteResExPair<WriteDiv64, [PdEX1, PdDiv], 14, [1, 14], 2>;
424 defm : PdWriteResExPair<WriteIDiv8, [PdEX1, PdDiv], 12, [1, 12]>;
425 defm : PdWriteResExPair<WriteIDiv16, [PdEX1, PdDiv], 15, [1, 17], 2>;
426 defm : PdWriteResExPair<WriteIDiv32, [PdEX1, PdDiv], 14, [1, 25], 2>;
427 defm : PdWriteResExPair<WriteIDiv64, [PdEX1, PdDiv], 14, [1, 14], 2>;
429 defm : PdWriteResExPair<WriteCRC32, [PdEX01], 3, [4], 3>;
431 def PdWriteCRC32r32r16 : SchedWriteRes<[PdEX01]> {
433 let ResourceCycles = [4];
436 def : InstRW<[PdWriteCRC32r32r16], (instrs CRC32r32r16)>;
438 def PdWriteCRC32r32r32 : SchedWriteRes<[PdEX01]> {
440 let ResourceCycles = [4];
443 def : InstRW<[PdWriteCRC32r32r32], (instrs CRC32r32r32)>;
445 def PdWriteCRC32r64r64 : SchedWriteRes<[PdEX01]> {
447 let ResourceCycles = [4];
448 let NumMicroOps = 11;
450 def : InstRW<[PdWriteCRC32r64r64], (instrs CRC32r64r64)>;
452 defm : PdWriteResExPair<WriteCMOV, [PdEX01]>; // Conditional move.
453 defm : PdWriteResExPair<WriteCMOV2, [PdEX01], 1, [], 1, 1>; // Conditional (CF + ZF flag) move.
455 def : InstRW<[WriteCMOV2.Folded], (instrs CMOVG16rm, CMOVG32rm, CMOVG64rm,
456 CMOVGE16rm, CMOVGE32rm, CMOVGE64rm,
457 CMOVL16rm, CMOVL32rm, CMOVL64rm,
458 CMOVLE16rm, CMOVLE32rm, CMOVLE64rm)>;
460 defm : PdWriteRes<WriteFCMOV, [PdFPU0, PdFPFMA]>; // x87 conditional move.
462 def : WriteRes<WriteSETCC, [PdEX01]>; // Setcc.
463 def : WriteRes<WriteSETCCStore, [PdEX01, PdStore]>;
465 def PdWriteSETGEmSETGmSETLEmSETLm : SchedWriteRes<[PdEX01]> {
466 let ResourceCycles = [2];
469 def : InstRW<[PdWriteSETGEmSETGmSETLEmSETLm], (instrs SETGEm, SETGm,
472 defm : PdWriteRes<WriteLAHFSAHF, [PdEX01], 2, [], 2>;
474 def WriteLAHF : SchedWriteRes<[PdEX01]> {
478 def : InstRW<[WriteLAHF], (instrs LAHF)>;
480 def WriteSAHF : SchedWriteRes<[PdEX01]> {
484 def : InstRW<[WriteSAHF], (instrs SAHF)>;
486 defm : PdWriteRes<WriteBitTest, [PdEX01], 1, [1], 1>;
487 defm : PdWriteRes<WriteBitTestImmLd, [PdEX01, PdLoad], 5, [1, 1], 1>;
488 defm : PdWriteRes<WriteBitTestRegLd, [PdEX01, PdLoad], 5, [1, 1], 7>;
489 defm : PdWriteRes<WriteBitTestSet, [PdEX01], 2, [1], 2>;
490 defm : PdWriteRes<WriteBitTestSetImmLd, [PdEX01, PdLoad], 6, [1, 1], 4>;
491 defm : PdWriteRes<WriteBitTestSetImmRMW, [PdEX01, PdLoad], 6, [1, 1], 4>;
492 defm : PdWriteRes<WriteBitTestSetRegLd, [PdEX01, PdLoad], 6, [1, 1], 10>;
493 defm : PdWriteRes<WriteBitTestSetRegRMW, [PdEX01, PdLoad], 6, [1, 1], 10>;
495 // This is for simple LEAs with one or two input operands.
496 // FIXME: SAGU 3-operand LEA
497 def : WriteRes<WriteLEA, [PdEX01]> { let NumMicroOps = 2; }
500 defm : PdWriteResExPair<WriteBSF, [PdEX01], 3, [4], 6, 2>;
501 defm : PdWriteResExPair<WriteBSR, [PdEX01], 4, [4], 7, 2>;
502 defm : PdWriteResExPair<WritePOPCNT, [PdEX01], 4>;
503 defm : PdWriteResExPair<WriteLZCNT, [PdEX01], 2, [], 2>;
504 defm : PdWriteResExPair<WriteTZCNT, [PdEX01], 2, [2], 2>;
506 // BMI1 BEXTR, BMI2 BZHI
507 defm : PdWriteResExPair<WriteBEXTR, [PdEX01], 2, [], 2>;
508 defm : PdWriteResExPair<WriteBLS, [PdEX01], 2, [], 2>;
509 defm : PdWriteResExPair<WriteBZHI, [PdEX01]>;
511 ////////////////////////////////////////////////////////////////////////////////
512 // Integer shifts and rotates.
513 ////////////////////////////////////////////////////////////////////////////////
515 defm : PdWriteResExPair<WriteShift, [PdEX01]>;
516 defm : PdWriteResExPair<WriteShiftCL, [PdEX01]>;
517 defm : PdWriteResExPair<WriteRotate, [PdEX01]>;
518 defm : PdWriteResExPair<WriteRotateCL, [PdEX01]>;
520 def PdWriteRCL8rCL : SchedWriteRes<[PdEX01]> {
522 let NumMicroOps = 26;
524 def : InstRW<[PdWriteRCL8rCL], (instrs RCL8rCL)>;
526 def PdWriteRCR8ri : SchedWriteRes<[PdEX01]> {
528 let NumMicroOps = 23;
530 def : InstRW<[PdWriteRCR8ri], (instrs RCR8ri)>;
532 def PdWriteRCR8rCL : SchedWriteRes<[PdEX01]> {
534 let NumMicroOps = 24;
536 def : InstRW<[PdWriteRCR8rCL], (instrs RCR8rCL)>;
538 def PdWriteRCL16rCL : SchedWriteRes<[PdEX01]> {
540 let NumMicroOps = 22;
542 def : InstRW<[PdWriteRCL16rCL], (instrs RCL16rCL)>;
544 def PdWriteRCR16ri : SchedWriteRes<[PdEX01]> {
546 let NumMicroOps = 19;
548 def : InstRW<[PdWriteRCR16ri], (instrs RCR16ri)>;
550 def PdWriteRCL32rCLRCL64rCL : SchedWriteRes<[PdEX01]> {
552 let NumMicroOps = 17;
554 def : InstRW<[PdWriteRCL32rCLRCL64rCL], (instrs RCL32rCL, RCL64rCL)>;
556 def PdWriteRCR64rCL : SchedWriteRes<[PdEX01]> {
558 let NumMicroOps = 16;
560 def : InstRW<[PdWriteRCR64rCL], (instrs RCR64rCL)>;
562 def PdWriteRCR32rCL : SchedWriteRes<[PdEX01]> {
564 let NumMicroOps = 16;
566 def : InstRW<[PdWriteRCR32rCL ], (instrs RCR32rCL)>;
568 def PdWriteRCR32riRCR64ri : SchedWriteRes<[PdEX01]> {
570 let NumMicroOps = 15;
572 def : InstRW<[PdWriteRCR32riRCR64ri], (instrs RCR32ri, RCR64ri)>;
575 def PdWriteRCR16rCL : SchedWriteRes<[PdEX01]> {
577 let NumMicroOps = 20;
579 def : InstRW<[PdWriteRCR16rCL], (instrs RCR16rCL)>;
581 def PdWriteRCL16ri : SchedWriteRes<[PdEX01]> {
583 let NumMicroOps = 21;
585 def : InstRW<[PdWriteRCL16ri], (instrs RCL16ri)>;
587 def PdWriteRCL3264ri : SchedWriteRes<[PdEX01]> {
589 let NumMicroOps = 16;
591 def : InstRW<[PdWriteRCL3264ri], (instrs RCL32ri, RCL64ri)>;
593 def PdWriteRCL8ri : SchedWriteRes<[PdEX01]> {
595 let NumMicroOps = 25;
597 def : InstRW<[PdWriteRCL8ri], (instrs RCL8ri)>;
600 defm : PdWriteRes<WriteSHDrri, [PdEX01], 4, [6], 6>;
601 defm : PdWriteRes<WriteSHDrrcl, [PdEX01], 4, [8], 7>;
603 def PdWriteSHLD32rri8SHRD16rri8 : SchedWriteRes<[PdEX01]> {
605 let ResourceCycles = [6];
608 def : InstRW<[PdWriteSHLD32rri8SHRD16rri8 ], (instrs SHLD32rri8, SHRD16rri8)>;
610 def PdWriteSHLD16rrCLSHLD32rrCLSHRD32rrCL : SchedWriteRes<[PdEX01]> {
612 let ResourceCycles = [8];
615 def : InstRW<[PdWriteSHLD16rrCLSHLD32rrCLSHRD32rrCL], (instrs SHLD16rrCL,
619 defm : PdWriteRes<WriteSHDmri, [PdLoad, PdEX01], 4, [1, 22], 8>;
620 defm : PdWriteRes<WriteSHDmrcl, [PdLoad, PdEX01], 4, [1, 22], 8>;
622 ////////////////////////////////////////////////////////////////////////////////
623 // Floating point. This covers both scalar and vector operations.
624 ////////////////////////////////////////////////////////////////////////////////
626 defm : PdWriteRes<WriteFLD0, [PdFPU1, PdFPSTO], 3>;
627 defm : PdWriteRes<WriteFLD1, [PdFPU1, PdFPSTO], 3>;
628 defm : PdWriteRes<WriteFLDC, [PdFPU1, PdFPSTO], 3>;
630 defm : PdWriteRes<WriteFLoad, [PdLoad, PdFPU01, PdFPFMA], 5>;
631 defm : PdWriteRes<WriteFLoadX, [PdLoad, PdFPU01, PdFPFMA], 5>;
632 defm : PdWriteRes<WriteFLoadY, [PdLoad, PdFPU01, PdFPFMA], 5, [], 2>;
634 defm : PdWriteRes<WriteFMaskedLoad, [PdLoad, PdFPU01, PdFPFMA], 6, [1, 1, 2]>;
635 defm : PdWriteRes<WriteFMaskedLoadY, [PdLoad, PdFPU01, PdFPFMA], 6, [2, 2, 4], 2>;
637 defm : PdWriteRes<WriteFStore, [PdStore, PdFPU1, PdFPSTO], 2>;
638 defm : PdWriteRes<WriteFStoreX, [PdStore, PdFPU1, PdFPSTO]>;
639 defm : PdWriteRes<WriteFStoreY, [PdStore, PdFPU1, PdFPSTO], 1, [], 4>;
641 def PdWriteMOVHPm : SchedWriteRes<[PdStore, PdFPU1, PdFPSTO]> {
645 def : InstRW<[PdWriteMOVHPm], (instrs MOVHPDmr, MOVHPSmr, VMOVHPDmr, VMOVHPSmr)>;
647 def PdWriteVMOVUPDYmrVMOVUPSYmr : SchedWriteRes<[PdStore, PdFPU1, PdFPSTO]> {
650 def : InstRW<[PdWriteVMOVUPDYmrVMOVUPSYmr], (instrs VMOVUPDYmr, VMOVUPSYmr)>;
652 defm : PdWriteRes<WriteFStoreNT, [PdStore, PdFPU1, PdFPSTO], 3>;
653 defm : PdWriteRes<WriteFStoreNTX, [PdStore, PdFPU1, PdFPSTO], 3>;
654 defm : PdWriteRes<WriteFStoreNTY, [PdStore, PdFPU1, PdFPSTO], 3, [2, 2, 2], 4>;
656 defm : PdWriteRes<WriteFMaskedStore, [PdStore, PdFPU01, PdFPFMA], 6, [1, 1, 4], 18>;
657 defm : PdWriteRes<WriteFMaskedStoreY, [PdStore, PdFPU01, PdFPFMA], 6, [2, 2, 4], 34>;
659 defm : PdWriteRes<WriteFMove, [PdFPU01, PdFPFMA]>;
660 defm : PdWriteRes<WriteFMoveX, [PdFPU01, PdFPFMA]>;
661 defm : PdWriteRes<WriteFMoveY, [PdFPU01, PdFPFMA], 2, [2, 2], 2>;
663 defm : PdWriteRes<WriteEMMS, [PdFPU01, PdFPFMA], 2>;
665 defm : PdWriteResXMMPair<WriteFAdd, [PdFPU0, PdFPFMA], 5>;
666 defm : PdWriteResXMMPair<WriteFAddX, [PdFPU0, PdFPFMA], 5>;
667 defm : PdWriteResYMMPair<WriteFAddY, [PdFPU0, PdFPFMA], 5, [2, 1]>;
668 defm : X86WriteResPairUnsupported<WriteFAddZ>;
670 defm : PdWriteResXMMPair<WriteFAdd64, [PdFPU0, PdFPFMA], 5>;
671 defm : PdWriteResXMMPair<WriteFAdd64X, [PdFPU0, PdFPFMA], 5>;
672 defm : PdWriteResYMMPair<WriteFAdd64Y, [PdFPU0, PdFPFMA], 5, [2, 1]>;
673 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
675 defm : PdWriteResXMMPair<WriteFCmp, [PdFPU0, PdFPFMA], 2>;
676 defm : PdWriteResXMMPair<WriteFCmpX, [PdFPU0, PdFPFMA], 2>;
677 defm : PdWriteResYMMPair<WriteFCmpY, [PdFPU0, PdFPFMA], 2, [2, 1]>;
678 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
680 defm : PdWriteResXMMPair<WriteFCmp64, [PdFPU0, PdFPFMA], 2>;
681 defm : PdWriteResXMMPair<WriteFCmp64X, [PdFPU0, PdFPFMA], 2>;
682 defm : PdWriteResYMMPair<WriteFCmp64Y, [PdFPU0, PdFPFMA], 2, [2, 1]>;
683 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
685 defm : PdWriteResXMMPair<WriteFCom, [PdFPU0, PdFPFMA, PdEX0], 1, [], 2>;
687 def PdWriteFCOMPm : SchedWriteRes<[PdFPU1, PdFPFMA]> {
690 def : InstRW<[PdWriteFCOMPm], (instrs FCOM32m, FCOM64m, FCOMP32m, FCOMP64m)>;
692 def PdWriteTST_F_UCOM_FPPr : SchedWriteRes<[PdFPU1, PdFPFMA]>;
693 def : InstRW<[PdWriteTST_F_UCOM_FPPr], (instrs TST_F, UCOM_FPPr)>;
695 defm : PdWriteResXMMPair<WriteFMul, [PdFPU1, PdFPFMA], 5>;
696 defm : PdWriteResXMMPair<WriteFMulX, [PdFPU1, PdFPFMA], 5>;
697 defm : PdWriteResYMMPair<WriteFMulY, [PdFPU1, PdFPFMA], 5, [2, 1]>;
698 defm : X86WriteResPairUnsupported<WriteFMulZ>;
700 defm : PdWriteResXMMPair<WriteFMul64, [PdFPU1, PdFPFMA], 5>;
701 defm : PdWriteResXMMPair<WriteFMul64X, [PdFPU1, PdFPFMA], 5>;
702 defm : PdWriteResYMMPair<WriteFMul64Y, [PdFPU1, PdFPFMA], 5, [2, 1]>;
703 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
705 defm : PdWriteResXMMPair<WriteFMA, [PdFPU, PdFPFMA], 5>;
706 defm : PdWriteResXMMPair<WriteFMAX, [PdFPU, PdFPFMA], 5>;
707 defm : PdWriteResYMMPair<WriteFMAY, [PdFPU, PdFPFMA], 5, [1, 1]>;
708 defm : X86WriteResPairUnsupported<WriteFMAZ>;
711 defm : PdWriteResXMMPair<WriteDPPD, [PdFPU1, PdFPFMA], 15, [1, 3], 15, 2>;
713 defm : PdWriteResXMMPair<WriteDPPS, [PdFPU1, PdFPFMA], 25, [1, 3], 16, 2>;
714 defm : PdWriteResYMMPair<WriteDPPSY, [PdFPU1, PdFPFMA], 27, [2, 6], /*or 29*/ 25, 4>;
715 defm : X86WriteResPairUnsupported<WriteDPPSZ>;
717 def PdWriteVDPPSrri : SchedWriteRes<[PdFPU1, PdFPFMA]> {
719 let ResourceCycles = [1, 3];
720 let NumMicroOps = 17;
722 def : InstRW<[PdWriteVDPPSrri], (instrs VDPPSrri)>;
724 defm : PdWriteResXMMPair<WriteFRcp, [PdFPU1, PdFPFMA], 5>;
725 defm : PdWriteResXMMPair<WriteFRcpX, [PdFPU1, PdFPFMA], 5>;
726 defm : PdWriteResYMMPair<WriteFRcpY, [PdFPU1, PdFPFMA], 5, [2, 1]>;
727 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
729 defm : PdWriteResXMMPair<WriteFRsqrt, [PdFPU1, PdFPFMA], 5>;
730 defm : PdWriteResXMMPair<WriteFRsqrtX, [PdFPU1, PdFPFMA], 5>;
731 defm : PdWriteResYMMPair<WriteFRsqrtY, [PdFPU1, PdFPFMA], 5, [2, 1]>;
732 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
734 defm : PdWriteResXMMPair<WriteFDiv, [PdFPU1, PdFPFMA], 9, [1, 19]>;
735 defm : PdWriteResXMMPair<WriteFDivX, [PdFPU1, PdFPFMA], 9, [1, 19]>;
736 defm : PdWriteResYMMPair<WriteFDivY, [PdFPU1, PdFPFMA], 9, [2, 38]>;
737 defm : X86WriteResPairUnsupported<WriteFDivZ>;
739 defm : PdWriteResXMMPair<WriteFDiv64, [PdFPU1, PdFPFMA], 9, [1, 19]>;
740 defm : PdWriteResXMMPair<WriteFDiv64X, [PdFPU1, PdFPFMA], 9, [1, 19]>;
741 defm : PdWriteResYMMPair<WriteFDiv64Y, [PdFPU1, PdFPFMA], 9, [2, 38]>;
742 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
744 defm : PdWriteResXMMPair<WriteFSqrt, [PdFPU1, PdFPFMA], 9, [1, 21]>;
745 defm : PdWriteResXMMPair<WriteFSqrtX, [PdFPU1, PdFPFMA], 9, [1, 21]>;
746 defm : PdWriteResYMMPair<WriteFSqrtY, [PdFPU1, PdFPFMA], 9, [2, 42]>;
747 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
749 defm : PdWriteResXMMPair<WriteFSqrt64, [PdFPU1, PdFPFMA], 9, [1, 27]>;
750 defm : PdWriteResXMMPair<WriteFSqrt64X, [PdFPU1, PdFPFMA], 9, [1, 27]>;
751 defm : PdWriteResYMMPair<WriteFSqrt64Y, [PdFPU1, PdFPFMA], 9, [2, 54]>;
752 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
754 defm : PdWriteResXMMPair<WriteFSqrt80, [PdFPU1, PdFPFMA], 1, [1, 35]>;
755 defm : PdWriteResXMMPair<WriteFSign, [PdFPU1, PdFPFMA]>;
757 defm : PdWriteResXMMPair<WriteFRnd, [PdFPU1, PdFPSTO], 4>;
758 defm : PdWriteResYMMPair<WriteFRndY, [PdFPU1, PdFPSTO], 4, [2, 1], 2>;
759 defm : X86WriteResPairUnsupported<WriteFRndZ>;
761 def PdWriteVFRCZ : SchedWriteRes<[PdFPU1, PdFPSTO]> {
765 def : InstRW<[PdWriteVFRCZ], (instrs VFRCZPDrr, VFRCZPSrr,
766 VFRCZSDrr, VFRCZSSrr)>;
768 def PdWriteVFRCZm : SchedWriteRes<[PdFPU1, PdFPSTO]> {
772 def : InstRW<[PdWriteVFRCZm], (instrs VFRCZPDrm, VFRCZPSrm,
773 VFRCZSDrm, VFRCZSSrm)>;
775 def PdWriteVFRCZY : SchedWriteRes<[PdFPU1, PdFPSTO]> {
777 let ResourceCycles = [2, 1];
780 def : InstRW<[PdWriteVFRCZY], (instrs VFRCZPSYrr, VFRCZPDYrr)>;
782 def PdWriteVFRCZYm : SchedWriteRes<[PdFPU1, PdFPSTO]> {
784 let ResourceCycles = [2, 1];
787 def : InstRW<[PdWriteVFRCZYm], (instrs VFRCZPSYrm, VFRCZPDYrm)>;
789 defm : PdWriteResXMMPair<WriteFLogic, [PdFPU01, PdFPFMA], 2>;
790 defm : PdWriteResYMMPair<WriteFLogicY, [PdFPU01, PdFPFMA], 2, [2, 2]>;
791 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
793 defm : PdWriteResXMMPair<WriteFTest, [PdFPU0, PdFPFMA, PdEX0], 1, [], 2>;
794 defm : PdWriteResYMMPair<WriteFTestY, [PdFPU01, PdFPFMA, PdEX0], 1, [2, 2, 1], 4, 2>;
795 defm : X86WriteResPairUnsupported<WriteFTestZ>;
797 defm : PdWriteResXMMPair<WriteFShuffle, [PdFPU01, PdFPFMA], 2>;
798 defm : PdWriteResYMMPair<WriteFShuffleY, [PdFPU01, PdFPFMA], 2, [2, 2], 2>;
799 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
801 def PdWriteVBROADCASTF128 : SchedWriteRes<[PdFPU01, PdFPFMA]> {
805 def : InstRW<[PdWriteVBROADCASTF128], (instrs VBROADCASTF128)>;
807 defm : PdWriteResXMMPair<WriteFVarShuffle, [PdFPU01, PdFPFMA], 3, [1, 4]>;
808 defm : PdWriteResYMMPair<WriteFVarShuffleY, [PdFPU01, PdFPFMA], 3, [2, 6], 2>;
809 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
811 defm : PdWriteResXMMPair<WriteFBlend, [PdFPU01, PdFPFMA], 2>;
812 defm : PdWriteResYMMPair<WriteFBlendY, [PdFPU01, PdFPFMA], 2, [2, 2], 2>;
813 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
815 defm : PdWriteResXMMPair<WriteFVarBlend, [PdFPU01, PdFPFMA], 2, [1, 4]>;
816 defm : PdWriteResYMMPair<WriteFVarBlendY, [PdFPU01, PdFPFMA], 2, [2, 6], 2>;
817 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
819 defm : PdWriteResXMMPair<WriteFShuffle256, [PdFPU01, PdFPFMA], 2, [], 2>;
820 defm : X86WriteResPairUnsupported<WriteFVarShuffle256>;
822 def PdWriteVEXTRACTF128rr : SchedWriteRes<[PdFPU01, PdFPFMA]> {
825 def : InstRW<[PdWriteVEXTRACTF128rr], (instrs VEXTRACTF128rr)>;
827 def PdWriteVEXTRACTF128mr : SchedWriteRes<[PdFPU01, PdFPFMA]> {
831 def : InstRW<[PdWriteVEXTRACTF128mr], (instrs VEXTRACTF128mr)>;
833 def PdWriteVPERM2F128rr : SchedWriteRes<[PdFPU01, PdFPFMA]> {
837 def : InstRW<[PdWriteVPERM2F128rr], (instrs VPERM2F128rr)>;
839 def PdWriteVPERM2F128rm : SchedWriteRes<[PdFPU01, PdFPFMA]> {
840 let Latency = 8; // 4 + 4
841 let NumMicroOps = 10;
843 def : InstRW<[PdWriteVPERM2F128rm], (instrs VPERM2F128rm)>;
845 ////////////////////////////////////////////////////////////////////////////////
847 ////////////////////////////////////////////////////////////////////////////////
849 defm : PdWriteResXMMPair<WriteCvtSS2I, [PdFPU1, PdFPSTO, PdFPFMA, PdEX0], 13, [], 2>;
851 defm : PdWriteResXMMPair<WriteCvtPS2I, [PdFPU1, PdFPSTO], 4>;
852 defm : PdWriteResYMMPair<WriteCvtPS2IY, [PdFPU1, PdFPSTO], 4, [2, 1]>;
853 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
855 defm : PdWriteResXMMPair<WriteCvtSD2I, [PdFPU1, PdFPSTO, PdFPFMA, PdEX0], 13, [], 2>;
857 defm : PdWriteResXMMPair<WriteCvtPD2I, [PdFPU1, PdFPSTO], 8, [], 2>;
858 defm : PdWriteResYMMPair<WriteCvtPD2IY, [PdFPU1, PdFPSTO, PdFPFMA], 8, [2, 1, 1], 4>;
859 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
861 def PdWriteMMX_CVTTPD2PIirr : SchedWriteRes<[PdFPU1, PdFPSTO]> {
865 def : InstRW<[PdWriteMMX_CVTTPD2PIirr], (instrs MMX_CVTTPD2PIirr)>;
867 // FIXME: f+3 ST, LD+STC latency
868 defm : PdWriteResXMMPair<WriteCvtI2SS, [PdFPU1, PdFPSTO], 4, [], 2>;
869 // FIXME: .Folded version is one NumMicroOp *less*..
871 defm : PdWriteResXMMPair<WriteCvtI2PS, [PdFPU1, PdFPSTO], 4>;
872 defm : PdWriteResYMMPair<WriteCvtI2PSY, [PdFPU1, PdFPSTO], 4, [2, 1]>;
873 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
875 defm : PdWriteResXMMPair<WriteCvtI2SD, [PdFPU1, PdFPSTO], 4, [], 2>;
876 // FIXME: .Folded version is one NumMicroOp *less*..
878 def WriteCVTSI642SDrr : SchedWriteRes<[PdFPU1, PdFPSTO]> {
882 def : InstRW<[WriteCVTSI642SDrr], (instrs CVTSI642SDrr, CVTSI642SSrr)>;
884 defm : PdWriteResXMMPair<WriteCvtI2PD, [PdFPU1, PdFPSTO], 8, [], 2>;
885 defm : PdWriteResYMMPair<WriteCvtI2PDY, [PdFPU1, PdFPSTO], 8, [2, 1], 4, 1>;
886 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
888 defm : PdWriteResXMMPair<WriteCvtSS2SD, [PdFPU1, PdFPSTO], 4>;
890 defm : PdWriteResXMMPair<WriteCvtPS2PD, [PdFPU1, PdFPSTO], 8, [], 2>;
891 defm : PdWriteResYMMPair<WriteCvtPS2PDY, [PdFPU1, PdFPSTO], 8, [2, 1], 4, 1>;
892 defm : X86WriteResPairUnsupported<WriteCvtPS2PDZ>;
894 defm : PdWriteResXMMPair<WriteCvtSD2SS, [PdFPU1, PdFPSTO], 4>;
896 defm : PdWriteResXMMPair<WriteCvtPD2PS, [PdFPU1, PdFPSTO], 8, [], 2>;
897 defm : PdWriteResYMMPair<WriteCvtPD2PSY, [PdFPU1, PdFPSTO, PdFPFMA], 8, [2, 1, 1], 4>;
898 defm : X86WriteResPairUnsupported<WriteCvtPD2PSZ>;
900 def WriteMMX_CVTPD2PIirrMMX_CVTPI2PDirr : SchedWriteRes<[PdFPU1, PdFPSTO]> {
904 def : InstRW<[WriteMMX_CVTPD2PIirrMMX_CVTPI2PDirr], (instrs MMX_CVTPD2PIirr,
907 def WriteMMX_CVTPI2PSirr : SchedWriteRes<[PdFPU1, PdFPSTO]> {
911 def : InstRW<[WriteMMX_CVTPI2PSirr], (instrs MMX_CVTPI2PSirr)>;
913 defm : PdWriteResXMMPair<WriteCvtPH2PS, [PdFPU1, PdFPSTO], 8, [], 2, 1>;
914 defm : PdWriteResYMMPair<WriteCvtPH2PSY, [PdFPU1, PdFPSTO], 8, [2, 1], 4, 3>;
915 defm : X86WriteResPairUnsupported<WriteCvtPH2PSZ>;
917 defm : PdWriteRes<WriteCvtPS2PH, [PdFPU1, PdFPSTO], 8, [], 2>;
918 defm : PdWriteRes<WriteCvtPS2PHY, [PdFPU1, PdFPSTO, PdFPFMA], 8, [2, 1, 1], 4>;
919 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
921 defm : PdWriteRes<WriteCvtPS2PHSt, [PdFPU1, PdFPSTO, PdStore], 4, [], 3>;
922 defm : PdWriteRes<WriteCvtPS2PHYSt, [PdFPU1, PdFPSTO, PdFPFMA, PdStore], 4, [2, 1, 1, 1], 4>;
923 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
925 ////////////////////////////////////////////////////////////////////////////////
926 // Vector integer operations.
927 ////////////////////////////////////////////////////////////////////////////////
929 defm : PdWriteRes<WriteVecLoad, [PdLoad, PdFPU01, PdFPMAL], 5>;
930 defm : PdWriteRes<WriteVecLoadX, [PdLoad, PdFPU01, PdFPMAL], 5>;
931 defm : PdWriteRes<WriteVecLoadY, [PdLoad, PdFPU01, PdFPMAL], 5, [], 2>;
933 defm : PdWriteRes<WriteVecLoadNT, [PdLoad, PdFPU01, PdFPMAL], 5>;
934 defm : PdWriteRes<WriteVecLoadNTY, [PdLoad, PdFPU01, PdFPMAL], 5>;
936 defm : PdWriteRes<WriteVecMaskedLoad, [PdLoad, PdFPU01, PdFPMAL], 6, [1, 1, 2]>;
937 defm : PdWriteRes<WriteVecMaskedLoadY, [PdLoad, PdFPU01, PdFPMAL], 6, [2, 2, 4], 2>;
939 defm : PdWriteRes<WriteVecStore, [PdStore, PdFPU1, PdFPSTO], 2>;
940 defm : PdWriteRes<WriteVecStoreX, [PdStore, PdFPU1, PdFPSTO]>;
941 defm : PdWriteRes<WriteVecStoreY, [PdStore, PdFPU1, PdFPSTO], 1, [], 4>;
943 def PdWriteVMOVDQUYmr : SchedWriteRes<[PdStore, PdFPU1, PdFPSTO]> {
946 def : InstRW<[PdWriteVMOVDQUYmr], (instrs VMOVDQUYmr)>;
948 defm : PdWriteRes<WriteVecStoreNT, [PdStore, PdFPU1, PdFPSTO], 2>;
949 defm : PdWriteRes<WriteVecStoreNTY, [PdStore, PdFPU1, PdFPSTO], 2, [2, 2, 2], 4>;
951 defm : PdWriteRes<WriteVecMaskedStore, [PdStore, PdFPU01, PdFPMAL], 6, [1, 1, 4]>;
952 defm : PdWriteRes<WriteVecMaskedStoreY, [PdStore, PdFPU01, PdFPMAL], 6, [2, 2, 4], 2>;
954 defm : PdWriteRes<WriteVecMove, [PdFPU01, PdFPMAL], 2>;
955 defm : PdWriteRes<WriteVecMoveX, [PdFPU01, PdFPMAL], 2>;
956 defm : PdWriteRes<WriteVecMoveY, [PdFPU01, PdFPMAL], 2, [2, 2], 2>;
958 defm : PdWriteRes<WriteVecMoveToGpr, [PdFPU0, PdFPFMA, PdEX0], 10>;
959 defm : PdWriteRes<WriteVecMoveFromGpr, [PdFPU01, PdFPFMA], 10, [], 2>;
961 defm : PdWriteResXMMPair<WriteVecALU, [PdFPU01, PdFPMAL], 2>;
962 defm : PdWriteResXMMPair<WriteVecALUX, [PdFPU01, PdFPMAL], 2>;
963 defm : X86WriteResPairUnsupported<WriteVecALUY>;
964 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
966 defm : PdWriteResXMMPair<WriteVecShift, [PdFPU01, PdFPMAL], 3>;
967 defm : PdWriteResXMMPair<WriteVecShiftX, [PdFPU01, PdFPMAL], 3>;
968 defm : X86WriteResPairUnsupported<WriteVecShiftY>;
969 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
971 defm : PdWriteResXMMPair<WriteVecShiftImm, [PdFPU01, PdFPMAL], 2>;
972 defm : PdWriteResXMMPair<WriteVecShiftImmX, [PdFPU01, PdFPMAL], 2>;
973 defm : X86WriteResPairUnsupported<WriteVecShiftImmY>;
974 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
976 defm : PdWriteResXMMPair<WriteVecIMul, [PdFPU0, PdFPMMA], 4>;
977 defm : PdWriteResXMMPair<WriteVecIMulX, [PdFPU0, PdFPMMA], 4>;
978 defm : X86WriteResPairUnsupported<WriteVecIMulY>;
979 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
981 defm : PdWriteResXMMPair<WritePMULLD, [PdFPU0, PdFPU01, PdFPMMA, PdFPMAL], 5, [2, 1, 2, 1]>;
982 defm : X86WriteResPairUnsupported<WritePMULLDY>;
983 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
985 def JWriteVPMACS : SchedWriteRes<[PdFPU0, PdFPU01, PdFPMMA, PdFPMAL]> {
987 let ResourceCycles = [2, 1, 2, 1];
989 def : InstRW<[JWriteVPMACS], (instrs VPMACSDQHrr, VPMACSDQLrr, VPMACSSDQHrr,
992 defm : PdWriteResXMMPair<WriteMPSAD, [PdFPU0, PdFPMMA], 9, [1, 2], 9>;
993 defm : X86WriteResPairUnsupported<WriteMPSADY>;
994 defm : X86WriteResPairUnsupported<WriteMPSADZ>;
996 defm : PdWriteResXMMPair<WritePSADBW, [PdFPU01, PdFPMAL], 4, [], 2>;
997 defm : PdWriteResXMMPair<WritePSADBWX, [PdFPU01, PdFPMAL], 4, [], 2>;
998 defm : X86WriteResPairUnsupported<WritePSADBWY>;
999 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
1001 defm : PdWriteResXMMPair<WritePHMINPOS, [PdFPU0, PdFPMAL], 4, [], 2>;
1003 defm : PdWriteResXMMPair<WriteShuffle, [PdFPU01, PdFPMAL], 2>;
1004 defm : PdWriteResXMMPair<WriteShuffleX, [PdFPU01, PdFPMAL], 2>;
1005 defm : PdWriteResYMMPair<WriteShuffleY, [PdFPU01, PdFPMAL], 2, [1, 1]>;
1006 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
1008 defm : PdWriteResXMMPair<WriteVarShuffle, [PdFPU01, PdFPMAL], 3, [1, 4]>;
1009 defm : PdWriteResXMMPair<WriteVarShuffleX, [PdFPU01, PdFPMAL], 3, [1, 4]>;
1010 defm : X86WriteResPairUnsupported<WriteVarShuffleY>;
1011 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
1013 defm : PdWriteResXMMPair<WriteBlend, [PdFPU01, PdFPMAL], 2>;
1014 defm : X86WriteResPairUnsupported<WriteBlendY>;
1015 defm : X86WriteResPairUnsupported<WriteBlendZ>;
1017 defm : PdWriteResXMMPair<WriteVarBlend, [PdFPU01, PdFPMAL], 2, [1, 4]>;
1018 defm : X86WriteResPairUnsupported<WriteVarBlendY>;
1019 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
1021 defm : PdWriteResXMMPair<WriteVecLogic, [PdFPU01, PdFPMAL], 2>;
1022 defm : PdWriteResXMMPair<WriteVecLogicX, [PdFPU01, PdFPMAL], 2>;
1023 defm : X86WriteResPairUnsupported<WriteVecLogicY>;
1024 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
1026 defm : PdWriteResXMMPair<WriteVecTest, [PdFPU0, PdFPFMA, PdEX0], 1, [], 2>;
1027 defm : PdWriteResYMMPair<WriteVecTestY, [PdFPU01, PdFPFMA, PdEX0], 1, [2, 2, 1], 4, 2>;
1028 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
1030 defm : PdWriteResXMMPair<WriteShuffle256, [PdFPU01, PdFPMAL]>;
1031 defm : PdWriteResXMMPair<WriteVarShuffle256, [PdFPU01, PdFPMAL]>;
1033 defm : PdWriteResXMMPair<WriteVarVecShift, [PdFPU01, PdFPMAL], 3>;
1034 defm : X86WriteResPairUnsupported<WriteVarVecShiftY>;
1035 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
1037 ////////////////////////////////////////////////////////////////////////////////
1038 // Vector insert/extract operations.
1039 ////////////////////////////////////////////////////////////////////////////////
1041 defm : PdWriteRes<WriteVecInsert, [PdFPU01, PdFPMAL], 2, [], 2>;
1042 defm : PdWriteRes<WriteVecInsertLd, [PdFPU01, PdFPMAL, PdLoad], 6, [], 2>;
1044 defm : PdWriteRes<WriteVecExtract, [PdFPU0, PdFPFMA, PdEX0], 13, [], 2>;
1045 defm : PdWriteRes<WriteVecExtractSt, [PdFPU1, PdFPSTO, PdStore], 13, [], 2>;
1047 def PdWriteEXTRQ : SchedWriteRes<[PdFPU01, PdFPMAL]> {
1050 def : InstRW<[PdWriteEXTRQ], (instrs EXTRQ, EXTRQI)>;
1052 ////////////////////////////////////////////////////////////////////////////////
1053 // SSE42 String instructions.
1054 ////////////////////////////////////////////////////////////////////////////////
1056 defm : PdWriteResXMMPair<WritePCmpIStrI, [PdFPU1, PdFPFMA, PdEX0], 14, [1, 2, 1], 7, 1>;
1057 defm : PdWriteResXMMPair<WritePCmpIStrM, [PdFPU1, PdFPFMA, PdEX0], 6, [1, 2, 1], 7, 2>;
1059 defm : PdWriteResXMMPair<WritePCmpEStrI, [PdFPU1, PdStore, PdLoad, PdFPMAL, PdFPFMA, PdEX0], 15, [1, 2, 6, 4, 1, 1], 27, 1>;
1060 defm : PdWriteResXMMPair<WritePCmpEStrM, [PdFPU1, PdStore, PdLoad, PdFPMAL, PdFPFMA, PdEX0], 10, [1, 2, 6, 4, 1, 1], 27, 1>;
1062 ////////////////////////////////////////////////////////////////////////////////
1063 // MOVMSK Instructions.
1064 ////////////////////////////////////////////////////////////////////////////////
1066 defm : PdWriteRes<WriteFMOVMSK, [PdFPU0, PdFPFMA, PdEX0], 10, [], 2>;
1068 defm : PdWriteRes<WriteVecMOVMSK, [PdFPU0, PdFPFMA, PdEX0], 13, [], 2>;
1069 defm : X86WriteResUnsupported<WriteVecMOVMSKY>;
1070 // defm : X86WriteResUnsupported<WriteVecMOVMSKZ>;
1072 defm : PdWriteRes<WriteMMXMOVMSK, [PdFPU0, PdFPFMA, PdEX0], 10, [], 2>;
1074 ////////////////////////////////////////////////////////////////////////////////
1075 // AES Instructions.
1076 ////////////////////////////////////////////////////////////////////////////////
1078 defm : PdWriteResXMMPair<WriteAESIMC, [PdFPU0, PdFPMMA], 5>;
1079 defm : PdWriteResXMMPair<WriteAESKeyGen, [PdFPU0, PdFPMMA], 5>;
1080 defm : PdWriteResXMMPair<WriteAESDecEnc, [PdFPU0, PdFPMMA], 9, [], 2>;
1082 ////////////////////////////////////////////////////////////////////////////////
1083 // Horizontal add/sub instructions.
1084 ////////////////////////////////////////////////////////////////////////////////
1086 defm : PdWriteResXMMPair<WriteFHAdd, [PdFPU0, PdFPFMA], 11, [], 3, 1>;
1087 defm : PdWriteResYMMPair<WriteFHAddY, [PdFPU0, PdFPFMA], 11, [2, 1], 8, 2>;
1088 defm : X86WriteResPairUnsupported<WriteFHAddZ>;
1090 defm : PdWriteResXMMPair<WritePHAdd, [PdFPU01, PdFPMAL], 5, [], 3, 1>;
1091 defm : PdWriteResXMMPair<WritePHAddX, [PdFPU01, PdFPMAL], 2>;
1092 defm : X86WriteResPairUnsupported<WritePHAddY>;
1093 defm : X86WriteResPairUnsupported<WritePHAddZ>;
1095 def : InstRW<[WritePHAdd], (instrs PHADDDrr, PHSUBDrr,
1097 PHADDSWrr, PHSUBSWrr,
1098 VPHADDDrr, VPHSUBDrr,
1099 VPHADDWrr, VPHSUBWrr,
1100 VPHADDSWrr, VPHSUBSWrr)>;
1102 def : InstRW<[WritePHAdd.Folded], (instrs PHADDDrm, PHSUBDrm,
1104 PHADDSWrm, PHSUBSWrm,
1105 VPHADDDrm, VPHSUBDrm,
1106 VPHADDWrm, VPHSUBWrm,
1107 VPHADDSWrm, VPHSUBSWrm)>;
1109 ////////////////////////////////////////////////////////////////////////////////
1110 // Carry-less multiplication instructions.
1111 ////////////////////////////////////////////////////////////////////////////////
1113 defm : PdWriteResXMMPair<WriteCLMul, [PdFPU0, PdFPMMA], 12, [], 5, 1>;
1115 def PdWriteVPCLMULQDQrr : SchedWriteRes<[PdFPU0, PdFPMMA]> {
1117 let NumMicroOps = 6;
1119 def : InstRW<[PdWriteVPCLMULQDQrr], (instrs VPCLMULQDQrr)>;
1121 ////////////////////////////////////////////////////////////////////////////////
1122 // SSE4A instructions.
1123 ////////////////////////////////////////////////////////////////////////////////
1125 def PdWriteINSERTQ : SchedWriteRes<[PdFPU01, PdFPMAL]> {
1127 let ResourceCycles = [1, 4];
1129 def : InstRW<[PdWriteINSERTQ], (instrs INSERTQ, INSERTQI)>;
1131 ////////////////////////////////////////////////////////////////////////////////
1132 // AVX instructions.
1133 ////////////////////////////////////////////////////////////////////////////////
1135 def PdWriteVBROADCASTYLd : SchedWriteRes<[PdLoad, PdFPU01, PdFPFMA]> {
1137 let ResourceCycles = [1, 2, 4];
1138 let NumMicroOps = 2;
1140 def : InstRW<[PdWriteVBROADCASTYLd, ReadAfterLd], (instrs VBROADCASTSDYrm,
1143 def PdWriteVZEROALL : SchedWriteRes<[]> {
1145 let NumMicroOps = 32;
1147 def : InstRW<[PdWriteVZEROALL], (instrs VZEROALL)>;
1149 def PdWriteVZEROUPPER : SchedWriteRes<[]> {
1151 let NumMicroOps = 16;
1153 def : InstRW<[PdWriteVZEROUPPER], (instrs VZEROUPPER)>;
1155 ///////////////////////////////////////////////////////////////////////////////
1156 // SchedWriteVariant definitions.
1157 ///////////////////////////////////////////////////////////////////////////////
1159 def PdWriteZeroLatency : SchedWriteRes<[]> {
1163 def PdWriteZeroIdiom : SchedWriteVariant<[
1164 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [PdWriteZeroLatency]>,
1165 SchedVar<MCSchedPredicate<TruePred>, [WriteALU]>
1167 def : InstRW<[PdWriteZeroIdiom], (instrs SUB32rr, SUB64rr,
1170 def PdWriteFZeroIdiom : SchedWriteVariant<[
1171 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [PdWriteZeroLatency]>,
1172 SchedVar<MCSchedPredicate<TruePred>, [WriteFLogic]>
1174 def : InstRW<[PdWriteFZeroIdiom], (instrs XORPSrr, VXORPSrr,
1176 ANDNPSrr, VANDNPSrr,
1177 ANDNPDrr, VANDNPDrr)>;
1179 // VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr "zero-idioms" have latency of 1.
1181 def PdWriteVZeroIdiomLogic : SchedWriteVariant<[
1182 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [PdWriteZeroLatency]>,
1183 SchedVar<MCSchedPredicate<TruePred>, [WriteVecLogic]>
1185 def : InstRW<[PdWriteVZeroIdiomLogic], (instrs MMX_PXORirr, MMX_PANDNirr)>;
1187 def PdWriteVZeroIdiomLogicX : SchedWriteVariant<[
1188 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [PdWriteZeroLatency]>,
1189 SchedVar<MCSchedPredicate<TruePred>, [WriteVecLogicX]>
1191 def : InstRW<[PdWriteVZeroIdiomLogicX], (instrs PXORrr, VPXORrr,
1192 PANDNrr, VPANDNrr)>;
1194 def PdWriteVZeroIdiomALU : SchedWriteVariant<[
1195 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [PdWriteZeroLatency]>,
1196 SchedVar<MCSchedPredicate<TruePred>, [WriteVecALU]>
1198 def : InstRW<[PdWriteVZeroIdiomALU], (instrs MMX_PSUBBirr, MMX_PSUBDirr,
1199 MMX_PSUBQirr, MMX_PSUBWirr,
1204 def PdWriteVZeroIdiomALUX : SchedWriteVariant<[
1205 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [PdWriteZeroLatency]>,
1206 SchedVar<MCSchedPredicate<TruePred>, [WriteVecALUX]>
1208 def : InstRW<[PdWriteVZeroIdiomALUX], (instrs PSUBBrr, VPSUBBrr,
1212 PCMPGTBrr, VPCMPGTBrr,
1213 PCMPGTDrr, VPCMPGTDrr,
1214 PCMPGTWrr, VPCMPGTWrr)>;
1216 ///////////////////////////////////////////////////////////////////////////////
1217 // Dependency breaking instructions.
1218 ///////////////////////////////////////////////////////////////////////////////
1220 // VPCMPGTQ, but not PCMPGTQ!
1222 def : IsZeroIdiomFunction<[
1224 DepBreakingClass<[ SUB32rr, SUB64rr, XOR32rr, XOR64rr ], ZeroIdiomPredicate>,
1228 MMX_PXORirr, MMX_PANDNirr, MMX_PSUBBirr,
1229 MMX_PSUBDirr, MMX_PSUBQirr, MMX_PSUBWirr,
1230 MMX_PSUBSBirr, MMX_PSUBSWirr, MMX_PSUBUSBirr, MMX_PSUBUSWirr,
1231 MMX_PCMPGTBirr, MMX_PCMPGTDirr, MMX_PCMPGTWirr
1232 ], ZeroIdiomPredicate>,
1237 XORPSrr, XORPDrr, ANDNPSrr, ANDNPDrr,
1241 PSUBBrr, PSUBWrr, PSUBDrr, PSUBQrr,
1242 PSUBSBrr, PSUBSWrr, PSUBUSBrr, PSUBUSWrr,
1243 PCMPGTBrr, PCMPGTDrr, PCMPGTWrr
1244 ], ZeroIdiomPredicate>,
1249 VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr,
1251 // xmm int variants.
1253 VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr,
1254 VPSUBSBrr, VPSUBSWrr, VPSUBUSBrr, VPSUBUSWrr,
1255 VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr,
1258 VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr
1259 ], ZeroIdiomPredicate>
1262 def : IsDepBreakingFunction<[
1264 DepBreakingClass<[ SBB32rr, SBB64rr ], ZeroIdiomPredicate>,
1265 DepBreakingClass<[ CMP32rr, CMP64rr ], CheckSameRegOperand<0, 1> >,
1269 MMX_PCMPEQBirr, MMX_PCMPEQDirr, MMX_PCMPEQWirr
1270 ], ZeroIdiomPredicate>,
1274 PCMPEQBrr, PCMPEQWrr, PCMPEQDrr
1275 // But not PCMPEQQrr.
1276 ], ZeroIdiomPredicate>,
1280 VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr
1281 // But not VPCMPEQQrr.
1282 ], ZeroIdiomPredicate>