LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lib/MC/MCDisassembler/Disassembler.h
Go to the documentation of this file.
1 //===------------- Disassembler.h - LLVM Disassembler -----------*- C++ -*-===//
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 //
10 // This file defines the interface for the Disassembly library's disassembler
11 // context. The disassembler is responsible for producing strings for
12 // individual instructions according to a given architecture and disassembly
13 // syntax.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_MC_DISASSEMBLER_H
18 #define LLVM_MC_DISASSEMBLER_H
19 
20 #include "llvm-c/Disassembler.h"
21 #include "llvm/ADT/OwningPtr.h"
22 #include "llvm/ADT/SmallString.h"
24 #include <string>
25 
26 namespace llvm {
27 class MCContext;
28 class MCAsmInfo;
29 class MCDisassembler;
30 class MCInstPrinter;
31 class MCInstrInfo;
32 class MCRegisterInfo;
33 class MCSubtargetInfo;
34 class Target;
35 
36 //
37 // This is the disassembler context returned by LLVMCreateDisasm().
38 //
40 private:
41  //
42  // The passed parameters when the disassembler context is created.
43  //
44  // The TripleName for this disassembler.
45  std::string TripleName;
46  // The pointer to the caller's block of symbolic information.
47  void *DisInfo;
48  // The Triple specific symbolic information type returned by GetOpInfo.
49  int TagType;
50  // The function to get the symbolic information for operands.
51  LLVMOpInfoCallback GetOpInfo;
52  // The function to look up a symbol name.
53  LLVMSymbolLookupCallback SymbolLookUp;
54  //
55  // The objects created and saved by LLVMCreateDisasm() then used by
56  // LLVMDisasmInstruction().
57  //
58  // The LLVM target corresponding to the disassembler.
59  // FIXME: using llvm::OwningPtr<const llvm::Target> causes a malloc error
60  // when this LLVMDisasmContext is deleted.
61  const Target *TheTarget;
62  // The assembly information for the target architecture.
64  // The register information for the target architecture.
66  // The subtarget information for the target architecture.
68  // The instruction information for the target architecture.
70  // The assembly context for creating symbols and MCExprs.
72  // The disassembler for the target architecture.
74  // The instruction printer for the target architecture.
76  // The options used to set up the disassembler.
77  uint64_t Options;
78  // The CPU string.
79  std::string CPU;
80 
81 public:
82  // Comment stream and backing vector.
85 
86  LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType,
87  LLVMOpInfoCallback getOpInfo,
88  LLVMSymbolLookupCallback symbolLookUp,
89  const Target *theTarget, const MCAsmInfo *mAI,
90  const MCRegisterInfo *mRI,
91  const MCSubtargetInfo *mSI,
92  const MCInstrInfo *mII,
93  llvm::MCContext *ctx, const MCDisassembler *disAsm,
94  MCInstPrinter *iP) : TripleName(tripleName),
95  DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo),
96  SymbolLookUp(symbolLookUp), TheTarget(theTarget),
97  Options(0),
99  MAI.reset(mAI);
100  MRI.reset(mRI);
101  MSI.reset(mSI);
102  MII.reset(mII);
103  Ctx.reset(ctx);
104  DisAsm.reset(disAsm);
105  IP.reset(iP);
106  }
107  const std::string &getTripleName() const { return TripleName; }
108  void *getDisInfo() const { return DisInfo; }
109  int getTagType() const { return TagType; }
110  LLVMOpInfoCallback getGetOpInfo() const { return GetOpInfo; }
112  return SymbolLookUp;
113  }
114  const Target *getTarget() const { return TheTarget; }
115  const MCDisassembler *getDisAsm() const { return DisAsm.get(); }
116  const MCAsmInfo *getAsmInfo() const { return MAI.get(); }
117  const MCInstrInfo *getInstrInfo() const { return MII.get(); }
118  const MCRegisterInfo *getRegisterInfo() const { return MRI.get(); }
119  const MCSubtargetInfo *getSubtargetInfo() const { return MSI.get(); }
120  MCInstPrinter *getIP() { return IP.get(); }
121  void setIP(MCInstPrinter *NewIP) { IP.reset(NewIP); }
122  uint64_t getOptions() const { return Options; }
123  void addOptions(uint64_t Options) { this->Options |= Options; }
124  StringRef getCPU() const { return CPU; }
125  void setCPU(const char *CPU) { this->CPU = CPU; }
126 };
127 
128 } // namespace llvm
129 
130 #endif
const MCRegisterInfo * getRegisterInfo() const
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
LLVMOpInfoCallback getGetOpInfo() const
const std::string & getTripleName() const
LLVMSymbolLookupCallback getSymbolLookupCallback() const
const MCDisassembler * getDisAsm() const
const MCSubtargetInfo * getSubtargetInfo() const
LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType, LLVMOpInfoCallback getOpInfo, LLVMSymbolLookupCallback symbolLookUp, const Target *theTarget, const MCAsmInfo *mAI, const MCRegisterInfo *mRI, const MCSubtargetInfo *mSI, const MCInstrInfo *mII, llvm::MCContext *ctx, const MCDisassembler *disAsm, MCInstPrinter *iP)
const MCInstrInfo * getInstrInfo() const
int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBuf)