19 #define DEBUG_TYPE "llvm-mca" 26 : LQSize(LQ), SQSize(SQ), UsedLQEntries(0), UsedSQEntries(0),
27 NoAlias(AssumeNoAlias), NextGroupID(1) {
45 for (
const std::pair<
unsigned, std::unique_ptr<MemoryGroup>> &
G : Groups)
46 G.second->cycleEvent();
56 for (
const auto &GroupIt : Groups) {
58 dbgs() <<
"[LSUnit] Group (" << GroupIt.first <<
"): " 88 unsigned ImmediateLoadDominator =
89 std::max(CurrentLoadGroupID, CurrentLoadBarrierGroupID);
90 if (ImmediateLoadDominator) {
92 LLVM_DEBUG(
dbgs() <<
"[LSUnit]: GROUP DEP: (" << ImmediateLoadDominator
93 <<
") --> (" << NewGID <<
")\n");
96 if (CurrentStoreGroupID) {
98 LLVM_DEBUG(
dbgs() <<
"[LSUnit]: GROUP DEP: (" << CurrentStoreGroupID
99 <<
") --> (" << NewGID <<
")\n");
103 CurrentStoreGroupID = NewGID;
105 CurrentLoadGroupID = NewGID;
107 CurrentLoadBarrierGroupID = NewGID;
121 bool ShouldCreateANewGroup = !CurrentLoadGroupID || IsMemBarrier ||
122 CurrentLoadGroupID <= CurrentStoreGroupID ||
123 CurrentLoadGroupID <= CurrentLoadBarrierGroupID;
124 if (ShouldCreateANewGroup) {
131 LLVM_DEBUG(
dbgs() <<
"[LSUnit]: GROUP DEP: (" << CurrentStoreGroupID
132 <<
") --> (" << NewGID <<
")\n");
135 if (CurrentLoadBarrierGroupID) {
137 LLVM_DEBUG(
dbgs() <<
"[LSUnit]: GROUP DEP: (" << CurrentLoadBarrierGroupID
138 <<
") --> (" << NewGID <<
")\n");
142 CurrentLoadGroupID = NewGID;
144 CurrentLoadBarrierGroupID = NewGID;
150 return CurrentLoadGroupID;
164 auto It = Groups.find(GroupID);
165 assert(It != Groups.end() &&
"Instruction not dispatched to the LS unit");
166 It->second->onInstructionExecuted();
167 if (It->second->isExecuted())
175 assert((IsALoad || IsAStore) &&
"Expected a memory operation!");
180 <<
" has been removed from the load queue.\n");
186 <<
" has been removed from the store queue.\n");
198 if (GroupID == CurrentLoadGroupID)
199 CurrentLoadGroupID = 0;
200 if (GroupID == CurrentStoreGroupID)
201 CurrentStoreGroupID = 0;
202 if (GroupID == CurrentLoadBarrierGroupID)
203 CurrentLoadBarrierGroupID = 0;
Instruction * getInstruction()
LSUnitBase(const MCSchedModel &SM, unsigned LoadQueueSize, unsigned StoreQueueSize, bool AssumeNoAlias)
An instruction propagated through the simulated instruction pipeline.
This class represents lattice values for constants.
bool isValidGroupID(unsigned Index) const
unsigned getLoadQueueSize() const
Returns the total number of entries in the load queue.
unsigned getNumInstructions() const
const MCProcResourceDesc * getProcResource(unsigned ProcResourceIdx) const
The two locations do not alias at all.
An InstRef contains both a SourceMgr index and Instruction pair.
A node of a memory dependency graph.
A Load/Store unit class that models load/store queues and that implements a simple weak memory consis...
virtual void cycleEvent()
unsigned getSourceIndex() const
virtual void onInstructionExecuted(const InstRef &IR)
unsigned createMemoryGroup()
unsigned dispatch(const InstRef &IR) override
Allocates LS resources for instruction IR.
unsigned getUsedLQEntries() const
unsigned getLSUTokenID() const
bool assumeNoAlias() const
void onInstructionExecuted(const InstRef &IR) override
unsigned getNumExecuted() const
const InstrDesc & getDesc() const
unsigned getNumExecutingPredecessors() const
bool hasExtraProcessorInfo() const
Status isAvailable(const InstRef &IR) const override
Returns LSU_AVAILABLE if there are enough load/store queue entries to accomodate instruction IR...
unsigned getNumExecutedPredecessors() const
unsigned getUsedSQEntries() const
Align max(MaybeAlign Lhs, Align Rhs)
Define a kind of processor resource that will be modeled by the scheduler.
void addSuccessor(MemoryGroup *Group)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned getNumExecuting() const
unsigned getNumPredecessors() const
unsigned getStoreQueueSize() const
Returns the total number of entries in the store queue.
virtual void onInstructionRetired(const InstRef &IR)
An instruction descriptor.
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
const MCExtraProcessorInfo & getExtraProcessorInfo() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Machine model for scheduling, bundling, and heuristics.
Statically lint checks LLVM IR
const MemoryGroup & getGroup(unsigned Index) const