22 #define DEBUG_TYPE "llvm-mca" 74 Error ExecuteStage::issueReadyInstructions() {
77 if (
Error Err = issueInstruction(IR))
104 for (
const InstRef &IR : Ready)
107 return issueReadyInstructions();
114 assert(Inst.
isReady() &&
"Instruction in an inconsistent state!");
119 assert(!Desc.MayLoad && !Desc.MayStore &&
"Cannot eliminate a memory op!");
123 Error ExecuteStage::handleInstructionEliminated(
InstRef &IR) {
144 return handleInstructionEliminated(IR);
164 return issueInstruction(IR);
168 LLVM_DEBUG(
dbgs() <<
"[E] Instruction Executed: #" << IR <<
'\n');
169 notifyEvent<HWInstructionEvent>(
175 notifyEvent<HWInstructionEvent>(
180 LLVM_DEBUG(
dbgs() <<
"[E] Resource Available: [" << RR.first <<
'.' 181 << RR.second <<
"]\n");
183 Listener->onResourceAvailable(RR);
190 dbgs() <<
"[E] Instruction Issued: #" << IR <<
'\n';
191 for (
const std::pair<ResourceRef, ResourceCycles> &Resource : Used) {
192 dbgs() <<
"[E] Resource Used: [" << Resource.first.first <<
'.' 193 << Resource.first.second <<
"], ";
194 dbgs() <<
"cycles: " << Resource.second <<
'\n';
199 for (std::pair<ResourceRef, ResourceCycles> &
Use : Used)
206 bool Reserved)
const {
216 Listener->onReservedBuffers(IR, BufferIDs);
221 Listener->onReleasedBuffers(IR, BufferIDs);
bool isReady(const InstRef &IR) const
Returns true if IR is ready to be executed by the underlying pipelines.
Instruction * getInstruction()
Status isAvailable(const InstRef &IR) const
Check if the instruction in 'IR' can be dispatched and returns an answer in the form of a Status valu...
An instruction propagated through the simulated instruction pipeline.
void cycleEvent(SmallVectorImpl< ResourceRef > &Freed, SmallVectorImpl< InstRef > &Ready, SmallVectorImpl< InstRef > &Executed)
This routine notifies the Scheduler that a new cycle just started.
This class represents lattice values for constants.
void sanityCheck(const InstRef &IR) const
SmallVector< uint64_t, 4 > Buffers
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
const InstrDesc & getDesc() const
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
void notifyReservedOrReleasedBuffers(const InstRef &IR, bool Reserved) const
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
void issueInstruction(InstRef &IR, SmallVectorImpl< std::pair< ResourceRef, ResourceCycles >> &Used, SmallVectorImpl< InstRef > &Ready)
Issue an instruction and populates a vector of used pipeline resources, and a vector of instructions ...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void notifyInstructionExecuted(const InstRef &IR) const
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.
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
LLVM_NODISCARD bool empty() const
OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate P)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Statically lint checks LLVM IR
void dispatch(const InstRef &IR)
Reserves buffer and LSUnit queue resources that are necessary to issue this instruction.