1 //===- MCDisassembler.cpp - Disassembler interface ------------------------===//
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 #include "llvm/MC/MCDisassembler/MCDisassembler.h"
11 #include "llvm/Support/raw_ostream.h"
12 #include <algorithm>
13
14 using namespace llvm;
15
16 MCDisassembler::~MCDisassembler() = default;
17
tryAddingSymbolicOperand(MCInst & Inst,int64_t Value,uint64_t Address,bool IsBranch,uint64_t Offset,uint64_t InstSize) const18 bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
19 uint64_t Address, bool IsBranch,
20 uint64_t Offset,
21 uint64_t InstSize) const {
22 raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
23 if (Symbolizer)
24 return Symbolizer->tryAddingSymbolicOperand(Inst, cStream, Value, Address,
25 IsBranch, Offset, InstSize);
26 return false;
27 }
28
tryAddingPcLoadReferenceComment(int64_t Value,uint64_t Address) const29 void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
30 uint64_t Address) const {
31 raw_ostream &cStream = CommentStream ? *CommentStream : nulls();
32 if (Symbolizer)
33 Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address);
34 }
35
setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer)36 void MCDisassembler::setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer) {
37 Symbolizer = std::move(Symzer);
38 }
39