15#ifndef LLVM_MCA_HARDWAREUNITS_LSUNIT_H
16#define LLVM_MCA_HARDWAREUNITS_LSUNIT_H
36 unsigned NumPredecessors;
37 unsigned NumExecutingPredecessors;
38 unsigned NumExecutedPredecessors;
40 unsigned NumInstructions;
41 unsigned NumExecuting;
49 InstRef CriticalMemoryInstruction;
56 : NumPredecessors(0), NumExecutingPredecessors(0),
57 NumExecutedPredecessors(0), NumInstructions(0), NumExecuting(0),
58 NumExecuted(0), CriticalPredecessor() {}
62 return OrderSucc.
size() + DataSucc.
size();
66 return NumExecutingPredecessors;
69 return NumExecutedPredecessors;
76 return CriticalMemoryInstruction;
79 return CriticalPredecessor;
89 Group->NumPredecessors++;
92 Group->
onGroupIssued(CriticalMemoryInstruction, IsDataDependent);
101 return NumPredecessors >
102 (NumExecutingPredecessors + NumExecutedPredecessors);
105 return NumExecutingPredecessors &&
106 ((NumExecutedPredecessors + NumExecutingPredecessors) ==
109 bool isReady()
const {
return NumExecutedPredecessors == NumPredecessors; }
111 return NumExecuting && (NumExecuting == (NumInstructions - NumExecuted));
113 bool isExecuted()
const {
return NumInstructions == NumExecuted; }
117 NumExecutingPredecessors++;
119 if (!ShouldUpdateCriticalDep)
122 unsigned Cycles =
IR.getInstruction()->getCyclesLeft();
123 if (CriticalPredecessor.
Cycles < Cycles) {
124 CriticalPredecessor.
IID =
IR.getSourceIndex();
125 CriticalPredecessor.
Cycles = Cycles;
131 NumExecutingPredecessors--;
132 NumExecutedPredecessors++;
141 if ((
bool)CriticalMemoryInstruction) {
142 const Instruction &OtherIS = *CriticalMemoryInstruction.getInstruction();
144 CriticalMemoryInstruction =
IR;
146 CriticalMemoryInstruction =
IR;
154 MG->onGroupIssued(CriticalMemoryInstruction,
false);
156 MG->onGroupExecuted();
160 MG->onGroupIssued(CriticalMemoryInstruction,
true);
168 if (CriticalMemoryInstruction &&
178 MG->onGroupExecuted();
188 CriticalPredecessor.
Cycles--;
210 unsigned UsedLQEntries;
211 unsigned UsedSQEntries;
222 unsigned NextGroupID;
226 unsigned StoreQueueSize,
bool AssumeNoAlias);
268 bool isSQFull()
const {
return SQSize && SQSize == UsedSQEntries; }
269 bool isLQFull()
const {
return LQSize && LQSize == UsedLQEntries; }
277 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
285 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
293 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
299 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
316 std::make_pair(NextGroupID, std::make_unique<MemoryGroup>()));
317 return NextGroupID++;
329 unsigned GroupID =
IR.getInstruction()->getLSUTokenID();
330 Groups[GroupID]->onInstructionIssued(
IR);
440 unsigned CurrentLoadGroupID;
441 unsigned CurrentLoadBarrierGroupID;
442 unsigned CurrentStoreGroupID;
443 unsigned CurrentStoreBarrierGroupID;
451 :
LSUnitBase(SM, LQ, SQ, AssumeNoAlias), CurrentLoadGroupID(0),
452 CurrentLoadBarrierGroupID(0), CurrentStoreGroupID(0),
453 CurrentStoreBarrierGroupID(0) {}
This file defines the DenseMap class.
This file defines a base class for describing a simulated hardware unit.
Statically lint checks LLVM 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.
iterator find(const_arg_type_t< KeyT > Val)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
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.
MemoryGroup & getGroup(unsigned Index)
virtual unsigned dispatch(const InstRef &IR)=0
Allocates LS resources for instruction IR.
virtual void onInstructionExecuted(const InstRef &IR)
unsigned getUsedSQEntries() const
bool isWaiting(const InstRef &IR) const
Check if instruction IR is still waiting on memory operations, and the wait time is still unknown.
virtual void onInstructionIssued(const InstRef &IR)
bool isValidGroupID(unsigned Index) const
const MemoryGroup & getGroup(unsigned Index) const
unsigned createMemoryGroup()
bool isPending(const InstRef &IR) const
Check if instruction IR only depends on memory instructions that are currently executing.
virtual Status isAvailable(const InstRef &IR) const =0
This method checks the availability of the load/store buffers.
virtual void cycleEvent()
unsigned getUsedLQEntries() const
bool assumeNoAlias() const
bool hasDependentUsers(const InstRef &IR) const
virtual void onInstructionRetired(const InstRef &IR)
unsigned getLoadQueueSize() const
Returns the total number of entries in the load queue.
unsigned getStoreQueueSize() const
Returns the total number of entries in the store queue.
bool isReady(const InstRef &IR) const
Check if a peviously dispatched instruction IR is now ready for execution.
Default Load/Store Unit (LS Unit) for simulated processors.
Status isAvailable(const InstRef &IR) const override
Returns LSU_AVAILABLE if there are enough load/store queue entries to accomodate instruction IR.
LSUnit(const MCSchedModel &SM, unsigned LQ, unsigned SQ, bool AssumeNoAlias)
void onInstructionExecuted(const InstRef &IR) override
unsigned dispatch(const InstRef &IR) override
Allocates LS resources for instruction IR.
LSUnit(const MCSchedModel &SM, unsigned LQ, unsigned SQ)
LSUnit(const MCSchedModel &SM)
A node of a memory dependency graph.
unsigned getNumExecuted() const
unsigned getNumExecutingPredecessors() const
unsigned getNumExecuting() const
const InstRef & getCriticalMemoryInstruction() const
unsigned getNumExecutedPredecessors() const
unsigned getNumInstructions() const
unsigned getNumPredecessors() const
void onGroupIssued(const InstRef &IR, bool ShouldUpdateCriticalDep)
const CriticalDependency & getCriticalPredecessor() const
void addSuccessor(MemoryGroup *Group, bool IsDataDependent)
void onInstructionExecuted(const InstRef &IR)
void onInstructionIssued(const InstRef &IR)
MemoryGroup(MemoryGroup &&)=default
size_t getNumSuccessors() const
This is an optimization pass for GlobalISel generic memory operations.
Machine model for scheduling, bundling, and heuristics.
A critical data dependency descriptor.