23 #define DEBUG_TYPE "llvm-mca" 32 : DispatchWidth(MaxDispatchWidth), AvailableEntries(MaxDispatchWidth),
33 CarryOver(0U), CarriedOver(), STI(Subtarget), RCU(R), PRF(F) {
38 void DispatchStage::notifyInstructionDispatched(
const InstRef &
IR,
40 unsigned UOps)
const {
41 LLVM_DEBUG(
dbgs() <<
"[E] Instruction Dispatched: #" << IR <<
'\n');
42 notifyEvent<HWInstructionEvent>(
46 bool DispatchStage::checkPRF(
const InstRef &IR)
const {
54 notifyEvent<HWStallEvent>(
62 bool DispatchStage::checkRCU(
const InstRef &IR)
const {
66 notifyEvent<HWStallEvent>(
71 bool DispatchStage::canDispatch(
const InstRef &IR)
const {
72 bool CanDispatch = checkRCU(IR);
73 CanDispatch &= checkPRF(IR);
79 assert(!CarryOver &&
"Cannot dispatch another instruction!");
83 if (NumMicroOps > DispatchWidth) {
84 assert(AvailableEntries == DispatchWidth);
86 CarryOver = NumMicroOps - DispatchWidth;
89 assert(AvailableEntries >= NumMicroOps);
90 AvailableEntries -= NumMicroOps;
99 assert(IS.
getDefs().size() == 1 &&
"Expected a single input!");
100 assert(IS.
getUses().size() == 1 &&
"Expected a single output!");
127 unsigned RCUTokenID = RCU.
dispatch(IR);
133 notifyInstructionDispatched(IR, RegisterFiles,
134 std::min(DispatchWidth, NumMicroOps));
142 AvailableEntries = DispatchWidth;
146 AvailableEntries = CarryOver >= DispatchWidth ? 0 : DispatchWidth - CarryOver;
147 unsigned DispatchedOpcodes = DispatchWidth - AvailableEntries;
148 CarryOver -= DispatchedOpcodes;
149 assert(CarriedOver &&
"Invalid dispatched instruction");
152 notifyInstructionDispatched(CarriedOver, RegisterFiles, DispatchedOpcodes);
162 unsigned Required = std::min(NumMicroOps, DispatchWidth);
163 if (Required > AvailableEntries)
166 if (Desc.
BeginGroup && AvailableEntries != DispatchWidth)
172 return canDispatch(IR);
176 assert(canDispatch(IR) &&
"Cannot dispatch another instruction!");
Instruction * getInstruction()
reference emplace_back(ArgTypes &&... Args)
An instruction propagated through the simulated instruction pipeline.
This class represents lattice values for constants.
void addRegisterWrite(WriteRef Write, MutableArrayRef< unsigned > UsedPhysRegs)
Subclass of Error for the sole purpose of identifying the success path in the type system...
unsigned getNumRegisterFiles() const
bool checkNextStage(const InstRef &IR) const
An InstRef contains both a SourceMgr index and Instruction pair.
unsigned getSourceIndex() const
unsigned isAvailable(ArrayRef< MCPhysReg > Regs) const
SmallVectorImpl< WriteState > & getDefs()
This class tracks which instructions are in-flight (i.e., dispatched but not retired) in the OoO back...
Tracks register operand latency in cycles.
bool isEliminated() const
Error cycleStart() override
Called once at the start of each cycle.
unsigned getNumMicroOps() const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
const InstrDesc & getDesc() const
unsigned const MachineRegisterInfo * MRI
unsigned dispatch(const InstRef &IS)
Manages hardware register files, and tracks register definitions for register renaming purposes...
SmallVectorImpl< ReadState > & getUses()
void dispatch(unsigned RCUTokenID)
This file defines the main interface for hardware event listeners.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Tracks uses of a register definition (e.g.
A reference to a register write.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isOptimizableMove() const
Error moveToTheNextStage(InstRef &IR)
Called when an instruction is ready to move the next pipeline stage.
An instruction descriptor.
This file models the dispatch component of an instruction pipeline.
DispatchStage(const MCSubtargetInfo &Subtarget, const MCRegisterInfo &MRI, unsigned MaxDispatchWidth, RetireControlUnit &R, RegisterFile &F)
bool isAvailable(unsigned Quantity=1) const
void addRegisterRead(ReadState &RS, const MCSubtargetInfo &STI) const
Generic base class for all target subtargets.
bool tryEliminateMove(WriteState &WS, ReadState &RS)
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
A scheduler for Processor Resource Units and Processor Resource Groups.
Statically lint checks LLVM IR
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget's CPU.
bool isAvailable(const InstRef &IR) const override
Returns true if it can execute IR during this cycle.