1 //===-- llvm/MC/MCDisassembler.h - 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 //===----------------------------------------------------------------------===//
9 #ifndef MCDISASSEMBLER_H
10 #define MCDISASSEMBLER_H
12 #include "llvm/Support/DataTypes.h"
13 #include "llvm-c/Disassembler.h"
24 /// MCDisassembler - Superclass for all disassemblers. Consumes a memory region
25 /// and provides an array of assembly instructions.
26 class MCDisassembler {
28 /// Constructor - Performs initial setup for the disassembler.
29 MCDisassembler() : GetOpInfo(0), DisInfo(0), Ctx(0) {}
31 virtual ~MCDisassembler();
33 /// getInstruction - Returns the disassembly of a single instruction.
35 /// @param instr - An MCInst to populate with the contents of the
37 /// @param size - A value to populate with the size of the instruction, or
38 /// the number of bytes consumed while attempting to decode
39 /// an invalid instruction.
40 /// @param region - The memory object to use as a source for machine code.
41 /// @param address - The address, in the memory space of region, of the first
42 /// byte of the instruction.
43 /// @param vStream - The stream to print warnings and diagnostic messages on.
44 /// @return - True if the instruction is valid; false otherwise.
45 virtual bool getInstruction(MCInst& instr,
47 const MemoryObject ®ion,
49 raw_ostream &vStream) const = 0;
51 /// getEDInfo - Returns the enhanced instruction information corresponding to
54 /// @return - An array of instruction information, with one entry for
55 /// each MCInst opcode this disassembler returns.
56 /// NULL if there is no info for this target.
57 virtual EDInstInfo *getEDInfo() const { return (EDInstInfo*)0; }
61 // Hooks for symbolic disassembly via the public 'C' interface.
63 // The function to get the symbolic information for operands.
64 LLVMOpInfoCallback GetOpInfo;
65 // The pointer to the block of symbolic information for above call back.
67 // The assembly context for creating symbols and MCExprs in place of
68 // immediate operands when there is symbolic information.
72 void setupForSymbolicDisassembly(LLVMOpInfoCallback getOpInfo,
75 GetOpInfo = getOpInfo;
79 LLVMOpInfoCallback getLLVMOpInfoCallback() const { return GetOpInfo; }
80 void *getDisInfoBlock() const { return DisInfo; }
81 MCContext *getMCContext() const { return Ctx; }