Path: blob/main/contrib/llvm-project/llvm/tools/llvm-mca/PipelinePrinter.h
35258 views
//===--------------------- PipelinePrinter.h --------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7/// \file8///9/// This file implements class PipelinePrinter.10///11/// PipelinePrinter allows the customization of the performance report.12///13//===----------------------------------------------------------------------===//1415#ifndef LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H16#define LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H1718#include "llvm/ADT/SmallVector.h"19#include "llvm/MC/MCSubtargetInfo.h"20#include "llvm/MCA/Context.h"21#include "llvm/MCA/Pipeline.h"22#include "llvm/MCA/View.h"23#include "llvm/Support/raw_ostream.h"2425#define DEBUG_TYPE "llvm-mca"2627namespace llvm {28namespace mca {2930class CodeRegion;3132/// A printer class that knows how to collects statistics on the33/// code analyzed by the llvm-mca tool.34///35/// This class knows how to print out the analysis information collected36/// during the execution of the code. Internally, it delegates to other37/// classes the task of printing out timeline information as well as38/// resource pressure.39class PipelinePrinter {40Pipeline &P;41const CodeRegion &Region;42unsigned RegionIdx;43const MCSubtargetInfo &STI;44const PipelineOptions &PO;45llvm::SmallVector<std::unique_ptr<View>, 8> Views;4647void printRegionHeader(llvm::raw_ostream &OS) const;48json::Object getJSONReportRegion() const;49json::Object getJSONTargetInfo() const;50json::Object getJSONSimulationParameters() const;5152public:53PipelinePrinter(Pipeline &Pipe, const CodeRegion &R, unsigned Idx,54const MCSubtargetInfo &STI, const PipelineOptions &PO)55: P(Pipe), Region(R), RegionIdx(Idx), STI(STI), PO(PO) {}5657void addView(std::unique_ptr<View> V) {58P.addEventListener(V.get());59Views.emplace_back(std::move(V));60}6162void printReport(llvm::raw_ostream &OS) const;63void printReport(json::Object &JO) const;64};65} // namespace mca66} // namespace llvm6768#endif // LLVM_TOOLS_LLVM_MCA_PIPELINEPRINTER_H697071