15 #ifndef LLVM_MCA_LSUNIT_H 16 #define LLVM_MCA_LSUNIT_H 38 unsigned NumPredecessors;
39 unsigned NumExecutingPredecessors;
40 unsigned NumExecutedPredecessors;
42 unsigned NumInstructions;
43 unsigned NumExecuting;
48 InstRef CriticalMemoryInstruction;
55 : NumPredecessors(0), NumExecutingPredecessors(0),
56 NumExecutedPredecessors(0), NumInstructions(0), NumExecuting(0),
57 NumExecuted(0), CriticalPredecessor(), CriticalMemoryInstruction() {}
64 return NumExecutingPredecessors;
67 return NumExecutedPredecessors;
74 return CriticalMemoryInstruction;
77 return CriticalPredecessor;
81 Group->NumPredecessors++;
89 return NumPredecessors >
90 (NumExecutingPredecessors + NumExecutedPredecessors);
93 return NumExecutingPredecessors &&
94 ((NumExecutedPredecessors + NumExecutingPredecessors) ==
97 bool isReady()
const {
return NumExecutedPredecessors == NumPredecessors; }
99 return NumExecuting && (NumExecuting == (NumInstructions - NumExecuted));
101 bool isExecuted()
const {
return NumInstructions == NumExecuted; }
105 NumExecutingPredecessors++;
108 if (CriticalPredecessor.
Cycles < Cycles) {
110 CriticalPredecessor.
Cycles = Cycles;
116 NumExecutingPredecessors--;
117 NumExecutedPredecessors++;
126 if ((
bool)CriticalMemoryInstruction) {
127 const Instruction &OtherIS = *CriticalMemoryInstruction.getInstruction();
129 CriticalMemoryInstruction = IR;
131 CriticalMemoryInstruction =
IR;
139 MG->onGroupIssued(CriticalMemoryInstruction);
152 MG->onGroupExecuted();
162 CriticalPredecessor.
Cycles--;
184 unsigned UsedLQEntries;
185 unsigned UsedSQEntries;
196 unsigned NextGroupID;
200 unsigned StoreQueueSize,
bool AssumeNoAlias);
238 virtual unsigned dispatch(
const InstRef &
IR) = 0;
242 bool isSQFull()
const {
return SQSize && SQSize == UsedSQEntries; }
243 bool isLQFull()
const {
return LQSize && LQSize == UsedLQEntries; }
246 return Index && (Groups.
find(Index) != Groups.
end());
279 assert(isValidGroupID(Index) &&
"Group doesn't exist!");
280 return *Groups.
find(Index)->second;
284 assert(isValidGroupID(Index) &&
"Group doesn't exist!");
285 return *Groups.
find(Index)->second;
290 std::make_pair(NextGroupID, std::make_unique<MemoryGroup>()));
291 return NextGroupID++;
300 virtual void onInstructionRetired(
const InstRef &IR);
304 Groups[GroupID]->onInstructionIssued(IR);
414 unsigned CurrentLoadGroupID;
415 unsigned CurrentLoadBarrierGroupID;
416 unsigned CurrentStoreGroupID;
424 :
LSUnitBase(SM, LQ, SQ, AssumeNoAlias), CurrentLoadGroupID(0),
425 CurrentLoadBarrierGroupID(0), CurrentStoreGroupID(0) {}
444 unsigned dispatch(
const InstRef &IR)
override;
452 #endif // LLVM_MCA_LSUNIT_H Instruction * getInstruction()
reference emplace_back(ArgTypes &&... Args)
An instruction propagated through the simulated instruction pipeline.
This class represents lattice values for constants.
int getCyclesLeft() const
bool isValidGroupID(unsigned Index) const
unsigned getLoadQueueSize() const
Returns the total number of entries in the load queue.
unsigned getNumInstructions() const
The two locations do not alias at all.
LSUnit(const MCSchedModel &SM, unsigned LQ, unsigned SQ)
An InstRef contains both a SourceMgr index and Instruction pair.
A node of a memory dependency graph.
const InstRef & getCriticalMemoryInstruction() const
void onInstructionIssued(const InstRef &IR)
unsigned getSourceIndex() const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Default Load/Store Unit (LS Unit) for simulated processors.
unsigned createMemoryGroup()
LSUnit(const MCSchedModel &SM)
unsigned getUsedLQEntries() const
ArrayRef< MemoryGroup * > getSuccessors() const
unsigned getLSUTokenID() const
Abstract base interface for LS (load/store) units in llvm-mca.
bool assumeNoAlias() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getNumExecuted() const
iterator find(const_arg_type_t< KeyT > Val)
void onInstructionExecuted()
unsigned getNumExecutingPredecessors() const
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool hasDependentUsers(const InstRef &IR) const
unsigned getNumExecutedPredecessors() const
This file defines a base class for describing a simulated hardware unit.
unsigned getUsedSQEntries() const
A critical data dependency descriptor.
static const X86InstrFMA3Group Groups[]
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void addSuccessor(MemoryGroup *Group)
const CriticalDependency & getCriticalPredecessor() const
unsigned getNumExecuting() const
unsigned getNumPredecessors() const
unsigned getStoreQueueSize() const
Returns the total number of entries in the store queue.
bool isPending(const InstRef &IR) const
Check if instruction IR only depends on memory instructions that are currently executing.
unsigned getNumSuccessors() const
MemoryGroup & getGroup(unsigned Index)
bool isWaiting(const InstRef &IR) const
Check if instruction IR is still waiting on memory operations, and the wait time is still unknown...
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Machine Instruction Scheduler
void onGroupIssued(const InstRef &IR)
LSUnit(const MCSchedModel &SM, unsigned LQ, unsigned SQ, bool AssumeNoAlias)
virtual void onInstructionIssued(const InstRef &IR)
Machine model for scheduling, bundling, and heuristics.
Statically lint checks LLVM IR
const MemoryGroup & getGroup(unsigned Index) const
bool isReady(const InstRef &IR) const
Check if a peviously dispatched instruction IR is now ready for execution.