LLVM  8.0.1
Public Types | Public Member Functions | List of all members
llvm::TargetSchedModel Class Reference

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 MCSchedClassDescresolveSchedClass (const MachineInstr *MI) const
 Return the MCSchedClassDesc for this instruction. More...
 
const TargetSubtargetInfogetSubtargetInfo () const
 TargetSubtargetInfo getter. 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
 
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 MCProcResourceDescgetProcResource (unsigned PIdx) const
 Get a processor resource by ID for convenience. More...
 
const chargetResourceName (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
 

Detailed Description

Provide an instruction scheduling machine model to CodeGen passes.

Definition at line 32 of file TargetSchedule.h.

Member Typedef Documentation

◆ ProcResIter

Definition at line 127 of file TargetSchedule.h.

Constructor & Destructor Documentation

◆ TargetSchedModel()

llvm::TargetSchedModel::TargetSchedModel ( )
inline

Definition at line 47 of file TargetSchedule.h.

References init(), MI, and resolveSchedClass().

Member Function Documentation

◆ computeInstrLatency() [1/3]

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().

◆ computeInstrLatency() [2/3]

unsigned TargetSchedModel::computeInstrLatency ( const MCInst Inst) const

◆ computeInstrLatency() [3/3]

unsigned TargetSchedModel::computeInstrLatency ( unsigned  Opcode) const

◆ computeOperandLatency()

unsigned TargetSchedModel::computeOperandLatency ( const MachineInstr DefMI,
unsigned  DefOperIdx,
const MachineInstr UseMI,
unsigned  UseOperIdx 
) const

◆ computeOutputLatency()

unsigned TargetSchedModel::computeOutputLatency ( const MachineInstr DefMI,
unsigned  DefOperIdx,
const MachineInstr DepMI 
) const

◆ computeReciprocalThroughput() [1/3]

double TargetSchedModel::computeReciprocalThroughput ( const MachineInstr MI) const

◆ computeReciprocalThroughput() [2/3]

double TargetSchedModel::computeReciprocalThroughput ( const MCInst MI) const

◆ computeReciprocalThroughput() [3/3]

double TargetSchedModel::computeReciprocalThroughput ( unsigned  Opcode) const

◆ getInstrInfo()

const TargetInstrInfo* llvm::TargetSchedModel::getInstrInfo ( ) const
inline

TargetInstrInfo getter.

Definition at line 63 of file TargetSchedule.h.

References hasInstrSchedModel().

◆ getInstrItineraries()

const InstrItineraryData* llvm::TargetSchedModel::getInstrItineraries ( ) const
inline

◆ getIssueWidth()

unsigned llvm::TargetSchedModel::getIssueWidth ( ) const
inline

◆ getLatencyFactor()

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

Referenced by llvm::SchedBoundary::getExecutedCount().

◆ getMCSchedModel()

const MCSchedModel* llvm::TargetSchedModel::getMCSchedModel ( ) const
inline

Definition at line 72 of file TargetSchedule.h.

References hasInstrItineraries().

◆ getMicroOpBufferSize()

unsigned llvm::TargetSchedModel::getMicroOpBufferSize ( ) const
inline

Number of micro-ops that may be buffered for OOO execution.

Definition at line 158 of file TargetSchedule.h.

References llvm::MCSchedModel::MicroOpBufferSize.

◆ getMicroOpFactor()

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

◆ getNumMicroOps()

unsigned TargetSchedModel::getNumMicroOps ( const MachineInstr MI,
const MCSchedClassDesc SC = nullptr 
) const

◆ getNumProcResourceKinds()

unsigned llvm::TargetSchedModel::getNumProcResourceKinds ( ) const
inline

◆ getProcessorID()

unsigned llvm::TargetSchedModel::getProcessorID ( ) const
inline

Identify the processor corresponding to the current subtarget.

Definition at line 93 of file TargetSchedule.h.

References llvm::MCSchedModel::getProcessorID().

◆ getProcResource()

const MCProcResourceDesc* llvm::TargetSchedModel::getProcResource ( unsigned  PIdx) const
inline

◆ getResourceBufferSize()

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

References llvm::MCProcResourceDesc::BufferSize, computeOperandLatency(), computeOutputLatency(), computeReciprocalThroughput(), DefMI, llvm::MCSchedModel::getProcResource(), and UseMI.

◆ getResourceFactor()

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

Referenced by llvm::MachineTraceMetrics::getResources(), llvm::SchedRemainder::init(), and pushDepHeight().

◆ getResourceName()

const char* llvm::TargetSchedModel::getResourceName ( unsigned  PIdx) const
inline

◆ getSubtargetInfo()

const TargetSubtargetInfo* llvm::TargetSchedModel::getSubtargetInfo ( ) const
inline

TargetSubtargetInfo getter.

Definition at line 60 of file TargetSchedule.h.

◆ getWriteProcResBegin()

ProcResIter llvm::TargetSchedModel::getWriteProcResBegin ( const MCSchedClassDesc SC) const
inline

◆ getWriteProcResEnd()

ProcResIter llvm::TargetSchedModel::getWriteProcResEnd ( const MCSchedClassDesc SC) const
inline

◆ hasInstrItineraries()

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().

◆ hasInstrSchedModel()

bool TargetSchedModel::hasInstrSchedModel ( ) const

◆ hasInstrSchedModelOrItineraries()

bool llvm::TargetSchedModel::hasInstrSchedModelOrItineraries ( ) const
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().

◆ init()

void TargetSchedModel::init ( const TargetSubtargetInfo TSInfo)

◆ mustBeginGroup()

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().

◆ mustEndGroup()

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().

◆ resolveSchedClass()

const MCSchedClassDesc * TargetSchedModel::resolveSchedClass ( const MachineInstr MI) const

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