15#ifndef LLVM_MCA_INSTRUCTION_H
16#define LLVM_MCA_INSTRUCTION_H
43 enum MCAOperandType :
unsigned char {
68 bool isValid()
const {
return Kind != kInvalid; }
69 bool isReg()
const {
return Kind == kRegister; }
70 bool isImm()
const {
return Kind == kImmediate; }
71 bool isSFPImm()
const {
return Kind == kSFPImmediate; }
72 bool isDFPImm()
const {
return Kind == kDFPImmediate; }
76 assert(
isReg() &&
"This is not a register operand!");
95 void setIndex(
const unsigned Idx) { Index = Idx; }
108 Op.Kind = kImmediate;
115 Op.Kind = kSFPImmediate;
122 Op.Kind = kDFPImmediate;
216 bool ClearsSuperRegs;
235 unsigned DependentWriteCyclesLeft;
250 bool clearsSuperRegs =
false,
bool writesZero =
false)
252 ClearsSuperRegs(clearsSuperRegs), WritesZero(writesZero),
253 IsEliminated(
false), DependentWrite(nullptr), PartialWrite(nullptr),
254 DependentWriteCyclesLeft(0), CRD() {}
266 return DependentWriteCyclesLeft;
282 unsigned NumUsers = Users.size();
296 return !CyclesLeft || CyclesLeft <
getLatency();
307 assert(Users.empty() &&
"Write is in an inconsistent state.");
312 void setPRF(
unsigned PRF) { PRFID = PRF; }
336 unsigned DependentWrites;
345 unsigned TotalCycles;
354 bool IndependentFromDef;
358 : RD(&
Desc), RegisterID(RegID), PRFID(0), DependentWrites(0),
368 bool isPending()
const {
return !IndependentFromDef && CyclesLeft > 0; }
378 DependentWrites = Writes;
400 CycleSegment(
unsigned StartCycle,
unsigned EndCycle,
bool IsReserved =
false)
401 : Begin(StartCycle), End(EndCycle), Reserved(IsReserved) {}
412 return Begin <
Other.Begin;
423 unsigned size()
const {
return End - Begin; };
429 unsigned begin()
const {
return Begin; }
430 unsigned end()
const {
return End; }
431 void setEnd(
unsigned NewEnd) { End = NewEnd; }
446 unsigned size()
const {
return CS.size(); }
507 bool IsOptimizableMove;
518 std::vector<MCAOperand> Operands;
524 bool IsALoadBarrier : 1;
525 bool IsAStoreBarrier : 1;
530 bool HasSideEffects : 1;
537 : Desc(
D), IsOptimizableMove(
false), Operands(0), Opcode(Opcode),
538 IsALoadBarrier(
false), IsAStoreBarrier(
false) {}
558 return Op.getIndex() == Idx;
560 if (It == Operands.end())
569 [](
const WriteState &Def) {
return Def.getNumUsers() > 0; });
573 unsigned NumUsers = 0;
575 NumUsers += Def.getNumUsers();
583 bool isMemOp()
const {
return MayLoad || MayStore; }
617 enum InstrStage Stage;
655 UsedBuffers(
D.UsedBuffers), CriticalRegDep(), CriticalMemDep(),
656 CriticalResourceMask(0), IsEliminated(
false) {}
692 bool isReady()
const {
return Stage == IS_READY; }
711 CriticalMemDep = MemDep;
716 CriticalResourceMask = ResourceMask;
726 std::pair<unsigned, Instruction *> Data;
735 return Data.first <
Other.Data.first;
743 explicit operator bool()
const {
return Data.second !=
nullptr; }
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Legalize the Machine IR a function s Machine IR
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
CycleSegment(unsigned StartCycle, unsigned EndCycle, bool IsReserved=false)
bool operator<(const CycleSegment &Other) const
bool startsAfter(const CycleSegment &CS) const
bool contains(unsigned Cycle) const
void setEnd(unsigned NewEnd)
void subtract(unsigned Cycles)
CycleSegment & operator--()
bool endsBefore(const CycleSegment &CS) const
bool overlaps(const CycleSegment &CS) const
An InstRef contains both a SourceMgr index and Instruction pair.
void invalidate()
Invalidate this reference.
bool operator<(const InstRef &Other) const
const Instruction * getInstruction() const
InstRef(unsigned Index, Instruction *I)
Instruction * getInstruction()
unsigned getSourceIndex() const
bool operator!=(const InstRef &Other) const
bool operator==(const InstRef &Other) const
void print(raw_ostream &OS) const
void setEndGroup(bool newVal)
unsigned getOpcode() const
bool isAStoreBarrier() const
bool isOptimizableMove() const
void setRetireOOO(bool newVal)
bool getRetireOOO() const
ArrayRef< WriteState > getDefs() const
void addOperand(const MCAOperand Op)
unsigned getNumMicroOps() const
const InstrDesc & getDesc() const
const MCAOperand * getOperand(const unsigned Idx) const
Return the MCAOperand which corresponds to index Idx within the original MCInst.
SmallVectorImpl< WriteState > & getDefs()
bool hasDependentUsers() const
unsigned getLatency() const
void clearOptimizableMove()
void setBeginGroup(bool newVal)
bool getHasSideEffects() const
SmallVectorImpl< ReadState > & getUses()
void setLoadBarrier(bool IsBarrier)
unsigned getNumOperands() const
bool getBeginGroup() const
void setStoreBarrier(bool IsBarrier)
void setHasSideEffects(bool newVal)
void setMayStore(bool newVal)
ArrayRef< ReadState > getUses() const
InstructionBase(const InstrDesc &D, const unsigned Opcode)
unsigned getNumUsers() const
void setOptimizableMove()
bool isALoadBarrier() const
void setMayLoad(bool newVal)
An instruction propagated through the simulated instruction pipeline.
LLVM_ABI void cycleEvent()
bool isDispatched() const
bool isEliminated() const
Instruction(const InstrDesc &D, const unsigned Opcode)
uint64_t getCriticalResourceMask() const
unsigned getRCUTokenID() const
LLVM_ABI bool updateDispatched()
const CriticalDependency & getCriticalMemDep() const
const CriticalDependency & getCriticalRegDep() const
LLVM_ABI void forceExecuted()
int getCyclesLeft() const
void setCriticalResourceMask(uint64_t ResourceMask)
LLVM_ABI const CriticalDependency & computeCriticalRegDep()
LLVM_ABI void execute(unsigned IID)
LLVM_ABI bool updatePending()
void setLSUTokenID(unsigned LSUTok)
void setUsedBuffers(uint64_t Mask)
void setCriticalMemDep(const CriticalDependency &MemDep)
LLVM_ABI void dispatch(unsigned RCUTokenID)
uint64_t getUsedBuffers() const
unsigned getLSUTokenID() const
A representation of an mca::Instruction operand for use in mca::CustomBehaviour.
unsigned getReg() const
Returns the register number.
static MCAOperand createSFPImm(uint32_t Val)
uint32_t getSFPImm() const
static MCAOperand createInvalid()
static MCAOperand createDFPImm(uint64_t Val)
static MCAOperand createImm(int64_t Val)
static MCAOperand createReg(unsigned Reg)
unsigned getIndex() const
uint64_t getDFPImm() const
void setIndex(const unsigned Idx)
Tracks register operand latency in cycles.
unsigned getRegisterFileID() const
unsigned getSchedClass() const
LLVM_ABI void writeStartEvent(unsigned IID, MCPhysReg RegID, unsigned Cycles)
bool isIndependentFromDef() const
const ReadDescriptor & getDescriptor() const
const CriticalDependency & getCriticalRegDep() const
LLVM_ABI void cycleEvent()
void setDependentWrites(unsigned Writes)
MCPhysReg getRegisterID() const
bool isImplicitRead() const
ReadState(const ReadDescriptor &Desc, MCPhysReg RegID)
void setIndependentFromDef()
Tracks uses of a register definition (e.g.
unsigned getRegisterFileID() const
bool isEliminated() const
const WriteState * getDependentWrite() const
LLVM_ABI void writeStartEvent(unsigned IID, MCPhysReg RegID, unsigned Cycles)
unsigned getDependentWriteCyclesLeft() const
void setRegisterID(const MCPhysReg RegID)
unsigned getLatency() const
WriteState & operator=(const WriteState &Other)=default
void setPRF(unsigned PRF)
void setDependentWrite(const WriteState *Other)
int getCyclesLeft() const
LLVM_ABI void cycleEvent()
WriteState(const WriteDescriptor &Desc, MCPhysReg RegID, bool clearsSuperRegs=false, bool writesZero=false)
const CriticalDependency & getCriticalRegDep() const
LLVM_ABI void onInstructionIssued(unsigned IID)
WriteState(const WriteState &Other)=default
bool clearsSuperRegisters() const
unsigned getNumUsers() const
MCPhysReg getRegisterID() const
unsigned getWriteResourceID() const
LLVM_ABI void addUser(unsigned IID, ReadState *Use, int ReadAdvance)
This class implements an extremely fast bulk output stream that can only output to a stream.
char InstructionError< T >::ID
raw_ostream & operator<<(raw_ostream &OS, const InstRef &IR)
constexpr int UNKNOWN_CYCLES
This is an optimization pass for GlobalISel generic memory operations.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
A critical data dependency descriptor.
An instruction descriptor.
uint64_t UsedProcResGroups
uint64_t UsedProcResUnits
SmallVector< WriteDescriptor, 2 > Writes
InstrDesc(const InstrDesc &Other)=delete
SmallVector< std::pair< uint64_t, ResourceUsage >, 4 > Resources
unsigned HasPartiallyOverlappingGroups
SmallVector< ReadDescriptor, 4 > Reads
bool isZeroLatency() const
InstrDesc & operator=(const InstrDesc &Other)=delete
unsigned MustIssueImmediately
A register read descriptor.
bool isImplicitRead() const
ResourceUsage(CycleSegment Cycles, unsigned Units=1)
A register write descriptor.
unsigned SClassOrWriteResourceID
bool isImplicitWrite() const