15 #ifndef LLVM_MCA_INSTRUCTION_H 16 #define LLVM_MCA_INSTRUCTION_H 117 bool ClearsSuperRegs;
136 unsigned DependentWriteCyclesLeft;
151 bool clearsSuperRegs =
false,
bool writesZero =
false)
152 : WD(&Desc), CyclesLeft(UNKNOWN_CYCLES), RegisterID(RegID), PRFID(0),
153 ClearsSuperRegs(clearsSuperRegs), WritesZero(writesZero),
154 IsEliminated(
false), DependentWrite(nullptr), PartialWrite(nullptr),
155 DependentWriteCyclesLeft(0), CRD() {}
166 return DependentWriteCyclesLeft;
175 void addUser(
unsigned IID,
ReadState *
Use,
int ReadAdvance);
182 unsigned NumUsers = Users.
size();
195 unsigned CyclesLeft = getDependentWriteCyclesLeft();
196 return !CyclesLeft || CyclesLeft <
getLatency();
200 return CyclesLeft != UNKNOWN_CYCLES && CyclesLeft <= 0;
204 void writeStartEvent(
unsigned IID,
MCPhysReg RegID,
unsigned Cycles);
207 assert(Users.
empty() &&
"Write is in an inconsistent state.");
212 void setPRF(
unsigned PRF) { PRFID = PRF; }
216 void onInstructionIssued(
unsigned IID);
236 unsigned DependentWrites;
245 unsigned TotalCycles;
254 bool IndependentFromDef;
258 : RD(&Desc), RegisterID(RegID), PRFID(0), DependentWrites(0),
259 CyclesLeft(UNKNOWN_CYCLES), TotalCycles(0), CRD(), IsReady(
true),
268 bool isPending()
const {
return !IndependentFromDef && CyclesLeft > 0; }
276 void writeStartEvent(
unsigned IID,
MCPhysReg RegID,
unsigned Cycles);
278 DependentWrites = Writes;
296 CycleSegment(
unsigned StartCycle,
unsigned EndCycle,
bool IsReserved =
false)
297 : Begin(StartCycle), End(EndCycle), Reserved(IsReserved) {}
299 bool contains(
unsigned Cycle)
const {
return Cycle >= Begin && Cycle < End; }
303 return !startsAfter(CS) && !endsBefore(CS);
308 return Begin < Other.Begin;
319 unsigned size()
const {
return End - Begin; };
325 unsigned begin()
const {
return Begin; }
326 unsigned end()
const {
return End; }
327 void setEnd(
unsigned NewEnd) { End = NewEnd; }
341 : CS(Cycles), NumUnits(Units) {}
401 bool IsOptimizableMove;
429 unsigned NumUsers = 0;
431 NumUsers +=
Def.getNumUsers();
457 enum InstrStage
Stage;
475 uint64_t UsedBuffers;
486 uint64_t CriticalResourceMask;
494 RCUTokenID(0), LSUTokenID(0), UsedBuffers(D.UsedBuffers),
495 CriticalRegDep(), CriticalMemDep(), CriticalResourceMask(0),
496 IsEliminated(
false) {}
511 void dispatch(
unsigned RCUTokenID);
515 void execute(
unsigned IID);
524 bool updateDispatched();
525 bool updatePending();
529 bool isReady()
const {
return Stage == IS_READY; }
536 void forceExecuted();
540 assert(isExecuted() &&
"Instruction is in an invalid state!");
548 CriticalMemDep = MemDep;
553 CriticalResourceMask = ResourceMask;
563 std::pair<unsigned, Instruction *>
Data;
572 return Data.first < Other.Data.first;
580 explicit operator bool()
const {
return Data.second !=
nullptr; }
603 std::pair<unsigned, WriteState *>
Data;
604 static const unsigned INVALID_IID;
615 assert(isValid() &&
"Invalid null WriteState found!");
616 return getWriteState()->isWriteZero();
622 if (getSourceIndex() == INVALID_IID)
628 bool isValid()
const {
return Data.second && Data.first != INVALID_IID; }
639 #endif // LLVM_MCA_INSTRUCTION_H void setCriticalMemDep(const CriticalDependency &MemDep)
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
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
const CriticalDependency & getCriticalRegDep() const
bool isDispatched() const
bool isImplicitRead() const
A register read descriptor.
Instruction(const InstrDesc &D)
Optional< std::vector< StOtherPiece > > Other
MCPhysReg getRegisterID() const
unsigned SClassOrWriteResourceID
WriteState * getWriteState()
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
void setUsedBuffers(uint64_t Mask)
SmallVectorImpl< WriteState > & getDefs()
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
void subtract(unsigned Cycles)
void setIndependentFromDef()
unsigned getLSUTokenID() const
unsigned getNumUsers() const
Helper used by class InstrDesc to describe how hardware resources are used.
uint64_t UsedProcResUnits
unsigned getLatency() const
uint64_t getCriticalResourceMask() const
A register write descriptor.
const CriticalDependency & getCriticalRegDep() const
bool isImplicitRead() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
MCPhysReg getRegisterID() const
unsigned getNumMicroOps() const
static int getLatency(LLVMDisasmContext *DC, const MCInst &Inst)
Gets latency information for Inst, based on DC information.
const InstrDesc & getDesc() const
uint64_t UsedProcResGroups
ResourceUsage(CycleSegment Cycles, unsigned Units=1)
int getCyclesLeft() const
WriteState(const WriteDescriptor &Desc, MCPhysReg RegID, bool clearsSuperRegs=false, bool writesZero=false)
ReadState(const ReadDescriptor &Desc, MCPhysReg RegID)
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
uint64_t getUsedBuffers() const
const ArrayRef< ReadState > getUses() const
bool operator<(const InstRef &Other) const
void setOptimizableMove()
const CriticalDependency & getCriticalRegDep() const
bool operator==(const InstRef &Other) const
CycleSegment(unsigned StartCycle, unsigned EndCycle, bool IsReserved=false)
void invalidate()
Invalidate this reference.
void setLSUTokenID(unsigned LSUTok)
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
A critical data dependency descriptor.
void setDependentWrites(unsigned Writes)
void setCriticalResourceMask(uint64_t ResourceMask)
unsigned getRegisterFileID() const
bool operator!=(const InstRef &Other) 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
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
bool operator<(const CycleSegment &Other) const
unsigned getWriteResourceID() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setDependentWrite(const WriteState *Other)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
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
const CriticalDependency & getCriticalMemDep() const
Statically lint checks LLVM IR
SmallVector< WriteDescriptor, 4 > Writes
unsigned getSchedClass() const