//=- X86ScheduleBtVer2.td - X86 BtVer2 (Jaguar) 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 AMD btver2 (Jaguar) to support // instruction scheduling and other instruction cost heuristics. Based off AMD Software // Optimization Guide for AMD Family 16h Processors & Instruction Latency appendix. // //===----------------------------------------------------------------------===// def BtVer2Model : SchedMachineModel { // All x86 instructions are modeled as a single micro-op, and btver2 can // decode 2 instructions per cycle. let IssueWidth = 2; let MicroOpBufferSize = 64; // Retire Control Unit let LoadLatency = 5; // FPU latency (worse case cf Integer 3 cycle latency) let HighLatency = 25; let MispredictPenalty = 14; // Minimum branch misdirection penalty let PostRAScheduler = 1; // FIXME: SSE4/AVX is unimplemented. This flag is set to allow // the scheduler to assign a default model to unrecognized opcodes. let CompleteModel = 0; } let SchedModel = BtVer2Model in { // Jaguar can issue up to 6 micro-ops in one cycle def JALU0 : ProcResource<1>; // Integer Pipe0: integer ALU0 (also handle FP->INT jam) def JALU1 : ProcResource<1>; // Integer Pipe1: integer ALU1/MUL/DIV def JLAGU : ProcResource<1>; // Integer Pipe2: LAGU def JSAGU : ProcResource<1>; // Integer Pipe3: SAGU (also handles 3-operand LEA) def JFPU0 : ProcResource<1>; // Vector/FPU Pipe0: VALU0/VIMUL/FPA def JFPU1 : ProcResource<1>; // Vector/FPU Pipe1: VALU1/STC/FPM // The Integer PRF for Jaguar is 64 entries, and it holds the architectural and // speculative version of the 64-bit integer registers. // Reference: www.realworldtech.com/jaguar/4/ // // The processor always keeps the different parts of an integer register // together. An instruction that writes to a part of a register will therefore // have a false dependence on any previous write to the same register or any // part of it. // Reference: Section 21.10 "AMD Bobcat and Jaguar pipeline: Partial register // access" - Agner Fog's "microarchitecture.pdf". def JIntegerPRF : RegisterFile<64, [GR64, CCR], [1, 1], [1, 0], 0, // Max moves that can be eliminated per cycle. 1>; // Restrict move elimination to zero regs. // The Jaguar FP Retire Queue renames SIMD and FP uOps onto a pool of 72 SSE // registers. Operations on 256-bit data types are cracked into two COPs. // Reference: www.realworldtech.com/jaguar/4/ // The PRF in the floating point unit can eliminate a move from a MMX or SSE // register that is know to be zero (i.e. it has been zeroed using a zero-idiom // dependency breaking instruction, or via VZEROALL). // Reference: Section 21.8 "AMD Bobcat and Jaguar pipeline: Dependency-breaking // instructions" - Agner Fog's "microarchitecture.pdf" def JFpuPRF: RegisterFile<72, [VR64, VR128, VR256], [1, 1, 2], [1, 1, 0], 0, // Max moves that can be eliminated per cycle. 1>; // Restrict move elimination to zero regs. // The retire control unit (RCU) can track up to 64 macro-ops in-flight. It can // retire up to two macro-ops per cycle. // Reference: "Software Optimization Guide for AMD Family 16h Processors" def JRCU : RetireControlUnit<64, 2>; // Integer Pipe Scheduler def JALU01 : ProcResGroup<[JALU0, JALU1]> { let BufferSize=20; } // AGU Pipe Scheduler def JLSAGU : ProcResGroup<[JLAGU, JSAGU]> { let BufferSize=12; } // Fpu Pipe Scheduler def JFPU01 : ProcResGroup<[JFPU0, JFPU1]> { let BufferSize=18; } // Functional units def JDiv : ProcResource<1>; // integer division def JMul : ProcResource<1>; // integer multiplication def JVALU0 : ProcResource<1>; // vector integer def JVALU1 : ProcResource<1>; // vector integer def JVIMUL : ProcResource<1>; // vector integer multiplication def JSTC : ProcResource<1>; // vector store/convert def JFPM : ProcResource<1>; // FP multiplication def JFPA : ProcResource<1>; // FP addition // Functional unit groups def JFPX : ProcResGroup<[JFPA, JFPM]>; def JVALU : ProcResGroup<[JVALU0, JVALU1]>; // Integer loads are 3 cycles, so ReadAfterLd registers needn't be available until 3 // cycles after the memory operand. def : ReadAdvance; // Vector loads are 5 cycles, so ReadAfterVec*Ld registers needn't be available until 5 // cycles after the memory operand. def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; /// "Additional 6 cycle transfer operation which moves a floating point /// operation input value from the integer unit to the floating point unit. /// Reference: AMDfam16h SOG (Appendix A "Instruction Latencies", Section A.2). def : ReadAdvance; // 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 JWriteResIntPair ExePorts, int Lat, list Res = [], int UOps = 1, int LoadUOps = 0> { // Register variant is using a single cycle on ExePort. def : WriteRes { let Latency = Lat; let ReleaseAtCycles = Res; let NumMicroOps = UOps; } // Memory variant also uses a cycle on JLAGU and adds 3 cycles to the // latency. def : WriteRes { let Latency = !add(Lat, 3); let ReleaseAtCycles = !if(!empty(Res), [], !listconcat([1], Res)); let NumMicroOps = !add(UOps, LoadUOps); } } multiclass JWriteResFpuPair ExePorts, int Lat, list Res = [], int UOps = 1, int LoadUOps = 0> { // Register variant is using a single cycle on ExePort. def : WriteRes { let Latency = Lat; let ReleaseAtCycles = Res; let NumMicroOps = UOps; } // Memory variant also uses a cycle on JLAGU and adds 5 cycles to the // latency. def : WriteRes { let Latency = !add(Lat, 5); let ReleaseAtCycles = !if(!empty(Res), [], !listconcat([1], Res)); let NumMicroOps = !add(UOps, LoadUOps); } } multiclass JWriteResYMMPair ExePorts, int Lat, list Res = [2], int UOps = 2, int LoadUOps = 0> { // Register variant is using a single cycle on ExePort. def : WriteRes { let Latency = Lat; let ReleaseAtCycles = Res; let NumMicroOps = UOps; } // Memory variant also uses 2 cycles on JLAGU and adds 5 cycles to the // latency. def : WriteRes { let Latency = !add(Lat, 5); let ReleaseAtCycles = !listconcat([2], Res); let NumMicroOps = !add(UOps, LoadUOps); } } // Instructions that have local forwarding disabled have an extra +1cy latency. // A folded store needs a cycle on the SAGU for the store data, most RMW // instructions don't need an extra uop. ALU RMW operations don't seem to // benefit from STLF, and their observed latency is 6cy. That is the reason why // this write adds two extra cycles (instead of just 1cy for the store). defm : X86WriteRes; //////////////////////////////////////////////////////////////////////////////// // Arithmetic. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResIntPair; defm : JWriteResIntPair; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; // Conditional move. defm : X86WriteRes; // x87 conditional move. def : WriteRes; // Setcc. def : WriteRes; def : WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; // This is for simple LEAs with one or two input operands. def : WriteRes; // Bit counts. defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; // BMI1 BEXTR/BLS, BMI2 BZHI defm : JWriteResIntPair; defm : JWriteResIntPair; defm : X86WriteResPairUnsupported; //////////////////////////////////////////////////////////////////////////////// // Integer shifts and rotates. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; defm : JWriteResIntPair; // SHLD/SHRD. defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; //////////////////////////////////////////////////////////////////////////////// // Loads, stores, and moves, not folded with other operations. //////////////////////////////////////////////////////////////////////////////// def : WriteRes { let Latency = 3; } def : WriteRes; def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; // Load/store MXCSR. def : WriteRes { let Latency = 3; } def : WriteRes; // Treat misc copies as a move. def : InstRW<[WriteMove], (instrs COPY)>; //////////////////////////////////////////////////////////////////////////////// // Idioms that clear a register, like xorps %xmm0, %xmm0. // These can often bypass execution ports completely. //////////////////////////////////////////////////////////////////////////////// def : WriteRes; //////////////////////////////////////////////////////////////////////////////// // Branches don't produce values, so they have no latency, but they still // consume resources. Indirect branches can fold loads. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResIntPair; //////////////////////////////////////////////////////////////////////////////// // Special case scheduling classes. //////////////////////////////////////////////////////////////////////////////// def : WriteRes { let Latency = 100; } def : WriteRes { let Latency = 100; } def : WriteRes; // Nops don't have dependencies, so there's no actual latency, but we set this // to '1' to tell the scheduler that the nop uses an ALU slot for a cycle. def : WriteRes { let Latency = 1; } def JWriteCMPXCHG8rr : SchedWriteRes<[JALU01]> { let Latency = 3; let ReleaseAtCycles = [3]; let NumMicroOps = 3; } def JWriteLOCK_CMPXCHG8rm : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 16; let ReleaseAtCycles = [3,16,16]; let NumMicroOps = 5; } def JWriteLOCK_CMPXCHGrm : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 17; let ReleaseAtCycles = [3,17,17]; let NumMicroOps = 6; } def JWriteCMPXCHG8rm : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 11; let ReleaseAtCycles = [3,1,1]; let NumMicroOps = 5; } def JWriteCMPXCHG8B : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 11; let ReleaseAtCycles = [3,1,1]; let NumMicroOps = 18; } def JWriteCMPXCHG16B : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 32; let ReleaseAtCycles = [6,1,1]; let NumMicroOps = 28; } def JWriteLOCK_CMPXCHG8B : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 19; let ReleaseAtCycles = [3,19,19]; let NumMicroOps = 18; } def JWriteLOCK_CMPXCHG16B : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 38; let ReleaseAtCycles = [6,38,38]; let NumMicroOps = 28; } def JWriteCMPXCHGVariant : SchedWriteVariant<[ SchedVar, [JWriteLOCK_CMPXCHG8B]>, SchedVar, [JWriteLOCK_CMPXCHG16B]>, SchedVar, [JWriteLOCK_CMPXCHG8rm]>, SchedVar, [JWriteLOCK_CMPXCHGrm]>, SchedVar, [JWriteCMPXCHG8B]>, SchedVar, [JWriteCMPXCHG16B]>, SchedVar, [JWriteCMPXCHG8rm]>, SchedVar, [WriteCMPXCHGRMW]>, SchedVar, [JWriteCMPXCHG8rr]>, SchedVar ]>; // The first five reads are contributed by the memory load operand. // We ignore those reads and set a read-advance for the other input operands // including the implicit read of RAX. def : InstRW<[JWriteCMPXCHGVariant, ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadAfterLd, ReadAfterLd], (instrs LCMPXCHG8, LCMPXCHG16, LCMPXCHG32, LCMPXCHG64, CMPXCHG8rm, CMPXCHG16rm, CMPXCHG32rm, CMPXCHG64rm)>; def : InstRW<[JWriteCMPXCHGVariant], (instrs CMPXCHG8rr, CMPXCHG16rr, CMPXCHG32rr, CMPXCHG64rr)>; def : InstRW<[JWriteCMPXCHGVariant, // Ignore reads contributed by the memory operand. ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault, // Add a read-advance to every implicit register read. ReadAfterLd, ReadAfterLd, ReadAfterLd, ReadAfterLd], (instrs LCMPXCHG8B, LCMPXCHG16B, CMPXCHG8B, CMPXCHG16B)>; def JWriteLOCK_ALURMW : SchedWriteRes<[JALU01, JLAGU, JSAGU]> { let Latency = 19; let ReleaseAtCycles = [1,19,19]; let NumMicroOps = 1; } def JWriteLOCK_ALURMWVariant : SchedWriteVariant<[ SchedVar, [JWriteLOCK_ALURMW]>, SchedVar ]>; def : InstRW<[JWriteLOCK_ALURMWVariant], (instrs INC8m, INC16m, INC32m, INC64m, DEC8m, DEC16m, DEC32m, DEC64m, NOT8m, NOT16m, NOT32m, NOT64m, NEG8m, NEG16m, NEG32m, NEG64m)>; def JWriteXCHG8rr_XADDrr : SchedWriteRes<[JALU01]> { let Latency = 2; let ReleaseAtCycles = [3]; let NumMicroOps = 3; } def : InstRW<[JWriteXCHG8rr_XADDrr], (instrs XCHG8rr, XADD8rr, XADD16rr, XADD32rr, XADD64rr)>; // This write defines the latency of the in/out register operand of a non-atomic // XADDrm. This is the first of a pair of writes that model non-atomic // XADDrm instructions (the second write definition is JWriteXADDrm_LdSt_Part). // // We need two writes because the instruction latency differs from the output // register operand latency. In particular, the first write describes the first // (and only) output register operand of the instruction. However, the // instruction latency is set to the MAX of all the write latencies. That's why // a second write is needed in this case (see example below). // // Example: // XADD %ecx, (%rsp) ## Instruction latency: 11cy // ## ECX write Latency: 3cy // // Register ECX becomes available in 3 cycles. That is because the value of ECX // is exchanged with the value read from the stack pointer, and the load-to-use // latency is assumed to be 3cy. def JWriteXADDrm_XCHG_Part : SchedWriteRes<[JALU01]> { let Latency = 3; // load-to-use latency let ReleaseAtCycles = [3]; let NumMicroOps = 3; } // This write defines the latency of the in/out register operand of an atomic // XADDrm. This is the first of a sequence of two writes used to model atomic // XADD instructions. The second write of the sequence is JWriteXCHGrm_LdSt_Part. // // // Example: // LOCK XADD %ecx, (%rsp) ## Instruction Latency: 16cy // ## ECX write Latency: 11cy // // The value of ECX becomes available only after 11cy from the start of // execution. This write is used to specifically set that operand latency. def JWriteLOCK_XADDrm_XCHG_Part : SchedWriteRes<[JALU01]> { let Latency = 11; let ReleaseAtCycles = [3]; let NumMicroOps = 3; } // This write defines the latency of the in/out register operand of an atomic // XCHGrm. This write is the first of a sequence of two writes that describe // atomic XCHG operations. We need two writes because the instruction latency // differs from the output register write latency. We want to make sure that // the output register operand becomes visible after 11cy. However, we want to // set the instruction latency to 16cy. def JWriteXCHGrm_XCHG_Part : SchedWriteRes<[JALU01]> { let Latency = 11; let ReleaseAtCycles = [2]; let NumMicroOps = 2; } def JWriteXADDrm_LdSt_Part : SchedWriteRes<[JLAGU, JSAGU]> { let Latency = 11; let ReleaseAtCycles = [1, 1]; let NumMicroOps = 1; } def JWriteXCHGrm_LdSt_Part : SchedWriteRes<[JLAGU, JSAGU]> { let Latency = 16; let ReleaseAtCycles = [16, 16]; let NumMicroOps = 1; } def JWriteXADDrm_Part1 : SchedWriteVariant<[ SchedVar, [JWriteLOCK_XADDrm_XCHG_Part]>, SchedVar ]>; def JWriteXADDrm_Part2 : SchedWriteVariant<[ SchedVar, [JWriteXCHGrm_LdSt_Part]>, SchedVar ]>; def : InstRW<[JWriteXADDrm_Part1, JWriteXADDrm_Part2, ReadAfterLd], (instrs XADD8rm, XADD16rm, XADD32rm, XADD64rm, LXADD8, LXADD16, LXADD32, LXADD64)>; def : InstRW<[JWriteXCHGrm_XCHG_Part, JWriteXCHGrm_LdSt_Part, ReadAfterLd], (instrs XCHG8rm, XCHG16rm, XCHG32rm, XCHG64rm)>; //////////////////////////////////////////////////////////////////////////////// // Floating point. This covers both scalar and vector 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 : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteResUnsupported; defm : X86WriteRes; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; // +1cy latency. defm : JWriteResYMMPair; // +1cy latency. defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; //////////////////////////////////////////////////////////////////////////////// // Conversions. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteResUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteResUnsupported; //////////////////////////////////////////////////////////////////////////////// // Vector integer 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 : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteResUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; // +1cy latency. defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; // +1cy latency. defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : JWriteResFpuPair; defm : JWriteResYMMPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; //////////////////////////////////////////////////////////////////////////////// // Vector insert/extract operations. //////////////////////////////////////////////////////////////////////////////// defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; //////////////////////////////////////////////////////////////////////////////// // SSE42 String instructions. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; //////////////////////////////////////////////////////////////////////////////// // MOVMSK Instructions. //////////////////////////////////////////////////////////////////////////////// def : WriteRes { let Latency = 3; } def : WriteRes { let Latency = 3; } defm : X86WriteResUnsupported; def : WriteRes { let Latency = 3; } //////////////////////////////////////////////////////////////////////////////// // AES Instructions. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResFpuPair; defm : JWriteResFpuPair; defm : JWriteResFpuPair; //////////////////////////////////////////////////////////////////////////////// // Horizontal add/sub instructions. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResFpuPair; // +1cy latency. defm : JWriteResYMMPair; // +1cy latency. defm : JWriteResFpuPair; defm : JWriteResFpuPair; // +1cy latency. defm : X86WriteResPairUnsupported; //////////////////////////////////////////////////////////////////////////////// // Carry-less multiplication instructions. //////////////////////////////////////////////////////////////////////////////// defm : JWriteResFpuPair; //////////////////////////////////////////////////////////////////////////////// // SSE4A instructions. //////////////////////////////////////////////////////////////////////////////// def JWriteINSERTQ: SchedWriteRes<[JFPU01, JVALU]> { let Latency = 2; let ReleaseAtCycles = [1, 4]; } def : InstRW<[JWriteINSERTQ], (instrs INSERTQ, INSERTQI)>; //////////////////////////////////////////////////////////////////////////////// // AVX instructions. //////////////////////////////////////////////////////////////////////////////// def JWriteVecExtractF128: SchedWriteRes<[JFPU01, JFPX]>; def : InstRW<[JWriteVecExtractF128], (instrs VEXTRACTF128rr)>; def JWriteVBROADCASTYLd: SchedWriteRes<[JLAGU, JFPU01, JFPX]> { let Latency = 6; let ReleaseAtCycles = [1, 2, 4]; let NumMicroOps = 2; } def : InstRW<[JWriteVBROADCASTYLd], (instrs VBROADCASTSDYrm, VBROADCASTSSYrm, VBROADCASTF128rm)>; def JWriteJVZEROALL: SchedWriteRes<[]> { let Latency = 90; let NumMicroOps = 73; } def : InstRW<[JWriteJVZEROALL], (instrs VZEROALL)>; def JWriteJVZEROUPPER: SchedWriteRes<[]> { let Latency = 46; let NumMicroOps = 37; } def : InstRW<[JWriteJVZEROUPPER], (instrs VZEROUPPER)>; /////////////////////////////////////////////////////////////////////////////// // SSE2/AVX Store Selected Bytes of Double Quadword - (V)MASKMOVDQ /////////////////////////////////////////////////////////////////////////////// def JWriteMASKMOVDQU: SchedWriteRes<[JFPU0, JFPA, JFPU1, JSTC, JLAGU, JSAGU, JALU01]> { let Latency = 34; let ReleaseAtCycles = [1, 1, 2, 2, 2, 16, 42]; let NumMicroOps = 63; } def : InstRW<[JWriteMASKMOVDQU], (instrs MASKMOVDQU, MASKMOVDQU64, VMASKMOVDQU, VMASKMOVDQU64)>; /////////////////////////////////////////////////////////////////////////////// // SchedWriteVariant definitions. /////////////////////////////////////////////////////////////////////////////// def JWriteZeroLatency : SchedWriteRes<[]> { let Latency = 0; } def JWriteZeroIdiomYmm : SchedWriteRes<[JFPU01, JFPX]> { let NumMicroOps = 2; } // Certain instructions that use the same register for both source // operands do not have a real dependency on the previous contents of the // register, and thus, do not have to wait before completing. They can be // optimized out at register renaming stage. // Reference: Section 10.8 of the "Software Optimization Guide for AMD Family // 15h Processors". // Reference: Agner's Fog "The microarchitecture of Intel, AMD and VIA CPUs", // Section 21.8 [Dependency-breaking instructions]. def JWriteZeroIdiom : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar ]>; def : InstRW<[JWriteZeroIdiom], (instrs SUB32rr, SUB64rr, XOR32rr, XOR64rr)>; def JWriteFZeroIdiom : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar ]>; def : InstRW<[JWriteFZeroIdiom], (instrs XORPSrr, VXORPSrr, XORPDrr, VXORPDrr, ANDNPSrr, VANDNPSrr, ANDNPDrr, VANDNPDrr)>; def JWriteFZeroIdiomY : SchedWriteVariant<[ SchedVar, [JWriteZeroIdiomYmm]>, SchedVar ]>; def : InstRW<[JWriteFZeroIdiomY], (instrs VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr)>; def JWriteVZeroIdiomLogic : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar ]>; def : InstRW<[JWriteVZeroIdiomLogic], (instrs MMX_PXORrr, MMX_PANDNrr)>; def JWriteVZeroIdiomLogicX : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar ]>; def : InstRW<[JWriteVZeroIdiomLogicX], (instrs PXORrr, VPXORrr, PANDNrr, VPANDNrr)>; def JWriteVZeroIdiomALU : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar ]>; def : InstRW<[JWriteVZeroIdiomALU], (instrs MMX_PSUBBrr, MMX_PSUBDrr, MMX_PSUBQrr, MMX_PSUBWrr, MMX_PSUBSBrr, MMX_PSUBSWrr, MMX_PSUBUSBrr, MMX_PSUBUSWrr, MMX_PCMPGTBrr, MMX_PCMPGTDrr, MMX_PCMPGTWrr)>; def JWriteVZeroIdiomALUX : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar ]>; def : InstRW<[JWriteVZeroIdiomALUX], (instrs PSUBBrr, VPSUBBrr, PSUBDrr, VPSUBDrr, PSUBQrr, VPSUBQrr, PSUBWrr, VPSUBWrr, PSUBSBrr, VPSUBSBrr, PSUBSWrr, VPSUBSWrr, PSUBUSBrr, VPSUBUSBrr, PSUBUSWrr, VPSUBUSWrr, PCMPGTBrr, VPCMPGTBrr, PCMPGTDrr, VPCMPGTDrr, PCMPGTQrr, VPCMPGTQrr, PCMPGTWrr, VPCMPGTWrr)>; def JWriteVPERM2F128 : SchedWriteVariant<[ SchedVar, [JWriteZeroIdiomYmm]>, SchedVar ]>; def : InstRW<[JWriteVPERM2F128], (instrs VPERM2F128rr)>; // This write is used for slow LEA instructions. def JWrite3OpsLEA : SchedWriteRes<[JALU1, JSAGU]> { let Latency = 2; } // On Jaguar, a slow LEA is either a 3Ops LEA (base, index, offset), or an LEA // with a `Scale` value different than 1. def JSlowLEAPredicate : MCSchedPredicate< CheckAny<[ // A 3-operand LEA (base, index, offset). IsThreeOperandsLEAFn, // An LEA with a "Scale" different than 1. CheckAll<[ CheckIsImmOperand<2>, CheckNot> ]> ]> >; def JWriteLEA : SchedWriteVariant<[ SchedVar, SchedVar ]>; def : InstRW<[JWriteLEA], (instrs LEA32r, LEA64r, LEA64_32r)>; def JSlowLEA16r : SchedWriteRes<[JALU01]> { let Latency = 3; let ReleaseAtCycles = [4]; } def : InstRW<[JSlowLEA16r], (instrs LEA16r)>; /////////////////////////////////////////////////////////////////////////////// // 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, PSUBSBrr, PSUBSWrr, PSUBUSBrr, PSUBUSWrr, PCMPGTBrr, PCMPGTDrr, PCMPGTQrr, PCMPGTWrr ], ZeroIdiomPredicate>, // AVX Zero-idioms. DepBreakingClass<[ // xmm fp variants. VXORPSrr, VXORPDrr, VANDNPSrr, VANDNPDrr, // xmm int variants. VPXORrr, VPANDNrr, VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr, VPSUBSBrr, VPSUBSWrr, VPSUBUSBrr, VPSUBUSWrr, VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr, // ymm variants. VXORPSYrr, VXORPDYrr, VANDNPSYrr, VANDNPDYrr ], ZeroIdiomPredicate>, DepBreakingClass<[ VPERM2F128rr ], ZeroIdiomVPERMPredicate> ]>; def : IsDepBreakingFunction<[ // GPR DepBreakingClass<[ SBB32rr, SBB64rr ], ZeroIdiomPredicate>, DepBreakingClass<[ CMP32rr, CMP64rr ], CheckSameRegOperand<0, 1> >, // MMX DepBreakingClass<[ MMX_PCMPEQBrr, MMX_PCMPEQDrr, MMX_PCMPEQWrr ], ZeroIdiomPredicate>, // SSE DepBreakingClass<[ PCMPEQBrr, PCMPEQWrr, PCMPEQDrr, PCMPEQQrr ], ZeroIdiomPredicate>, // AVX DepBreakingClass<[ VPCMPEQBrr, VPCMPEQWrr, VPCMPEQDrr, VPCMPEQQrr ], ZeroIdiomPredicate> ]>; def : IsOptimizableRegisterMove<[ InstructionEquivalenceClass<[ // GPR variants. MOV32rr, MOV64rr, // MMX variants. MMX_MOVQ64rr, // SSE variants. MOVAPSrr, MOVUPSrr, MOVAPDrr, MOVUPDrr, MOVDQArr, MOVDQUrr, // AVX variants. VMOVAPSrr, VMOVUPSrr, VMOVAPDrr, VMOVUPDrr, VMOVDQArr, VMOVDQUrr ], TruePred > ]>; } // SchedModel