//=- X86ScheduleZnver1.td - X86 Znver1 Scheduling -------------*- tablegen -*-=// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines the machine model for Znver1 to support instruction // scheduling and other instruction cost heuristics. // //===----------------------------------------------------------------------===// def Znver1Model : SchedMachineModel { // Zen can decode 4 instructions per cycle. let IssueWidth = 4; // Based on the reorder buffer we define MicroOpBufferSize let MicroOpBufferSize = 192; let LoadLatency = 4; let MispredictPenalty = 17; let HighLatency = 25; let PostRAScheduler = 1; // FIXME: This variable is required for incomplete model. // We haven't catered all instructions. // So, we reset the value of this variable so as to // say that the model is incomplete. let CompleteModel = 0; } let SchedModel = Znver1Model in { // Zen can issue micro-ops to 10 different units in one cycle. // These are // * Four integer ALU units (ZALU0, ZALU1, ZALU2, ZALU3) // * Two AGU units (ZAGU0, ZAGU1) // * Four FPU units (ZFPU0, ZFPU1, ZFPU2, ZFPU3) // AGUs feed load store queues @two loads and 1 store per cycle. // Four ALU units are defined below def ZnALU0 : ProcResource<1>; def ZnALU1 : ProcResource<1>; def ZnALU2 : ProcResource<1>; def ZnALU3 : ProcResource<1>; // Two AGU units are defined below def ZnAGU0 : ProcResource<1>; def ZnAGU1 : ProcResource<1>; // Four FPU units are defined below def ZnFPU0 : ProcResource<1>; def ZnFPU1 : ProcResource<1>; def ZnFPU2 : ProcResource<1>; def ZnFPU3 : ProcResource<1>; // FPU grouping def ZnFPU013 : ProcResGroup<[ZnFPU0, ZnFPU1, ZnFPU3]>; def ZnFPU01 : ProcResGroup<[ZnFPU0, ZnFPU1]>; def ZnFPU12 : ProcResGroup<[ZnFPU1, ZnFPU2]>; def ZnFPU13 : ProcResGroup<[ZnFPU1, ZnFPU3]>; def ZnFPU23 : ProcResGroup<[ZnFPU2, ZnFPU3]>; def ZnFPU02 : ProcResGroup<[ZnFPU0, ZnFPU2]>; def ZnFPU03 : ProcResGroup<[ZnFPU0, ZnFPU3]>; // Below are the grouping of the units. // Micro-ops to be issued to multiple units are tackled this way. // ALU grouping // ZnALU03 - 0,3 grouping def ZnALU03: ProcResGroup<[ZnALU0, ZnALU3]>; // 56 Entry (14x4 entries) Int Scheduler def ZnALU : ProcResGroup<[ZnALU0, ZnALU1, ZnALU2, ZnALU3]> { let BufferSize=56; } // 28 Entry (14x2) AGU group. AGUs can't be used for all ALU operations // but are relevant for some instructions def ZnAGU : ProcResGroup<[ZnAGU0, ZnAGU1]> { let BufferSize=28; } // Integer Multiplication issued on ALU1. def ZnMultiplier : ProcResource<1>; // Integer division issued on ALU2. def ZnDivider : ProcResource<1>; // 4 Cycles integer load-to use Latency is captured def : ReadAdvance; // 8 Cycles vector load-to use Latency is captured def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; // The Integer PRF for Zen is 168 entries, and it holds the architectural and // speculative version of the 64-bit integer registers. // Reference: "Software Optimization Guide for AMD Family 17h Processors" def ZnIntegerPRF : RegisterFile<168, [GR64, CCR]>; // 36 Entry (9x4 entries) floating-point Scheduler def ZnFPU : ProcResGroup<[ZnFPU0, ZnFPU1, ZnFPU2, ZnFPU3]> { let BufferSize=36; } // The Zen FP Retire Queue renames SIMD and FP uOps onto a pool of 160 128-bit // registers. Operations on 256-bit data types are cracked into two COPs. // Reference: "Software Optimization Guide for AMD Family 17h Processors" def ZnFpuPRF: RegisterFile<160, [VR64, VR128, VR256], [1, 1, 2]>; // The unit can track up to 192 macro ops in-flight. // The retire unit handles in-order commit of up to 8 macro ops per cycle. // Reference: "Software Optimization Guide for AMD Family 17h Processors" // To be noted, the retire unit is shared between integer and FP ops. // In SMT mode it is 96 entry per thread. But, we do not use the conservative // value here because there is currently no way to fully mode the SMT mode, // so there is no point in trying. def ZnRCU : RetireControlUnit<192, 8>; // FIXME: there are 72 read buffers and 44 write buffers. // (a folded load is an instruction that loads and does some operation) // Ex: ADDPD xmm,[mem]-> This instruction has two micro-ops // Instructions with folded loads are usually micro-fused, so they only appear // as two micro-ops. // a. load and // b. addpd // This multiclass is for folded loads for integer units. multiclass ZnWriteResPair ExePorts, int Lat, list Res = [], int UOps = 1, int LoadLat = 4, int LoadUOps = 1> { // Register variant takes 1-cycle on Execution Port. def : WriteRes { let Latency = Lat; let ResourceCycles = Res; let NumMicroOps = UOps; } // Memory variant also uses a cycle on ZnAGU // adds LoadLat cycles to the latency (default = 4). def : WriteRes { let Latency = !add(Lat, LoadLat); let ResourceCycles = !if(!empty(Res), [], !listconcat([1], Res)); let NumMicroOps = !add(UOps, LoadUOps); } } // This multiclass is for folded loads for floating point units. multiclass ZnWriteResFpuPair ExePorts, int Lat, list Res = [], int UOps = 1, int LoadLat = 7, int LoadUOps = 0> { // Register variant takes 1-cycle on Execution Port. def : WriteRes { let Latency = Lat; let ResourceCycles = Res; let NumMicroOps = UOps; } // Memory variant also uses a cycle on ZnAGU // adds LoadLat cycles to the latency (default = 7). def : WriteRes { let Latency = !add(Lat, LoadLat); let ResourceCycles = !if(!empty(Res), [], !listconcat([1], Res)); let NumMicroOps = !add(UOps, LoadUOps); } } // WriteRMW is set for instructions with Memory write // operation in codegen def : WriteRes; def : WriteRes; def : WriteRes; def : WriteRes; def : WriteRes { let Latency = 4; } // Model the effect of clobbering the read-write mask operand of the GATHER operation. // Does not cost anything by itself, only has latency, matching that of the WriteLoad, def : WriteRes { let Latency = 8; let NumMicroOps = 0; } def : WriteRes; def : WriteRes; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : X86WriteRes; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : ZnWriteResPair; defm : ZnWriteResFpuPair; defm : ZnWriteResPair; def : WriteRes; def : WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; // Bit counts. defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; // Treat misc copies as a move. def : InstRW<[WriteMove], (instrs COPY)>; // BMI1 BEXTR, BMI2 BZHI defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; // IDIV defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; defm : ZnWriteResPair; // IMULH def ZnWriteIMulH : WriteRes{ let Latency = 3; let NumMicroOps = 0; } def : WriteRes { let Latency = !add(ZnWriteIMulH.Latency, Znver1Model.LoadLatency); let NumMicroOps = ZnWriteIMulH.NumMicroOps; } // Floating point operations defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteResUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; // FIXME: Should folds require 1 extra uops? defm : ZnWriteResFpuPair; // FIXME: Should folds require 1 extra uops? defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; // Vector integer operations which uses FPU units defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteResUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : ZnWriteResFpuPair; // Vector insert/extract operations. defm : ZnWriteResFpuPair; def : WriteRes { let Latency = 2; let ResourceCycles = [1, 2]; } def : WriteRes { let Latency = 5; let NumMicroOps = 2; let ResourceCycles = [1, 2, 3]; } // MOVMSK Instructions. def : WriteRes; def : WriteRes; def : WriteRes; def : WriteRes { let NumMicroOps = 2; let Latency = 2; let ResourceCycles = [2]; } // AES Instructions. defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; def : WriteRes; def : WriteRes; // Microcoded Instructions def ZnWriteMicrocoded : SchedWriteRes<[]> { let Latency = 100; } def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; def : SchedAlias; //=== Regex based InstRW ===// // Notation: // - r: register. // - m = memory. // - i = immediate // - mm: 64 bit mmx register. // - x = 128 bit xmm register. // - (x)mm = mmx or xmm register. // - y = 256 bit ymm register. // - v = any vector register. //=== Integer Instructions ===// //-- Move instructions --// // MOV. // r16,m. def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>; // XCHG. // r,m. def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> { let Latency = 5; let NumMicroOps = 2; } def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>; def : InstRW<[WriteMicrocoded], (instrs XLAT)>; // POP16. // r. def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{ let Latency = 5; let NumMicroOps = 2; } def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>; def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>; def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>; // PUSH. // r. Has default values. // m. def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{ let Latency = 4; } def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>; // PUSHF def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>; // PUSHA. def ZnWritePushA : SchedWriteRes<[ZnAGU]> { let Latency = 8; } def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>; //LAHF def : InstRW<[WriteMicrocoded], (instrs LAHF)>; // MOVBE. // r,m. def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> { let Latency = 5; } def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>; // m16,r16. def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>; //-- Arithmetic instructions --// // ADD SUB. // m,r/i. def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)", "(ADD|SUB)(8|16|32|64)mi8", "(ADD|SUB)64mi32")>; // ADC SBB. // m,r/i. def : InstRW<[WriteALULd], (instregex "(ADC|SBB)(8|16|32|64)m(r|i)", "(ADC|SBB)(16|32|64)mi8", "(ADC|SBB)64mi32")>; // INC DEC NOT NEG. // m. def : InstRW<[WriteALULd], (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>; // MUL IMUL. // r16. def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { let Latency = 3; } def : SchedAlias; def : SchedAlias; // TODO: is this right? def : SchedAlias; // TODO: is this right? // m16. def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { let Latency = 8; } def : SchedAlias; def : SchedAlias; // TODO: this is definitely wrong but matches what the instregex did. def : SchedAlias; // TODO: this is definitely wrong but matches what the instregex did. // r32. def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { let Latency = 3; } def : SchedAlias; def : SchedAlias; // TODO: is this right? def : SchedAlias; // TODO: is this right? // m32. def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { let Latency = 8; } def : SchedAlias; def : SchedAlias; // TODO: this is definitely wrong but matches what the instregex did. def : SchedAlias; // TODO: this is definitely wrong but matches what the instregex did. // r64. def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { let Latency = 4; let NumMicroOps = 2; } def : SchedAlias; def : SchedAlias; // TODO: is this right? def : SchedAlias; // TODO: is this right? // m64. def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { let Latency = 9; let NumMicroOps = 2; } def : SchedAlias; def : SchedAlias; // TODO: this is definitely wrong but matches what the instregex did. def : SchedAlias; // TODO: this is definitely wrong but matches what the instregex did. // MULX // Numbers are based on the AMD SOG for Family 17h - Instruction Latencies. defm : ZnWriteResPair; defm : ZnWriteResPair; //-- Control transfer instructions --// // J(E|R)CXZ. def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>; def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>; // LOOP. def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>; def : InstRW<[ZnWriteLOOP], (instrs LOOP)>; // LOOP(N)E, LOOP(N)Z def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>; def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>; // CALL. // r. def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>; def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>; def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>; // RET. def ZnWriteRET : SchedWriteRes<[ZnALU03]> { let NumMicroOps = 2; } def : InstRW<[ZnWriteRET], (instregex "RET(16|32|64)", "LRET(16|32|64)", "IRET(16|32|64)")>; //-- Logic instructions --// // AND OR XOR. // m,r/i. def : InstRW<[WriteALULd], (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)", "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>; // Define ALU latency variants def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> { let Latency = 2; } def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> { let Latency = 6; } // BTR BTS BTC. // m,r,i. def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> { let Latency = 6; let NumMicroOps = 2; } // m,r,i. def : SchedAlias; def : SchedAlias; // PDEP PEXT. // r,r,r. def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>; // r,r,m. def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>; // RCR RCL. // m,i. def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>; // SHR SHL SAR. // m,i. def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>; // SHRD SHLD. // m,r def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>; // r,r,cl. def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>; // m,r,cl. def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>; //-- Misc instructions --// // CMPXCHG8B. def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> { let NumMicroOps = 18; } def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>; def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>; // LEAVE def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> { let Latency = 8; let NumMicroOps = 2; } def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>; // PAUSE. def : InstRW<[WriteMicrocoded], (instrs PAUSE)>; // XADD. def ZnXADD : SchedWriteRes<[ZnALU]>; def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>; def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>; //=== Floating Point x87 Instructions ===// //-- Move instructions --// def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ; def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> { let Latency = 5; let NumMicroOps = 2; } // LD_F. // r. def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>; // m. def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> { let NumMicroOps = 2; } def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>; // FST(P). // r. def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>; // m80. def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> { let Latency = 5; } def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>; def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>; // FXCHG. def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>; // FILD. def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> { let Latency = 11; let NumMicroOps = 2; } def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>; // FIST(P) FISTTP. def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> { let Latency = 12; } def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>; def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> { let Latency = 8; } def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> { let Latency = 11; } // FLDZ. def : SchedAlias; // FLD1. def : SchedAlias; // FLDPI FLDL2E etc. def : SchedAlias; // FNSTSW. // AX. def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>; // FLDCW. def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>; // FNSTCW. def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>; // FINCSTP FDECSTP. def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>; // FFREE. def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>; //-- Arithmetic instructions --// def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ; def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ; def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> { let Latency = 8; } // FCHS. def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>; // FCOM(P) FUCOM(P). // r. def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>; // m. def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>; // FCOMPP FUCOMPP. // r. def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>; def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]> { let Latency = 9; } // FCOMI(P) FUCOMI(P). // m. def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>; def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]> { let Latency = 12; let NumMicroOps = 2; let ResourceCycles = [1,3]; } // FICOM(P). def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>; // FTST. def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>; // FXAM. def : InstRW<[ZnWriteFPU3Lat1], (instrs XAM_F)>; // FNOP. def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>; // WAIT. def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>; //=== Integer MMX and XMM Instructions ===// def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ; def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> { let Latency = 8; let NumMicroOps = 2; } def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ; def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> { let NumMicroOps = 2; } // VPBLENDD. // v,v,v,i. def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>; // ymm def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>; // v,v,m,i def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> { let NumMicroOps = 2; let Latency = 8; let ResourceCycles = [1, 2]; } def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> { let NumMicroOps = 2; let Latency = 9; let ResourceCycles = [1, 3]; } def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>; def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>; // MASKMOVQ. def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>; // MASKMOVDQU. def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>; // VPMASKMOVD. // ymm def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOVD(Y?)rm")>; // m, v,v. def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>; // VPBROADCAST B/W. // x, m8/16. def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { let Latency = 8; let NumMicroOps = 2; let ResourceCycles = [1, 2]; } def : InstRW<[ZnWriteVPBROADCAST128Ld], (instregex "VPBROADCAST(B|W)rm")>; // y, m8/16 def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { let Latency = 8; let NumMicroOps = 2; let ResourceCycles = [1, 2]; } def : InstRW<[ZnWriteVPBROADCAST256Ld], (instregex "VPBROADCAST(B|W)Yrm")>; // VPGATHER. def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>; //-- Arithmetic instructions --// // HADD, HSUB PS/PD // PHADD|PHSUB (S) W/D. defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; defm : ZnWriteResFpuPair; // PCMPGTQ. def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>; def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>; // x <- x,m. def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> { let Latency = 8; } // ymm. def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> { let Latency = 8; let NumMicroOps = 2; let ResourceCycles = [1,2]; } def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>; def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>; //=== Floating Point XMM and YMM Instructions ===// //-- Move instructions --// // VPERM2F128 / VPERM2I128. def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr, VPERM2I128rr)>; def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm, VPERM2I128rm)>; def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> { let NumMicroOps = 2; let Latency = 8; } // VBROADCASTF128 / VBROADCASTI128. def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128, VBROADCASTI128)>; // EXTRACTPS. // r32,x,i. def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> { let Latency = 2; let NumMicroOps = 2; let ResourceCycles = [1, 2]; } def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>; def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> { let Latency = 5; let NumMicroOps = 2; let ResourceCycles = [5, 1, 2]; } // m32,x,i. def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>; // VEXTRACTF128 / VEXTRACTI128. // x,y,i. def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rr, VEXTRACTI128rr)>; // m128,y,i. def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mr, VEXTRACTI128mr)>; def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> { let Latency = 2; let ResourceCycles = [2]; } def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> { let Latency = 9; let NumMicroOps = 2; let ResourceCycles = [1, 2]; } // VINSERTF128 / VINSERTI128. // y,y,x,i. def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rr, VINSERTI128rr)>; def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rm, VINSERTI128rm)>; // VGATHER. def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>; //-- Conversion instructions --// def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> { let Latency = 4; } def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> { let Latency = 5; let NumMicroOps = 2; let ResourceCycles = [2]; } // CVTPD2PS. // x,x. def : SchedAlias; // y,y. def : SchedAlias; // z,z. defm : X86WriteResUnsupported; def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU3]> { let Latency = 11; } // x,m128. def : SchedAlias; // x,m256. def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { let Latency = 11; let NumMicroOps = 2; let ResourceCycles = [1,2]; } def : SchedAlias; // z,m512 defm : X86WriteResUnsupported; // CVTSD2SS. // x,x. // Same as WriteCVTPD2PSr def : SchedAlias; // x,m64. def : SchedAlias; // CVTPS2PD. // x,x. def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> { let Latency = 3; } def : SchedAlias; // x,m64. // y,m128. def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { let Latency = 10; let NumMicroOps = 2; } def : SchedAlias; def : SchedAlias; defm : X86WriteResUnsupported; // y,x. def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> { let Latency = 3; } def : SchedAlias; defm : X86WriteResUnsupported; // CVTSS2SD. // x,x. def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> { let Latency = 4; } def : SchedAlias; // x,m32. def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { let Latency = 11; let NumMicroOps = 2; let ResourceCycles = [1, 2]; } def : SchedAlias; def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> { let Latency = 5; } // CVTDQ2PD. // x,x. def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>; // Same as xmm // y,x. def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>; def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> { let Latency = 5; } // CVT(T)PD2DQ. // x,x. def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)PD2DQrr")>; def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> { let Latency = 12; let NumMicroOps = 2; } // x,m128. def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>; // same as xmm handling // x,y. def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>; // x,m256. def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>; def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> { let Latency = 4; } // CVT(T)PS2PI. // mm,x. def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIrr")>; // CVTPI2PD. // x,mm. def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDrr)>; // CVT(T)PD2PI. // mm,x. def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIrr")>; def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> { let Latency = 5; } // same as CVTPD2DQr // CVT(T)SS2SI. // r32,x. def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>; // same as CVTPD2DQm // r32,m32. def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>; def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> { let Latency = 5; } // CVTSI2SD. // x,r32/64. def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>; def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> { let Latency = 5; } def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> { let Latency = 12; } // CVTSD2SI. // r32/64 def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>; // r32,m32. def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>; // VCVTPS2PH. // x,v,i. def : SchedAlias; def : SchedAlias; defm : X86WriteResUnsupported; // m,v,i. def : SchedAlias; def : SchedAlias; defm : X86WriteResUnsupported; // VCVTPH2PS. // v,x. def : SchedAlias; def : SchedAlias; defm : X86WriteResUnsupported; // v,m. def : SchedAlias; def : SchedAlias; defm : X86WriteResUnsupported; //-- SSE4A instructions --// // EXTRQ def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> { let Latency = 2; } def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>; // INSERTQ def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> { let Latency = 4; } def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>; //-- SHA instructions --// // SHA256MSG2 def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>; // SHA1MSG1, SHA256MSG1 // x,x. def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> { let Latency = 2; let ResourceCycles = [2]; } def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>; // x,m. def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { let Latency = 9; let ResourceCycles = [1,2]; } def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>; // SHA1MSG2 // x,x. def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ; def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>; // x,m. def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { let Latency = 8; } def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>; // SHA1NEXTE // x,x. def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ; def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>; // x,m. def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> { let Latency = 8; } def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>; // SHA1RNDS4 // x,x. def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> { let Latency = 6; } def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>; // x,m. def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { let Latency = 13; } def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>; // SHA256RNDS2 // x,x. def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> { let Latency = 4; } def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>; // x,m. def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { let Latency = 11; } def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>; //-- Arithmetic instructions --// // DPPS. // x,x,i / v,v,v,i. def : SchedAlias; def : SchedAlias; // x,m,i / v,v,m,i. def : SchedAlias; def : SchedAlias; // DPPD. // x,x,i. def : SchedAlias; // x,m,i. def : SchedAlias; //-- Other instructions --// // VZEROUPPER. def : InstRW<[WriteMicrocoded], (instrs VZEROUPPER)>; // VZEROALL. def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>; /////////////////////////////////////////////////////////////////////////////// // Dependency breaking instructions. /////////////////////////////////////////////////////////////////////////////// def : IsZeroIdiomFunction<[ // GPR Zero-idioms. DepBreakingClass<[ SUB32rr, SUB64rr, XOR32rr, XOR64rr ], ZeroIdiomPredicate>, // MMX Zero-idioms. DepBreakingClass<[ MMX_PXORrr, MMX_PANDNrr, MMX_PSUBBrr, MMX_PSUBDrr, MMX_PSUBQrr, MMX_PSUBWrr, MMX_PSUBSBrr, MMX_PSUBSWrr, MMX_PSUBUSBrr, MMX_PSUBUSWrr, MMX_PCMPGTBrr, MMX_PCMPGTDrr, MMX_PCMPGTWrr ], ZeroIdiomPredicate>, // SSE Zero-idioms. DepBreakingClass<[ // fp variants. XORPSrr, XORPDrr, ANDNPSrr, ANDNPDrr, // int variants. PXORrr, PANDNrr, PSUBBrr, PSUBWrr, PSUBDrr, PSUBQrr, PCMPGTBrr, PCMPGTDrr, PCMPGTQrr, PCMPGTWrr ], ZeroIdiomPredicate>, // AVX XMM Zero-idioms. DepBreakingClass<[ // fp variants. VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr, // int variants. VPXORrr, VPANDNrr, VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr, VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr ], ZeroIdiomPredicate>, // AVX YMM Zero-idioms. DepBreakingClass<[ // fp variants VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr, // int variants VPXORYrr, VPANDNYrr, VPSUBBYrr, VPSUBWYrr, VPSUBDYrr, VPSUBQYrr, VPCMPGTBYrr, VPCMPGTWYrr, VPCMPGTDYrr, VPCMPGTQYrr ], ZeroIdiomPredicate> ]>; def : IsDepBreakingFunction<[ // GPR DepBreakingClass<[ SBB32rr, SBB64rr ], ZeroIdiomPredicate>, DepBreakingClass<[ CMP32rr, CMP64rr ], CheckSameRegOperand<0, 1> >, // MMX DepBreakingClass<[ MMX_PCMPEQBrr, MMX_PCMPEQWrr, MMX_PCMPEQDrr ], ZeroIdiomPredicate>, // SSE DepBreakingClass<[ PCMPEQBrr, PCMPEQWrr, PCMPEQDrr, PCMPEQQrr ], ZeroIdiomPredicate>, // AVX XMM DepBreakingClass<[ VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr, VPCMPEQQrr ], ZeroIdiomPredicate>, // AVX YMM DepBreakingClass<[ VPCMPEQBYrr, VPCMPEQWYrr, VPCMPEQDYrr, VPCMPEQQYrr ], ZeroIdiomPredicate>, ]>; } // SchedModel