|
LLVM 23.0.0git
|
Machine model for scheduling, bundling, and heuristics. More...
#include "llvm/MC/MCSchedule.h"
Static Public Member Functions | |
| static LLVM_ABI int | computeInstrLatency (const MCSubtargetInfo &STI, const MCSchedClassDesc &SCDesc) |
| Returns the latency value for the scheduling class. | |
| static LLVM_ABI double | getReciprocalThroughput (const MCSubtargetInfo &STI, const MCSchedClassDesc &SCDesc) |
| static LLVM_ABI double | getReciprocalThroughput (unsigned SchedClass, const InstrItineraryData &IID) |
| static LLVM_ABI unsigned | getForwardingDelayCycles (ArrayRef< MCReadAdvanceEntry > Entries, unsigned WriteResourceIdx=0) |
| Returns the maximum forwarding delay for register reads dependent on writes of scheduling class WriteResourceIdx. | |
| static LLVM_ABI unsigned | getBypassDelayCycles (const MCSubtargetInfo &STI, const MCSchedClassDesc &SCDesc) |
| Returns the bypass delay cycle for the maximum latency write cycle. | |
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 LLVM_ABI 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 264 of file MCSchedule.h.
| int MCSchedModel::computeInstrLatency | ( | const MCSubtargetInfo & | STI, |
| const MCInstrInfo & | MCII, | ||
| const MCInst & | Inst ) const |
Definition at line 86 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 444 of file MCSchedule.h.
References computeInstrLatency(), llvm::MCInstrInfo::get(), llvm::MCSubtargetInfo::getCPU(), llvm::MCSubtargetInfo::getInstrItineraryForCPU(), llvm::InstrItineraryData::getOperandCycle(), llvm::MCInstrDesc::getSchedClass(), getSchedClassDesc(), hasInstrSchedModel(), InstrItineraryData, llvm::MCSchedClassDesc::isValid(), and llvm::Latency.
|
static |
Returns the latency value for the scheduling class.
Definition at line 59 of file MCSchedule.cpp.
References llvm::MCWriteLatencyEntry::Cycles, llvm::MCSubtargetInfo::getWriteLatencyEntry(), llvm::Latency, and llvm::MCSchedClassDesc::NumWriteLatencyEntries.
Referenced by computeInstrLatency(), computeInstrLatency(), computeInstrLatency(), llvm::mca::computeMaxLatency(), emitComments(), and emitLatency().
| int MCSchedModel::computeInstrLatency | ( | const MCSubtargetInfo & | STI, |
| unsigned | SClass ) const |
Definition at line 75 of file MCSchedule.cpp.
References computeInstrLatency(), getSchedClassDesc(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::isVariant(), and llvm_unreachable.
|
static |
Returns the bypass delay cycle for the maximum latency write cycle.
Definition at line 198 of file MCSchedule.cpp.
References llvm::MCWriteLatencyEntry::Cycles, llvm::ArrayRef< T >::empty(), llvm::MCSubtargetInfo::getReadAdvanceEntries(), llvm::MCSubtargetInfo::getWriteLatencyEntry(), llvm::MCSchedClassDesc::NumWriteLatencyEntries, and llvm::MCWriteLatencyEntry::WriteResourceID.
|
inline |
Definition at line 348 of file MCSchedule.h.
References assert(), ExtraProcessorInfo, and hasExtraProcessorInfo().
|
static |
Returns the maximum forwarding delay for register reads dependent on writes of scheduling class WriteResourceIdx.
Definition at line 183 of file MCSchedule.cpp.
References llvm::ArrayRef< T >::empty().
|
inline |
Definition at line 361 of file MCSchedule.h.
References NumProcResourceKinds.
|
inline |
Definition at line 343 of file MCSchedule.h.
References ProcID.
Referenced by computeInstrLatency(), and getReciprocalThroughput().
|
inline |
Definition at line 365 of file MCSchedule.h.
References assert(), hasInstrSchedModel(), NumProcResourceKinds, and ProcResourceTable.
Referenced by getResourceBufferSize().
| double MCSchedModel::getReciprocalThroughput | ( | const MCSubtargetInfo & | STI, |
| const MCInstrInfo & | MCII, | ||
| const MCInst & | Inst ) const |
Definition at line 139 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 114 of file MCSchedule.cpp.
References assert(), llvm::MCSubtargetInfo::getSchedModel(), llvm::MCSubtargetInfo::getWriteProcResBegin(), llvm::MCSubtargetInfo::getWriteProcResEnd(), I, llvm::MCSchedClassDesc::NumMicroOps, and SM().
Referenced by llvm::TargetSchedModel::computeReciprocalThroughput(), llvm::TargetSchedModel::computeReciprocalThroughput(), getReciprocalThroughput(), and llvm::AArch64TTIImpl::hasKnownLowerThroughputFromSchedulingModel().
|
static |
Definition at line 163 of file MCSchedule.cpp.
References llvm::InstrItineraryData::beginStage(), DefaultIssueWidth, llvm::InstrItineraryData::endStage(), I, InstrItineraryData, and llvm::popcount().
| int MCSchedModel::getResourceBufferSize | ( | unsigned | ProcResourceIdx | ) | const |
Return the buffer size of the resource.
If a positive scale factor is provided and the original buffer size is > 1, the size is scaled accordingly.
Definition at line 235 of file MCSchedule.cpp.
References llvm::MCProcResourceDesc::BufferSize, llvm::APFloat::convertToInteger(), DefaultReservationStationScaleFactor, getProcResource(), llvm::APFloat::isNegative(), llvm::APFloat::isZero(), LLVM_LIKELY, llvm::APFloat::multiply(), llvm::APFloatBase::opInvalidOp, ReservationStationScaleFactor, llvm::APFloatBase::rmTowardZero, and Scaled.
|
inline |
Definition at line 372 of file MCSchedule.h.
References assert(), hasInstrSchedModel(), NumSchedClasses, and SchedClassTable.
Referenced by computeInstrLatency(), computeInstrLatency(), computeInstrLatency(), and getReciprocalThroughput().
Definition at line 379 of file MCSchedule.h.
References SchedClassNames, and SchedClassTable.
|
inline |
Definition at line 341 of file MCSchedule.h.
References ExtraProcessorInfo.
Referenced by getExtraProcessorInfo().
|
inline |
Does this machine model include instruction-level scheduling.
Definition at line 346 of file MCSchedule.h.
References SchedClassTable.
Referenced by computeInstrLatency(), getProcResource(), and getSchedClassDesc().
|
inline |
Return true if this machine model data for all instructions with a scheduling class (itinerary class or SchedRW list).
Definition at line 356 of file MCSchedule.h.
References CompleteModel.
|
inline |
Return true if machine supports out of order execution.
Definition at line 359 of file MCSchedule.h.
References MicroOpBufferSize.
|
friend |
Definition at line 336 of file MCSchedule.h.
References InstrItineraryData.
Referenced by computeInstrLatency(), computeInstrLatency(), getReciprocalThroughput(), and InstrItineraryData.
| bool llvm::MCSchedModel::CompleteModel |
Definition at line 322 of file MCSchedule.h.
Referenced by isComplete().
|
static |
Returns the default initialized model.
Definition at line 435 of file MCSchedule.h.
Referenced by llvm::MCSubtargetInfo::getSchedModelForCPU(), and llvm::MCSubtargetInfo::InitMCProcessorInfo().
Definition at line 313 of file MCSchedule.h.
Definition at line 277 of file MCSchedule.h.
Referenced by getReciprocalThroughput().
Definition at line 306 of file MCSchedule.h.
Definition at line 302 of file MCSchedule.h.
Definition at line 294 of file MCSchedule.h.
Definition at line 318 of file MCSchedule.h.
| bool llvm::MCSchedModel::EnableIntervals |
Definition at line 327 of file MCSchedule.h.
| const MCExtraProcessorInfo* llvm::MCSchedModel::ExtraProcessorInfo |
Definition at line 339 of file MCSchedule.h.
Referenced by getExtraProcessorInfo(), and hasExtraProcessorInfo().
| unsigned llvm::MCSchedModel::HighLatency |
Definition at line 312 of file MCSchedule.h.
Referenced by llvm::TargetInstrInfo::defaultDefLatency().
| const InstrItinerary* llvm::MCSchedModel::InstrItineraries |
Definition at line 337 of file MCSchedule.h.
Referenced by llvm::HexagonMCInstrInfo::getCVIResources(), llvm::HexagonMCInstrInfo::getOtherReservedSlots(), and llvm::HexagonMCInstrInfo::getUnits().
| unsigned llvm::MCSchedModel::IssueWidth |
Definition at line 276 of file MCSchedule.h.
Referenced by llvm::mca::DispatchStage::DispatchStage(), and getReciprocalThroughput().
| unsigned llvm::MCSchedModel::LoadLatency |
Definition at line 305 of file MCSchedule.h.
Referenced by llvm::TargetInstrInfo::defaultDefLatency().
| unsigned llvm::MCSchedModel::LoopMicroOpBufferSize |
Definition at line 301 of file MCSchedule.h.
| unsigned llvm::MCSchedModel::MicroOpBufferSize |
Definition at line 293 of file MCSchedule.h.
Referenced by isOutOfOrder().
| unsigned llvm::MCSchedModel::MispredictPenalty |
Definition at line 317 of file MCSchedule.h.
| unsigned llvm::MCSchedModel::NumProcResourceKinds |
Definition at line 332 of file MCSchedule.h.
Referenced by getNumProcResourceKinds(), and getProcResource().
| unsigned llvm::MCSchedModel::NumSchedClasses |
Definition at line 333 of file MCSchedule.h.
Referenced by getSchedClassDesc().
| bool llvm::MCSchedModel::PostRAScheduler |
Definition at line 320 of file MCSchedule.h.
Referenced by llvm::TargetSubtargetInfo::enablePostRAScheduler().
| unsigned llvm::MCSchedModel::ProcID |
Definition at line 329 of file MCSchedule.h.
Referenced by getProcessorID().
| const MCProcResourceDesc* llvm::MCSchedModel::ProcResourceTable |
Definition at line 330 of file MCSchedule.h.
Referenced by getProcResource().
| const StringTable* llvm::MCSchedModel::SchedClassNames |
Definition at line 334 of file MCSchedule.h.
Referenced by getSchedClassName().
| const MCSchedClassDesc* llvm::MCSchedModel::SchedClassTable |
Definition at line 331 of file MCSchedule.h.
Referenced by getSchedClassDesc(), getSchedClassName(), and hasInstrSchedModel().