[llvm-mca] Turn InstructionTables into a Stage.
Summary:
This patch converts the InstructionTables class into a subclass of mca::Stage. This change allows us to use the Stage's inherited Listeners for event notifications. This also allows us to create a simple pipeline for viewing the InstructionTables report.
I have been working on a follow on patch that should cleanup addView in InstructionTables. Right now, addView adds the view to both the Listener list and Views list. The follow-on patch addresses the fact that we don't really need two lists in this case. That change is not specific to just InstructionTables, so it will be a separate patch.
Reviewers: andreadb, courbet, RKSimon
Reviewed By: andreadb
Subscribers: tschuett, gbedwell, llvm-commits
Differential Revision: https://reviews.llvm.org/D49329
llvm-svn: 337113
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 97de338..2d292f3 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -24,6 +24,7 @@
#include "CodeRegion.h"
#include "Context.h"
#include "DispatchStatistics.h"
+#include "FetchStage.h"
#include "InstructionInfoView.h"
#include "InstructionTables.h"
#include "Pipeline.h"
@@ -489,16 +490,21 @@
PrintInstructionTables ? 1 : Iterations);
if (PrintInstructionTables) {
- mca::InstructionTables IT(SM, IB, S);
+ // Create a pipeline, stages, and a printer.
+ auto P = llvm::make_unique<mca::Pipeline>();
+ P->appendStage(llvm::make_unique<mca::FetchStage>(IB, S));
+ P->appendStage(llvm::make_unique<mca::InstructionTables>(SM, IB));
+ mca::PipelinePrinter Printer(*P);
+ // Create the views for this pipeline, execute, and emit a report.
if (PrintInstructionInfoView) {
- IT.addView(
+ Printer.addView(
llvm::make_unique<mca::InstructionInfoView>(*STI, *MCII, S, *IP));
}
-
- IT.addView(llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, S));
- IT.run();
- IT.printReport(TOF->os());
+ Printer.addView(
+ llvm::make_unique<mca::ResourcePressureView>(*STI, *IP, S));
+ P->run();
+ Printer.printReport(TOF->os());
continue;
}