LLVM API Documentation
Provide an instruction scheduling machine model to CodeGen passes. More...
#include <TargetSchedule.h>
Public Types | |
typedef const MCWriteProcResEntry * | ProcResIter |
Public Member Functions | |
TargetSchedModel () | |
void | init (const MCSchedModel &sm, const TargetSubtargetInfo *sti, const TargetInstrInfo *tii) |
Initialize the machine model for instruction scheduling. | |
const MCSchedClassDesc * | resolveSchedClass (const MachineInstr *MI) const |
Return the MCSchedClassDesc for this instruction. | |
const TargetInstrInfo * | getInstrInfo () const |
TargetInstrInfo getter. | |
bool | hasInstrSchedModel () const |
Return true if this machine model includes an instruction-level scheduling model. | |
const MCSchedModel * | getMCSchedModel () const |
bool | hasInstrItineraries () const |
Return true if this machine model includes cycle-to-cycle itinerary data. | |
const InstrItineraryData * | getInstrItineraries () const |
unsigned | getProcessorID () const |
Identify the processor corresponding to the current subtarget. | |
unsigned | getIssueWidth () const |
Maximum number of micro-ops that may be scheduled per cycle. | |
unsigned | getNumMicroOps (const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const |
Return the number of issue slots required for this MI. | |
unsigned | getNumProcResourceKinds () const |
Get the number of kinds of resources for this target. | |
const MCProcResourceDesc * | getProcResource (unsigned PIdx) const |
Get a processor resource by ID for convenience. | |
const char * | getResourceName (unsigned PIdx) const |
ProcResIter | getWriteProcResBegin (const MCSchedClassDesc *SC) const |
ProcResIter | getWriteProcResEnd (const MCSchedClassDesc *SC) const |
unsigned | getResourceFactor (unsigned ResIdx) const |
Multiply the number of units consumed for a resource by this factor to normalize it relative to other resources. | |
unsigned | getMicroOpFactor () const |
Multiply number of micro-ops by this factor to normalize it relative to other resources. | |
unsigned | getLatencyFactor () const |
Multiply cycle count by this factor to normalize it relative to other resources. This is the number of resource units per cycle. | |
unsigned | getMicroOpBufferSize () const |
Number of micro-ops that may be buffered for OOO execution. | |
int | getResourceBufferSize (unsigned PIdx) const |
Number of resource units that may be buffered for OOO execution. | |
unsigned | computeOperandLatency (const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const |
Compute operand latency based on the available machine model. | |
unsigned | computeInstrLatency (const MachineInstr *MI, bool UseDefaultDefLatency=true) const |
Compute the instruction latency based on the available machine model. | |
unsigned | computeInstrLatency (unsigned Opcode) const |
unsigned | computeOutputLatency (const MachineInstr *DefMI, unsigned DefIdx, const MachineInstr *DepMI) const |
Output dependency latency of a pair of defs of the same register. |
Provide an instruction scheduling machine model to CodeGen passes.
Definition at line 32 of file TargetSchedule.h.
Definition at line 109 of file TargetSchedule.h.
llvm::TargetSchedModel::TargetSchedModel | ( | ) | [inline] |
Definition at line 44 of file TargetSchedule.h.
unsigned TargetSchedModel::computeInstrLatency | ( | const MachineInstr * | MI, |
bool | UseDefaultDefLatency = true |
||
) | const |
Compute the instruction latency based on the available machine model.
Compute and return the expected latency of this instruction independent of a particular use. computeOperandLatency is the preferred API, but this is occasionally useful to help estimate instruction cost.
If UseDefaultDefLatency is false and no new machine sched model is present this method falls back to TII->getInstrLatency with an empty instruction itinerary (this is so we preserve the previous behavior of the if converter after moving it to TargetSchedModel).
Definition at line 251 of file TargetSchedule.cpp.
References capLatency(), llvm::MCWriteLatencyEntry::Cycles, llvm::TargetInstrInfo::defaultDefLatency(), llvm::TargetInstrInfo::getInstrLatency(), llvm::MCSubtargetInfo::getWriteLatencyEntry(), hasInstrItineraries(), hasInstrSchedModel(), llvm::MachineInstr::isBundle(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::NumWriteLatencyEntries, and resolveSchedClass().
Referenced by computeOutputLatency(), and llvm::ScheduleDAGInstrs::initSUnits().
unsigned TargetSchedModel::computeInstrLatency | ( | unsigned | Opcode | ) | const |
Definition at line 228 of file TargetSchedule.cpp.
References capLatency(), llvm::MCWriteLatencyEntry::Cycles, llvm::MCInstrInfo::get(), llvm::MCInstrDesc::getSchedClass(), llvm::MCSchedModel::getSchedClassDesc(), llvm::MCSubtargetInfo::getWriteLatencyEntry(), hasInstrSchedModel(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::isVariant(), and llvm::MCSchedClassDesc::NumWriteLatencyEntries.
unsigned TargetSchedModel::computeOperandLatency | ( | const MachineInstr * | DefMI, |
unsigned | DefOperIdx, | ||
const MachineInstr * | UseMI, | ||
unsigned | UseOperIdx | ||
) | const |
Compute operand latency based on the available machine model.
Compute and return the latency of the given data dependent def and use when the operand indices are already known. UseMI may be NULL for an unknown user.
Definition at line 155 of file TargetSchedule.cpp.
References capLatency(), llvm::MCWriteLatencyEntry::Cycles, llvm::TargetInstrInfo::defaultDefLatency(), findDefIdx(), findUseIdx(), llvm::MachineInstr::getDesc(), llvm::TargetInstrInfo::getInstrLatency(), llvm::MachineInstr::getOperand(), llvm::InstrItineraryData::getOperandCycle(), llvm::TargetInstrInfo::getOperandLatency(), llvm::MCSubtargetInfo::getReadAdvanceCycles(), llvm::MCInstrDesc::getSchedClass(), llvm::MCSubtargetInfo::getWriteLatencyEntry(), hasInstrItineraries(), hasInstrSchedModel(), llvm::MCSchedModel::isComplete(), llvm::MachineOperand::isImplicit(), llvm::MCOperandInfo::isOptionalDef(), llvm::MachineInstr::isTransient(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::NumReadAdvanceEntries, llvm::MCInstrDesc::OpInfo, llvm::report_fatal_error(), resolveSchedClass(), llvm::raw_string_ostream::str(), and llvm::MCWriteLatencyEntry::WriteResourceID.
Referenced by llvm::ScheduleDAGInstrs::addPhysRegDataDeps(), llvm::ScheduleDAGInstrs::addVRegUseDeps(), pushDepHeight(), and updatePhysDepsUpwards().
unsigned TargetSchedModel::computeOutputLatency | ( | const MachineInstr * | DefMI, |
unsigned | DefIdx, | ||
const MachineInstr * | DepMI | ||
) | const |
Output dependency latency of a pair of defs of the same register.
This is typically one cycle.
Definition at line 277 of file TargetSchedule.cpp.
References llvm::MCProcResourceDesc::BufferSize, computeInstrLatency(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineBasicBlock::getParent(), llvm::MCSchedModel::getProcResource(), llvm::MachineOperand::getReg(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::MCSubtargetInfo::getWriteProcResBegin(), llvm::MCSubtargetInfo::getWriteProcResEnd(), hasInstrSchedModel(), llvm::TargetInstrInfo::isPredicated(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedModel::MicroOpBufferSize, llvm::MachineInstr::readsRegister(), and resolveSchedClass().
Referenced by llvm::ScheduleDAGInstrs::addPhysRegDeps(), and llvm::ScheduleDAGInstrs::addVRegDefDeps().
const TargetInstrInfo* llvm::TargetSchedModel::getInstrInfo | ( | ) | const [inline] |
TargetInstrInfo getter.
Definition at line 58 of file TargetSchedule.h.
const InstrItineraryData* llvm::TargetSchedModel::getInstrItineraries | ( | ) | const [inline] |
Definition at line 75 of file TargetSchedule.h.
References hasInstrItineraries().
Referenced by llvm::ConvergingVLIWScheduler::initialize(), llvm::GenericScheduler::initialize(), and llvm::PostGenericScheduler::initialize().
unsigned llvm::TargetSchedModel::getIssueWidth | ( | ) | const [inline] |
Maximum number of micro-ops that may be scheduled per cycle.
Definition at line 85 of file TargetSchedule.h.
References llvm::MCSchedModel::IssueWidth.
Referenced by llvm::SchedBoundary::bumpCycle(), llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), and llvm::VLIWResourceModel::reserveResources().
unsigned llvm::TargetSchedModel::getLatencyFactor | ( | ) | const [inline] |
Multiply cycle count by this factor to normalize it relative to other resources. This is the number of resource units per cycle.
Definition at line 135 of file TargetSchedule.h.
Referenced by llvm::SchedBoundary::bumpCycle(), llvm::SchedBoundary::bumpNode(), llvm::GenericScheduler::checkAcyclicLatency(), llvm::SchedBoundary::countResource(), llvm::SchedBoundary::dumpScheduledState(), llvm::SchedBoundary::getExecutedCount(), and llvm::GenericSchedulerBase::setPolicy().
const MCSchedModel* llvm::TargetSchedModel::getMCSchedModel | ( | ) | const [inline] |
Definition at line 67 of file TargetSchedule.h.
unsigned llvm::TargetSchedModel::getMicroOpBufferSize | ( | ) | const [inline] |
Number of micro-ops that may be buffered for OOO execution.
Definition at line 140 of file TargetSchedule.h.
References llvm::MCSchedModel::MicroOpBufferSize.
Referenced by llvm::SchedBoundary::bumpCycle(), llvm::SchedBoundary::bumpNode(), llvm::GenericScheduler::checkAcyclicLatency(), llvm::SchedBoundary::releaseNode(), and llvm::SchedBoundary::releasePending().
unsigned llvm::TargetSchedModel::getMicroOpFactor | ( | ) | const [inline] |
Multiply number of micro-ops by this factor to normalize it relative to other resources.
Definition at line 129 of file TargetSchedule.h.
Referenced by llvm::SchedBoundary::bumpNode(), llvm::GenericScheduler::checkAcyclicLatency(), llvm::SchedBoundary::dumpScheduledState(), llvm::SchedBoundary::getCriticalCount(), llvm::SchedBoundary::getOtherResourceCount(), and llvm::SchedRemainder::init().
unsigned TargetSchedModel::getNumMicroOps | ( | const MachineInstr * | MI, |
const MCSchedClassDesc * | SC = nullptr |
||
) | const |
Return the number of issue slots required for this MI.
Definition at line 77 of file TargetSchedule.cpp.
References llvm::MachineInstr::getDesc(), llvm::InstrItineraryData::getNumMicroOps(), llvm::TargetInstrInfo::getNumMicroOps(), llvm::MCInstrDesc::getSchedClass(), hasInstrItineraries(), hasInstrSchedModel(), llvm::MachineInstr::isTransient(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::NumMicroOps, and resolveSchedClass().
Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), and llvm::SchedRemainder::init().
unsigned llvm::TargetSchedModel::getNumProcResourceKinds | ( | ) | const [inline] |
Get the number of kinds of resources for this target.
Definition at line 92 of file TargetSchedule.h.
References llvm::MCSchedModel::getNumProcResourceKinds().
Referenced by llvm::MachineTraceMetrics::Ensemble::Ensemble(), llvm::SchedBoundary::getOtherResourceCount(), llvm::MachineTraceMetrics::getProcResourceCycles(), llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), llvm::SchedBoundary::init(), and llvm::MachineTraceMetrics::runOnMachineFunction().
unsigned llvm::TargetSchedModel::getProcessorID | ( | ) | const [inline] |
Identify the processor corresponding to the current subtarget.
Definition at line 82 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcessorID().
const MCProcResourceDesc* llvm::TargetSchedModel::getProcResource | ( | unsigned | PIdx | ) | const [inline] |
Get a processor resource by ID for convenience.
Definition at line 97 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcResource().
Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::countResource(), llvm::ScheduleDAGInstrs::initSUnits(), and llvm::GenericSchedulerBase::traceCandidate().
int llvm::TargetSchedModel::getResourceBufferSize | ( | unsigned | PIdx | ) | const [inline] |
Number of resource units that may be buffered for OOO execution.
Definition at line 144 of file TargetSchedule.h.
References llvm::MCProcResourceDesc::BufferSize, and llvm::MCSchedModel::getProcResource().
unsigned llvm::TargetSchedModel::getResourceFactor | ( | unsigned | ResIdx | ) | const [inline] |
Multiply the number of units consumed for a resource by this factor to normalize it relative to other resources.
Definition at line 123 of file TargetSchedule.h.
Referenced by llvm::SchedBoundary::countResource(), llvm::SchedBoundary::dumpScheduledState(), llvm::SchedBoundary::getOtherResourceCount(), llvm::MachineTraceMetrics::getResources(), and llvm::SchedRemainder::init().
const char* llvm::TargetSchedModel::getResourceName | ( | unsigned | PIdx | ) | const [inline] |
Definition at line 102 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcResource(), and llvm::MCProcResourceDesc::Name.
Referenced by llvm::SchedBoundary::checkHazard(), llvm::SchedBoundary::countResource(), llvm::SchedBoundary::dumpScheduledState(), llvm::SchedBoundary::getOtherResourceCount(), and llvm::GenericSchedulerBase::setPolicy().
ProcResIter llvm::TargetSchedModel::getWriteProcResBegin | ( | const MCSchedClassDesc * | SC | ) | const [inline] |
Definition at line 113 of file TargetSchedule.h.
References llvm::MCSubtargetInfo::getWriteProcResBegin().
Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), and llvm::ScheduleDAGInstrs::initSUnits().
ProcResIter llvm::TargetSchedModel::getWriteProcResEnd | ( | const MCSchedClassDesc * | SC | ) | const [inline] |
Definition at line 117 of file TargetSchedule.h.
References llvm::MCSubtargetInfo::getWriteProcResEnd().
Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), and llvm::ScheduleDAGInstrs::initSUnits().
bool TargetSchedModel::hasInstrItineraries | ( | ) | const |
Return true if this machine model includes cycle-to-cycle itinerary data.
This models scheduling at each stage in the processor pipeline.
Definition at line 35 of file TargetSchedule.cpp.
References EnableSchedItins, and llvm::InstrItineraryData::isEmpty().
Referenced by computeInstrLatency(), computeOperandLatency(), getInstrItineraries(), and getNumMicroOps().
bool TargetSchedModel::hasInstrSchedModel | ( | ) | const |
Return true if this machine model includes an instruction-level scheduling model.
This is more detailed than the course grain IssueWidth and default latency properties, but separate from the per-cycle itinerary data.
Definition at line 31 of file TargetSchedule.cpp.
References EnableSchedModel, and llvm::MCSchedModel::hasInstrSchedModel().
Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), computeInstrLatency(), computeOperandLatency(), computeOutputLatency(), getNumMicroOps(), llvm::SchedBoundary::getOtherResourceCount(), llvm::MachineTraceMetrics::getResources(), llvm::ScheduleDAGInstrs::getSchedClass(), llvm::SchedRemainder::init(), llvm::SchedBoundary::init(), llvm::ScheduleDAGInstrs::initSUnits(), and llvm::GenericSchedulerBase::setPolicy().
void TargetSchedModel::init | ( | const MCSchedModel & | sm, |
const TargetSubtargetInfo * | sti, | ||
const TargetInstrInfo * | tii | ||
) |
Initialize the machine model for instruction scheduling.
The machine model API keeps a copy of the top-level MCSchedModel table indices and may query TargetSubtargetInfo and TargetInstrInfo to resolve dynamic properties.
Definition at line 54 of file TargetSchedule.cpp.
References llvm::MCSchedModel::getNumProcResourceKinds(), llvm::MCSchedModel::getProcResource(), llvm::MCSubtargetInfo::initInstrItins(), llvm::MCSchedModel::IssueWidth, lcm(), llvm::MCProcResourceDesc::NumUnits, and llvm::SmallVectorImpl< T >::resize().
Referenced by llvm::MachineTraceMetrics::runOnMachineFunction(), and llvm::ScheduleDAGInstrs::ScheduleDAGInstrs().
const MCSchedClassDesc * TargetSchedModel::resolveSchedClass | ( | const MachineInstr * | MI | ) | const |
Return the MCSchedClassDesc for this instruction.
Return the MCSchedClassDesc for this instruction. Some SchedClasses require evaluation of predicates that depend on instruction operands or flags.
Definition at line 103 of file TargetSchedule.cpp.
References llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getSchedClass(), llvm::MCSchedModel::getSchedClassDesc(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::isVariant(), and llvm::TargetSubtargetInfo::resolveSchedClass().
Referenced by computeInstrLatency(), computeOperandLatency(), computeOutputLatency(), getNumMicroOps(), llvm::MachineTraceMetrics::getResources(), and llvm::ScheduleDAGInstrs::getSchedClass().