LLVM
8.0.1
|
Provide an instruction scheduling machine model to CodeGen passes. More...
#include "llvm/CodeGen/TargetSchedule.h"
Public Types | |
using | ProcResIter = const MCWriteProcResEntry * |
Public Member Functions | |
TargetSchedModel () | |
void | init (const TargetSubtargetInfo *TSInfo) |
Initialize the machine model for instruction scheduling. More... | |
const MCSchedClassDesc * | resolveSchedClass (const MachineInstr *MI) const |
Return the MCSchedClassDesc for this instruction. More... | |
const TargetSubtargetInfo * | getSubtargetInfo () const |
TargetSubtargetInfo getter. More... | |
const TargetInstrInfo * | getInstrInfo () const |
TargetInstrInfo getter. More... | |
bool | hasInstrSchedModel () const |
Return true if this machine model includes an instruction-level scheduling model. More... | |
const MCSchedModel * | getMCSchedModel () const |
bool | hasInstrItineraries () const |
Return true if this machine model includes cycle-to-cycle itinerary data. More... | |
const InstrItineraryData * | getInstrItineraries () const |
bool | hasInstrSchedModelOrItineraries () const |
Return true if this machine model includes an instruction-level scheduling model or cycle-to-cycle itinerary data. More... | |
unsigned | getProcessorID () const |
Identify the processor corresponding to the current subtarget. More... | |
unsigned | getIssueWidth () const |
Maximum number of micro-ops that may be scheduled per cycle. More... | |
bool | mustBeginGroup (const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const |
Return true if new group must begin. More... | |
bool | mustEndGroup (const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const |
Return true if current group must end. More... | |
unsigned | getNumMicroOps (const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const |
Return the number of issue slots required for this MI. More... | |
unsigned | getNumProcResourceKinds () const |
Get the number of kinds of resources for this target. More... | |
const MCProcResourceDesc * | getProcResource (unsigned PIdx) const |
Get a processor resource by ID for convenience. More... | |
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. More... | |
unsigned | getMicroOpFactor () const |
Multiply number of micro-ops by this factor to normalize it relative to other resources. More... | |
unsigned | getLatencyFactor () const |
Multiply cycle count by this factor to normalize it relative to other resources. More... | |
unsigned | getMicroOpBufferSize () const |
Number of micro-ops that may be buffered for OOO execution. More... | |
int | getResourceBufferSize (unsigned PIdx) const |
Number of resource units that may be buffered for OOO execution. More... | |
unsigned | computeOperandLatency (const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const |
Compute operand latency based on the available machine model. More... | |
unsigned | computeInstrLatency (const MachineInstr *MI, bool UseDefaultDefLatency=true) const |
Compute the instruction latency based on the available machine model. More... | |
unsigned | computeInstrLatency (const MCInst &Inst) const |
unsigned | computeInstrLatency (unsigned Opcode) const |
unsigned | computeOutputLatency (const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *DepMI) const |
Output dependency latency of a pair of defs of the same register. More... | |
double | computeReciprocalThroughput (const MachineInstr *MI) const |
Compute the reciprocal throughput of the given instruction. More... | |
double | computeReciprocalThroughput (const MCInst &MI) const |
double | computeReciprocalThroughput (unsigned Opcode) const |
Provide an instruction scheduling machine model to CodeGen passes.
Definition at line 32 of file TargetSchedule.h.
Definition at line 127 of file TargetSchedule.h.
|
inline |
Definition at line 47 of file TargetSchedule.h.
References init(), MI, and resolveSchedClass().
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 274 of file TargetSchedule.cpp.
References computeOutputLatency(), llvm::TargetInstrInfo::defaultDefLatency(), llvm::TargetInstrInfo::getInstrLatency(), hasInstrItineraries(), hasInstrSchedModel(), llvm::MachineInstr::isBundle(), llvm::MCSchedClassDesc::isValid(), and resolveSchedClass().
Definition at line 267 of file TargetSchedule.cpp.
References capLatency(), llvm::MCSchedModel::computeInstrLatency(), llvm::MCInst::getOpcode(), and hasInstrSchedModel().
Definition at line 261 of file TargetSchedule.cpp.
References assert(), capLatency(), llvm::MCSchedModel::computeInstrLatency(), llvm::MCInstrInfo::get(), llvm::MCInstrDesc::getSchedClass(), and hasInstrSchedModel().
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 185 of file TargetSchedule.cpp.
References capLatency(), llvm::MCSchedModel::computeInstrLatency(), llvm::MCWriteLatencyEntry::Cycles, llvm::TargetInstrInfo::defaultDefLatency(), llvm::errs(), 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::Latency, llvm_unreachable, llvm::max(), llvm::MCSchedClassDesc::NumReadAdvanceEntries, llvm::MCInstrDesc::OpInfo, resolveSchedClass(), and llvm::MCWriteLatencyEntry::WriteResourceID.
Referenced by llvm::ScheduleDAGInstrs::addPhysRegDataDeps(), llvm::ScheduleDAGInstrs::addVRegDefDeps(), getResourceBufferSize(), pushDepHeight(), llvm::MachineTraceMetrics::Ensemble::updateDepth(), and updatePhysDepsUpwards().
unsigned TargetSchedModel::computeOutputLatency | ( | const MachineInstr * | DefMI, |
unsigned | DefOperIdx, | ||
const MachineInstr * | DepMI | ||
) | const |
Output dependency latency of a pair of defs of the same register.
This is typically one cycle.
Definition at line 291 of file TargetSchedule.cpp.
References llvm::MCProcResourceDesc::BufferSize, llvm::MachineInstr::getMF(), llvm::MachineInstr::getOperand(), llvm::MCSchedModel::getProcResource(), llvm::MachineOperand::getReg(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::MCSubtargetInfo::getWriteProcResBegin(), llvm::MCSubtargetInfo::getWriteProcResEnd(), hasInstrSchedModel(), llvm::MCSchedModel::isOutOfOrder(), llvm::TargetInstrInfo::isPredicated(), llvm::MCSchedClassDesc::isValid(), llvm::MachineInstr::readsRegister(), Reg, resolveSchedClass(), and TRI.
Referenced by llvm::ScheduleDAGInstrs::addPhysRegDeps(), llvm::ScheduleDAGInstrs::addVRegDefDeps(), computeInstrLatency(), and getResourceBufferSize().
double TargetSchedModel::computeReciprocalThroughput | ( | const MachineInstr * | MI | ) | const |
Compute the reciprocal throughput of the given instruction.
Definition at line 326 of file TargetSchedule.cpp.
References llvm::MachineInstr::getDesc(), getInstrItineraries(), llvm::MCSchedModel::getReciprocalThroughput(), llvm::MCInstrDesc::getSchedClass(), hasInstrItineraries(), hasInstrSchedModel(), and resolveSchedClass().
Referenced by computeReciprocalThroughput(), getResourceBufferSize(), and llvm::TargetSubtargetInfo::getSchedInfoStr().
Definition at line 355 of file TargetSchedule.cpp.
References computeReciprocalThroughput(), llvm::MCInst::getOpcode(), llvm::MCSchedModel::getReciprocalThroughput(), and hasInstrSchedModel().
double TargetSchedModel::computeReciprocalThroughput | ( | unsigned | Opcode | ) | const |
Definition at line 340 of file TargetSchedule.cpp.
References llvm::MCInstrInfo::get(), getInstrItineraries(), llvm::MCSchedModel::getReciprocalThroughput(), llvm::MCInstrDesc::getSchedClass(), llvm::MCSchedModel::getSchedClassDesc(), hasInstrItineraries(), hasInstrSchedModel(), llvm::MCSchedClassDesc::isValid(), and llvm::MCSchedClassDesc::isVariant().
|
inline |
TargetInstrInfo getter.
Definition at line 63 of file TargetSchedule.h.
References hasInstrSchedModel().
|
inline |
Definition at line 80 of file TargetSchedule.h.
References hasInstrItineraries().
Referenced by computeReciprocalThroughput(), llvm::TargetSubtargetInfo::getSchedInfoStr(), and llvm::TargetInstrInfo::hasLowDefLatency().
|
inline |
Maximum number of micro-ops that may be scheduled per cycle.
Definition at line 96 of file TargetSchedule.h.
References getNumMicroOps(), llvm::MCSchedModel::IssueWidth, mustBeginGroup(), mustEndGroup(), and llvm::PPCISD::SC.
Referenced by llvm::ConvergingVLIWScheduler::releaseBottomNode(), llvm::VLIWResourceModel::reserveResources(), and llvm::VLIWResourceModel::VLIWResourceModel().
|
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 153 of file TargetSchedule.h.
Referenced by llvm::SchedBoundary::getExecutedCount().
|
inline |
Definition at line 72 of file TargetSchedule.h.
References hasInstrItineraries().
|
inline |
Number of micro-ops that may be buffered for OOO execution.
Definition at line 158 of file TargetSchedule.h.
References llvm::MCSchedModel::MicroOpBufferSize.
|
inline |
Multiply number of micro-ops by this factor to normalize it relative to other resources.
Definition at line 147 of file TargetSchedule.h.
Referenced by llvm::SchedBoundary::getCriticalCount(), 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 108 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 getIssueWidth(), llvm::SchedRemainder::init(), and llvm::ConvergingVLIWScheduler::releaseBottomNode().
|
inline |
Get the number of kinds of resources for this target.
Definition at line 110 of file TargetSchedule.h.
References llvm::MCSchedModel::getNumProcResourceKinds().
Referenced by llvm::SystemZHazardRecognizer::dumpProcResourceCounters(), llvm::SystemZHazardRecognizer::dumpState(), llvm::MachineTraceMetrics::Ensemble::Ensemble(), llvm::MachineTraceMetrics::Ensemble::getLoopFor(), llvm::MachineTraceMetrics::getProcResourceCycles(), llvm::MachineTraceMetrics::Ensemble::getProcResourceDepths(), llvm::MachineTraceMetrics::Ensemble::getProcResourceHeights(), llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), llvm::SystemZHazardRecognizer::Reset(), and llvm::MachineTraceMetrics::runOnMachineFunction().
|
inline |
Identify the processor corresponding to the current subtarget.
Definition at line 93 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcessorID().
|
inline |
Get a processor resource by ID for convenience.
Definition at line 115 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcResource().
Referenced by llvm::SystemZHazardRecognizer::dumpProcResourceCounters(), llvm::SystemZHazardRecognizer::dumpSU(), llvm::SystemZHazardRecognizer::EmitInstruction(), llvm::SystemZHazardRecognizer::emitInstruction(), llvm::ScheduleDAGInstrs::initSUnits(), and pushDepHeight().
|
inline |
Number of resource units that may be buffered for OOO execution.
Definition at line 162 of file TargetSchedule.h.
References llvm::MCProcResourceDesc::BufferSize, computeOperandLatency(), computeOutputLatency(), computeReciprocalThroughput(), DefMI, llvm::MCSchedModel::getProcResource(), and UseMI.
Multiply the number of units consumed for a resource by this factor to normalize it relative to other resources.
Definition at line 141 of file TargetSchedule.h.
Referenced by llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), and pushDepHeight().
Definition at line 120 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcResource(), and llvm::MCProcResourceDesc::Name.
|
inline |
TargetSubtargetInfo getter.
Definition at line 60 of file TargetSchedule.h.
|
inline |
Definition at line 131 of file TargetSchedule.h.
References llvm::MCSubtargetInfo::getWriteProcResBegin().
Referenced by llvm::SystemZHazardRecognizer::dumpSU(), llvm::SystemZHazardRecognizer::EmitInstruction(), llvm::SystemZHazardRecognizer::emitInstruction(), llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), llvm::ScheduleDAGInstrs::initSUnits(), and llvm::SystemZHazardRecognizer::resourcesCost().
|
inline |
Definition at line 135 of file TargetSchedule.h.
References llvm::MCSubtargetInfo::getWriteProcResEnd().
Referenced by llvm::SystemZHazardRecognizer::dumpSU(), llvm::SystemZHazardRecognizer::EmitInstruction(), llvm::SystemZHazardRecognizer::emitInstruction(), llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), llvm::ScheduleDAGInstrs::initSUnits(), and llvm::SystemZHazardRecognizer::resourcesCost().
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 44 of file TargetSchedule.cpp.
References EnableSchedItins, and llvm::InstrItineraryData::isEmpty().
Referenced by computeInstrLatency(), computeOperandLatency(), computeReciprocalThroughput(), getInstrItineraries(), getMCSchedModel(), getNumMicroOps(), llvm::TargetSubtargetInfo::getSchedInfoStr(), and hasInstrSchedModelOrItineraries().
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 40 of file TargetSchedule.cpp.
References EnableSchedModel, and llvm::MCSchedModel::hasInstrSchedModel().
Referenced by computeInstrLatency(), computeOperandLatency(), computeOutputLatency(), computeReciprocalThroughput(), getInstrInfo(), getNumMicroOps(), llvm::MachineTraceMetrics::getResources(), llvm::SystemZHazardRecognizer::getSchedClass(), llvm::ScheduleDAGInstrs::getSchedClass(), llvm::TargetSubtargetInfo::getSchedInfoStr(), hasInstrSchedModelOrItineraries(), llvm::SchedRemainder::init(), llvm::ScheduleDAGInstrs::initSUnits(), mustBeginGroup(), and mustEndGroup().
|
inline |
Return true if this machine model includes an instruction-level scheduling model or cycle-to-cycle itinerary data.
Definition at line 88 of file TargetSchedule.h.
References hasInstrItineraries(), and hasInstrSchedModel().
void TargetSchedModel::init | ( | const TargetSubtargetInfo * | TSInfo | ) |
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 64 of file TargetSchedule.cpp.
References llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MCSchedModel::getNumProcResourceKinds(), llvm::MCSchedModel::getProcResource(), llvm::MCSubtargetInfo::getSchedModel(), llvm::MCSubtargetInfo::initInstrItins(), llvm::MCSchedModel::IssueWidth, lcm(), llvm::MCProcResourceDesc::NumUnits, and llvm::SmallVectorImpl< T >::resize().
Referenced by llvm::TargetSubtargetInfo::getSchedInfoStr(), llvm::ConvergingVLIWScheduler::initialize(), LoopIsOuterMostWithPredecessor(), llvm::MachineTraceMetrics::runOnMachineFunction(), llvm::ScheduleDAGInstrs::ScheduleDAGInstrs(), llvm::SystemZPostRASchedStrategy::SystemZPostRASchedStrategy(), and TargetSchedModel().
bool TargetSchedModel::mustBeginGroup | ( | const MachineInstr * | MI, |
const MCSchedClassDesc * | SC = nullptr |
||
) | const |
Return true if new group must begin.
Returns true only if instruction is specified as single issue.
Definition at line 86 of file TargetSchedule.cpp.
References llvm::MCSchedClassDesc::BeginGroup, hasInstrSchedModel(), llvm::MCSchedClassDesc::isValid(), and resolveSchedClass().
Referenced by getIssueWidth().
bool TargetSchedModel::mustEndGroup | ( | const MachineInstr * | MI, |
const MCSchedClassDesc * | SC = nullptr |
||
) | const |
Return true if current group must end.
Definition at line 97 of file TargetSchedule.cpp.
References llvm::MCSchedClassDesc::EndGroup, hasInstrSchedModel(), llvm::MCSchedClassDesc::isValid(), and resolveSchedClass().
Referenced by getIssueWidth().
const MCSchedClassDesc * TargetSchedModel::resolveSchedClass | ( | const MachineInstr * | MI | ) | const |
Return the MCSchedClassDesc for this instruction.
Some SchedClasses require evaluation of predicates that depend on instruction operands or flags.
Definition at line 134 of file TargetSchedule.cpp.
References assert(), llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getSchedClass(), llvm::MCSchedModel::getSchedClassDesc(), llvm::MCSchedClassDesc::isValid(), llvm::MCSchedClassDesc::isVariant(), and llvm::TargetSubtargetInfo::resolveSchedClass().
Referenced by capLatency(), computeInstrLatency(), computeOperandLatency(), computeOutputLatency(), computeReciprocalThroughput(), llvm::SystemZHazardRecognizer::emitInstruction(), getNumMicroOps(), llvm::MachineTraceMetrics::getResources(), llvm::SystemZHazardRecognizer::getSchedClass(), llvm::ScheduleDAGInstrs::getSchedClass(), mustBeginGroup(), mustEndGroup(), and TargetSchedModel().