1 //===- MCDisassembler.cpp - Disassembler interface ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/MC/MCDisassembler/MCDisassembler.h"
10 #include "llvm/ADT/ArrayRef.h"
11 #include "llvm/ADT/StringRef.h"
12 #include "llvm/Support/raw_ostream.h"
13 #include <algorithm>
14
15 using namespace llvm;
16
17 MCDisassembler::~MCDisassembler() = default;
18
19 MCDisassembler::DecodeStatus
onSymbolStart(StringRef Name,uint64_t & Size,ArrayRef<uint8_t> Bytes,uint64_t Address,raw_ostream & CStream) const20 MCDisassembler::onSymbolStart(StringRef Name, uint64_t &Size,
21 ArrayRef<uint8_t> Bytes, uint64_t Address,
22 raw_ostream &CStream) const {
23 Size = 0;
24 return MCDisassembler::Success;
25 }
26
tryAddingSymbolicOperand(MCInst & Inst,int64_t Value,uint64_t Address,bool IsBranch,uint64_t Offset,uint64_t InstSize) const27 bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
28 uint64_t Address, bool IsBranch,
29 uint64_t Offset,
30 uint64_t InstSize) const {
31 if (Symbolizer)
32 return Symbolizer->tryAddingSymbolicOperand(
33 Inst, *CommentStream, Value, Address, IsBranch, Offset, InstSize);
34 return false;
35 }
36
tryAddingPcLoadReferenceComment(int64_t Value,uint64_t Address) const37 void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
38 uint64_t Address) const {
39 if (Symbolizer)
40 Symbolizer->tryAddingPcLoadReferenceComment(*CommentStream, Value, Address);
41 }
42
setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer)43 void MCDisassembler::setSymbolizer(std::unique_ptr<MCSymbolizer> Symzer) {
44 Symbolizer = std::move(Symzer);
45 }
46