[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / tools / llvm-mca / Views / InstructionView.h
blobae57246fc35f3787bbbd44115f63ec09a12c4f62
1 //===----------------------- InstructionView.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 defines the main interface for Views that examine and reference
11 /// a sequence of machine instructions.
12 ///
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TOOLS_LLVM_MCA_INSTRUCTIONVIEW_H
16 #define LLVM_TOOLS_LLVM_MCA_INSTRUCTIONVIEW_H
18 #include "llvm/MCA/View.h"
19 #include "llvm/Support/JSON.h"
21 namespace llvm {
22 class MCInstPrinter;
24 namespace mca {
26 // The base class for views that deal with individual machine instructions.
27 class InstructionView : public View {
28 const llvm::MCSubtargetInfo &STI;
29 llvm::MCInstPrinter &MCIP;
30 llvm::ArrayRef<llvm::MCInst> Source;
32 mutable std::string InstructionString;
33 mutable raw_string_ostream InstrStream;
35 public:
36 void printView(llvm::raw_ostream &) const override {}
37 InstructionView(const llvm::MCSubtargetInfo &STI,
38 llvm::MCInstPrinter &Printer, llvm::ArrayRef<llvm::MCInst> S)
39 : STI(STI), MCIP(Printer), Source(S), InstrStream(InstructionString) {}
41 virtual ~InstructionView();
43 StringRef getNameAsString() const override { return "Instructions"; }
45 // Return a reference to a string representing a given machine instruction.
46 // The result should be used or copied before the next call to
47 // printInstructionString() as it will overwrite the previous result.
48 StringRef printInstructionString(const llvm::MCInst &MCI) const;
49 const llvm::MCSubtargetInfo &getSubTargetInfo() const { return STI; }
51 llvm::MCInstPrinter &getInstPrinter() const { return MCIP; }
52 llvm::ArrayRef<llvm::MCInst> getSource() const { return Source; }
54 json::Value toJSON() const override;
57 } // namespace mca
58 } // namespace llvm
60 #endif