PipelinePrinter.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //===--------------------- PipelinePrinter.h --------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. ///
  10. /// This file implements class PipelinePrinter.
  11. ///
  12. /// PipelinePrinter allows the customization of the performance report.
  13. ///
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H
  16. #define LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H
  17. #include "Views/View.h"
  18. #include "llvm/ADT/SmallVector.h"
  19. #include "llvm/MCA/Pipeline.h"
  20. #include "llvm/Support/raw_ostream.h"
  21. #define DEBUG_TYPE "llvm-mca"
  22. namespace llvm {
  23. namespace mca {
  24. /// A printer class that knows how to collects statistics on the
  25. /// code analyzed by the llvm-mca tool.
  26. ///
  27. /// This class knows how to print out the analysis information collected
  28. /// during the execution of the code. Internally, it delegates to other
  29. /// classes the task of printing out timeline information as well as
  30. /// resource pressure.
  31. class PipelinePrinter {
  32. Pipeline &P;
  33. llvm::SmallVector<std::unique_ptr<View>, 8> Views;
  34. View::OutputKind OutputKind;
  35. public:
  36. PipelinePrinter(Pipeline &pipeline, View::OutputKind OutputKind)
  37. : P(pipeline), OutputKind(OutputKind) {}
  38. void addView(std::unique_ptr<View> V) {
  39. P.addEventListener(V.get());
  40. Views.emplace_back(std::move(V));
  41. }
  42. void printReport(llvm::raw_ostream &OS) const;
  43. };
  44. } // namespace mca
  45. } // namespace llvm
  46. #endif // LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H