summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/Pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca/Pipeline.cpp')
-rw-r--r--llvm/tools/llvm-mca/Pipeline.cpp55
1 files changed, 17 insertions, 38 deletions
diff --git a/llvm/tools/llvm-mca/Pipeline.cpp b/llvm/tools/llvm-mca/Pipeline.cpp
index 91c7a5d25ea..a67ae98d7cd 100644
--- a/llvm/tools/llvm-mca/Pipeline.cpp
+++ b/llvm/tools/llvm-mca/Pipeline.cpp
@@ -37,29 +37,6 @@ bool Pipeline::hasWorkToProcess() {
});
}
-// This routine returns early if any stage returns 'false' after execute() is
-// called on it.
-Stage::Status Pipeline::executeStages(InstRef &IR) {
- for (const std::unique_ptr<Stage> &S : Stages) {
- Stage::Status StatusOrErr = S->execute(IR);
- if (!StatusOrErr)
- return StatusOrErr.takeError();
- else if (StatusOrErr.get() == Stage::Stop)
- return Stage::Stop;
- }
- return Stage::Continue;
-}
-
-void Pipeline::preExecuteStages() {
- for (const std::unique_ptr<Stage> &S : Stages)
- S->preExecute();
-}
-
-void Pipeline::postExecuteStages() {
- for (const std::unique_ptr<Stage> &S : Stages)
- S->postExecute();
-}
-
llvm::Error Pipeline::run() {
assert(!Stages.empty() && "Unexpected empty pipeline found!");
@@ -74,36 +51,38 @@ llvm::Error Pipeline::run() {
}
llvm::Error Pipeline::runCycle() {
- // Update stages before we start processing new instructions.
llvm::Error Err = llvm::ErrorSuccess();
- for (auto I = Stages.begin(), E = Stages.end(); I != E && !Err; ++I) {
+ // Update stages before we start processing new instructions.
+ for (auto I = Stages.rbegin(), E = Stages.rend(); I != E && !Err; ++I) {
const std::unique_ptr<Stage> &S = *I;
Err = S->cycleStart();
}
- if (Err)
- return Err;
-
// Now fetch and execute new instructions.
InstRef IR;
- while (true) {
- preExecuteStages();
- Stage::Status Val = executeStages(IR);
- if (!Val)
- return Val.takeError();
- if (Val.get() == Stage::Stop)
- break;
- postExecuteStages();
- }
+ Stage &FirstStage = *Stages[0];
+ while (!Err && FirstStage.isAvailable(IR))
+ Err = FirstStage.execute(IR);
// Update stages in preparation for a new cycle.
- for (auto I = Stages.begin(), E = Stages.end(); I != E && !Err; ++I) {
+ for (auto I = Stages.rbegin(), E = Stages.rend(); I != E && !Err; ++I) {
const std::unique_ptr<Stage> &S = *I;
Err = S->cycleEnd();
}
+
return Err;
}
+void Pipeline::appendStage(std::unique_ptr<Stage> S) {
+ assert(S && "Invalid null stage in input!");
+ if (!Stages.empty()) {
+ Stage *Last = Stages.back().get();
+ Last->setNextInSequence(S.get());
+ }
+
+ Stages.push_back(std::move(S));
+}
+
void Pipeline::notifyCycleBegin() {
LLVM_DEBUG(dbgs() << "[E] Cycle begin: " << Cycles << '\n');
for (HWEventListener *Listener : Listeners)
OpenPOWER on IntegriCloud