aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-mca/llvm-mca.cpp
diff options
context:
space:
mode:
authorWolfgang Pieb <wolfgang_pieb@playstation.sony.com>2021-01-21 14:04:13 -0800
committerWolfgang Pieb <wolfgang_pieb@playstation.sony.com>2021-01-21 15:15:54 -0800
commitd38be2ba0e4ebfed4c13ab79f3a8631011d185eb (patch)
tree9f72a15ca49bf71016778ec31d01fcd7497486b4 /llvm/tools/llvm-mca/llvm-mca.cpp
parent922b26cde4d1c89a5fa90e6a1d6d97d0f8eace6d (diff)
downloadllvm-d38be2ba0e4ebfed4c13ab79f3a8631011d185eb.zip
llvm-d38be2ba0e4ebfed4c13ab79f3a8631011d185eb.tar.gz
llvm-d38be2ba0e4ebfed4c13ab79f3a8631011d185eb.tar.bz2
[llvm-mca] Initial implementation of serialization using JSON. The views
implemented at this time are Summary, Timeline, ResourcePressure and InstructionInfo. Use --json on the command line to obtain JSON output.
Diffstat (limited to 'llvm/tools/llvm-mca/llvm-mca.cpp')
-rw-r--r--llvm/tools/llvm-mca/llvm-mca.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index d122e64..13a2c63 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -96,6 +96,11 @@ static cl::opt<std::string>
cl::desc("Additional target features."),
cl::cat(ToolOptions));
+static cl::opt<bool>
+ PrintJson("json",
+ cl::desc("Print the output in json format"),
+ cl::cat(ToolOptions), cl::init(false));
+
static cl::opt<int>
OutputAsmVariant("output-asm-variant",
cl::desc("Syntax variant to use for output printing"),
@@ -501,7 +506,7 @@ int main(int argc, char **argv) {
auto P = std::make_unique<mca::Pipeline>();
P->appendStage(std::make_unique<mca::EntryStage>(S));
P->appendStage(std::make_unique<mca::InstructionTables>(SM));
- mca::PipelinePrinter Printer(*P);
+ mca::PipelinePrinter Printer(*P, mca::View::OK_READABLE);
// Create the views for this pipeline, execute, and emit a report.
if (PrintInstructionInfoView) {
@@ -520,7 +525,14 @@ int main(int argc, char **argv) {
// Create a basic pipeline simulating an out-of-order backend.
auto P = MCA.createDefaultPipeline(PO, S);
- mca::PipelinePrinter Printer(*P);
+ mca::PipelinePrinter Printer(*P, PrintJson ? mca::View::OK_JSON
+ : mca::View::OK_READABLE);
+
+ // When we output JSON, we add a view that contains the instructions
+ // and CPU resource information.
+ if (PrintJson)
+ Printer.addView(
+ std::make_unique<mca::InstructionView>(*STI, *IP, Insts, MCPU));
if (PrintSummaryView)
Printer.addView(