1 //===-- lib/MC/MCDisassembler.cpp - Disassembler interface ------*- 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 #include "llvm/MC/MCDisassembler.h"
11 #include "llvm/MC/MCExternalSymbolizer.h"
12 #include "llvm/Support/raw_ostream.h"
16 MCDisassembler::~MCDisassembler() {
20 MCDisassembler::setupForSymbolicDisassembly(
21 LLVMOpInfoCallback GetOpInfo,
22 LLVMSymbolLookupCallback SymbolLookUp,
25 OwningPtr<MCRelocationInfo> &RelInfo) {
26 this->GetOpInfo = GetOpInfo;
27 this->SymbolLookUp = SymbolLookUp;
28 this->DisInfo = DisInfo;
30 assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
32 Symbolizer.reset(new MCExternalSymbolizer(*Ctx, RelInfo, GetOpInfo,
33 SymbolLookUp, DisInfo));
36 bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
37 uint64_t Address, bool IsBranch,
39 uint64_t InstSize) const {
40 raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
42 return Symbolizer->tryAddingSymbolicOperand(Inst, cStream, Value, Address,
43 IsBranch, Offset, InstSize);
47 void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
48 uint64_t Address) const {
49 raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
51 Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address);
54 void MCDisassembler::setSymbolizer(OwningPtr<MCSymbolizer> &Symzer) {
55 Symbolizer.reset(Symzer.take());