1 //===------------- Disassembler.h - LLVM Disassembler -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_MC_DISASSEMBLER_H
18 #define LLVM_MC_DISASSEMBLER_H
20 #include "llvm-c/Disassembler.h"
22 #include "llvm/ADT/OwningPtr.h"
34 // This is the disassembler context returned by LLVMCreateDisasm().
36 class LLVMDisasmContext
{
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.
45 // The Triple specific symbolic information type returned by GetOpInfo.
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
;
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
) {
90 const MCDisassembler
*getDisAsm() const { return DisAsm
.get(); }
91 MCInstPrinter
*getIP() { return IP
.get(); }