LLVM 20.0.0git
|
Machine model for scheduling, bundling, and heuristics. More...
#include "llvm/MC/MCSchedule.h"
Static Public Member Functions | |
static int | computeInstrLatency (const MCSubtargetInfo &STI, const MCSchedClassDesc &SCDesc) |
Returns the latency value for the scheduling class. | |
static double | getReciprocalThroughput (const MCSubtargetInfo &STI, const MCSchedClassDesc &SCDesc) |
static double | getReciprocalThroughput (unsigned SchedClass, const InstrItineraryData &IID) |
static unsigned | getForwardingDelayCycles (ArrayRef< MCReadAdvanceEntry > Entries, unsigned WriteResourceIdx=0) |
Returns the maximum forwarding delay for register reads dependent on writes of scheduling class WriteResourceIdx. | |
Static Public Attributes | |
static const unsigned | DefaultIssueWidth = 1 |
static const unsigned | DefaultMicroOpBufferSize = 0 |
static const unsigned | DefaultLoopMicroOpBufferSize = 0 |
static const unsigned | DefaultLoadLatency = 4 |
static const unsigned | DefaultHighLatency = 10 |
static const unsigned | DefaultMispredictPenalty = 10 |
static const MCSchedModel | Default |
Returns the default initialized model. | |
Friends | |
class | InstrItineraryData |
Machine model for scheduling, bundling, and heuristics.
The machine model directly provides basic information about the microarchitecture to the scheduler in the form of properties. It also optionally refers to scheduler resource tables and itinerary tables. Scheduler resource tables model the latency and cost for each instruction type. Itinerary tables are an independent mechanism that provides a detailed reservation table describing each cycle of instruction execution. Subtargets may define any or all of the above categories of data depending on the type of CPU and selected scheduler.
The machine independent properties defined here are used by the scheduler as an abstract machine model. A real micro-architecture has a number of buffers, queues, and stages. Declaring that a given machine-independent abstract property corresponds to a specific physical property across all subtargets can't be done. Nonetheless, the abstract model is useful. Futhermore, subtargets typically extend this model with processor specific resources to model any hardware features that can be exploited by scheduling heuristics and aren't sufficiently represented in the abstract.
The abstract pipeline is built around the notion of an "issue point". This is merely a reference point for counting machine cycles. The physical machine will have pipeline stages that delay execution. The scheduler does not model those delays because they are irrelevant as long as they are consistent. Inaccuracies arise when instructions have different execution delays relative to each other, in addition to their intrinsic latency. Those special cases can be handled by TableGen constructs such as, ReadAdvance, which reduces latency when reading data, and ReleaseAtCycles, which consumes a processor resource when writing data for a number of abstract cycles.
TODO: One tool currently missing is the ability to add a delay to ReleaseAtCycles. That would be easy to add and would likely cover all cases currently handled by the legacy itinerary tables.
A note on out-of-order execution and, more generally, instruction buffers. Part of the CPU pipeline is always in-order. The issue point, which is the point of reference for counting cycles, only makes sense as an in-order part of the pipeline. Other parts of the pipeline are sometimes falling behind and sometimes catching up. It's only interesting to model those other, decoupled parts of the pipeline if they may be predictably resource constrained in a way that the scheduler can exploit.
The LLVM machine model distinguishes between in-order constraints and out-of-order constraints so that the target's scheduling strategy can apply appropriate heuristics. For a well-balanced CPU pipeline, out-of-order resources would not typically be treated as a hard scheduling constraint. For example, in the GenericScheduler, a delay caused by limited out-of-order resources is not directly reflected in the number of cycles that the scheduler sees between issuing an instruction and its dependent instructions. In other words, out-of-order resources don't directly increase the latency between pairs of instructions. However, they can still be used to detect potential bottlenecks across a sequence of instructions and bias the scheduling heuristics appropriately.
Definition at line 256 of file MCSchedule.h.
int MCSchedModel::computeInstrLatency | ( | const MCSubtargetInfo & | STI, |
const MCInstrInfo & | MCII, | ||
const MCInst & | Inst | ||
) | const |
Definition at line 69 of file MCSchedule.cpp.
References assert(), computeInstrLatency(), getProcessorID(), getSchedClassDesc(), InstrItineraryData, and llvm::MCSubtargetInfo::resolveVariantSchedClass().
int llvm::MCSchedModel::computeInstrLatency | ( | const MCSubtargetInfo & | STI, |
const MCInstrInfo & | MCII, | ||
const MCInstOrMachineInstr & | Inst, | ||
llvm::function_ref< const MCSchedClassDesc *(const MCSchedClassDesc *)> | ResolveVariantSchedClass = [](const MCSchedClassDesc *SCDesc) { return SCDesc; } |
||
) | const |
Definition at line 415 of file MCSchedule.h.
References computeInstrLatency(), llvm::StringRef::empty(), llvm::MCInstrInfo::get(), llvm::MCSubtargetInfo::getCPU(), llvm::MCSubtargetInfo::getInstrItineraryForCPU(), llvm::InstrItineraryData::getOperandCycle(), llvm::MCInstrDesc::getSchedClass(), getSchedClassDesc(), hasInstrSchedModel(), Idx, llvm::MCSchedClassDesc::isValid(), and llvm::Latency.
|
static |
Returns the latency value for the scheduling class.
Definition at line 42 of file MCSchedule.cpp.
References llvm::MCWriteLatencyEntry::Cycles, llvm::MCSubtargetInfo::getWriteLatencyEntry(), llvm::Latency, and llvm::MCSchedClassDesc::NumWriteLatencyEntries.
Referenced by computeInstrLatency(), llvm::TargetSchedModel::computeInstrLatency(), llvm::mca::computeMaxLatency(), emitComments(), and emitLatency().
int MCSchedModel::computeInstrLatency | ( | const MCSubtargetInfo & | STI, |
unsigned | SClass | ||
) | const |
Definition at line 58 of file MCSchedule.cpp.
References computeInstrLatency(), getSchedClassDesc(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::isVariant(), and llvm_unreachable.
|
inline |
Definition at line 339 of file MCSchedule.h.
References assert(), ExtraProcessorInfo, and hasExtraProcessorInfo().
Referenced by llvm::mca::LSUnitBase::LSUnitBase(), and llvm::mca::RetireControlUnit::RetireControlUnit().
|
static |
Returns the maximum forwarding delay for register reads dependent on writes of scheduling class WriteResourceIdx.
Definition at line 163 of file MCSchedule.cpp.
|
inline |
Definition at line 352 of file MCSchedule.h.
References NumProcResourceKinds.
Referenced by llvm::ResourceManager::calculateResMII(), llvm::mca::computeBlockRThroughput(), llvm::mca::computeProcResourceMasks(), llvm::TargetSchedModel::getNumProcResourceKinds(), llvm::TargetSchedModel::init(), llvm::ResourceManager::init(), llvm::mca::initializeUsedResources(), llvm::ResourceManager::initProcResourceVectors(), llvm::mca::InstrBuilder::InstrBuilder(), and llvm::mca::ResourceManager::ResourceManager().
|
inline |
Definition at line 334 of file MCSchedule.h.
References ProcID.
Referenced by computeInstrLatency(), llvm::mca::InstrBuilder::createInstruction(), llvm::TargetSchedModel::getProcessorID(), and getReciprocalThroughput().
|
inline |
Definition at line 356 of file MCSchedule.h.
References assert(), hasInstrSchedModel(), NumProcResourceKinds, and ProcResourceTable.
Referenced by llvm::ResourceManager::calculateResMII(), llvm::mca::computeBlockRThroughput(), llvm::TargetSchedModel::computeOutputLatency(), llvm::mca::computeProcResourceMasks(), llvm::mca::InstructionTables::execute(), llvm::TargetSchedModel::getProcResource(), getReciprocalThroughput(), llvm::TargetSchedModel::getResourceBufferSize(), llvm::TargetSchedModel::getResourceName(), llvm::TargetSchedModel::init(), llvm::mca::initializeUsedResources(), llvm::ResourceManager::initProcResourceVectors(), llvm::mca::LSUnitBase::LSUnitBase(), and llvm::mca::ResourceManager::ResourceManager().
double MCSchedModel::getReciprocalThroughput | ( | const MCSubtargetInfo & | STI, |
const MCInstrInfo & | MCII, | ||
const MCInst & | Inst | ||
) | const |
Definition at line 119 of file MCSchedule.cpp.
References llvm::MCInstrInfo::get(), llvm::MCInst::getOpcode(), getProcessorID(), getReciprocalThroughput(), llvm::MCInstrDesc::getSchedClass(), getSchedClassDesc(), IssueWidth, llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::isVariant(), llvm_unreachable, and llvm::MCSubtargetInfo::resolveVariantSchedClass().
|
static |
Definition at line 97 of file MCSchedule.cpp.
References getProcResource(), llvm::MCSubtargetInfo::getSchedModel(), llvm::MCSubtargetInfo::getWriteProcResBegin(), llvm::MCSubtargetInfo::getWriteProcResEnd(), I, IssueWidth, llvm::MCSchedClassDesc::NumMicroOps, and llvm::MCProcResourceDesc::NumUnits.
Referenced by llvm::TargetSchedModel::computeReciprocalThroughput(), and getReciprocalThroughput().
|
static |
Definition at line 143 of file MCSchedule.cpp.
References llvm::InstrItineraryData::beginStage(), DefaultIssueWidth, llvm::InstrItineraryData::endStage(), I, and llvm::popcount().
|
inline |
Definition at line 363 of file MCSchedule.h.
References assert(), hasInstrSchedModel(), NumSchedClasses, and SchedClassTable.
Referenced by llvm::mca::RegisterFile::addRegisterRead(), llvm::mca::RegisterFile::checkRAWHazards(), llvm::mca::RegisterFile::collectWrites(), computeInstrLatency(), llvm::TargetSchedModel::computeReciprocalThroughput(), llvm::mca::InstrBuilder::createInstruction(), getReciprocalThroughput(), and llvm::TargetSchedModel::resolveSchedClass().
|
inline |
Definition at line 332 of file MCSchedule.h.
References ExtraProcessorInfo.
Referenced by getExtraProcessorInfo(), llvm::mca::LSUnitBase::LSUnitBase(), and llvm::mca::RetireControlUnit::RetireControlUnit().
|
inline |
Does this machine model include instruction-level scheduling.
Definition at line 337 of file MCSchedule.h.
References SchedClassTable.
Referenced by computeInstrLatency(), getProcResource(), getSchedClassDesc(), and llvm::TargetSchedModel::hasInstrSchedModel().
|
inline |
Return true if this machine model data for all instructions with a scheduling class (itinerary class or SchedRW list).
Definition at line 347 of file MCSchedule.h.
References CompleteModel.
Referenced by llvm::TargetSchedModel::computeOperandLatency().
|
inline |
Return true if machine supports out of order execution.
Definition at line 350 of file MCSchedule.h.
References MicroOpBufferSize.
Referenced by llvm::TargetSchedModel::computeOutputLatency(), llvm::mca::Context::createDefaultPipeline(), and llvm::mca::RetireControlUnit::RetireControlUnit().
|
friend |
Definition at line 327 of file MCSchedule.h.
Referenced by computeInstrLatency().
bool llvm::MCSchedModel::CompleteModel |
Definition at line 314 of file MCSchedule.h.
Referenced by isComplete().
|
static |
Returns the default initialized model.
Definition at line 406 of file MCSchedule.h.
Referenced by llvm::MCSubtargetInfo::getSchedModelForCPU(), and llvm::MCSubtargetInfo::InitMCProcessorInfo().
Definition at line 305 of file MCSchedule.h.
Definition at line 269 of file MCSchedule.h.
Referenced by getReciprocalThroughput().
Definition at line 298 of file MCSchedule.h.
Definition at line 294 of file MCSchedule.h.
Definition at line 286 of file MCSchedule.h.
Definition at line 310 of file MCSchedule.h.
bool llvm::MCSchedModel::EnableIntervals |
Definition at line 319 of file MCSchedule.h.
Referenced by llvm::TargetSchedModel::enableIntervals().
const MCExtraProcessorInfo* llvm::MCSchedModel::ExtraProcessorInfo |
Definition at line 330 of file MCSchedule.h.
Referenced by getExtraProcessorInfo(), and hasExtraProcessorInfo().
unsigned llvm::MCSchedModel::HighLatency |
Definition at line 304 of file MCSchedule.h.
Referenced by llvm::TargetInstrInfo::defaultDefLatency().
const InstrItinerary* llvm::MCSchedModel::InstrItineraries |
Definition at line 328 of file MCSchedule.h.
Referenced by llvm::HexagonMCInstrInfo::getCVIResources(), llvm::HexagonMCInstrInfo::getOtherReservedSlots(), and llvm::HexagonMCInstrInfo::getUnits().
unsigned llvm::MCSchedModel::IssueWidth |
Definition at line 268 of file MCSchedule.h.
Referenced by llvm::mca::DispatchStage::DispatchStage(), llvm::TargetSchedModel::getIssueWidth(), llvm::mca::InOrderIssueStage::getIssueWidth(), getReciprocalThroughput(), llvm::TargetSchedModel::init(), llvm::ResourcePriorityQueue::reserveResources(), and llvm::ScoreboardHazardRecognizer::ScoreboardHazardRecognizer().
unsigned llvm::MCSchedModel::LoadLatency |
Definition at line 297 of file MCSchedule.h.
Referenced by llvm::TargetInstrInfo::defaultDefLatency().
unsigned llvm::MCSchedModel::LoopMicroOpBufferSize |
Definition at line 293 of file MCSchedule.h.
unsigned llvm::MCSchedModel::MicroOpBufferSize |
Definition at line 285 of file MCSchedule.h.
Referenced by llvm::TargetSchedModel::getMicroOpBufferSize(), and isOutOfOrder().
unsigned llvm::MCSchedModel::MispredictPenalty |
Definition at line 309 of file MCSchedule.h.
Referenced by llvm::ARMSubtarget::getMispredictionPenalty().
unsigned llvm::MCSchedModel::NumProcResourceKinds |
Definition at line 324 of file MCSchedule.h.
Referenced by getNumProcResourceKinds(), and getProcResource().
unsigned llvm::MCSchedModel::NumSchedClasses |
Definition at line 325 of file MCSchedule.h.
Referenced by getSchedClassDesc().
bool llvm::MCSchedModel::PostRAScheduler |
Definition at line 312 of file MCSchedule.h.
Referenced by llvm::TargetSubtargetInfo::enablePostRAScheduler().
unsigned llvm::MCSchedModel::ProcID |
Definition at line 321 of file MCSchedule.h.
Referenced by getProcessorID().
const MCProcResourceDesc* llvm::MCSchedModel::ProcResourceTable |
Definition at line 322 of file MCSchedule.h.
Referenced by getProcResource().
const MCSchedClassDesc* llvm::MCSchedModel::SchedClassTable |
Definition at line 323 of file MCSchedule.h.
Referenced by getSchedClassDesc(), and hasInstrSchedModel().