Disassembler.h revision 221337
1227569Sphilip//===------------- Disassembler.h - LLVM Disassembler -----------*- C++ -*-===// 2227569Sphilip// 3227569Sphilip// The LLVM Compiler Infrastructure 4227569Sphilip// 5227569Sphilip// This file is distributed under the University of Illinois Open Source 6227569Sphilip// License. See LICENSE.TXT for details. 7227569Sphilip// 8227569Sphilip//===----------------------------------------------------------------------===// 9227569Sphilip// 10227569Sphilip// This file defines the interface for the Disassembly library's disassembler 11227569Sphilip// context. The disassembler is responsible for producing strings for 12227569Sphilip// individual instructions according to a given architecture and disassembly 13227569Sphilip// syntax. 14227569Sphilip// 15227569Sphilip//===----------------------------------------------------------------------===// 16227569Sphilip 17227569Sphilip#ifndef LLVM_MC_DISASSEMBLER_H 18227569Sphilip#define LLVM_MC_DISASSEMBLER_H 19227569Sphilip 20227569Sphilip#include "llvm-c/Disassembler.h" 21227569Sphilip#include <string> 22227569Sphilip#include "llvm/ADT/OwningPtr.h" 23227569Sphilip 24227569Sphilipnamespace llvm { 25227569Sphilipclass TargetAsmInfo; 26228078Sphilipclass MCContext; 27228078Sphilipclass MCAsmInfo; 28228078Sphilipclass MCDisassembler; 29227569Sphilipclass MCInstPrinter; 30227569Sphilipclass Target; 31227569Sphilipclass TargetMachine; 32227569Sphilip 33227569Sphilip// 34227569Sphilip// This is the disassembler context returned by LLVMCreateDisasm(). 35227569Sphilip// 36227569Sphilipclass LLVMDisasmContext { 37227569Sphilipprivate: 38227569Sphilip // 39227569Sphilip // The passed parameters when the disassembler context is created. 40227569Sphilip // 41227569Sphilip // The TripleName for this disassembler. 42227569Sphilip std::string TripleName; 43227569Sphilip // The pointer to the caller's block of symbolic information. 44227569Sphilip void *DisInfo; 45227569Sphilip // The Triple specific symbolic information type returned by GetOpInfo. 46227569Sphilip int TagType; 47227569Sphilip // The function to get the symbolic information for operands. 48227569Sphilip LLVMOpInfoCallback GetOpInfo; 49227569Sphilip // The function to look up a symbol name. 50227569Sphilip LLVMSymbolLookupCallback SymbolLookUp; 51227569Sphilip // 52227569Sphilip // The objects created and saved by LLVMCreateDisasm() then used by 53227569Sphilip // LLVMDisasmInstruction(). 54227569Sphilip // 55227569Sphilip // The LLVM target corresponding to the disassembler. 56227569Sphilip // FIXME: using llvm::OwningPtr<const llvm::Target> causes a malloc error 57227569Sphilip // when this LLVMDisasmContext is deleted. 58227569Sphilip const Target *TheTarget; 59227569Sphilip // The assembly information for the target architecture. 60227569Sphilip llvm::OwningPtr<const llvm::MCAsmInfo> MAI; 61227569Sphilip // The target machine instance. 62227569Sphilip llvm::OwningPtr<llvm::TargetMachine> TM; 63227569Sphilip // The disassembler for the target architecture. 64227569Sphilip // FIXME: using llvm::OwningPtr<const llvm::TargetAsmInfo> causes a malloc 65227569Sphilip // error when this LLVMDisasmContext is deleted. 66227569Sphilip const TargetAsmInfo *Tai; 67227569Sphilip // The assembly context for creating symbols and MCExprs. 68227569Sphilip llvm::OwningPtr<const llvm::MCContext> Ctx; 69227569Sphilip // The disassembler for the target architecture. 70227569Sphilip llvm::OwningPtr<const llvm::MCDisassembler> DisAsm; 71227569Sphilip // The instruction printer for the target architecture. 72227569Sphilip llvm::OwningPtr<llvm::MCInstPrinter> IP; 73227569Sphilip 74227569Sphilippublic: 75227569Sphilip LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType, 76227569Sphilip LLVMOpInfoCallback getOpInfo, 77227569Sphilip LLVMSymbolLookupCallback symbolLookUp, 78227569Sphilip const Target *theTarget, const MCAsmInfo *mAI, 79227569Sphilip llvm::TargetMachine *tM, const TargetAsmInfo *tai, 80227569Sphilip llvm::MCContext *ctx, const MCDisassembler *disAsm, 81227569Sphilip MCInstPrinter *iP) : TripleName(tripleName), 82227569Sphilip DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo), 83227569Sphilip SymbolLookUp(symbolLookUp), TheTarget(theTarget), Tai(tai) { 84227569Sphilip TM.reset(tM); 85227569Sphilip MAI.reset(mAI); 86227569Sphilip Ctx.reset(ctx); 87227569Sphilip DisAsm.reset(disAsm); 88227569Sphilip IP.reset(iP); 89227569Sphilip } 90227569Sphilip const MCDisassembler *getDisAsm() const { return DisAsm.get(); } 91227569Sphilip MCInstPrinter *getIP() { return IP.get(); } 92227569Sphilip}; 93227569Sphilip 94227569Sphilip} // namespace llvm 95227569Sphilip 96227569Sphilip#endif 97227569Sphilip