blob: db2d4c4b1b73c6ea1810efa98abbbd24cb3abd47 [file] [log] [blame]
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +00001//===--------------------- SummaryView.h ---------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
10///
11/// This file implements the summary view.
12///
13/// The goal of the summary view is to give a very quick overview of the
14/// performance throughput. Below is an example of summary view:
15///
16///
17/// Iterations: 300
18/// Instructions: 900
19/// Total Cycles: 610
20/// Dispatch Width: 2
21/// IPC: 1.48
22///
23///
24/// Instruction Info:
25/// [1]: #uOps
26/// [2]: Latency
27/// [3]: RThroughput
28/// [4]: MayLoad
29/// [5]: MayStore
30/// [6]: HasSideEffects
31///
32/// [1] [2] [3] [4] [5] [6] Instructions:
33/// 1 2 1.00 vmulps %xmm0, %xmm1, %xmm2
34/// 1 3 1.00 vhaddps %xmm2, %xmm2, %xmm3
35/// 1 3 1.00 vhaddps %xmm3, %xmm3, %xmm4
36///
37/// The summary view is structured in two sections.
38///
39/// The first section collects a a few performance numbers. The two main
40/// performance indicators are 'Total Cycles' and IPC (Instructions Per Cycle).
41///
42/// The second section shows the latency and reciprocal throughput of every
43/// instruction in the sequence. This section also reports extra informaton
44/// related to the number of micro opcodes, and opcode properties (i.e.
45/// 'MayLoad', 'MayStore', 'HasSideEffects)
46///
47//===----------------------------------------------------------------------===//
48
49#ifndef LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
50#define LLVM_TOOLS_LLVM_MCA_SUMMARYVIEW_H
51
Andrea Di Biagiob5229752018-03-13 17:24:32 +000052#include "SourceMgr.h"
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000053#include "View.h"
54#include "llvm/MC/MCInstPrinter.h"
Andrea Di Biagiob5229752018-03-13 17:24:32 +000055#include "llvm/MC/MCSubtargetInfo.h"
56#include "llvm/MC/MCInstrInfo.h"
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000057#include "llvm/Support/raw_ostream.h"
58
59#define DEBUG_TYPE "llvm-mca"
60
61namespace mca {
62
63/// \brief A printer class that knows how to collects statistics on the
64/// code analyzed by the llvm-mca tool.
65///
66/// This class knows how to print out the analysis information collected
67/// during the execution of the code. Internally, it delegates to other
68/// classes the task of printing out timeline information as well as
69/// resource pressure.
70class SummaryView : public View {
Andrea Di Biagiob5229752018-03-13 17:24:32 +000071 const llvm::MCSubtargetInfo &STI;
72 const llvm::MCInstrInfo &MCII;
73 const SourceMgr &Source;
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000074 llvm::MCInstPrinter &MCIP;
Andrea Di Biagiob5229752018-03-13 17:24:32 +000075
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000076 const unsigned DispatchWidth;
77 unsigned TotalCycles;
78
79 void printSummary(llvm::raw_ostream &OS) const;
80 void printInstructionInfo(llvm::raw_ostream &OS) const;
81
82public:
Andrea Di Biagiob5229752018-03-13 17:24:32 +000083 SummaryView(const llvm::MCSubtargetInfo &sti, const llvm::MCInstrInfo &mcii,
84 const SourceMgr &S, llvm::MCInstPrinter &IP, unsigned Width)
85 : STI(sti), MCII(mcii), Source(S), MCIP(IP), DispatchWidth(Width),
86 TotalCycles(0) {}
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000087
88 void onCycleEnd(unsigned /* unused */) override { ++TotalCycles; }
89
90 void printView(llvm::raw_ostream &OS) const override {
91 printSummary(OS);
92 printInstructionInfo(OS);
93 }
94};
95
96} // namespace mca
97
98#endif