22#define DEBUG_TYPE "llvm-mca"
26 Listeners.insert(Listener);
27 for (
auto &S : Stages)
28 S->addListener(Listener);
31bool Pipeline::hasWorkToProcess() {
32 return any_of(Stages, [](
const std::unique_ptr<Stage> &S) {
33 return S->hasWorkToComplete();
38 assert(!Stages.empty() &&
"Unexpected empty pipeline found!");
43 if (
Error Err = runCycle())
44 return std::move(Err);
47 }
while (hasWorkToProcess());
52Error Pipeline::runCycle() {
55 for (
auto I = Stages.rbegin(),
E = Stages.rend();
I !=
E && !Err; ++
I) {
56 const std::unique_ptr<Stage> &S = *
I;
58 Err = S->cycleResume();
60 Err = S->cycleStart();
63 CurrentState = State::Started;
67 Stage &FirstStage = *Stages[0];
68 while (!Err && FirstStage.isAvailable(
IR))
69 Err = FirstStage.execute(
IR);
71 if (Err.isA<InstStreamPause>()) {
72 CurrentState = State::Paused;
77 for (
const std::unique_ptr<Stage> &S : Stages) {
87 assert(S &&
"Invalid null stage in input!");
88 if (!Stages.empty()) {
90 Last->setNextInSequence(S.get());
93 Stages.push_back(std::move(S));
96void Pipeline::notifyCycleBegin() {
99 Listener->onCycleBegin();
102void Pipeline::notifyCycleEnd() {
104 for (HWEventListener *Listener : Listeners)
105 Listener->onCycleEnd();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the main interface for hardware event listeners.
Legalize the Machine IR a function s Machine IR
This file implements an ordered container of stages that simulate the pipeline of a hardware backend.
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.
Tagged union holding either a T or a Error.
LLVM_ABI void addEventListener(HWEventListener *Listener)
bool isPaused() const
Returns whether the pipeline is currently paused.
LLVM_ABI void appendStage(std::unique_ptr< Stage > S)
LLVM_ABI Expected< unsigned > run()
Returns the total number of simulated 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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.