LLVM 20.0.0git
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.
 
const MCSchedClassDescresolveSchedClass (const MachineInstr *MI) const
 Return the MCSchedClassDesc for this instruction.
 
const TargetSubtargetInfogetSubtargetInfo () const
 TargetSubtargetInfo getter.
 
const TargetInstrInfogetInstrInfo () const
 TargetInstrInfo getter.
 
bool hasInstrSchedModel () const
 Return true if this machine model includes an instruction-level scheduling model.
 
const MCSchedModelgetMCSchedModel () const
 
bool hasInstrItineraries () const
 Return true if this machine model includes cycle-to-cycle itinerary data.
 
const InstrItineraryDatagetInstrItineraries () const
 
bool hasInstrSchedModelOrItineraries () const
 Return true if this machine model includes an instruction-level scheduling model or cycle-to-cycle itinerary data.
 
bool enableIntervals () 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.
 
bool mustBeginGroup (const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const
 Return true if new group must begin.
 
bool mustEndGroup (const MachineInstr *MI, const MCSchedClassDesc *SC=nullptr) const
 Return true if current group must end.
 
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 MCProcResourceDescgetProcResource (unsigned PIdx) const
 Get a processor resource by ID for convenience.
 
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.
 
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.
 
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 (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.
 
double computeReciprocalThroughput (const MachineInstr *MI) const
 Compute the reciprocal throughput of the given instruction.
 
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 30 of file TargetSchedule.h.

Member Typedef Documentation

◆ ProcResIter

Definition at line 129 of file TargetSchedule.h.

Constructor & Destructor Documentation

◆ TargetSchedModel()

llvm::TargetSchedModel::TargetSchedModel ( )
inline

Definition at line 49 of file TargetSchedule.h.

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 257 of file TargetSchedule.cpp.

References llvm::TargetInstrInfo::defaultDefLatency(), llvm::TargetInstrInfo::getInstrLatency(), hasInstrItineraries(), hasInstrSchedModel(), llvm::MCSchedClassDesc::isValid(), MI, 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

Compute the reciprocal throughput of the given instruction.

Definition at line 309 of file TargetSchedule.cpp.

References getInstrItineraries(), llvm::MCSchedModel::getReciprocalThroughput(), hasInstrItineraries(), hasInstrSchedModel(), MI, and resolveSchedClass().

Referenced by computeReciprocalThroughput().

◆ computeReciprocalThroughput() [2/3]

double TargetSchedModel::computeReciprocalThroughput ( const MCInst MI) const

◆ computeReciprocalThroughput() [3/3]

double TargetSchedModel::computeReciprocalThroughput ( unsigned  Opcode) const

◆ enableIntervals()

bool TargetSchedModel::enableIntervals ( ) const

◆ getInstrInfo()

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

TargetInstrInfo getter.

Definition at line 65 of file TargetSchedule.h.

References TII.

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

◆ getMCSchedModel()

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

Definition at line 74 of file TargetSchedule.h.

◆ getMicroOpBufferSize()

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

◆ getMicroOpFactor()

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

◆ 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 95 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 164 of file TargetSchedule.h.

References llvm::MCProcResourceDesc::BufferSize, and llvm::MCSchedModel::getProcResource().

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

Referenced by llvm::SchedBoundary::countResource(), llvm::SchedBoundary::dumpScheduledState(), llvm::SchedBoundary::getOtherResourceCount(), llvm::MachineTraceMetrics::getResources(), and llvm::SchedRemainder::init().

◆ getResourceName()

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

◆ getSubtargetInfo()

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

TargetSubtargetInfo getter.

Definition at line 62 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 47 of file TargetSchedule.cpp.

References EnableSchedItins, and llvm::InstrItineraryData::isEmpty().

Referenced by computeInstrLatency(), computeOperandLatency(), computeReciprocalThroughput(), getInstrItineraries(), getNumMicroOps(), 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 90 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 73 of file TargetSchedule.cpp.

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

Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), and llvm::ScheduleDAGMILive::dump().

◆ mustEndGroup()

bool TargetSchedModel::mustEndGroup ( const MachineInstr MI,
const MCSchedClassDesc SC = nullptr 
) const

Return true if current group must end.

Definition at line 84 of file TargetSchedule.cpp.

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

Referenced by llvm::SchedBoundary::bumpNode(), llvm::SchedBoundary::checkHazard(), and llvm::ScheduleDAGMILive::dump().

◆ resolveSchedClass()

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

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