forked from OSchip/llvm-project
227 lines
8.0 KiB
TableGen
227 lines
8.0 KiB
TableGen
//==- RISCVSchedRocket32.td - Rocket Scheduling Definitions -*- 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ===---------------------------------------------------------------------===//
|
|
// The following definitions describe the simpler per-operand machine model.
|
|
// This works with MachineScheduler. See MCSchedule.h for details.
|
|
|
|
// Rocket machine model for scheduling and other instruction cost heuristics.
|
|
def Rocket32Model : SchedMachineModel {
|
|
let MicroOpBufferSize = 0; // Explicitly set to zero since Rocket is in-order.
|
|
let IssueWidth = 1; // 1 micro-ops are dispatched per cycle.
|
|
let LoadLatency = 3;
|
|
let MispredictPenalty = 3;
|
|
let CompleteModel = 1;
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Define each kind of processor resource and number available.
|
|
|
|
// Modeling each pipeline as a ProcResource using the BufferSize = 0 since
|
|
// Rocket is in-order.
|
|
|
|
let BufferSize = 0 in {
|
|
def Rocket32UnitALU : ProcResource<1>; // Int ALU
|
|
def Rocket32UnitIMul : ProcResource<1>; // Int Multiply
|
|
def Rocket32UnitMem : ProcResource<1>; // Load/Store
|
|
def Rocket32UnitB : ProcResource<1>; // Branch
|
|
|
|
def Rocket32UnitFPALU : ProcResource<1>; // FP ALU
|
|
}
|
|
|
|
let BufferSize = 1 in {
|
|
def Rocket32UnitIDiv : ProcResource<1>; // Int Division
|
|
def Rocket32UnitFPDivSqrt : ProcResource<1>; // FP Divide/Sqrt'
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Subtarget-specific SchedWrite types which both map the ProcResources and
|
|
// set the latency.
|
|
|
|
let SchedModel = Rocket32Model in {
|
|
|
|
def : WriteRes<WriteJmp, [Rocket32UnitB]>;
|
|
def : WriteRes<WriteJal, [Rocket32UnitB]>;
|
|
def : WriteRes<WriteJalr, [Rocket32UnitB]>;
|
|
def : WriteRes<WriteJmpReg, [Rocket32UnitB]>;
|
|
|
|
def : WriteRes<WriteIALU, [Rocket32UnitALU]>;
|
|
def : WriteRes<WriteShift, [Rocket32UnitALU]>;
|
|
|
|
// Multiplies on Rocket differ by implementation; placeholder until
|
|
// we can determine how to read from command line
|
|
def : WriteRes<WriteIMul, [Rocket32UnitIMul]> { let Latency = 4; }
|
|
|
|
// 32-bit divides have worse case latency of 34 cycle
|
|
def : WriteRes<WriteIDiv, [Rocket32UnitIDiv]> {
|
|
let Latency = 34;
|
|
let ResourceCycles = [34];
|
|
}
|
|
|
|
// Memory
|
|
def : WriteRes<WriteSTB, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteSTH, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteSTW, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteFST32, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteFST64, [Rocket32UnitMem]>;
|
|
|
|
let Latency = 3 in {
|
|
def : WriteRes<WriteLDB, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteLDH, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteCSR, [Rocket32UnitALU]>;
|
|
}
|
|
|
|
let Latency = 2 in {
|
|
def : WriteRes<WriteLDW, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteFLD32, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteFLD64, [Rocket32UnitMem]>;
|
|
|
|
def : WriteRes<WriteAtomicW, [Rocket32UnitMem]>;
|
|
def : WriteRes<WriteAtomicLDW, [Rocket32UnitMem]>;
|
|
}
|
|
|
|
def : WriteRes<WriteAtomicSTW, [Rocket32UnitMem]>;
|
|
|
|
// Most FP single precision operations are 4 cycles
|
|
let Latency = 4 in {
|
|
def : WriteRes<WriteFALU32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFSGNJ32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMinMax32, [Rocket32UnitFPALU]>;
|
|
}
|
|
|
|
// Most FP double precision operations are 6 cycles
|
|
let Latency = 6 in {
|
|
def : WriteRes<WriteFALU64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFSGNJ64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMinMax64, [Rocket32UnitFPALU]>;
|
|
}
|
|
|
|
let Latency = 2 in {
|
|
def : WriteRes<WriteFCvtI32ToF32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCvtI32ToF64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCvtF32ToI32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCvtF64ToI32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCvtF32ToF64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCvtF64ToF32, [Rocket32UnitFPALU]>;
|
|
|
|
def : WriteRes<WriteFClass32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFClass64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCmp32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFCmp64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMovF32ToI32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMovI32ToF32, [Rocket32UnitFPALU]>;
|
|
}
|
|
|
|
let Latency = 5 in {
|
|
def : WriteRes<WriteFMul32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMulAdd32, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMulSub32, [Rocket32UnitFPALU]>;
|
|
}
|
|
|
|
let Latency = 7 in {
|
|
def : WriteRes<WriteFMul64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMulAdd64, [Rocket32UnitFPALU]>;
|
|
def : WriteRes<WriteFMulSub64, [Rocket32UnitFPALU]>;
|
|
}
|
|
|
|
// FP Divide unit on Rocket is not pipelined, so set resource cycles to latency
|
|
let Latency = 20, ResourceCycles = [20] in {
|
|
def : WriteRes<WriteFDiv32, [Rocket32UnitFPDivSqrt]>;
|
|
def : WriteRes<WriteFDiv64, [Rocket32UnitFPDivSqrt]>;
|
|
}
|
|
|
|
// FP Sqrt unit on Rocket is not pipelined, so set resource cycles to latency
|
|
def : WriteRes<WriteFSqrt32, [Rocket32UnitFPDivSqrt]> { let Latency = 20;
|
|
let ResourceCycles = [20];}
|
|
def : WriteRes<WriteFSqrt64, [Rocket32UnitFPDivSqrt]> { let Latency = 25;
|
|
let ResourceCycles = [25];}
|
|
|
|
def : WriteRes<WriteNop, []>;
|
|
|
|
def : InstRW<[WriteIALU], (instrs COPY)>;
|
|
|
|
let Unsupported = 1 in {
|
|
def : WriteRes<WriteIALU32, []>;
|
|
def : WriteRes<WriteShift32, []>;
|
|
def : WriteRes<WriteIMul32, []>;
|
|
def : WriteRes<WriteIDiv32, []>;
|
|
def : WriteRes<WriteSTD, []>;
|
|
def : WriteRes<WriteLDWU, []>;
|
|
def : WriteRes<WriteLDD, []>;
|
|
def : WriteRes<WriteAtomicD, []>;
|
|
def : WriteRes<WriteAtomicLDD, []>;
|
|
def : WriteRes<WriteAtomicSTD, []>;
|
|
def : WriteRes<WriteFCvtI64ToF32, []>;
|
|
def : WriteRes<WriteFCvtI64ToF64, []>;
|
|
def : WriteRes<WriteFCvtF64ToI64, []>;
|
|
def : WriteRes<WriteFCvtF32ToI64, []>;
|
|
def : WriteRes<WriteFMovI64ToF64, []>;
|
|
def : WriteRes<WriteFMovF64ToI64, []>;
|
|
}
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Subtarget-specific SchedRead types with cycles.
|
|
// Dummy definitions for RocketCore.
|
|
def : ReadAdvance<ReadJmp, 0>;
|
|
def : ReadAdvance<ReadJalr, 0>;
|
|
def : ReadAdvance<ReadCSR, 0>;
|
|
def : ReadAdvance<ReadStoreData, 0>;
|
|
def : ReadAdvance<ReadMemBase, 0>;
|
|
def : ReadAdvance<ReadIALU, 0>;
|
|
def : ReadAdvance<ReadIALU32, 0>;
|
|
def : ReadAdvance<ReadShift, 0>;
|
|
def : ReadAdvance<ReadShift32, 0>;
|
|
def : ReadAdvance<ReadIDiv, 0>;
|
|
def : ReadAdvance<ReadIDiv32, 0>;
|
|
def : ReadAdvance<ReadIMul, 0>;
|
|
def : ReadAdvance<ReadIMul32, 0>;
|
|
def : ReadAdvance<ReadAtomicWA, 0>;
|
|
def : ReadAdvance<ReadAtomicWD, 0>;
|
|
def : ReadAdvance<ReadAtomicDA, 0>;
|
|
def : ReadAdvance<ReadAtomicDD, 0>;
|
|
def : ReadAdvance<ReadAtomicLDW, 0>;
|
|
def : ReadAdvance<ReadAtomicLDD, 0>;
|
|
def : ReadAdvance<ReadAtomicSTW, 0>;
|
|
def : ReadAdvance<ReadAtomicSTD, 0>;
|
|
def : ReadAdvance<ReadFMemBase, 0>;
|
|
def : ReadAdvance<ReadFALU32, 0>;
|
|
def : ReadAdvance<ReadFALU64, 0>;
|
|
def : ReadAdvance<ReadFMul32, 0>;
|
|
def : ReadAdvance<ReadFMulAdd32, 0>;
|
|
def : ReadAdvance<ReadFMulSub32, 0>;
|
|
def : ReadAdvance<ReadFMul64, 0>;
|
|
def : ReadAdvance<ReadFMulAdd64, 0>;
|
|
def : ReadAdvance<ReadFMulSub64, 0>;
|
|
def : ReadAdvance<ReadFDiv32, 0>;
|
|
def : ReadAdvance<ReadFDiv64, 0>;
|
|
def : ReadAdvance<ReadFSqrt32, 0>;
|
|
def : ReadAdvance<ReadFSqrt64, 0>;
|
|
def : ReadAdvance<ReadFCmp32, 0>;
|
|
def : ReadAdvance<ReadFCmp64, 0>;
|
|
def : ReadAdvance<ReadFSGNJ32, 0>;
|
|
def : ReadAdvance<ReadFSGNJ64, 0>;
|
|
def : ReadAdvance<ReadFMinMax32, 0>;
|
|
def : ReadAdvance<ReadFMinMax64, 0>;
|
|
def : ReadAdvance<ReadFCvtF32ToI32, 0>;
|
|
def : ReadAdvance<ReadFCvtF32ToI64, 0>;
|
|
def : ReadAdvance<ReadFCvtF64ToI32, 0>;
|
|
def : ReadAdvance<ReadFCvtF64ToI64, 0>;
|
|
def : ReadAdvance<ReadFCvtI32ToF32, 0>;
|
|
def : ReadAdvance<ReadFCvtI32ToF64, 0>;
|
|
def : ReadAdvance<ReadFCvtI64ToF32, 0>;
|
|
def : ReadAdvance<ReadFCvtI64ToF64, 0>;
|
|
def : ReadAdvance<ReadFCvtF32ToF64, 0>;
|
|
def : ReadAdvance<ReadFCvtF64ToF32, 0>;
|
|
def : ReadAdvance<ReadFMovF32ToI32, 0>;
|
|
def : ReadAdvance<ReadFMovI32ToF32, 0>;
|
|
def : ReadAdvance<ReadFMovF64ToI64, 0>;
|
|
def : ReadAdvance<ReadFMovI64ToF64, 0>;
|
|
def : ReadAdvance<ReadFClass32, 0>;
|
|
def : ReadAdvance<ReadFClass64, 0>;
|
|
}
|