Path: blob/main/contrib/llvm-project/llvm/tools/llvm-mca/Views/InstructionView.h
35290 views
//===----------------------- InstructionView.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 defines the main interface for Views that examine and reference10/// a sequence of machine instructions.11///12//===----------------------------------------------------------------------===//1314#ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONVIEW_H15#define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONVIEW_H1617#include "llvm/MCA/View.h"18#include "llvm/Support/JSON.h"1920namespace llvm {21class MCInstPrinter;2223namespace mca {2425// The base class for views that deal with individual machine instructions.26class InstructionView : public View {27const llvm::MCSubtargetInfo &STI;28llvm::MCInstPrinter &MCIP;29llvm::ArrayRef<llvm::MCInst> Source;3031mutable std::string InstructionString;32mutable raw_string_ostream InstrStream;3334public:35void printView(llvm::raw_ostream &) const override {}36InstructionView(const llvm::MCSubtargetInfo &STI,37llvm::MCInstPrinter &Printer, llvm::ArrayRef<llvm::MCInst> S)38: STI(STI), MCIP(Printer), Source(S), InstrStream(InstructionString) {}3940virtual ~InstructionView();4142StringRef getNameAsString() const override { return "Instructions"; }4344// Return a reference to a string representing a given machine instruction.45// The result should be used or copied before the next call to46// printInstructionString() as it will overwrite the previous result.47StringRef printInstructionString(const llvm::MCInst &MCI) const;48const llvm::MCSubtargetInfo &getSubTargetInfo() const { return STI; }4950llvm::MCInstPrinter &getInstPrinter() const { return MCIP; }51llvm::ArrayRef<llvm::MCInst> getSource() const { return Source; }5253json::Value toJSON() const override;54};5556} // namespace mca57} // namespace llvm5859#endif606162