//=- X86ScheduleSLM.td - X86 Silvermont 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 Intel Silvermont to support // instruction scheduling and other instruction cost heuristics. // //===----------------------------------------------------------------------===// def SLMModel : SchedMachineModel { // All x86 instructions are modeled as a single micro-op, and SLM can decode 2 // instructions per cycle. let IssueWidth = 2; let MicroOpBufferSize = 32; // Based on the reorder buffer. let LoadLatency = 3; let MispredictPenalty = 10; let PostRAScheduler = 1; // For small loops, expand by a small factor to hide the backedge cost. let LoopMicroOpBufferSize = 10; // FIXME: SSE4 is unimplemented. This flag is set to allow // the scheduler to assign a default model to unrecognized opcodes. let CompleteModel = 0; } let SchedModel = SLMModel in { // Silvermont has 5 reservation stations for micro-ops def SLM_IEC_RSV0 : ProcResource<1>; def SLM_IEC_RSV1 : ProcResource<1>; def SLM_FPC_RSV0 : ProcResource<1> { let BufferSize = 1; } def SLM_FPC_RSV1 : ProcResource<1> { let BufferSize = 1; } def SLM_MEC_RSV : ProcResource<1>; // Many micro-ops are capable of issuing on multiple ports. def SLM_IEC_RSV01 : ProcResGroup<[SLM_IEC_RSV0, SLM_IEC_RSV1]>; def SLM_FPC_RSV01 : ProcResGroup<[SLM_FPC_RSV0, SLM_FPC_RSV1]>; def SLMDivider : ProcResource<1>; def SLMFPMultiplier : ProcResource<1>; def SLMFPDivider : ProcResource<1>; // Loads are 3 cycles, so ReadAfterLd registers needn't be available until 3 // cycles after the memory operand. def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; def : ReadAdvance; 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 queued in the reservation station. // This multiclass defines the resource usage for variants with and without // folded loads. multiclass SLMWriteResPair ExePorts, int Lat, list Res = [1], int UOps = 1, int LoadUOps = 0, int LoadLat = 3> { // 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 MEC_RSV and adds LoadLat cycles to // the latency (default = 3). def : WriteRes { let Latency = !add(Lat, LoadLat); let ReleaseAtCycles = !listconcat([1], Res); let NumMicroOps = !add(UOps, LoadUOps); } } // A folded store needs a cycle on MEC_RSV for the store data (using the same uop), // but it does not need an extra port cycle to recompute the address. def : WriteRes { let NumMicroOps = 0; } def : WriteRes; def : WriteRes; def : WriteRes { let Latency = 3; } def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; // Load/store MXCSR. defm : X86WriteRes; defm : X86WriteRes; // Treat misc copies as a move. def : InstRW<[WriteMove], (instrs COPY)>; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteRes; // x87 conditional move. def : WriteRes; def : WriteRes { // FIXME Latency and NumMicrOps? let ReleaseAtCycles = [2,1]; } defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; // This is for simple LEAs with one or two input operands. // The complex ones can only execute on port 1, and they require two cycles on // the port to read all inputs. We don't model that. def : WriteRes; // Bit counts. defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; // BMI1 BEXTR/BLS, BMI2 BZHI defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; // Scalar and vector floating point. defm : X86WriteRes; defm : X86WriteRes; defm : X86WriteRes; def : WriteRes { let Latency = 3; } def : WriteRes { let Latency = 3; } defm : X86WriteResUnsupported; def : WriteRes { let Latency = 3; } defm : X86WriteResUnsupported; def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteRes; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; // Conversion between integer and float. defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; // Vector integer operations. def : WriteRes { let Latency = 3; } def : WriteRes { let Latency = 3; } defm : X86WriteResUnsupported; def : WriteRes { let Latency = 3; } defm : X86WriteResUnsupported; def : WriteRes { let Latency = 3; } defm : X86WriteResUnsupported; def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; defm : X86WriteResUnsupported; def : WriteRes; def : WriteRes; defm : X86WriteResUnsupported; defm : X86WriteResUnsupported; def : WriteRes; def : WriteRes; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; // Vector insert/extract operations. defm : SLMWriteResPair; def : WriteRes { let NumMicroOps = 2; } def : WriteRes { let Latency = 4; let NumMicroOps = 5; let ReleaseAtCycles = [1, 2]; } //////////////////////////////////////////////////////////////////////////////// // Horizontal add/sub instructions. //////////////////////////////////////////////////////////////////////////////// defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; defm : SLMWriteResPair; defm : SLMWriteResPair; defm : X86WriteResPairUnsupported; defm : X86WriteResPairUnsupported; // String instructions. // Packed Compare Implicit Length Strings, Return Mask defm : SLMWriteResPair; // Packed Compare Explicit Length Strings, Return Mask defm : SLMWriteResPair; // Packed Compare Implicit Length Strings, Return Index defm : SLMWriteResPair; // Packed Compare Explicit Length Strings, Return Index defm : SLMWriteResPair; // MOVMSK Instructions. def : WriteRes { let Latency = 4; } def : WriteRes { let Latency = 4; } def : WriteRes { let Latency = 4; } defm : X86WriteResUnsupported; // AES Instructions. defm : SLMWriteResPair; defm : SLMWriteResPair; defm : SLMWriteResPair; // Carry-less multiplication instructions. defm : SLMWriteResPair; def : WriteRes { let Latency = 100; } def : WriteRes { let Latency = 100; } def : WriteRes; def : WriteRes; // Remaining SLM instrs. def SLMWriteResGroup1rr : SchedWriteRes<[SLM_FPC_RSV01]> { let Latency = 4; let NumMicroOps = 2; let ReleaseAtCycles = [8]; } def: InstRW<[SLMWriteResGroup1rr], (instrs MMX_PADDQrr, PADDQrr, MMX_PSUBQrr, PSUBQrr, PCMPEQQrr)>; def SLMWriteResGroup2rr : SchedWriteRes<[SLM_FPC_RSV0]> { let Latency = 5; let NumMicroOps = 1; let ReleaseAtCycles = [2]; } def: InstRW<[SLMWriteResGroup2rr], (instrs PCMPGTQrr)>; def SLMWriteResGroup1rm : SchedWriteRes<[SLM_MEC_RSV,SLM_FPC_RSV01]> { let Latency = 7; let NumMicroOps = 3; let ReleaseAtCycles = [1,8]; } def: InstRW<[SLMWriteResGroup1rm], (instrs MMX_PADDQrm, PADDQrm, MMX_PSUBQrm, PSUBQrm, PCMPEQQrm)>; def SLMWriteResGroup2rm : SchedWriteRes<[SLM_MEC_RSV,SLM_FPC_RSV0]> { let Latency = 8; let NumMicroOps = 2; let ReleaseAtCycles = [1,2]; } def: InstRW<[SLMWriteResGroup2rm], (instrs PCMPGTQrm)>; /////////////////////////////////////////////////////////////////////////////// // Dependency breaking instructions. /////////////////////////////////////////////////////////////////////////////// def : IsZeroIdiomFunction<[ // GPR Zero-idioms. DepBreakingClass<[ XOR32rr ], ZeroIdiomPredicate>, // SSE Zero-idioms. DepBreakingClass<[ // fp variants. XORPSrr, XORPDrr, // int variants. PXORrr, ], ZeroIdiomPredicate>, ]>; } // SchedModel