LLVM: lib/MCA/Stages/EntryStage.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
17
18namespace llvm {
19namespace mca {
20
22 return static_cast<bool>(CurrentInstruction) || !SM.isEnd();
23}
24
26 if (CurrentInstruction)
28 return false;
29}
30
31Error EntryStage::getNextInstruction() {
32 assert(!CurrentInstruction && "There is already an instruction to process!");
36 else
38 }
40 std::unique_ptr Inst = std::make_unique(SR.second);
41 CurrentInstruction = InstRef(SR.first, Inst.get());
42 Instructions.emplace_back(std::move(Inst));
45}
46
48 assert(CurrentInstruction && "There is no instruction to process!");
50 return Val;
51
52
53 CurrentInstruction.invalidate();
54 return getNextInstruction();
55}
56
58 if (!CurrentInstruction)
59 return getNextInstruction();
61}
62
64 assert(!CurrentInstruction);
65 return getNextInstruction();
66}
67
69
71 auto It = find_if(Range, [](const std::unique_ptr &I) {
72 return ->isRetired();
73 });
74
75 NumRetired = std::distance(Instructions.begin(), It);
76
77 if ((NumRetired * 2) >= Instructions.size()) {
78 Instructions.erase(Instructions.begin(), It);
79 NumRetired = 0;
80 }
81
83}
84
85}
86}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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))
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.
Definition EntryStage.cpp:57
bool hasWorkToComplete() const override
Returns true if some instructions are still executing this stage.
Definition EntryStage.cpp:21
Error cycleEnd() override
Called once at the end of each cycle.
Definition EntryStage.cpp:68
bool isAvailable(const InstRef &IR) const override
Returns true if it can execute IR during this cycle.
Definition EntryStage.cpp:25
Error execute(InstRef &IR) override
The primary action that this stage performs on instruction IR.
Definition EntryStage.cpp:47
Error cycleResume() override
Called after the pipeline is resumed from pausing state.
Definition EntryStage.cpp:63
An InstRef contains both a SourceMgr index and Instruction pair.
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.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
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.