21#define DEBUG_TYPE "llvm-mca"
72 for (
const InstRef &
I : Pending)
75 for (
const InstRef &
I : Ready)
80Error ExecuteStage::issueReadyInstructions() {
83 if (Error Err = issueInstruction(
IR))
90 return ErrorSuccess();
99 HWS.
cycleEvent(Freed, Executed, Pending, Ready);
100 NumDispatchedOpcodes = 0;
101 NumIssuedOpcodes = 0;
119 return issueReadyInstructions();
123 if (!EnablePressureEvents)
128 if (!HWS.
hadTokenStall() && NumDispatchedOpcodes <= NumIssuedOpcodes)
134 LLVM_DEBUG(
dbgs() <<
"[E] Backpressure increased because of unavailable "
135 "pipeline resources: "
144 if (RegDeps.
size()) {
146 dbgs() <<
"[E] Backpressure increased by register dependencies\n");
151 if (MemDeps.
size()) {
152 LLVM_DEBUG(
dbgs() <<
"[E] Backpressure increased by memory dependencies\n");
164 assert(Inst.
isReady() &&
"Instruction in an inconsistent state!");
169 "Cannot eliminate a memory op!");
173Error ExecuteStage::handleInstructionEliminated(InstRef &
IR) {
180 IR.getInstruction()->forceExecuted();
194 if (
IR.getInstruction()->isEliminated())
195 return handleInstructionEliminated(
IR);
204 NumDispatchedOpcodes += NumMicroOps;
207 if (!IsReadyInstruction) {
224 return issueInstruction(
IR);
229 notifyEvent<HWInstructionEvent>(
235 notifyEvent<HWInstructionEvent>(
241 notifyEvent<HWInstructionEvent>(
246 LLVM_DEBUG(
dbgs() <<
"[E] Resource Available: [" << RR.first <<
'.'
247 << RR.second <<
"]\n");
249 Listener->onResourceAvailable(RR);
255 dbgs() <<
"[E] Instruction Issued: #" <<
IR <<
'\n';
257 assert(
Use.second.getDenominator() == 1 &&
"Invalid cycles!");
258 dbgs() <<
"[E] Resource Used: [" <<
Use.first.first <<
'.'
259 <<
Use.first.second <<
"], ";
260 dbgs() <<
"cycles: " <<
Use.second.getNumerator() <<
'\n';
273 uint64_t UsedBuffers =
IR.getInstruction()->getDesc().UsedBuffers;
278 for (
unsigned I = 0,
E = BufferIDs.
size();
I <
E; ++
I) {
279 uint64_t CurrentBufferMask = UsedBuffers & (-UsedBuffers);
281 UsedBuffers ^= CurrentBufferMask;
286 Listener->onReservedBuffers(
IR, BufferIDs);
291 Listener->onReleasedBuffers(
IR, BufferIDs);
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the execution stage of a default instruction pipeline.
Legalize the Machine IR a function s Machine IR
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Subclass of Error for the sole purpose of identifying the success path in the type system.
Lightweight error class with error context and mandatory checking.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
void notifyResourceAvailable(const ResourceRef &RR) const
Error cycleStart() override
Called once at the start of each cycle.
bool isAvailable(const InstRef &IR) const override
Returns true if it can execute IR during this cycle.
Error cycleEnd() override
Called once at the end of each cycle.
void notifyInstructionExecuted(const InstRef &IR) const
void notifyInstructionIssued(const InstRef &IR, MutableArrayRef< ResourceUse > Used) const
void notifyReservedOrReleasedBuffers(const InstRef &IR, bool Reserved) const
void notifyInstructionReady(const InstRef &IR) const
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
void notifyInstructionPending(const InstRef &IR) const
An InstRef contains both a SourceMgr index and Instruction pair.
unsigned getNumMicroOps() const
An instruction propagated through the simulated instruction pipeline.
bool isEliminated() const
@ SC_DISPATCH_GROUP_STALL
InstRef select()
Select the next instruction to issue from the ReadySet.
unsigned getResourceID(uint64_t Mask) const
Convert a resource mask into a valid llvm processor resource identifier.
void issueInstruction(InstRef &IR, SmallVectorImpl< std::pair< ResourceRef, ReleaseAtCycles > > &Used, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)
Issue an instruction and populates a vector of used pipeline resources, and a vector of instructions ...
Status isAvailable(const InstRef &IR)
Check if the instruction in 'IR' can be dispatched during this cycle.
void analyzeDataDependencies(SmallVectorImpl< InstRef > &RegDeps, SmallVectorImpl< InstRef > &MemDeps)
This method is called by the ExecuteStage at the end of each cycle to identify bottlenecks caused by ...
bool dispatch(InstRef &IR)
Reserves buffer and LSUnit queue resources that are necessary to issue this instruction.
void cycleEvent(SmallVectorImpl< ResourceRef > &Freed, SmallVectorImpl< InstRef > &Executed, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)
This routine notifies the Scheduler that a new cycle just started.
bool mustIssueImmediately(const InstRef &IR) const
Returns true if IR has to be issued immediately, or if IR is a zero latency instruction.
uint64_t analyzeResourcePressure(SmallVectorImpl< InstRef > &Insts)
Returns a mask of busy resources, and populates vector Insts with instructions that could not be issu...
void instructionCheck(const InstRef &IR) const
bool hadTokenStall() const
Error moveToTheNextStage(InstRef &IR)
Called when an instruction is ready to move the next pipeline stage.
void notifyEvent(const EventT &Event) const
Notify listeners of a particular hardware event.
const std::set< HWEventListener * > & getListeners() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::pair< ResourceRef, ReleaseAtCycles > ResourceUse
HWStallEvent::GenericEventType toHWStallEventType(Scheduler::Status Status)
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
static void verifyInstructionEliminated(const InstRef &IR)
This is an optimization pass for GlobalISel generic memory operations.
int popcount(T Value) noexcept
Count the number of set bits in a value.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.