//=- X86ScheduleZnver3.td - X86 Znver3 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 Znver3 to support instruction // scheduling and other instruction cost heuristics. // Based on: // * AMD Software Optimization Guide for AMD Family 19h Processors. // https://www.amd.com/system/files/TechDocs/56665.zip // * The microarchitecture of Intel, AMD and VIA CPUs, By Agner Fog // http://www.agner.org/optimize/microarchitecture.pdf // * AMD Zen 3 Ryzen Deep Dive Review // https://www.anandtech.com/show/16214/ //===----------------------------------------------------------------------===// def Znver3Model : SchedMachineModel { // AMD SOG 19h, 2.9.6 Dispatch // The processor may dispatch up to 6 macro ops per cycle // into the execution engine. let IssueWidth = 6; // AMD SOG 19h, 2.10.3 // The retire control unit (RCU) tracks the completion status of all // outstanding operations (integer, load/store, and floating-point) and is // the final arbiter for exception processing and recovery. // The unit can receive up to 6 macro ops dispatched per cycle and track up // to 256 macro ops in-flight in non-SMT mode or 128 per thread in SMT mode. let MicroOpBufferSize = 256; // AMD SOG 19h, 2.9.1 Op Cache // The op cache is organized as an associative cache with 64 sets and 8 ways. // At each set-way intersection is an entry containing up to 8 macro ops. // The maximum capacity of the op cache is 4K ops. // Agner, 22.5 µop cache // The size of the µop cache is big enough for holding most critical loops. let LoopMicroOpBufferSize = 4096; // AMD SOG 19h, 2.6.2 L1 Data Cache // The L1 data cache has a 4- or 5- cycle integer load-to-use latency. // AMD SOG 19h, 2.12 L1 Data Cache // The AGU and LS pipelines are optimized for simple address generation modes. // <...> and can achieve 4-cycle load-to-use integer load latency. let LoadLatency = 4; // AMD SOG 19h, 2.12 L1 Data Cache // The AGU and LS pipelines are optimized for simple address generation modes. // <...> and can achieve <...> 7-cycle load-to-use FP load latency. int VecLoadLatency = 7; // Latency of a simple store operation. int StoreLatency = 1; // FIXME let HighLatency = 25; // FIXME: any better choice? // AMD SOG 19h, 2.8 Optimizing Branching // The branch misprediction penalty is in the range from 11 to 18 cycles, // <...>. The common case penalty is 13 cycles. let MispredictPenalty = 13; let PostRAScheduler = 1; // Enable Post RegAlloc Scheduler pass. let CompleteModel = 1; } let SchedModel = Znver3Model in { //===----------------------------------------------------------------------===// // RCU //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.10.3 Retire Control Unit // The unit can receive up to 6 macro ops dispatched per cycle and track up to // 256 macro ops in-flight in non-SMT mode or 128 per thread in SMT mode. <...> // The retire unit handles in-order commit of up to eight macro ops per cycle. def Zn3RCU : RetireControlUnit; //===----------------------------------------------------------------------===// // Units //===----------------------------------------------------------------------===// // There are total of three Units, each one with it's own schedulers. //===----------------------------------------------------------------------===// // Integer Execution Unit // // AMD SOG 19h, 2.4 Superscalar Organization // The processor uses four decoupled independent integer scheduler queues, // each one servicing one ALU pipeline and one or two other pipelines // // Execution pipes //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.10.2 Execution Units // The processor contains 4 general purpose integer execution pipes. // Each pipe has an ALU capable of general purpose integer operations. def Zn3ALU0 : ProcResource<1>; def Zn3ALU1 : ProcResource<1>; def Zn3ALU2 : ProcResource<1>; def Zn3ALU3 : ProcResource<1>; // AMD SOG 19h, 2.10.2 Execution Units // There is also a separate branch execution unit. def Zn3BRU1 : ProcResource<1>; // AMD SOG 19h, 2.10.2 Execution Units // There are three Address Generation Units (AGUs) for all load and store // address generation. There are also 3 store data movement units // associated with the same schedulers as the AGUs. def Zn3AGU0 : ProcResource<1>; def Zn3AGU1 : ProcResource<1>; def Zn3AGU2 : ProcResource<1>; // // Execution Units //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.10.2 Execution Units // ALU0 additionally has divide <...> execution capability. defvar Zn3Divider = Zn3ALU0; // AMD SOG 19h, 2.10.2 Execution Units // ALU0 additionally has <...> branch execution capability. defvar Zn3BRU0 = Zn3ALU0; // Integer Multiplication issued on ALU1. defvar Zn3Multiplier = Zn3ALU1; // Execution pipeline grouping //===----------------------------------------------------------------------===// // General ALU operations def Zn3ALU0123 : ProcResGroup<[Zn3ALU0, Zn3ALU1, Zn3ALU2, Zn3ALU3]>; // General AGU operations def Zn3AGU012 : ProcResGroup<[Zn3AGU0, Zn3AGU1, Zn3AGU2]>; // Control flow: jumps, calls def Zn3BRU01 : ProcResGroup<[Zn3BRU0, Zn3BRU1]>; // Everything that isn't control flow, but still needs to access CC register, // namely: conditional moves, SETcc. def Zn3ALU03 : ProcResGroup<[Zn3ALU0, Zn3ALU3]>; // Zn3ALU1 handles complex bit twiddling: CRC/PDEP/PEXT // Simple bit twiddling: bit test, shift/rotate, bit extraction def Zn3ALU12 : ProcResGroup<[Zn3ALU1, Zn3ALU2]>; // // Scheduling //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.10.3 Retire Control Unit // The integer physical register file (PRF) consists of 192 registers. def Zn3IntegerPRF : RegisterFile<192, [GR64, CCR], [1, 1], [1, 0], 6, // Max moves that can be eliminated per cycle. 0>; // Restrict move elimination to zero regs. // anandtech, The integer scheduler has a 4*24 entry macro op capacity. // AMD SOG 19h, 2.10.1 Schedulers // The schedulers can receive up to six macro ops per cycle, with a limit of // two per scheduler. Each scheduler can issue one micro op per cycle into // each of its associated pipelines // FIXME: these are 4 separate schedulers, not a single big one. def Zn3Int : ProcResGroup<[Zn3ALU0, Zn3AGU0, Zn3BRU0, // scheduler 0 Zn3ALU1, Zn3AGU1, // scheduler 1 Zn3ALU2, Zn3AGU2, // scheduler 2 Zn3ALU3, Zn3BRU1 // scheduler 3 ]> { let BufferSize = !mul(4, 24); } //===----------------------------------------------------------------------===// // Floating-Point Unit // // AMD SOG 19h, 2.4 Superscalar Organization // The processor uses <...> two decoupled independent floating point schedulers // each servicing two FP pipelines and one store or FP-to-integer pipeline. // // Execution pipes //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.10.1 Schedulers // <...>, and six FPU pipes. // Agner, 22.10 Floating point execution pipes // There are six floating point/vector execution pipes, def Zn3FPP0 : ProcResource<1>; def Zn3FPP1 : ProcResource<1>; def Zn3FPP2 : ProcResource<1>; def Zn3FPP3 : ProcResource<1>; def Zn3FPP45 : ProcResource<2>; // // Execution Units //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.11.1 Floating Point Execution Resources // (v)FMUL*, (v)FMA*, Floating Point Compares, Blendv(DQ) defvar Zn3FPFMul0 = Zn3FPP0; defvar Zn3FPFMul1 = Zn3FPP1; // (v)FADD* defvar Zn3FPFAdd0 = Zn3FPP2; defvar Zn3FPFAdd1 = Zn3FPP3; // All convert operations except pack/unpack defvar Zn3FPFCvt0 = Zn3FPP2; defvar Zn3FPFCvt1 = Zn3FPP3; // All Divide and Square Root except Reciprocal Approximation // AMD SOG 19h, 2.11.1 Floating Point Execution Resources // FDIV unit can support 2 simultaneous operations in flight // even though it occupies a single pipe. // FIXME: BufferSize=2 ? defvar Zn3FPFDiv = Zn3FPP1; // Moves and Logical operations on Floating Point Data Types defvar Zn3FPFMisc0 = Zn3FPP0; defvar Zn3FPFMisc1 = Zn3FPP1; defvar Zn3FPFMisc2 = Zn3FPP2; defvar Zn3FPFMisc3 = Zn3FPP3; // Integer Adds, Subtracts, and Compares // Some complex VADD operations are not available in all pipes. defvar Zn3FPVAdd0 = Zn3FPP0; defvar Zn3FPVAdd1 = Zn3FPP1; defvar Zn3FPVAdd2 = Zn3FPP2; defvar Zn3FPVAdd3 = Zn3FPP3; // Integer Multiplies, SAD, Blendvb defvar Zn3FPVMul0 = Zn3FPP0; defvar Zn3FPVMul1 = Zn3FPP3; // Data Shuffles, Packs, Unpacks, Permute // Some complex shuffle operations are only available in pipe1. defvar Zn3FPVShuf = Zn3FPP1; defvar Zn3FPVShufAux = Zn3FPP2; // Bit Shift Left/Right operations defvar Zn3FPVShift0 = Zn3FPP1; defvar Zn3FPVShift1 = Zn3FPP2; // Moves and Logical operations on Packed Integer Data Types defvar Zn3FPVMisc0 = Zn3FPP0; defvar Zn3FPVMisc1 = Zn3FPP1; defvar Zn3FPVMisc2 = Zn3FPP2; defvar Zn3FPVMisc3 = Zn3FPP3; // *AES* defvar Zn3FPAES0 = Zn3FPP0; defvar Zn3FPAES1 = Zn3FPP1; // *CLM* defvar Zn3FPCLM0 = Zn3FPP0; defvar Zn3FPCLM1 = Zn3FPP1; // Execution pipeline grouping //===----------------------------------------------------------------------===// // AMD SOG 19h, 2.11 Floating-Point Unit // Stores and floating point to general purpose register transfer // have 2 dedicated pipelines (pipe 5 and 6). def Zn3FPU0123 : ProcResGroup<[Zn3FPP0, Zn3FPP1, Zn3FPP2, Zn3FPP3]>; // (v)FMUL*, (v)FMA*, Floating Point Compares, Blendv(DQ) def Zn3FPFMul01 : ProcResGroup<[Zn3FPFMul0, Zn3FPFMul1]>; // (v)FADD* // Some complex VADD operations are not available in all pipes. def Zn3FPFAdd01 : ProcResGroup<[Zn3FPFAdd0, Zn3FPFAdd1]>; // All convert operations except pack/unpack def Zn3FPFCvt01 : ProcResGroup<[Zn3FPFCvt0, Zn3FPFCvt1]>; // All Divide and Square Root except Reciprocal Approximation // def Zn3FPFDiv : ProcResGroup<[Zn3FPFDiv]>; // Moves and Logical operations on Floating Point Data Types def Zn3FPFMisc0123 : ProcResGroup<[Zn3FPFMisc0, Zn3FPFMisc1, Zn3FPFMisc2, Zn3FPFMisc3]>; def Zn3FPFMisc12 : ProcResGroup<[Zn3FPFMisc1, Zn3FPFMisc2]>; // Loads, Stores and Move to General Register (EX) Operations // AMD SOG 19h, 2.11 Floating-Point Unit // Stores and floating point to general purpose register transfer // have 2 dedicated pipelines (pipe 5 and 6). defvar Zn3FPLd01 = Zn3FPP45; // AMD SOG 19h, 2.11 Floating-Point Unit // Note that FP stores are supported on two pipelines, // but throughput is limited to one per cycle. let Super = Zn3FPP45 in def Zn3FPSt : ProcResource<1>; // Integer Adds, Subtracts, and Compares // Some complex VADD operations are not available in all pipes. def Zn3FPVAdd0123 : ProcResGroup<[Zn3FPVAdd0, Zn3FPVAdd1, Zn3FPVAdd2, Zn3FPVAdd3]>; def Zn3FPVAdd01: ProcResGroup<[Zn3FPVAdd0, Zn3FPVAdd1]>; def Zn3FPVAdd12: ProcResGroup<[Zn3FPVAdd1, Zn3FPVAdd2]>; // Integer Multiplies, SAD, Blendvb def Zn3FPVMul01 : ProcResGroup<[Zn3FPVMul0, Zn3FPVMul1]>; // Data Shuffles, Packs, Unpacks, Permute // Some complex shuffle operations are only available in pipe1. def Zn3FPVShuf01 : ProcResGroup<[Zn3FPVShuf, Zn3FPVShufAux]>; // Bit Shift Left/Right operations def Zn3FPVShift01 : ProcResGroup<[Zn3FPVShift0, Zn3FPVShift1]>; // Moves and Logical operations on Packed Integer Data Types def Zn3FPVMisc0123 : ProcResGroup<[Zn3FPVMisc0, Zn3FPVMisc1, Zn3FPVMisc2, Zn3FPVMisc3]>; // *AES* def Zn3FPAES01 : ProcResGroup<[Zn3FPAES0, Zn3FPAES1]>; // *CLM* def Zn3FPCLM01 : ProcResGroup<[Zn3FPCLM0, Zn3FPCLM1]>; // // Scheduling //===----------------------------------------------------------------------===// // Agner, 21.8 Register renaming and out-of-order schedulers // The floating point register file has 160 vector registers // of 128 bits each in Zen 1 and 256 bits each in Zen 2. // anandtech also confirms this. def Zn3FpPRF : RegisterFile<160, [VR64, VR128, VR256], [1, 1, 1], [0, 1, 1], 6, // Max moves that can be eliminated per cycle. 0>; // Restrict move elimination to zero regs. // AMD SOG 19h, 2.11 Floating-Point Unit // The floating-point scheduler has a 2*32 entry macro op capacity. // AMD SOG 19h, 2.11 Floating-Point Unit // <...> the scheduler can issue 1 micro op per cycle for each pipe. // FIXME: those are two separate schedulers, not a single big one. def Zn3FP : ProcResGroup<[Zn3FPP0, Zn3FPP2, /*Zn3FPP4,*/ // scheduler 0 Zn3FPP1, Zn3FPP3, Zn3FPP45 /*Zn3FPP5*/ // scheduler 1 ]> { let BufferSize = !mul(2, 32); } // AMD SOG 19h, 2.11 Floating-Point Unit // Macro ops can be dispatched to the 64 entry Non Scheduling Queue (NSQ) // even if floating-point scheduler is full. // FIXME: how to model this properly? //===----------------------------------------------------------------------===// // Load-Store Unit // // AMD SOG 19h, 2.12 Load-Store Unit // The LS unit contains three largely independent pipe-lines // enabling the execution of three 256-bit memory operations per cycle. def Zn3LSU : ProcResource<3>; // AMD SOG 19h, 2.12 Load-Store Unit // All three memory operations can be loads. let Super = Zn3LSU in def Zn3Load : ProcResource<3> { // AMD SOG 19h, 2.12 Load-Store Unit // The LS unit can process up to 72 out-of-order loads. let BufferSize = 72; } def Zn3LoadQueue : LoadQueue; // AMD SOG 19h, 2.12 Load-Store Unit // A maximum of two of the memory operations can be stores. let Super = Zn3LSU in def Zn3Store : ProcResource<2> { // AMD SOG 19h, 2.12 Load-Store Unit // The LS unit utilizes a 64-entry store queue (STQ). let BufferSize = 64; } def Zn3StoreQueue : StoreQueue; //===----------------------------------------------------------------------===// // Basic helper classes. //===----------------------------------------------------------------------===// // Many SchedWrites are defined in pairs with and without a folded load. // Instructions with folded loads are usually micro-fused, so they only appear // as two micro-ops when dispatched by the schedulers. // This multiclass defines the resource usage for variants with and without // folded loads. multiclass __zn3WriteRes ExePorts, int Lat = 1, list Res = [], int UOps = 1> { def : WriteRes { let Latency = Lat; let ResourceCycles = Res; let NumMicroOps = UOps; } } multiclass __zn3WriteResPair ExePorts, int Lat, list Res, int UOps, int LoadLat, int LoadUOps, ProcResourceKind AGU, int LoadRes> { defm : __zn3WriteRes; defm : __zn3WriteRes; } // For classes without folded loads. multiclass Zn3WriteResInt ExePorts, int Lat = 1, list Res = [], int UOps = 1> { defm : __zn3WriteRes; } multiclass Zn3WriteResXMM ExePorts, int Lat = 1, list Res = [], int UOps = 1> { defm : __zn3WriteRes; } multiclass Zn3WriteResYMM ExePorts, int Lat = 1, list Res = [], int UOps = 1> { defm : __zn3WriteRes; } // For classes with folded loads. multiclass Zn3WriteResIntPair ExePorts, int Lat = 1, list Res = [], int UOps = 1, int LoadUOps = 0, int LoadRes = 1> { defm : __zn3WriteResPair; } multiclass Zn3WriteResXMMPair ExePorts, int Lat = 1, list Res = [], int UOps = 1, int LoadUOps = 0, int LoadRes = 1> { defm : __zn3WriteResPair; } multiclass Zn3WriteResYMMPair ExePorts, int Lat = 1, list Res = [], int UOps = 1, int LoadUOps = 0, int LoadRes = 1> { defm : __zn3WriteResPair; } //===----------------------------------------------------------------------===// // Here be dragons. //===----------------------------------------------------------------------===// def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; // AMD SOG 19h, 2.11 Floating-Point Unit // There is 1 cycle of added latency for a result to cross // from F to I or I to F domain. def : ReadAdvance; // Instructions with both a load and a store folded are modeled as a folded // load + WriteRMW. defm : Zn3WriteResInt; // Loads, stores, and moves, not folded with other operations. defm : Zn3WriteResInt; def Zn3WriteMOVSlow : SchedWriteRes<[Zn3AGU012, Zn3Load]> { let Latency = !add(Znver3Model.LoadLatency, 1); let ResourceCycles = [3, 1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteMOVSlow], (instrs MOV8rm, MOV8rm_NOREX, MOV16rm, MOVSX16rm16, MOVSX16rm32, MOVZX16rm16, MOVSX16rm8, MOVZX16rm8)>; defm : Zn3WriteResInt; defm : Zn3WriteResInt; defm : Zn3WriteResInt; // Treat misc copies as a move. def : InstRW<[WriteMove], (instrs COPY)>; def Zn3WriteMOVBE16rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU0123]> { let Latency = Znver3Model.LoadLatency; let ResourceCycles = [1, 1, 4]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteMOVBE16rm], (instrs MOVBE16rm)>; def Zn3WriteMOVBEmr : SchedWriteRes<[Zn3ALU0123, Zn3AGU012, Zn3Store]> { let Latency = Znver3Model.StoreLatency; let ResourceCycles = [4, 1, 1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteMOVBEmr], (instrs MOVBE16mr, MOVBE32mr, MOVBE64mr)>; // Arithmetic. defm : Zn3WriteResIntPair; // Simple integer ALU op. def Zn3WriteALUSlow : SchedWriteRes<[Zn3ALU0123]> { let Latency = 1; let ResourceCycles = [4]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteALUSlow], (instrs ADD8i8, ADD16i16, ADD32i32, ADD64i32, AND8i8, AND16i16, AND32i32, AND64i32, OR8i8, OR16i16, OR32i32, OR64i32, SUB8i8, SUB16i16, SUB32i32, SUB64i32, XOR8i8, XOR16i16, XOR32i32, XOR64i32)>; def Zn3WriteMoveExtend : SchedWriteRes<[Zn3ALU0123]> { let Latency = 1; let ResourceCycles = [4]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteMoveExtend], (instrs MOVSX16rr16, MOVSX16rr32, MOVZX16rr16, MOVSX16rr8, MOVZX16rr8)>; def Zn3WriteMaterialize32bitImm: SchedWriteRes<[Zn3ALU0123]> { let Latency = 1; let ResourceCycles = [2]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteMaterialize32bitImm], (instrs MOV32ri, MOV32ri_alt, MOV64ri32)>; def Zn3WritePDEP_PEXT : SchedWriteRes<[Zn3ALU1]> { let Latency = 3; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WritePDEP_PEXT], (instrs PDEP32rr, PDEP64rr, PEXT32rr, PEXT64rr)>; defm : Zn3WriteResIntPair; // Integer ALU + flags op. def Zn3WriteADC8mr_SBB8mr : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU0123, Zn3Store]> { let Latency = 1; let ResourceCycles = [1, 1, 7, 1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteADC8mr_SBB8mr], (instrs ADC8mr, SBB8mr)>; // This is for simple LEAs with one or two input operands. defm : Zn3WriteResInt; // LEA instructions can't fold loads. // This write is used for slow LEA instructions. def Zn3Write3OpsLEA : SchedWriteRes<[Zn3ALU0123]> { let Latency = 2; let ResourceCycles = [1]; let NumMicroOps = 2; } // On Piledriver, a slow LEA is either a 3Ops LEA (base, index, offset), // or an LEA with a `Scale` value different than 1. def Zn3SlowLEAPredicate : MCSchedPredicate< CheckAny<[ // A 3-operand LEA (base, index, offset). IsThreeOperandsLEAFn, // An LEA with a "Scale" different than 1. CheckAll<[ CheckIsImmOperand<2>, CheckNot> ]> ]> >; def Zn3WriteLEA : SchedWriteVariant<[ SchedVar, SchedVar ]>; def : InstRW<[Zn3WriteLEA], (instrs LEA32r, LEA64r, LEA64_32r)>; def Zn3SlowLEA16r : SchedWriteRes<[Zn3ALU0123]> { let Latency = 2; // FIXME: not from llvm-exegesis let ResourceCycles = [4]; let NumMicroOps = 2; } def : InstRW<[Zn3SlowLEA16r], (instrs LEA16r)>; // Integer multiplication defm : Zn3WriteResIntPair; // Integer 8-bit multiplication. defm : Zn3WriteResIntPair; // Integer 16-bit multiplication. defm : Zn3WriteResIntPair; // Integer 16-bit multiplication by immediate. defm : Zn3WriteResIntPair; // Integer 16-bit multiplication by register. defm : Zn3WriteResIntPair; // Integer 32-bit multiplication. def Zn3MULX32rr : SchedWriteRes<[Zn3Multiplier]> { let Latency = 4; let ResourceCycles = [1]; let NumMicroOps = 2; } def : InstRW<[Zn3MULX32rr], (instrs MULX32rr)>; def Zn3MULX32rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3Multiplier]> { let Latency = !add(Znver3Model.LoadLatency, Zn3MULX32rr.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = Zn3MULX32rr.NumMicroOps; } def : InstRW<[Zn3MULX32rm], (instrs MULX32rm)>; defm : Zn3WriteResIntPair; // Integer 32-bit multiplication by immediate. defm : Zn3WriteResIntPair; // Integer 32-bit multiplication by register. defm : Zn3WriteResIntPair; // Integer 64-bit multiplication. def Zn3MULX64rr : SchedWriteRes<[Zn3Multiplier]> { let Latency = 4; let ResourceCycles = [1]; let NumMicroOps = 2; } def : InstRW<[Zn3MULX64rr], (instrs MULX64rr)>; def Zn3MULX64rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3Multiplier]> { let Latency = !add(Znver3Model.LoadLatency, Zn3MULX64rr.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = Zn3MULX64rr.NumMicroOps; } def : InstRW<[Zn3MULX64rm], (instrs MULX64rm)>; defm : Zn3WriteResIntPair; // Integer 64-bit multiplication by immediate. defm : Zn3WriteResIntPair; // Integer 64-bit multiplication by register. defm : Zn3WriteResInt; // Integer multiplication, high part. defm : Zn3WriteResInt; // Byte Order (Endianness) 32-bit Swap. defm : Zn3WriteResInt; // Byte Order (Endianness) 64-bit Swap. defm : Zn3WriteResIntPair; // Compare and set, compare and swap. def Zn3WriteCMPXCHG8rr : SchedWriteRes<[Zn3ALU0123]> { let Latency = 3; let ResourceCycles = [12]; let NumMicroOps = 3; } def : InstRW<[Zn3WriteCMPXCHG8rr], (instrs CMPXCHG8rr)>; defm : Zn3WriteResInt; // Compare and set, compare and swap. def Zn3WriteCMPXCHG8rm_LCMPXCHG8 : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU0123]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteCMPXCHG8rr.Latency); let ResourceCycles = [1, 1, 12]; let NumMicroOps = !add(Zn3WriteCMPXCHG8rr.NumMicroOps, 2); } def : InstRW<[Zn3WriteCMPXCHG8rm_LCMPXCHG8], (instrs CMPXCHG8rm, LCMPXCHG8)>; def Zn3WriteCMPXCHG8B : SchedWriteRes<[Zn3ALU0123]> { let Latency = 3; // FIXME: not from llvm-exegesis let ResourceCycles = [24]; let NumMicroOps = 19; } def : InstRW<[Zn3WriteCMPXCHG8B], (instrs CMPXCHG8B)>; def Zn3WriteCMPXCHG16B_LCMPXCHG16B : SchedWriteRes<[Zn3ALU0123]> { let Latency = 4; // FIXME: not from llvm-exegesis let ResourceCycles = [59]; let NumMicroOps = 28; } def : InstRW<[Zn3WriteCMPXCHG16B_LCMPXCHG16B], (instrs CMPXCHG16B, LCMPXCHG16B)>; def Zn3WriteWriteXCHGUnrenameable : SchedWriteRes<[Zn3ALU0123]> { let Latency = 1; let ResourceCycles = [2]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteWriteXCHGUnrenameable], (instrs XCHG8rr, XCHG16rr, XCHG16ar)>; def Zn3WriteXCHG8rm_XCHG16rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU0123]> { let Latency = !add(Znver3Model.LoadLatency, 3); // FIXME: not from llvm-exegesis let ResourceCycles = [1, 1, 2]; let NumMicroOps = 5; } def : InstRW<[Zn3WriteXCHG8rm_XCHG16rm], (instrs XCHG8rm, XCHG16rm)>; def Zn3WriteXCHG32rm_XCHG64rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU0123]> { let Latency = !add(Znver3Model.LoadLatency, 2); // FIXME: not from llvm-exegesis let ResourceCycles = [1, 1, 2]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteXCHG32rm_XCHG64rm], (instrs XCHG32rm, XCHG64rm)>; // Integer division. // FIXME: uops for 8-bit division measures as 2. for others it's a guess. // FIXME: latency for 8-bit division measures as 10. for others it's a guess. defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; // Bit scan forward. defm : Zn3WriteResIntPair; // Bit scan reverse. defm : Zn3WriteResIntPair; // Bit population count. def Zn3WritePOPCNT16rr : SchedWriteRes<[Zn3ALU0123]> { let Latency = 1; let ResourceCycles = [4]; let NumMicroOps = 1; } def : InstRW<[Zn3WritePOPCNT16rr], (instrs POPCNT16rr)>; defm : Zn3WriteResIntPair; // Leading zero count. def Zn3WriteLZCNT16rr : SchedWriteRes<[Zn3ALU0123]> { let Latency = 1; let ResourceCycles = [4]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteLZCNT16rr], (instrs LZCNT16rr)>; defm : Zn3WriteResIntPair; // Trailing zero count. def Zn3WriteTZCNT16rr : SchedWriteRes<[Zn3ALU0123]> { let Latency = 2; let ResourceCycles = [4]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteTZCNT16rr], (instrs TZCNT16rr)>; defm : Zn3WriteResIntPair; // Conditional move. defm : Zn3WriteResInt; // FIXME: not from llvm-exegesis // X87 conditional move. defm : Zn3WriteResInt; // Set register based on condition code. defm : Zn3WriteResInt; // FIXME: latency not from llvm-exegesis defm : Zn3WriteResInt; // Load/Store flags in AH. defm : Zn3WriteResInt; // Bit Test defm : Zn3WriteResInt; defm : Zn3WriteResInt; defm : Zn3WriteResInt; // Bit Test + Set defm : Zn3WriteResInt; defm : Zn3WriteResInt; // Integer shifts and rotates. defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; def Zn3WriteRotateR1 : SchedWriteRes<[Zn3ALU12]> { let Latency = 1; let ResourceCycles = [2]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteRotateR1], (instrs RCL8r1, RCL16r1, RCL32r1, RCL64r1, RCR8r1, RCR16r1, RCR32r1, RCR64r1)>; def Zn3WriteRotateM1 : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU12]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteRotateR1.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = !add(Zn3WriteRotateR1.NumMicroOps, 1); } def : InstRW<[Zn3WriteRotateM1], (instrs RCL8m1, RCL16m1, RCL32m1, RCL64m1, RCR8m1, RCR16m1, RCR32m1, RCR64m1)>; def Zn3WriteRotateRightRI : SchedWriteRes<[Zn3ALU12]> { let Latency = 3; let ResourceCycles = [6]; let NumMicroOps = 7; } def : InstRW<[Zn3WriteRotateRightRI], (instrs RCR8ri, RCR16ri, RCR32ri, RCR64ri)>; def Zn3WriteRotateRightMI : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU12]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteRotateRightRI.Latency); let ResourceCycles = [1, 1, 8]; let NumMicroOps = !add(Zn3WriteRotateRightRI.NumMicroOps, 3); } def : InstRW<[Zn3WriteRotateRightMI], (instrs RCR8mi, RCR16mi, RCR32mi, RCR64mi)>; def Zn3WriteRotateLeftRI : SchedWriteRes<[Zn3ALU12]> { let Latency = 4; let ResourceCycles = [8]; let NumMicroOps = 9; } def : InstRW<[Zn3WriteRotateLeftRI], (instrs RCL8ri, RCL16ri, RCL32ri, RCL64ri)>; def Zn3WriteRotateLeftMI : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU12]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteRotateLeftRI.Latency); let ResourceCycles = [1, 1, 8]; let NumMicroOps = !add(Zn3WriteRotateLeftRI.NumMicroOps, 2); } def : InstRW<[Zn3WriteRotateLeftMI], (instrs RCL8mi, RCL16mi, RCL32mi, RCL64mi)>; defm : Zn3WriteResIntPair; def Zn3WriteRotateRightRCL : SchedWriteRes<[Zn3ALU12]> { let Latency = 3; let ResourceCycles = [6]; let NumMicroOps = 7; } def : InstRW<[Zn3WriteRotateRightRCL], (instrs RCR8rCL, RCR16rCL, RCR32rCL, RCR64rCL)>; def Zn3WriteRotateRightMCL : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU12]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteRotateRightRCL.Latency); let ResourceCycles = [1, 1, 8]; let NumMicroOps = !add(Zn3WriteRotateRightRCL.NumMicroOps, 2); } def : InstRW<[Zn3WriteRotateRightMCL], (instrs RCR8mCL, RCR16mCL, RCR32mCL, RCR64mCL)>; def Zn3WriteRotateLeftRCL : SchedWriteRes<[Zn3ALU12]> { let Latency = 4; let ResourceCycles = [8]; let NumMicroOps = 9; } def : InstRW<[Zn3WriteRotateLeftRCL], (instrs RCL8rCL, RCL16rCL, RCL32rCL, RCL64rCL)>; def Zn3WriteRotateLeftMCL : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3ALU12]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteRotateLeftRCL.Latency); let ResourceCycles = [1, 1, 8]; let NumMicroOps = !add(Zn3WriteRotateLeftRCL.NumMicroOps, 2); } def : InstRW<[Zn3WriteRotateLeftMCL], (instrs RCL8mCL, RCL16mCL, RCL32mCL, RCL64mCL)>; // Double shift instructions. defm : Zn3WriteResInt; defm : Zn3WriteResInt; defm : Zn3WriteResInt; defm : Zn3WriteResInt; // BMI1 BEXTR/BLS, BMI2 BZHI defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; defm : Zn3WriteResIntPair; // Idioms that clear a register, like xorps %xmm0, %xmm0. // These can often bypass execution ports completely. defm : Zn3WriteResInt; // Branches don't produce values, so they have no latency, but they still // consume resources. Indirect branches can fold loads. defm : Zn3WriteResIntPair; // FIXME: not from llvm-exegesis // Floating point. This covers both scalar and vector operations. defm : Zn3WriteResInt; defm : Zn3WriteResInt; defm : Zn3WriteResInt; defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; def Zn3WriteWriteFStoreMMX : SchedWriteRes<[Zn3FPSt, Zn3Store]> { let Latency = 2; // FIXME: not from llvm-exegesis let ResourceCycles = [1, 1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteWriteFStoreMMX], (instrs MOVHPDmr, MOVHPSmr, VMOVHPDmr, VMOVHPSmr)>; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMMPair; // Floating point add/sub. def Zn3WriteX87Arith : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPU0123]> { let Latency = !add(Znver3Model.LoadLatency, 1); // FIXME: not from llvm-exegesis let ResourceCycles = [1, 1, 24]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteX87Arith], (instrs ADD_FI16m, ADD_FI32m, SUB_FI16m, SUB_FI32m, SUBR_FI16m, SUBR_FI32m, MUL_FI16m, MUL_FI32m)>; def Zn3WriteX87Div : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPU0123]> { let Latency = !add(Znver3Model.LoadLatency, 1); // FIXME: not from llvm-exegesis let ResourceCycles = [1, 1, 62]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteX87Div], (instrs DIV_FI16m, DIV_FI32m, DIVR_FI16m, DIVR_FI32m)>; defm : Zn3WriteResXMMPair; // Floating point add/sub (XMM). defm : Zn3WriteResYMMPair; // Floating point add/sub (YMM). defm : X86WriteResPairUnsupported; // Floating point add/sub (ZMM). defm : Zn3WriteResXMMPair; // Floating point double add/sub. defm : Zn3WriteResXMMPair; // Floating point double add/sub (XMM). defm : Zn3WriteResYMMPair; // Floating point double add/sub (YMM). defm : X86WriteResPairUnsupported; // Floating point double add/sub (ZMM). defm : Zn3WriteResXMMPair; // Floating point compare. defm : Zn3WriteResXMMPair; // Floating point compare (XMM). defm : Zn3WriteResYMMPair; // Floating point compare (YMM). defm : X86WriteResPairUnsupported; // Floating point compare (ZMM). defm : Zn3WriteResXMMPair; // Floating point double compare. defm : Zn3WriteResXMMPair; // Floating point double compare (XMM). defm : Zn3WriteResYMMPair; // Floating point double compare (YMM). defm : X86WriteResPairUnsupported; // Floating point double compare (ZMM). defm : Zn3WriteResXMMPair; // FIXME: latency not from llvm-exegesis // Floating point compare to flags (X87). defm : Zn3WriteResXMMPair; // FIXME: latency not from llvm-exegesis // Floating point compare to flags (SSE). defm : Zn3WriteResXMMPair; // Floating point multiplication. defm : Zn3WriteResXMMPair; // Floating point multiplication (XMM). defm : Zn3WriteResYMMPair; // Floating point multiplication (YMM). defm : X86WriteResPairUnsupported; // Floating point multiplication (YMM). defm : Zn3WriteResXMMPair; // Floating point double multiplication. defm : Zn3WriteResXMMPair; // Floating point double multiplication (XMM). defm : Zn3WriteResYMMPair; // Floating point double multiplication (YMM). defm : X86WriteResPairUnsupported; // Floating point double multiplication (ZMM). defm : Zn3WriteResXMMPair; // Floating point division. defm : Zn3WriteResXMMPair; // Floating point division (XMM). defm : Zn3WriteResYMMPair; // Floating point division (YMM). defm : X86WriteResPairUnsupported; // Floating point division (ZMM). defm : Zn3WriteResXMMPair; // Floating point double division. defm : Zn3WriteResXMMPair; // Floating point double division (XMM). defm : Zn3WriteResYMMPair; // Floating point double division (YMM). defm : X86WriteResPairUnsupported; // Floating point double division (ZMM). defm : Zn3WriteResXMMPair; // Floating point square root. defm : Zn3WriteResXMMPair; // Floating point square root (XMM). defm : Zn3WriteResYMMPair; // Floating point square root (YMM). defm : X86WriteResPairUnsupported; // Floating point square root (ZMM). defm : Zn3WriteResXMMPair; // Floating point double square root. defm : Zn3WriteResXMMPair; // Floating point double square root (XMM). defm : Zn3WriteResYMMPair; // Floating point double square root (YMM). defm : X86WriteResPairUnsupported; // Floating point double square root (ZMM). defm : Zn3WriteResXMMPair; // FIXME: latency not from llvm-exegesis // Floating point long double square root. defm : Zn3WriteResXMMPair; // Floating point reciprocal estimate. defm : Zn3WriteResXMMPair; // Floating point reciprocal estimate (XMM). defm : Zn3WriteResYMMPair; // Floating point reciprocal estimate (YMM). defm : X86WriteResPairUnsupported; // Floating point reciprocal estimate (ZMM). defm : Zn3WriteResXMMPair; // Floating point reciprocal square root estimate. defm : Zn3WriteResXMMPair; // Floating point reciprocal square root estimate (XMM). defm : Zn3WriteResYMMPair; // Floating point reciprocal square root estimate (YMM). defm : X86WriteResPairUnsupported; // Floating point reciprocal square root estimate (ZMM). defm : Zn3WriteResXMMPair; // Fused Multiply Add. defm : Zn3WriteResXMMPair; // Fused Multiply Add (XMM). defm : Zn3WriteResYMMPair; // Fused Multiply Add (YMM). defm : X86WriteResPairUnsupported; // Fused Multiply Add (ZMM). defm : Zn3WriteResXMMPair; // Floating point double dot product. defm : Zn3WriteResXMMPair; // Floating point single dot product. defm : Zn3WriteResYMMPair; // Floating point single dot product (YMM). defm : X86WriteResPairUnsupported; // Floating point single dot product (ZMM). defm : Zn3WriteResXMMPair; // FIXME: latency not from llvm-exegesis // Floating point fabs/fchs. defm : Zn3WriteResXMMPair; // Floating point rounding. defm : Zn3WriteResYMMPair; // Floating point rounding (YMM). defm : X86WriteResPairUnsupported; // Floating point rounding (ZMM). defm : Zn3WriteResXMMPair; // Floating point and/or/xor logicals. defm : Zn3WriteResYMMPair; // Floating point and/or/xor logicals (YMM). defm : X86WriteResPairUnsupported; // Floating point and/or/xor logicals (ZMM). defm : Zn3WriteResXMMPair; // FIXME: latency not from llvm-exegesis // Floating point TEST instructions. defm : Zn3WriteResYMMPair; // FIXME: latency not from llvm-exegesis // Floating point TEST instructions (YMM). defm : X86WriteResPairUnsupported; // Floating point TEST instructions (ZMM). defm : Zn3WriteResXMMPair; // Floating point vector shuffles. defm : Zn3WriteResYMMPair; // Floating point vector shuffles (YMM). defm : X86WriteResPairUnsupported; // Floating point vector shuffles (ZMM). defm : Zn3WriteResXMMPair; // Floating point vector variable shuffles. defm : Zn3WriteResYMMPair; // Floating point vector variable shuffles (YMM). defm : X86WriteResPairUnsupported; // Floating point vector variable shuffles (ZMM). defm : Zn3WriteResXMMPair; // Floating point vector blends. defm : Zn3WriteResYMMPair; // Floating point vector blends (YMM). defm : X86WriteResPairUnsupported; // Floating point vector blends (ZMM). defm : Zn3WriteResXMMPair; // Fp vector variable blends. defm : Zn3WriteResYMMPair; // Fp vector variable blends (YMM). defm : X86WriteResPairUnsupported; // Fp vector variable blends (ZMM). // Horizontal Add/Sub (float and integer) defm : Zn3WriteResXMMPair; defm : Zn3WriteResYMMPair; defm : X86WriteResPairUnsupported; defm : Zn3WriteResXMMPair; defm : Zn3WriteResXMMPair; defm : Zn3WriteResYMMPair; defm : X86WriteResPairUnsupported; // Vector integer operations. defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; def Zn3WriteVEXTRACTF128rr_VEXTRACTI128rr : SchedWriteRes<[Zn3FPFMisc0]> { let Latency = 4; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteVEXTRACTF128rr_VEXTRACTI128rr], (instrs VEXTRACTF128rr, VEXTRACTI128rr)>; def Zn3WriteVEXTRACTI128mr : SchedWriteRes<[Zn3FPFMisc0, Zn3FPSt, Zn3Store]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteVEXTRACTF128rr_VEXTRACTI128rr.Latency); let ResourceCycles = [1, 1, 1]; let NumMicroOps = !add(Zn3WriteVEXTRACTF128rr_VEXTRACTI128rr.NumMicroOps, 1); } def : InstRW<[Zn3WriteVEXTRACTI128mr], (instrs VEXTRACTI128mr, VEXTRACTF128mr)>; def Zn3WriteVINSERTF128rmr : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPFMisc0]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteVEXTRACTF128rr_VEXTRACTI128rr.Latency); let ResourceCycles = [1, 1, 1]; let NumMicroOps = !add(Zn3WriteVEXTRACTF128rr_VEXTRACTI128rr.NumMicroOps, 0); } def : InstRW<[Zn3WriteVINSERTF128rmr], (instrs VINSERTF128rm)>; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; def Zn3WriteMOVMMX : SchedWriteRes<[Zn3FPLd01, Zn3FPFMisc0123]> { let Latency = 1; let ResourceCycles = [1, 2]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteMOVMMX], (instrs MMX_MOVQ2FR64rr, MMX_MOVQ2DQrr)>; def Zn3WriteMOVMMXSlow : SchedWriteRes<[Zn3FPLd01, Zn3FPFMisc0123]> { let Latency = 1; let ResourceCycles = [1, 4]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteMOVMMXSlow], (instrs MMX_MOVD64rr, MMX_MOVD64to64rr)>; defm : Zn3WriteResXMMPair; // Vector integer ALU op, no logicals. def Zn3WriteEXTRQ_INSERTQ : SchedWriteRes<[Zn3FPVShuf01, Zn3FPLd01]> { let Latency = 3; let ResourceCycles = [1, 1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteEXTRQ_INSERTQ], (instrs EXTRQ, INSERTQ)>; def Zn3WriteEXTRQI_INSERTQI : SchedWriteRes<[Zn3FPVShuf01, Zn3FPLd01]> { let Latency = 3; let ResourceCycles = [1, 1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteEXTRQI_INSERTQI], (instrs EXTRQI, INSERTQI)>; defm : Zn3WriteResXMMPair; // Vector integer ALU op, no logicals (XMM). def Zn3WriteVecALUXSlow : SchedWriteRes<[Zn3FPVAdd01]> { let Latency = 1; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteVecALUXSlow], (instrs PABSBrr, PABSDrr, PABSWrr, PADDSBrr, PADDSWrr, PADDUSBrr, PADDUSWrr, PAVGBrr, PAVGWrr, PSIGNBrr, PSIGNDrr, PSIGNWrr, VPABSBrr, VPABSDrr, VPABSWrr, VPADDSBrr, VPADDSWrr, VPADDUSBrr, VPADDUSWrr, VPAVGBrr, VPAVGWrr, VPCMPEQQrr, VPSIGNBrr, VPSIGNDrr, VPSIGNWrr, PSUBSBrr, PSUBSWrr, PSUBUSBrr, PSUBUSWrr, VPSUBSBrr, VPSUBSWrr, VPSUBUSBrr, VPSUBUSWrr)>; def Zn3WriteVecALUXMMX : SchedWriteRes<[Zn3FPVAdd01]> { let Latency = 1; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteVecALUXMMX], (instrs MMX_PABSBrr, MMX_PABSDrr, MMX_PABSWrr, MMX_PSIGNBrr, MMX_PSIGNDrr, MMX_PSIGNWrr, MMX_PADDSBirr, MMX_PADDSWirr, MMX_PADDUSBirr, MMX_PADDUSWirr, MMX_PAVGBirr, MMX_PAVGWirr, MMX_PSUBSBirr, MMX_PSUBSWirr, MMX_PSUBUSBirr, MMX_PSUBUSWirr)>; defm : Zn3WriteResYMMPair; // Vector integer ALU op, no logicals (YMM). def Zn3WriteVecALUYSlow : SchedWriteRes<[Zn3FPVAdd01]> { let Latency = 1; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteVecALUYSlow], (instrs VPABSBYrr, VPABSDYrr, VPABSWYrr, VPADDSBYrr, VPADDSWYrr, VPADDUSBYrr, VPADDUSWYrr, VPSUBSBYrr, VPSUBSWYrr, VPSUBUSBYrr, VPSUBUSWYrr, VPAVGBYrr, VPAVGWYrr, VPCMPEQQYrr, VPSIGNBYrr, VPSIGNDYrr, VPSIGNWYrr)>; defm : X86WriteResPairUnsupported; // Vector integer ALU op, no logicals (ZMM). defm : Zn3WriteResXMMPair; // Vector integer and/or/xor logicals. defm : Zn3WriteResXMMPair; // Vector integer and/or/xor logicals (XMM). defm : Zn3WriteResYMMPair; // Vector integer and/or/xor logicals (YMM). defm : X86WriteResPairUnsupported; // Vector integer and/or/xor logicals (ZMM). defm : Zn3WriteResXMMPair; // FIXME: latency not from llvm-exegesis // Vector integer TEST instructions. defm : Zn3WriteResYMMPair; // FIXME: latency not from llvm-exegesis // Vector integer TEST instructions (YMM). defm : X86WriteResPairUnsupported; // Vector integer TEST instructions (ZMM). defm : Zn3WriteResXMMPair; // Vector integer shifts (default). defm : Zn3WriteResXMMPair; // Vector integer shifts (XMM). defm : Zn3WriteResYMMPair; // Vector integer shifts (YMM). defm : X86WriteResPairUnsupported; // Vector integer shifts (ZMM). defm : Zn3WriteResXMMPair; // Vector integer immediate shifts (default). defm : Zn3WriteResXMMPair; // Vector integer immediate shifts (XMM). defm : Zn3WriteResYMMPair; // Vector integer immediate shifts (YMM). defm : X86WriteResPairUnsupported; // Vector integer immediate shifts (ZMM). defm : Zn3WriteResXMMPair; // Vector integer multiply (default). defm : Zn3WriteResXMMPair; // Vector integer multiply (XMM). defm : Zn3WriteResYMMPair; // Vector integer multiply (YMM). defm : X86WriteResPairUnsupported; // Vector integer multiply (ZMM). defm : Zn3WriteResXMMPair; // Vector PMULLD. defm : Zn3WriteResYMMPair; // Vector PMULLD (YMM). defm : X86WriteResPairUnsupported; // Vector PMULLD (ZMM). defm : Zn3WriteResXMMPair; // Vector shuffles. defm : Zn3WriteResXMMPair; // Vector shuffles (XMM). defm : Zn3WriteResYMMPair; // Vector shuffles (YMM). defm : X86WriteResPairUnsupported; // Vector shuffles (ZMM). defm : Zn3WriteResXMMPair; // Vector variable shuffles. defm : Zn3WriteResXMMPair; // Vector variable shuffles (XMM). defm : Zn3WriteResYMMPair; // Vector variable shuffles (YMM). defm : X86WriteResPairUnsupported; // Vector variable shuffles (ZMM). defm : Zn3WriteResXMMPair; // Vector blends. defm : Zn3WriteResYMMPair; // Vector blends (YMM). defm : X86WriteResPairUnsupported; // Vector blends (ZMM). defm : Zn3WriteResXMMPair; // Vector variable blends. defm : Zn3WriteResYMMPair; // Vector variable blends (YMM). defm : X86WriteResPairUnsupported; // Vector variable blends (ZMM). defm : Zn3WriteResXMMPair; // Vector PSADBW. defm : Zn3WriteResXMMPair; // Vector PSADBW (XMM). defm : Zn3WriteResYMMPair; // Vector PSADBW (YMM). defm : X86WriteResPairUnsupported; // Vector PSADBW (ZMM). defm : Zn3WriteResXMMPair; // Vector MPSAD. defm : Zn3WriteResYMMPair; // Vector MPSAD (YMM). defm : X86WriteResPairUnsupported; // Vector MPSAD (ZMM). defm : Zn3WriteResXMMPair; // Vector PHMINPOS. // Vector insert/extract operations. defm : Zn3WriteResXMMPair; // Insert gpr to vector element. defm : Zn3WriteResXMM; // Extract vector element to gpr. defm : Zn3WriteResXMM; // Extract vector element and store. // MOVMSK operations. defm : Zn3WriteResXMM; defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; // Conversion between integer and float. defm : Zn3WriteResXMMPair; // Double -> Integer. defm : Zn3WriteResXMMPair; // Double -> Integer (XMM). defm : Zn3WriteResYMMPair; // Double -> Integer (YMM). defm : X86WriteResPairUnsupported; // Double -> Integer (ZMM). def Zn3WriteCvtPD2IMMX : SchedWriteRes<[Zn3FPFCvt01]> { let Latency = 1; let ResourceCycles = [2]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteCvtPD2IMMX], (instrs MMX_CVTPD2PIirm, MMX_CVTTPD2PIirm, MMX_CVTPD2PIirr, MMX_CVTTPD2PIirr)>; defm : Zn3WriteResXMMPair; // Float -> Integer. defm : Zn3WriteResXMMPair; // Float -> Integer (XMM). defm : Zn3WriteResYMMPair; // Float -> Integer (YMM). defm : X86WriteResPairUnsupported; // Float -> Integer (ZMM). defm : Zn3WriteResXMMPair; // Integer -> Double. defm : Zn3WriteResXMMPair; // Integer -> Double (XMM). defm : Zn3WriteResYMMPair; // Integer -> Double (YMM). defm : X86WriteResPairUnsupported; // Integer -> Double (ZMM). def Zn3WriteCvtI2PDMMX : SchedWriteRes<[Zn3FPFCvt01]> { let Latency = 2; let ResourceCycles = [6]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteCvtI2PDMMX], (instrs MMX_CVTPI2PDirm, MMX_CVTPI2PDirr)>; defm : Zn3WriteResXMMPair; // Integer -> Float. defm : Zn3WriteResXMMPair; // Integer -> Float (XMM). defm : Zn3WriteResYMMPair; // Integer -> Float (YMM). defm : X86WriteResPairUnsupported; // Integer -> Float (ZMM). def Zn3WriteCvtI2PSMMX : SchedWriteRes<[Zn3FPFCvt01]> { let Latency = 3; let ResourceCycles = [1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteCvtI2PSMMX], (instrs MMX_CVTPI2PSirr)>; defm : Zn3WriteResXMMPair; // Float -> Double size conversion. defm : Zn3WriteResXMMPair; // Float -> Double size conversion (XMM). defm : Zn3WriteResYMMPair; // Float -> Double size conversion (YMM). defm : X86WriteResPairUnsupported; // Float -> Double size conversion (ZMM). defm : Zn3WriteResXMMPair; // Double -> Float size conversion. defm : Zn3WriteResXMMPair; // Double -> Float size conversion (XMM). defm : Zn3WriteResYMMPair; // Double -> Float size conversion (YMM). defm : X86WriteResPairUnsupported; // Double -> Float size conversion (ZMM). defm : Zn3WriteResXMMPair; // Half -> Float size conversion. defm : Zn3WriteResYMMPair; // Half -> Float size conversion (YMM). defm : X86WriteResPairUnsupported; // Half -> Float size conversion (ZMM). defm : Zn3WriteResXMM; // Float -> Half size conversion. defm : Zn3WriteResYMM; // Float -> Half size conversion (YMM). defm : X86WriteResUnsupported; // Float -> Half size conversion (ZMM). defm : Zn3WriteResXMM; // Float -> Half + store size conversion. defm : Zn3WriteResYMM; // Float -> Half + store size conversion (YMM). defm : X86WriteResUnsupported; // Float -> Half + store size conversion (ZMM). // CRC32 instruction. defm : Zn3WriteResIntPair; def Zn3WriteSHA1MSG1rr : SchedWriteRes<[Zn3FPU0123]> { let Latency = 2; let ResourceCycles = [2]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteSHA1MSG1rr], (instrs SHA1MSG1rr)>; def Zn3WriteSHA1MSG1rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPU0123]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteSHA1MSG1rr.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = !add(Zn3WriteSHA1MSG1rr.NumMicroOps, 0); } def : InstRW<[Zn3WriteSHA1MSG1rm], (instrs SHA1MSG1rm)>; def Zn3WriteSHA1MSG2rr_SHA1NEXTErr : SchedWriteRes<[Zn3FPU0123]> { let Latency = 1; let ResourceCycles = [2]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteSHA1MSG2rr_SHA1NEXTErr], (instrs SHA1MSG2rr, SHA1NEXTErr)>; def Zn3Writerm_SHA1MSG2rm_SHA1NEXTErm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPU0123]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteSHA1MSG2rr_SHA1NEXTErr.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = !add(Zn3WriteSHA1MSG2rr_SHA1NEXTErr.NumMicroOps, 0); } def : InstRW<[Zn3Writerm_SHA1MSG2rm_SHA1NEXTErm], (instrs SHA1MSG2rm, SHA1NEXTErm)>; def Zn3WriteSHA256MSG1rr : SchedWriteRes<[Zn3FPU0123]> { let Latency = 2; let ResourceCycles = [3]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteSHA256MSG1rr], (instrs SHA256MSG1rr)>; def Zn3Writerm_SHA256MSG1rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPU0123]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteSHA256MSG1rr.Latency); let ResourceCycles = [1, 1, 3]; let NumMicroOps = !add(Zn3WriteSHA256MSG1rr.NumMicroOps, 0); } def : InstRW<[Zn3Writerm_SHA256MSG1rm], (instrs SHA256MSG1rm)>; def Zn3WriteSHA256MSG2rr : SchedWriteRes<[Zn3FPU0123]> { let Latency = 3; let ResourceCycles = [8]; let NumMicroOps = 4; } def : InstRW<[Zn3WriteSHA256MSG2rr], (instrs SHA256MSG2rr)>; def Zn3WriteSHA256MSG2rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPU0123]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteSHA256MSG2rr.Latency); let ResourceCycles = [1, 1, 8]; let NumMicroOps = !add(Zn3WriteSHA256MSG2rr.NumMicroOps, 1); } def : InstRW<[Zn3WriteSHA256MSG2rm], (instrs SHA256MSG2rm)>; def Zn3WriteSHA1RNDS4rri : SchedWriteRes<[Zn3FPU0123]> { let Latency = 6; let ResourceCycles = [8]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteSHA1RNDS4rri], (instrs SHA1RNDS4rri)>; def Zn3WriteSHA256RNDS2rr : SchedWriteRes<[Zn3FPU0123]> { let Latency = 4; let ResourceCycles = [8]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteSHA256RNDS2rr], (instrs SHA256RNDS2rr)>; // Strings instructions. // Packed Compare Implicit Length Strings, Return Mask defm : Zn3WriteResXMMPair; // Packed Compare Explicit Length Strings, Return Mask defm : Zn3WriteResXMMPair; // Packed Compare Implicit Length Strings, Return Index defm : Zn3WriteResXMMPair; // Packed Compare Explicit Length Strings, Return Index defm : Zn3WriteResXMMPair; // AES instructions. defm : Zn3WriteResXMMPair; // Decryption, encryption. defm : Zn3WriteResXMMPair; // InvMixColumn. defm : Zn3WriteResXMMPair; // Key Generation. // Carry-less multiplication instructions. defm : Zn3WriteResXMMPair; // EMMS/FEMMS defm : Zn3WriteResInt; // FIXME: latency not from llvm-exegesis // Load/store MXCSR defm : Zn3WriteResInt; // FIXME: latency not from llvm-exegesis defm : Zn3WriteResInt; // FIXME: latency not from llvm-exegesis // Catch-all for expensive system instructions. defm : Zn3WriteResInt; def Zn3WriteVZEROUPPER : SchedWriteRes<[Zn3FPU0123]> { let Latency = 0; // FIXME: not from llvm-exegesis let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteVZEROUPPER], (instrs VZEROUPPER)>; def Zn3WriteVZEROALL : SchedWriteRes<[Zn3FPU0123]> { let Latency = 10; // FIXME: not from llvm-exegesis let ResourceCycles = [24]; let NumMicroOps = 18; } def : InstRW<[Zn3WriteVZEROALL], (instrs VZEROALL)>; // AVX2. defm : Zn3WriteResYMMPair; // Fp 256-bit width vector shuffles. defm : Zn3WriteResYMMPair; // Fp 256-bit width variable shuffles. defm : Zn3WriteResYMMPair; // 256-bit width vector shuffles. def Zn3WriteVPERM2I128rr_VPERM2F128rr : SchedWriteRes<[Zn3FPVShuf]> { let Latency = 3; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteVPERM2I128rr_VPERM2F128rr], (instrs VPERM2I128rr, VPERM2F128rr)>; def Zn3WriteVPERM2F128rm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPVShuf]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteVPERM2I128rr_VPERM2F128rr.Latency); let ResourceCycles = [1, 1, 1]; let NumMicroOps = !add(Zn3WriteVPERM2I128rr_VPERM2F128rr.NumMicroOps, 0); } def : InstRW<[Zn3WriteVPERM2F128rm], (instrs VPERM2F128rm)>; def Zn3WriteVPERMPSYrr : SchedWriteRes<[Zn3FPVShuf]> { let Latency = 7; let ResourceCycles = [1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteVPERMPSYrr], (instrs VPERMPSYrr)>; def Zn3WriteVPERMPSYrm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPVShuf]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteVPERMPSYrr.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = !add(Zn3WriteVPERMPSYrr.NumMicroOps, 1); } def : InstRW<[Zn3WriteVPERMPSYrm], (instrs VPERMPSYrm)>; def Zn3WriteVPERMYri : SchedWriteRes<[Zn3FPVShuf]> { let Latency = 6; let ResourceCycles = [1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteVPERMYri], (instrs VPERMPDYri, VPERMQYri)>; def Zn3WriteVPERMPDYmi : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPVShuf]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteVPERMYri.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = !add(Zn3WriteVPERMYri.NumMicroOps, 1); } def : InstRW<[Zn3WriteVPERMPDYmi], (instrs VPERMPDYmi)>; def Zn3WriteVPERMDYrr : SchedWriteRes<[Zn3FPVShuf]> { let Latency = 5; let ResourceCycles = [1]; let NumMicroOps = 2; } def : InstRW<[Zn3WriteVPERMDYrr], (instrs VPERMDYrr)>; def Zn3WriteVPERMYm : SchedWriteRes<[Zn3AGU012, Zn3Load, Zn3FPVShuf]> { let Latency = !add(Znver3Model.LoadLatency, Zn3WriteVPERMDYrr.Latency); let ResourceCycles = [1, 1, 2]; let NumMicroOps = !add(Zn3WriteVPERMDYrr.NumMicroOps, 0); } def : InstRW<[Zn3WriteVPERMYm], (instrs VPERMQYmi, VPERMDYrm)>; defm : Zn3WriteResYMMPair; // 256-bit width packed vector width-changing move. defm : Zn3WriteResYMMPair; // 256-bit width vector variable shuffles. defm : Zn3WriteResXMMPair; // Variable vector shifts. defm : Zn3WriteResYMMPair; // Variable vector shifts (YMM). defm : X86WriteResPairUnsupported; // Variable vector shifts (ZMM). // Old microcoded instructions that nobody use. defm : Zn3WriteResInt; // Fence instructions. defm : Zn3WriteResInt; def Zn3WriteLFENCE : SchedWriteRes<[Zn3LSU]> { let Latency = 1; let ResourceCycles = [30]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteLFENCE], (instrs LFENCE)>; def Zn3WriteSFENCE : SchedWriteRes<[Zn3LSU]> { let Latency = 1; let ResourceCycles = [1]; let NumMicroOps = 1; } def : InstRW<[Zn3WriteSFENCE], (instrs SFENCE)>; // Nop, not very useful expect it provides a model for nops! defm : Zn3WriteResInt; // FIXME: latency not from llvm-exegesis /////////////////////////////////////////////////////////////////////////////// // Zero Cycle Move /////////////////////////////////////////////////////////////////////////////// def Zn3WriteZeroLatency : SchedWriteRes<[]> { let Latency = 0; let ResourceCycles = []; let NumMicroOps = 1; } def : InstRW<[Zn3WriteZeroLatency], (instrs MOV32rr, MOV32rr_REV, MOV64rr, MOV64rr_REV, MOVSX32rr32)>; def Zn3WriteSwapRenameable : SchedWriteRes<[]> { let Latency = 0; let ResourceCycles = []; let NumMicroOps = 2; } def : InstRW<[Zn3WriteSwapRenameable], (instrs XCHG32rr, XCHG32ar, XCHG64rr, XCHG64ar)>; defm : Zn3WriteResInt; // Compare+Exchange - TODO RMW support. defm : Zn3WriteResXMM; // Empty sched class defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; defm : Zn3WriteResXMM; // MMX defm : Zn3WriteResXMM; defm : Zn3WriteResYMM; def : IsOptimizableRegisterMove<[ InstructionEquivalenceClass<[ // GPR variants. MOV32rr, MOV32rr_REV, MOV64rr, MOV64rr_REV, MOVSX32rr32, XCHG32rr, XCHG32ar, XCHG64rr, XCHG64ar, // MMX variants. // MMX moves are *NOT* eliminated. // SSE variants. MOVAPSrr, MOVAPSrr_REV, MOVUPSrr, MOVUPSrr_REV, MOVAPDrr, MOVAPDrr_REV, MOVUPDrr, MOVUPDrr_REV, MOVDQArr, MOVDQArr_REV, MOVDQUrr, MOVDQUrr_REV, // AVX variants. VMOVAPSrr, VMOVAPSrr_REV, VMOVUPSrr, VMOVUPSrr_REV, VMOVAPDrr, VMOVAPDrr_REV, VMOVUPDrr, VMOVUPDrr_REV, VMOVDQArr, VMOVDQArr_REV, VMOVDQUrr, VMOVDQUrr_REV, // AVX YMM variants. VMOVAPSYrr, VMOVAPSYrr_REV, VMOVUPSYrr, VMOVUPSYrr_REV, VMOVAPDYrr, VMOVAPDYrr_REV, VMOVUPDYrr, VMOVUPDYrr_REV, VMOVDQAYrr, VMOVDQAYrr_REV, VMOVDQUYrr, VMOVDQUYrr_REV, ], TruePred > ]>; /////////////////////////////////////////////////////////////////////////////// // Dependency breaking instructions. /////////////////////////////////////////////////////////////////////////////// def Zn3WriteZeroIdiom : SchedWriteVariant<[ SchedVar, [Zn3WriteZeroLatency]>, SchedVar ]>; def : InstRW<[Zn3WriteZeroIdiom], (instrs XOR32rr, XOR32rr_REV, XOR64rr, XOR64rr_REV, SUB32rr, SUB32rr_REV, SUB64rr, SUB64rr_REV)>; def Zn3WriteZeroIdiomEFLAGS : SchedWriteVariant<[ SchedVar>, [Zn3WriteZeroLatency]>, SchedVar ]>; def : InstRW<[Zn3WriteZeroIdiomEFLAGS], (instrs CMP8rr, CMP8rr_REV, CMP16rr, CMP16rr_REV, CMP32rr, CMP32rr_REV, CMP64rr, CMP64rr_REV)>; def : IsZeroIdiomFunction<[ // GPR Zero-idioms. DepBreakingClass<[ XOR32rr, XOR32rr_REV, XOR64rr, XOR64rr_REV, SUB32rr, SUB32rr_REV, SUB64rr, SUB64rr_REV ], ZeroIdiomPredicate>, ]>; def : IsDepBreakingFunction<[ // GPR DepBreakingClass<[ SBB32rr, SBB32rr_REV, SBB64rr, SBB64rr_REV ], ZeroIdiomPredicate>, DepBreakingClass<[ CMP8rr, CMP8rr_REV, CMP16rr, CMP16rr_REV, CMP32rr, CMP32rr_REV, CMP64rr, CMP64rr_REV ], CheckSameRegOperand<0, 1> >, // MMX DepBreakingClass<[ MMX_PCMPEQBirr, MMX_PCMPEQWirr, MMX_PCMPEQDirr ], ZeroIdiomPredicate>, // SSE DepBreakingClass<[ PCMPEQBrr, PCMPEQWrr, PCMPEQDrr, PCMPEQQrr ], ZeroIdiomPredicate>, // AVX XMM DepBreakingClass<[ VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr, VPCMPEQQrr ], ZeroIdiomPredicate>, ]>; } // SchedModel