blob: 456026e12df39fe029619e07d15794f52bd5ad68 [file] [log] [blame]
Matt Davisd8c387b2018-06-25 16:53:00 +00001//===--------------------- PipelinePrinter.h --------------------*- C++ -*-===//
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +00002//
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///
Matt Davisd8c387b2018-06-25 16:53:00 +000011/// This file implements class PipelinePrinter.
Andrea Di Biagio6b07e2f2018-03-08 16:08:43 +000012///
Matt Davisd8c387b2018-06-25 16:53:00 +000013/// PipelinePrinter allows the customization of the performance report.
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000014///
15//===----------------------------------------------------------------------===//
16
Matt Davisd8c387b2018-06-25 16:53:00 +000017#ifndef LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H
18#define LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000019
Matt Davis444bd812018-08-24 20:24:53 +000020#include "Views/View.h"
Andrea Di Biagio6b07e2f2018-03-08 16:08:43 +000021#include "llvm/ADT/SmallVector.h"
Clement Courbet8178ac82018-12-17 08:08:31 +000022#include "llvm/MCA/Pipeline.h"
Andrea Di Biagio6b07e2f2018-03-08 16:08:43 +000023#include "llvm/Support/raw_ostream.h"
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000024
25#define DEBUG_TYPE "llvm-mca"
26
Fangrui Song467c3072018-10-30 15:56:08 +000027namespace llvm {
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000028namespace mca {
29
Adrian Prantl26b584c2018-05-01 15:54:18 +000030/// A printer class that knows how to collects statistics on the
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000031/// code analyzed by the llvm-mca tool.
32///
33/// This class knows how to print out the analysis information collected
34/// during the execution of the code. Internally, it delegates to other
35/// classes the task of printing out timeline information as well as
36/// resource pressure.
Matt Davisd8c387b2018-06-25 16:53:00 +000037class PipelinePrinter {
38 Pipeline &P;
Andrea Di Biagio6b07e2f2018-03-08 16:08:43 +000039 llvm::SmallVector<std::unique_ptr<View>, 8> Views;
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000040
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000041public:
Matt Davisd8c387b2018-06-25 16:53:00 +000042 PipelinePrinter(Pipeline &pipeline) : P(pipeline) {}
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000043
Andrea Di Biagio7ebbb192018-03-09 13:52:03 +000044 void addView(std::unique_ptr<View> V) {
Matt Davisd8c387b2018-06-25 16:53:00 +000045 P.addEventListener(V.get());
Andrea Di Biagio7ebbb192018-03-09 13:52:03 +000046 Views.emplace_back(std::move(V));
47 }
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000048
Andrea Di Biagio6b07e2f2018-03-08 16:08:43 +000049 void printReport(llvm::raw_ostream &OS) const;
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000050};
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000051} // namespace mca
Fangrui Song467c3072018-10-30 15:56:08 +000052} // namespace llvm
Andrea Di Biagio29b29cc2018-03-08 13:05:02 +000053
Matt Davisd8c387b2018-06-25 16:53:00 +000054#endif // LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H