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. More... | |
const MCSchedClassDesc * | resolveSchedClass (const MachineInstr *MI) const |
Return the MCSchedClassDesc for this instruction. 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 |
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... | |
unsigned | getNumMicroOps (const MachineInstr *MI, const MCSchedClassDesc *SC=0) 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... | |
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. This is the number of resource units per cycle. 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 | computeOutputLatency (const MachineInstr *DefMI, unsigned DefIdx, const MachineInstr *DepMI) const |
Output dependency latency of a pair of defs of the same register. More... | |
Provide an instruction scheduling machine model to CodeGen passes.
Definition at line 32 of file TargetSchedule.h.
typedef const MCWriteProcResEntry* llvm::TargetSchedModel::ProcResIter |
Definition at line 101 of file TargetSchedule.h.
|
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 prefered 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 229 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::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 255 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::TargetMachine::getRegisterInfo(), llvm::MachineFunction::getTarget(), 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().
|
inline |
TargetInstrInfo getter.
Definition at line 58 of file TargetSchedule.h.
|
inline |
Definition at line 75 of file TargetSchedule.h.
References hasInstrItineraries().
Referenced by llvm::ConvergingVLIWScheduler::initialize().
|
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::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 127 of file TargetSchedule.h.
|
inline |
Definition at line 67 of file TargetSchedule.h.
|
inline |
Number of micro-ops that may be buffered for OOO execution.
Definition at line 132 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 121 of file TargetSchedule.h.
unsigned TargetSchedModel::getNumMicroOps | ( | const MachineInstr * | MI, |
const MCSchedClassDesc * | SC = 0 |
||
) | 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().
|
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::MachineTraceMetrics::getProcResourceCycles(), llvm::MachineTraceMetrics::getResources(), and llvm::MachineTraceMetrics::runOnMachineFunction().
|
inline |
Identify the processor corresponding to the current subtarget.
Definition at line 82 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcessorID().
|
inline |
Get a processor resource by ID for convenience.
Definition at line 97 of file TargetSchedule.h.
References llvm::MCSchedModel::getProcResource().
|
inline |
Number of resource units that may be buffered for OOO execution.
Definition at line 136 of file TargetSchedule.h.
References llvm::MCProcResourceDesc::BufferSize, and llvm::MCSchedModel::getProcResource().
Multiply the number of units consumed for a resource by this factor to normalize it relative to other resources.
Definition at line 115 of file TargetSchedule.h.
Referenced by llvm::MachineTraceMetrics::getResources().
|
inline |
Definition at line 105 of file TargetSchedule.h.
References llvm::MCSubtargetInfo::getWriteProcResBegin().
Referenced by llvm::MachineTraceMetrics::getResources().
|
inline |
Definition at line 109 of file TargetSchedule.h.
References llvm::MCSubtargetInfo::getWriteProcResEnd().
Referenced by llvm::MachineTraceMetrics::getResources().
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 computeInstrLatency(), computeOperandLatency(), computeOutputLatency(), getNumMicroOps(), llvm::MachineTraceMetrics::getResources(), and llvm::ScheduleDAGInstrs::getSchedClass().
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().