summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/llvm-mca.cpp
diff options
context:
space:
mode:
authorMatt Davis <Matthew.Davis@sony.com>2018-06-22 16:17:26 +0000
committerMatt Davis <Matthew.Davis@sony.com>2018-06-22 16:17:26 +0000
commit43de6db2f4d2d2134db29e5696616f99cdb33c40 (patch)
treea11c51d426bb6a622de85130d3676e8cc254c1ed /llvm/tools/llvm-mca/llvm-mca.cpp
parenta68951e37e3df3ba19d9df0dde3bf6353e7109ad (diff)
downloadbcm5719-llvm-43de6db2f4d2d2134db29e5696616f99cdb33c40.tar.gz
bcm5719-llvm-43de6db2f4d2d2134db29e5696616f99cdb33c40.zip
[llvm-mca] Introduce a sequential container of Stages
Summary: Remove explicit stages and introduce a list of stages. A pipeline should be composed of an arbitrary list of stages, and not any predefined list of stages in the Backend. The Backend should not know of any particular stage, rather it should only be concerned that it has a list of stages, and that those stages will fulfill the contract of what it means to be a Stage (namely pre/post/execute a given instruction). For now, we leave the original set of stages defined in the Backend ctor; however, I imagine these will be moved out at a later time. This patch makes an adjustment to the semantics of Stage::isReady. Specifically, what the Backend really needs to know is if a Stage has unfinished work. With that said, it is more appropriately renamed Stage::hasWorkToComplete(). This change will clean up the check in Backend::run(), allowing us to query each stage to see if there is unfinished work, regardless of what subclass a stage might be. I feel that this change simplifies the semantics too, but that's a subjective statement. Given how RetireStage and ExecuteStage handle data in their preExecute(), I've had to change the order of Retire and Execute in our stage list. Retire must complete any of its preExecute actions before ExecuteStage's preExecute can take control. This is mainly because both stages utilize the RCU. In the meantime, I want to see if I can adjust that or remove that coupling. Reviewers: andreadb, RKSimon, courbet Reviewed By: andreadb Subscribers: tschuett, gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D46907 llvm-svn: 335361
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 372be3e0d6d..fb019f12580 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -23,13 +23,19 @@
#include "BackendPrinter.h"
#include "CodeRegion.h"
+#include "DispatchStage.h"
#include "DispatchStatistics.h"
+#include "ExecuteStage.h"
#include "FetchStage.h"
#include "InstructionInfoView.h"
#include "InstructionTables.h"
+#include "RegisterFile.h"
#include "RegisterFileStatistics.h"
#include "ResourcePressureView.h"
+#include "RetireControlUnit.h"
#include "RetireControlUnitStatistics.h"
+#include "RetireStage.h"
+#include "Scheduler.h"
#include "SchedulerStatistics.h"
#include "SummaryView.h"
#include "TimelineView.h"
@@ -65,15 +71,13 @@ static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
cl::value_desc("filename"));
static cl::opt<std::string>
- ArchName("march",
- cl::desc("Target arch to assemble for, "
- "see -version for available targets"),
+ ArchName("march", cl::desc("Target arch to assemble for, "
+ "see -version for available targets"),
cl::cat(ToolOptions));
static cl::opt<std::string>
- TripleName("mtriple",
- cl::desc("Target triple to assemble for, "
- "see -version for available targets"),
+ TripleName("mtriple", cl::desc("Target triple to assemble for, "
+ "see -version for available targets"),
cl::cat(ToolOptions));
static cl::opt<std::string>
@@ -483,7 +487,7 @@ int main(int argc, char **argv) {
PrintInstructionTables ? 1 : Iterations);
if (PrintInstructionTables) {
- mca::InstructionTables IT(STI->getSchedModel(), IB, S);
+ mca::InstructionTables IT(SM, IB, S);
if (PrintInstructionInfoView) {
IT.addView(
@@ -496,14 +500,20 @@ int main(int argc, char **argv) {
continue;
}
- // Ideally, I'd like to expose the pipeline building here,
- // by registering all of the Stage instances.
- // But for now, it's just this single puppy.
- std::unique_ptr<mca::FetchStage> Fetch =
- llvm::make_unique<mca::FetchStage>(IB, S);
- mca::Backend B(*STI, *MRI, std::move(Fetch), Width, RegisterFileSize,
- LoadQueueSize, StoreQueueSize, AssumeNoAlias);
- mca::BackendPrinter Printer(B);
+ // Create the hardware components required for the pipeline.
+ mca::RetireControlUnit RCU(SM);
+ mca::RegisterFile PRF(SM, *MRI, RegisterFileSize);
+ mca::Scheduler HWS(SM, LoadQueueSize, StoreQueueSize, AssumeNoAlias);
+
+ // Create the pipeline and add stages to it.
+ auto B = llvm::make_unique<mca::Backend>(
+ Width, RegisterFileSize, LoadQueueSize, StoreQueueSize, AssumeNoAlias);
+ B->appendStage(llvm::make_unique<mca::FetchStage>(IB, S));
+ B->appendStage(llvm::make_unique<mca::DispatchStage>(
+ B.get(), *STI, *MRI, RegisterFileSize, Width, RCU, PRF, HWS));
+ B->appendStage(llvm::make_unique<mca::RetireStage>(B.get(), RCU, PRF));
+ B->appendStage(llvm::make_unique<mca::ExecuteStage>(B.get(), RCU, HWS));
+ mca::BackendPrinter Printer(*B);
if (PrintSummaryView)
Printer.addView(llvm::make_unique<mca::SummaryView>(SM, S, Width));
@@ -533,7 +543,7 @@ int main(int argc, char **argv) {
*STI, *IP, S, TimelineMaxIterations, TimelineMaxCycles));
}
- B.run();
+ B->run();
Printer.printReport(TOF->os());
}
OpenPOWER on IntegriCloud