LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
llvm::TargetSchedModel Class Reference

Provide an instruction scheduling machine model to CodeGen passes. More...

#include <TargetSchedule.h>

Public Types

typedef const MCWriteProcResEntryProcResIter
 

Public Member Functions

 TargetSchedModel ()
 
void init (const MCSchedModel &sm, const TargetSubtargetInfo *sti, const TargetInstrInfo *tii)
 Initialize the machine model for instruction scheduling. More...
 
const MCSchedClassDescresolveSchedClass (const MachineInstr *MI) const
 Return the MCSchedClassDesc for this instruction. More...
 
const TargetInstrInfogetInstrInfo () const
 TargetInstrInfo getter. More...
 
bool hasInstrSchedModel () const
 Return true if this machine model includes an instruction-level scheduling model. More...
 
const MCSchedModelgetMCSchedModel () const
 
bool hasInstrItineraries () const
 Return true if this machine model includes cycle-to-cycle itinerary data. More...
 
const InstrItineraryDatagetInstrItineraries () 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 MCProcResourceDescgetProcResource (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...
 

Detailed Description

Provide an instruction scheduling machine model to CodeGen passes.

Definition at line 32 of file TargetSchedule.h.

Member Typedef Documentation

Definition at line 101 of file TargetSchedule.h.

Constructor & Destructor Documentation

llvm::TargetSchedModel::TargetSchedModel ( )
inline

Definition at line 44 of file TargetSchedule.h.

Member Function Documentation

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
unsigned TargetSchedModel::computeOutputLatency ( const MachineInstr DefMI,
unsigned  DefIdx,
const MachineInstr DepMI 
) const
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().

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::VLIWResourceModel::reserveResources(), and llvm::VLIWResourceModel::VLIWResourceModel().

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 127 of file TargetSchedule.h.

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 132 of file TargetSchedule.h.

References llvm::MCSchedModel::MicroOpBufferSize.

unsigned llvm::TargetSchedModel::getMicroOpFactor ( ) const
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
unsigned llvm::TargetSchedModel::getNumProcResourceKinds ( ) const
inline
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().

int llvm::TargetSchedModel::getResourceBufferSize ( unsigned  PIdx) const
inline

Number of resource units that may be buffered for OOO execution.

Returns
The buffer size in resource units or -1 for unlimited.

Definition at line 136 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 115 of file TargetSchedule.h.

Referenced by llvm::MachineTraceMetrics::getResources().

ProcResIter llvm::TargetSchedModel::getWriteProcResBegin ( const MCSchedClassDesc SC) const
inline
ProcResIter llvm::TargetSchedModel::getWriteProcResEnd ( const MCSchedClassDesc SC) const
inline
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

The documentation for this class was generated from the following files: