Silence -Wunused-variable in release builds.
[llvm/stm8.git] / lib / MC / MCDisassembler / Disassembler.h
blobf0ec42a017a43c82a164a9ddb39b6f142ea399f6
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_MC_DISASSEMBLER_H
18 #define LLVM_MC_DISASSEMBLER_H
20 #include "llvm-c/Disassembler.h"
21 #include <string>
22 #include "llvm/ADT/OwningPtr.h"
24 namespace llvm {
25 class TargetAsmInfo;
26 class MCContext;
27 class MCAsmInfo;
28 class MCDisassembler;
29 class MCInstPrinter;
30 class Target;
31 class TargetMachine;
34 // This is the disassembler context returned by LLVMCreateDisasm().
36 class LLVMDisasmContext {
37 private:
39 // The passed parameters when the disassembler context is created.
41 // The TripleName for this disassembler.
42 std::string TripleName;
43 // The pointer to the caller's block of symbolic information.
44 void *DisInfo;
45 // The Triple specific symbolic information type returned by GetOpInfo.
46 int TagType;
47 // The function to get the symbolic information for operands.
48 LLVMOpInfoCallback GetOpInfo;
49 // The function to look up a symbol name.
50 LLVMSymbolLookupCallback SymbolLookUp;
52 // The objects created and saved by LLVMCreateDisasm() then used by
53 // LLVMDisasmInstruction().
55 // The LLVM target corresponding to the disassembler.
56 // FIXME: using llvm::OwningPtr<const llvm::Target> causes a malloc error
57 // when this LLVMDisasmContext is deleted.
58 const Target *TheTarget;
59 // The assembly information for the target architecture.
60 llvm::OwningPtr<const llvm::MCAsmInfo> MAI;
61 // The target machine instance.
62 llvm::OwningPtr<llvm::TargetMachine> TM;
63 // The disassembler for the target architecture.
64 // FIXME: using llvm::OwningPtr<const llvm::TargetAsmInfo> causes a malloc
65 // error when this LLVMDisasmContext is deleted.
66 const TargetAsmInfo *Tai;
67 // The assembly context for creating symbols and MCExprs.
68 llvm::OwningPtr<const llvm::MCContext> Ctx;
69 // The disassembler for the target architecture.
70 llvm::OwningPtr<const llvm::MCDisassembler> DisAsm;
71 // The instruction printer for the target architecture.
72 llvm::OwningPtr<llvm::MCInstPrinter> IP;
74 public:
75 LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType,
76 LLVMOpInfoCallback getOpInfo,
77 LLVMSymbolLookupCallback symbolLookUp,
78 const Target *theTarget, const MCAsmInfo *mAI,
79 llvm::TargetMachine *tM, const TargetAsmInfo *tai,
80 llvm::MCContext *ctx, const MCDisassembler *disAsm,
81 MCInstPrinter *iP) : TripleName(tripleName),
82 DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo),
83 SymbolLookUp(symbolLookUp), TheTarget(theTarget), Tai(tai) {
84 TM.reset(tM);
85 MAI.reset(mAI);
86 Ctx.reset(ctx);
87 DisAsm.reset(disAsm);
88 IP.reset(iP);
90 const MCDisassembler *getDisAsm() const { return DisAsm.get(); }
91 MCInstPrinter *getIP() { return IP.get(); }
94 } // namespace llvm
96 #endif