Add MCSymbolizer for symbolic/annotated disassembly.
[oota-llvm.git] / include / llvm / MC / MCExternalSymbolizer.h
1 //===-- llvm/MC/MCExternalSymbolizer.h - ------------------------*- C++ -*-===//
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 // This file contains the declaration of the MCExternalSymbolizer class, which
11 // enables library users to provide callbacks (through the C API) to do the
12 // symbolization externally.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_MC_MCEXTERNALSYMBOLIZER_H
17 #define LLVM_MC_MCEXTERNALSYMBOLIZER_H
18
19 #include "llvm-c/Disassembler.h"
20 #include "llvm/MC/MCSymbolizer.h"
21
22 namespace llvm {
23
24 /// \brief Symbolize using user-provided, C API, callbacks.
25 ///
26 /// See llvm-c/Disassembler.h.
27 class MCExternalSymbolizer : public MCSymbolizer {
28
29   /// \name Hooks for symbolic disassembly via the public 'C' interface.
30   /// @{
31   /// The function to get the symbolic information for operands.
32   LLVMOpInfoCallback GetOpInfo;
33   /// The function to lookup a symbol name.
34   LLVMSymbolLookupCallback SymbolLookUp;
35   /// The pointer to the block of symbolic information for above call back.
36   void *DisInfo;
37   /// @}
38
39 public:
40   MCExternalSymbolizer(MCContext &Ctx,
41                        OwningPtr<MCRelocationInfo> &RelInfo,
42                        LLVMOpInfoCallback getOpInfo,
43                        LLVMSymbolLookupCallback symbolLookUp,
44                        void *disInfo)
45     : MCSymbolizer(Ctx, RelInfo),
46       GetOpInfo(getOpInfo), SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
47
48   bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
49                                 int64_t Value,
50                                 uint64_t Address, bool IsBranch,
51                                 uint64_t Offset, uint64_t InstSize);
52   void tryAddingPcLoadReferenceComment(raw_ostream &CommentStream,
53                                        int64_t Value, uint64_t Address);
54 };
55
56 }
57
58 #endif