15#ifndef LLVM_MCA_HARDWAREUNITS_LSUNIT_H
16#define LLVM_MCA_HARDWAREUNITS_LSUNIT_H
45 unsigned UsedLQEntries;
46 unsigned UsedSQEntries;
57 unsigned StoreQueueSize,
bool AssumeNoAlias);
99 bool isSQFull()
const {
return SQSize && SQSize == UsedSQEntries; }
100 bool isLQFull()
const {
return LQSize && LQSize == UsedLQEntries; }
246 unsigned NumPredecessors = 0;
247 unsigned NumExecutingPredecessors = 0;
248 unsigned NumExecutedPredecessors = 0;
250 unsigned NumInstructions = 0;
251 unsigned NumExecuting = 0;
252 unsigned NumExecuted = 0;
259 InstRef CriticalMemoryInstruction;
269 return OrderSucc.
size() + DataSucc.
size();
273 return NumExecutingPredecessors;
276 return NumExecutedPredecessors;
283 return CriticalMemoryInstruction;
286 return CriticalPredecessor;
296 Group->NumPredecessors++;
299 Group->
onGroupIssued(CriticalMemoryInstruction, IsDataDependent);
308 return NumPredecessors >
309 (NumExecutingPredecessors + NumExecutedPredecessors);
312 return NumExecutingPredecessors &&
313 ((NumExecutedPredecessors + NumExecutingPredecessors) ==
316 bool isReady()
const {
return NumExecutedPredecessors == NumPredecessors; }
318 return NumExecuting && (NumExecuting == (NumInstructions - NumExecuted));
320 bool isExecuted()
const {
return NumInstructions == NumExecuted; }
324 NumExecutingPredecessors++;
326 if (!ShouldUpdateCriticalDep)
329 unsigned Cycles =
IR.getInstruction()->getCyclesLeft();
330 if (CriticalPredecessor.
Cycles < Cycles) {
331 CriticalPredecessor.
IID =
IR.getSourceIndex();
332 CriticalPredecessor.
Cycles = Cycles;
338 NumExecutingPredecessors--;
339 NumExecutedPredecessors++;
348 if ((
bool)CriticalMemoryInstruction) {
350 *CriticalMemoryInstruction.getInstruction();
352 CriticalMemoryInstruction =
IR;
354 CriticalMemoryInstruction =
IR;
362 MG->onGroupIssued(CriticalMemoryInstruction,
false);
364 MG->onGroupExecuted();
368 MG->onGroupIssued(CriticalMemoryInstruction,
true);
376 if (CriticalMemoryInstruction &&
387 MG->onGroupExecuted();
397 CriticalPredecessor.
Cycles--;
424 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
430 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
436 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
442 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
468 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
469 Groups[GroupID]->onInstructionIssued(
IR);
479 virtual void dump()
const override;
483 bool isValidGroupID(
unsigned Index)
const {
487 const MemoryGroup &getGroup(
unsigned Index)
const {
488 assert(isValidGroupID(
Index) &&
"Group doesn't exist!");
492 MemoryGroup &getGroup(
unsigned Index) {
493 assert(isValidGroupID(
Index) &&
"Group doesn't exist!");
497 unsigned createMemoryGroup() {
This file defines the DenseMap class.
This file defines a base class for describing a simulated hardware unit.
Legalize the Machine IR a function s Machine IR
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An InstRef contains both a SourceMgr index and Instruction pair.
void invalidate()
Invalidate this reference.
unsigned getSourceIndex() const
An instruction propagated through the simulated instruction pipeline.
int getCyclesLeft() const
Abstract base interface for LS (load/store) units in llvm-mca.
virtual void dump() const =0
virtual unsigned dispatch(const InstRef &IR)=0
Allocates LS resources for instruction IR.
unsigned getUsedSQEntries() const
virtual bool isReady(const InstRef &IR) const =0
Check if a peviously dispatched instruction IR is now ready for execution.
virtual Status isAvailable(const InstRef &IR) const =0
This method checks the availability of the load/store buffers.
virtual void onInstructionRetired(const InstRef &IR)=0
virtual void onInstructionExecuted(const InstRef &IR)=0
virtual void cycleEvent()=0
unsigned getUsedLQEntries() const
bool assumeNoAlias() const
unsigned getLoadQueueSize() const
Returns the total number of entries in the load queue.
virtual bool isWaiting(const InstRef &IR) const =0
Check if instruction IR is still waiting on memory operations, and the wait time is still unknown.
virtual const CriticalDependency getCriticalPredecessor(unsigned GroupId)=0
virtual bool isPending(const InstRef &IR) const =0
Check if instruction IR only depends on memory instructions that are currently executing.
virtual bool hasDependentUsers(const InstRef &IR) const =0
unsigned getStoreQueueSize() const
Returns the total number of entries in the store queue.
virtual void onInstructionIssued(const InstRef &IR)=0
A node of a memory dependency graph.
unsigned getNumInstructions() const
unsigned getNumExecutingPredecessors() const
unsigned getNumExecuting() const
void onGroupIssued(const InstRef &IR, bool ShouldUpdateCriticalDep)
unsigned getNumPredecessors() const
void onInstructionExecuted(const InstRef &IR)
const CriticalDependency & getCriticalPredecessor() const
void addSuccessor(MemoryGroup *Group, bool IsDataDependent)
unsigned getNumExecuted() const
unsigned getNumExecutedPredecessors() const
MemoryGroup(MemoryGroup &&)=default
size_t getNumSuccessors() const
void onInstructionIssued(const InstRef &IR)
const InstRef & getCriticalMemoryInstruction() const
Default Load/Store Unit (LS Unit) for simulated processors.
virtual void dump() const override
unsigned CurrentLoadGroupID
bool isPending(const InstRef &IR) const override
Check if instruction IR only depends on memory instructions that are currently executing.
Status isAvailable(const InstRef &IR) const override
Returns LSU_AVAILABLE if there are enough load/store queue entries to accomodate instruction IR.
bool isReady(const InstRef &IR) const override
Check if a peviously dispatched instruction IR is now ready for execution.
DenseMap< unsigned, std::unique_ptr< MemoryGroup > > Groups
Used to map group identifiers to MemoryGroups.
virtual void onInstructionIssued(const InstRef &IR) override
unsigned CurrentStoreGroupID
virtual void cycleEvent() override
LSUnit(const MCSchedModel &SM, unsigned LQ, unsigned SQ, bool AssumeNoAlias)
virtual void onInstructionExecuted(const InstRef &IR) override
unsigned CurrentLoadBarrierGroupID
bool isWaiting(const InstRef &IR) const override
Check if instruction IR is still waiting on memory operations, and the wait time is still unknown.
virtual void onInstructionRetired(const InstRef &IR) override
unsigned dispatch(const InstRef &IR) override
Allocates LS resources for instruction IR.
unsigned CurrentStoreBarrierGroupID
LSUnit(const MCSchedModel &SM, unsigned LQ, unsigned SQ)
const CriticalDependency getCriticalPredecessor(unsigned GroupId) override
bool hasDependentUsers(const InstRef &IR) const override
LSUnit(const MCSchedModel &SM)
This is an optimization pass for GlobalISel generic memory operations.
Machine model for scheduling, bundling, and heuristics.
A critical data dependency descriptor.