blob: d159a950baa8c41cf97bb7a60c2911cc91efa96d [file] [log] [blame]
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +00001//===--------------------- BackendPrinter.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 class BackendPrinter.
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000012///
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000013/// BackendPrinter allows the customization of the performance report.
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000014///
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_TOOLS_LLVM_MCA_BACKENDPRINTER_H
18#define LLVM_TOOLS_LLVM_MCA_BACKENDPRINTER_H
19
20#include "Backend.h"
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000021#include "View.h"
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000022#include "llvm/ADT/SmallVector.h"
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000023#include "llvm/Support/raw_ostream.h"
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000024
25#define DEBUG_TYPE "llvm-mca"
26
27namespace mca {
28
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000029/// \brief A printer class that knows how to collects statistics on the
30/// code analyzed by the llvm-mca tool.
31///
32/// This class knows how to print out the analysis information collected
33/// during the execution of the code. Internally, it delegates to other
34/// classes the task of printing out timeline information as well as
35/// resource pressure.
36class BackendPrinter {
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000037 Backend &B;
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000038 llvm::SmallVector<std::unique_ptr<View>, 8> Views;
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000039
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000040public:
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000041 BackendPrinter(Backend &backend) : B(backend) {}
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000042
Andrea Di Biagio0cc66c72018-03-09 13:52:03 +000043 void addView(std::unique_ptr<View> V) {
44 B.addEventListener(V.get());
45 Views.emplace_back(std::move(V));
46 }
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000047
Andrea Di Biagio8af3fe82018-03-08 16:08:43 +000048 void printReport(llvm::raw_ostream &OS) const;
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000049};
Andrea Di Biagio3a6b0922018-03-08 13:05:02 +000050} // namespace mca
51
52#endif