22 return static_cast<bool>(CurrentInstruction) || !SM.
isEnd();
26 if (CurrentInstruction)
31Error EntryStage::getNextInstruction() {
32 assert(!CurrentInstruction &&
"There is already an instruction to process!");
35 return llvm::make_error<InstStreamPause>();
40 std::unique_ptr<Instruction> Inst = std::make_unique<Instruction>(SR.second);
41 CurrentInstruction = InstRef(SR.first, Inst.get());
42 Instructions.emplace_back(std::move(Inst));
48 assert(CurrentInstruction &&
"There is no instruction to process!");
54 return getNextInstruction();
58 if (!CurrentInstruction)
59 return getNextInstruction();
64 assert(!CurrentInstruction);
65 return getNextInstruction();
71 auto It =
find_if(
Range, [](
const std::unique_ptr<Instruction> &
I) {
72 return !
I->isRetired();
75 NumRetired = std::distance(Instructions.begin(), It);
77 if ((NumRetired * 2) >= Instructions.size()) {
78 Instructions.erase(Instructions.begin(), It);
This file defines the Entry stage of an instruction pipeline.
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Subclass of Error for the sole purpose of identifying the success path in the type system.
Lightweight error class with error context and mandatory checking.
Error cycleStart() override
Called once at the start of each cycle.
bool hasWorkToComplete() const override
Returns true if some instructions are still executing this stage.
Error cycleEnd() override
Called once at the end of each cycle.
bool isAvailable(const InstRef &IR) const override
Returns true if it can execute IR during this cycle.
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Error cycleResume() override
Called after the pipeline is resumed from pausing state.
An InstRef contains both a SourceMgr index and Instruction pair.
void invalidate()
Invalidate this reference.
Error moveToTheNextStage(InstRef &IR)
Called when an instruction is ready to move the next pipeline stage.
bool checkNextStage(const InstRef &IR) const
std::pair< unsigned, const Instruction & > SourceRef
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
virtual void updateNext()=0
Advance to the next SourceRef.
virtual bool isEnd() const =0
Whether the instruction stream has eneded.
virtual SourceRef peekNext() const =0
The next SourceRef.
virtual bool hasNext() const =0
Whether there is any SourceRef to inspect / peek next.