Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 1 | //===--------------------- PipelinePrinter.h --------------------*- C++ -*-===// |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 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 | /// |
Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 11 | /// This file implements class PipelinePrinter. |
Andrea Di Biagio | 6b07e2f | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 12 | /// |
Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 13 | /// PipelinePrinter allows the customization of the performance report. |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 14 | /// |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 17 | #ifndef LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H |
| 18 | #define LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 19 | |
Matt Davis | 444bd81 | 2018-08-24 20:24:53 +0000 | [diff] [blame] | 20 | #include "Views/View.h" |
Andrea Di Biagio | 6b07e2f | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallVector.h" |
Clement Courbet | 8178ac8 | 2018-12-17 08:08:31 +0000 | [diff] [blame] | 22 | #include "llvm/MCA/Pipeline.h" |
Andrea Di Biagio | 6b07e2f | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 23 | #include "llvm/Support/raw_ostream.h" |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 24 | |
| 25 | #define DEBUG_TYPE "llvm-mca" |
| 26 | |
Fangrui Song | 467c307 | 2018-10-30 15:56:08 +0000 | [diff] [blame] | 27 | namespace llvm { |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 28 | namespace mca { |
| 29 | |
Adrian Prantl | 26b584c | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 30 | /// A printer class that knows how to collects statistics on the |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 31 | /// 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 Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 37 | class PipelinePrinter { |
| 38 | Pipeline &P; |
Andrea Di Biagio | 6b07e2f | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 39 | llvm::SmallVector<std::unique_ptr<View>, 8> Views; |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 40 | |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 41 | public: |
Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 42 | PipelinePrinter(Pipeline &pipeline) : P(pipeline) {} |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 43 | |
Andrea Di Biagio | 7ebbb19 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 44 | void addView(std::unique_ptr<View> V) { |
Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 45 | P.addEventListener(V.get()); |
Andrea Di Biagio | 7ebbb19 | 2018-03-09 13:52:03 +0000 | [diff] [blame] | 46 | Views.emplace_back(std::move(V)); |
| 47 | } |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 48 | |
Andrea Di Biagio | 6b07e2f | 2018-03-08 16:08:43 +0000 | [diff] [blame] | 49 | void printReport(llvm::raw_ostream &OS) const; |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 50 | }; |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 51 | } // namespace mca |
Fangrui Song | 467c307 | 2018-10-30 15:56:08 +0000 | [diff] [blame] | 52 | } // namespace llvm |
Andrea Di Biagio | 29b29cc | 2018-03-08 13:05:02 +0000 | [diff] [blame] | 53 | |
Matt Davis | d8c387b | 2018-06-25 16:53:00 +0000 | [diff] [blame] | 54 | #endif // LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H |