21 #define DEBUG_TYPE "llvm-mca" 80 Error ExecuteStage::issueReadyInstructions() {
83 if (
Error Err = issueInstruction(IR))
99 HWS.
cycleEvent(Freed, Executed, Pending, Ready);
100 NumDispatchedOpcodes = 0;
101 NumIssuedOpcodes = 0;
113 for (
const InstRef &IR : Pending)
116 for (
const InstRef &IR : Ready)
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 assert(!Desc.MayLoad && !Desc.MayStore &&
"Cannot eliminate a memory op!");
173 Error ExecuteStage::handleInstructionEliminated(
InstRef &IR) {
195 return handleInstructionEliminated(IR);
201 bool IsReadyInstruction = HWS.
dispatch(IR);
204 NumDispatchedOpcodes += NumMicroOps;
207 if (!IsReadyInstruction) {
224 return issueInstruction(IR);
228 LLVM_DEBUG(
dbgs() <<
"[E] Instruction Executed: #" << IR <<
'\n');
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);
256 dbgs() <<
"[E] Instruction Issued: #" << IR <<
'\n';
257 for (
const std::pair<ResourceRef, ResourceCycles> &Resource : Used) {
258 assert(Resource.second.getDenominator() == 1 &&
"Invalid cycles!");
259 dbgs() <<
"[E] Resource Used: [" << Resource.first.first <<
'.' 260 << Resource.first.second <<
"], ";
261 dbgs() <<
"cycles: " << Resource.second.getNumerator() <<
'\n';
266 for (std::pair<ResourceRef, ResourceCycles> &
Use : Used)
273 bool Reserved)
const {
279 for (
unsigned I = 0,
E = BufferIDs.
size();
I <
E; ++
I) {
280 uint64_t CurrentBufferMask = UsedBuffers & (-UsedBuffers);
282 UsedBuffers ^= CurrentBufferMask;
287 Listener->onReservedBuffers(IR, BufferIDs);
292 Listener->onReleasedBuffers(IR, BufferIDs);
Instruction * getInstruction()
void notifyEvent(const EventT &Event) const
Notify listeners of a particular hardware event.
void notifyInstructionPending(const InstRef &IR) const
An instruction propagated through the simulated instruction pipeline.
This class represents lattice values for constants.
void sanityCheck(const InstRef &IR) const
Status isAvailable(const InstRef &IR)
Check if the instruction in 'IR' can be dispatched during this cycle.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
void issueInstruction(InstRef &IR, SmallVectorImpl< std::pair< ResourceRef, ResourceCycles >> &Used, SmallVectorImpl< InstRef > &Pending, SmallVectorImpl< InstRef > &Ready)
Issue an instruction and populates a vector of used pipeline resources, and a vector of instructions ...
const std::set< HWEventListener * > & getListeners() const
Subclass of Error for the sole purpose of identifying the success path in the type system...
void notifyInstructionReady(const InstRef &IR) const
InstRef select()
Select the next instruction to issue from the ReadySet.
bool isAvailable(const InstRef &IR) const override
Returns true if it can execute IR during this cycle.
An InstRef contains both a SourceMgr index and Instruction pair.
Error cycleStart() override
Called once at the start of each cycle.
HWStallEvent::GenericEventType toHWStallEventType(Scheduler::Status Status)
void notifyResourceAvailable(const ResourceRef &RR) const
This file defines the execution stage of a default instruction pipeline.
unsigned getResourceID(uint64_t Mask) const
Convert a resource mask into a valid llvm processor resource identifier.
A Use represents the edge between a Value definition and its users.
static void verifyInstructionEliminated(const InstRef &IR)
bool isEliminated() const
void notifyInstructionIssued(const InstRef &IR, MutableArrayRef< std::pair< ResourceRef, ResourceCycles >> Used) const
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.
uint64_t analyzeResourcePressure(SmallVectorImpl< InstRef > &Insts)
Returns a mask of busy resources, and populates vector Insts with instructions that could not be issu...
unsigned getNumMicroOps() const
const InstrDesc & getDesc() const
Error cycleEnd() override
Called once at the end of each cycle.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void notifyReservedOrReleasedBuffers(const InstRef &IR, bool Reserved) const
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void notifyInstructionExecuted(const InstRef &IR) const
unsigned countPopulation(T Value)
Count the number of set bits in a value.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool hadTokenStall() const
Error moveToTheNextStage(InstRef &IR)
Called when an instruction is ready to move the next pipeline stage.
An instruction descriptor.
bool mustIssueImmediately(const InstRef &IR) const
Returns true if IR has to be issued immediately, or if IR is a zero latency instruction.
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 ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
bool dispatch(InstRef &IR)
Reserves buffer and LSUnit queue resources that are necessary to issue this instruction.
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Statically lint checks LLVM IR