16 #ifndef LLVM_MCA_INSTRUCTION_H 17 #define LLVM_MCA_INSTRUCTION_H 108 bool ClearsSuperRegs;
128 unsigned DependentWriteCyclesLeft;
140 bool clearsSuperRegs =
false,
bool writesZero =
false)
141 : WD(&Desc), CyclesLeft(UNKNOWN_CYCLES), RegisterID(RegID), PRFID(0),
142 ClearsSuperRegs(clearsSuperRegs), WritesZero(writesZero),
143 IsEliminated(
false), DependentWrite(nullptr), PartialWrite(nullptr),
144 DependentWriteCyclesLeft(0) {}
159 return DependentWriteCyclesLeft;
163 unsigned NumUsers = Users.
size();
173 return CyclesLeft != UNKNOWN_CYCLES && CyclesLeft <= 0;
179 DependentWriteCyclesLeft = Cycles;
180 DependentWrite =
nullptr;
185 assert(Users.
empty() &&
"Write is in an inconsistent state.");
190 void setPRF(
unsigned PRF) { PRFID = PRF; }
194 void onInstructionIssued();
214 unsigned DependentWrites;
223 unsigned TotalCycles;
230 bool IndependentFromDef;
234 : RD(&Desc), RegisterID(RegID), PRFID(0), DependentWrites(0),
235 CyclesLeft(UNKNOWN_CYCLES), TotalCycles(0), IsReady(
true),
250 void writeStartEvent(
unsigned Cycles);
252 DependentWrites = Writes;
270 CycleSegment(
unsigned StartCycle,
unsigned EndCycle,
bool IsReserved =
false)
271 : Begin(StartCycle), End(EndCycle), Reserved(IsReserved) {}
273 bool contains(
unsigned Cycle)
const {
return Cycle >= Begin && Cycle < End; }
277 return !startsAfter(CS) && !endsBefore(CS);
282 return Begin < Other.Begin;
293 unsigned size()
const {
return End - Begin; };
299 unsigned begin()
const {
return Begin; }
300 unsigned end()
const {
return End; }
301 void setEnd(
unsigned NewEnd) { End = NewEnd; }
315 : CS(Cycles), NumUnits(Units) {}
365 bool IsOptimizableMove;
392 unsigned NumUsers = 0;
394 NumUsers +=
Def.getNumUsers();
418 enum InstrStage
Stage;
438 void dispatch(
unsigned RCUTokenID);
453 bool isReady()
const {
return Stage == IS_READY; }
459 return isReady() && getDefs().size() &&
465 void forceExecuted();
468 assert(isExecuted() &&
"Instruction is in an invalid state!");
479 std::pair<unsigned, Instruction *>
Data;
492 operator bool()
const {
return Data.second !=
nullptr; }
515 std::pair<unsigned, WriteState *>
Data;
516 static const unsigned INVALID_IID;
527 assert(isValid() &&
"Invalid null WriteState found!");
528 return getWriteState()->isWriteZero();
534 if (getSourceIndex() == INVALID_IID)
540 bool isValid()
const {
return Data.first != INVALID_IID && Data.second; }
551 #endif // LLVM_MCA_INSTRUCTION_H const WriteState * getWriteState() const
Instruction * getInstruction()
unsigned getRegisterFileID() const
bool isEliminated() const
An instruction propagated through the simulated instruction pipeline.
bool hasDependentUsers() const
unsigned getLatency() const
WriteState(const WriteDescriptor &Desc, unsigned RegID, bool clearsSuperRegs=false, bool writesZero=false)
InstructionBase(const InstrDesc &D)
This class represents lattice values for constants.
constexpr int UNKNOWN_CYCLES
int getCyclesLeft() const
bool isAvailable() const
Returns true if this register write has been executed, and the new register value is therefore availa...
InstRef(unsigned Index, Instruction *I)
bool operator==(const WriteRef &Other) const
SmallVector< uint64_t, 4 > Buffers
bool isDispatched() const
bool isImplicitRead() const
A register read descriptor.
Instruction(const InstrDesc &D)
unsigned SClassOrWriteResourceID
WriteState * getWriteState()
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
block Block Frequency true
iv Induction Variable Users
An InstRef contains both a SourceMgr index and Instruction pair.
WriteRef(unsigned SourceIndex, WriteState *WS)
const ReadDescriptor & getDescriptor() const
unsigned getSourceIndex() const
SmallVectorImpl< WriteState > & getDefs()
void setDependentWrite(WriteState *Other)
Tracks register operand latency in cycles.
A Use represents the edge between a Value definition and its users.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isEliminated() const
SmallVector< ReadDescriptor, 4 > Reads
unsigned getRegisterID() const
void subtract(unsigned Cycles)
void setIndependentFromDef()
unsigned getNumUsers() const
Helper used by class InstrDesc to describe how hardware resources are used.
unsigned getLatency() const
A register write descriptor.
bool isImplicitRead() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const InstrDesc & getDesc() const
ResourceUsage(CycleSegment Cycles, unsigned Units=1)
int getCyclesLeft() const
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
const ArrayRef< ReadState > getUses() const
void setOptimizableMove()
bool operator==(const InstRef &Other) const
ReadState(const ReadDescriptor &Desc, unsigned RegID)
CycleSegment(unsigned StartCycle, unsigned EndCycle, bool IsReserved=false)
void invalidate()
Invalidate this reference.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
SmallVectorImpl< ReadState > & getUses()
unsigned getRCUTokenID() const
CycleSegment & operator--(void)
const ArrayRef< WriteState > getDefs() const
SmallVector< std::pair< uint64_t, ResourceUsage >, 4 > Resources
void setDependentWrites(unsigned Writes)
unsigned getRegisterFileID() const
Base class for instructions consumed by the simulation pipeline.
bool startsAfter(const CycleSegment &CS) const
bool isImplicitWrite() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Tracks uses of a register definition (e.g.
bool endsBefore(const CycleSegment &CS) const
void writeStartEvent(unsigned Cycles)
const WriteState * getDependentWrite() const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
A reference to a register write.
void setEnd(unsigned NewEnd)
bool isOptimizableMove() const
bool isIndependentFromDef() const
bool MustIssueImmediately
raw_ostream & operator<<(raw_ostream &OS, const InstRef &IR)
void setPRF(unsigned PRF)
An instruction descriptor.
unsigned getSourceIndex() const
bool overlaps(const CycleSegment &CS) const
LLVM_NODISCARD bool empty() const
bool isZeroLatency() const
unsigned getDependentWriteCyclesLeft() const
unsigned getNumUsers() const
unsigned getRegisterID() const
bool operator<(const CycleSegment &Other) const
unsigned getWriteResourceID() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const Instruction * getInstruction() const
void print(raw_ostream &OS) const
This class implements an extremely fast bulk output stream that can only output to a stream...
bool clearsSuperRegisters() const
bool contains(unsigned Cycle) const
Statically lint checks LLVM IR
SmallVector< WriteDescriptor, 4 > Writes
unsigned getSchedClass() const