193f79364351650b58172522ae8346153a3c67a5cKevin Enderby/*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
293f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*                                                                            *|
393f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*                     The LLVM Compiler Infrastructure                       *|
493f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*                                                                            *|
593f79364351650b58172522ae8346153a3c67a5cKevin Enderby|* This file is distributed under the University of Illinois Open Source      *|
693f79364351650b58172522ae8346153a3c67a5cKevin Enderby|* License. See LICENSE.TXT for details.                                      *|
793f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*                                                                            *|
893f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*===----------------------------------------------------------------------===*|
993f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*                                                                            *|
101a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner|* This header provides a public interface to a disassembler library.         *|
1193f79364351650b58172522ae8346153a3c67a5cKevin Enderby|* LLVM provides an implementation of this interface.                         *|
1293f79364351650b58172522ae8346153a3c67a5cKevin Enderby|*                                                                            *|
1393f79364351650b58172522ae8346153a3c67a5cKevin Enderby\*===----------------------------------------------------------------------===*/
1493f79364351650b58172522ae8346153a3c67a5cKevin Enderby
1593f79364351650b58172522ae8346153a3c67a5cKevin Enderby#ifndef LLVM_C_DISASSEMBLER_H
161a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner#define LLVM_C_DISASSEMBLER_H
1793f79364351650b58172522ae8346153a3c67a5cKevin Enderby
188470475d6b684b7f9a4871dd90e4382ad8a509b2Daniel Dunbar#include "llvm/Support/DataTypes.h"
191a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner#include <stddef.h>
2093f79364351650b58172522ae8346153a3c67a5cKevin Enderby
2193f79364351650b58172522ae8346153a3c67a5cKevin Enderby/**
226244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @defgroup LLVMCDisassembler Disassembler
236244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @ingroup LLVMC
246244b518880842f2c15200ee041e06799e4cc779Gregory Szorc *
256244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @{
266244b518880842f2c15200ee041e06799e4cc779Gregory Szorc */
276244b518880842f2c15200ee041e06799e4cc779Gregory Szorc
286244b518880842f2c15200ee041e06799e4cc779Gregory Szorc/**
2993f79364351650b58172522ae8346153a3c67a5cKevin Enderby * An opaque reference to a disassembler context.
3093f79364351650b58172522ae8346153a3c67a5cKevin Enderby */
3193f79364351650b58172522ae8346153a3c67a5cKevin Enderbytypedef void *LLVMDisasmContextRef;
3293f79364351650b58172522ae8346153a3c67a5cKevin Enderby
3393f79364351650b58172522ae8346153a3c67a5cKevin Enderby/**
3493f79364351650b58172522ae8346153a3c67a5cKevin Enderby * The type for the operand information call back function.  This is called to
3593f79364351650b58172522ae8346153a3c67a5cKevin Enderby * get the symbolic information for an operand of an instruction.  Typically
3693f79364351650b58172522ae8346153a3c67a5cKevin Enderby * this is from the relocation information, symbol table, etc.  That block of
3793f79364351650b58172522ae8346153a3c67a5cKevin Enderby * information is saved when the disassembler context is created and passed to
3893f79364351650b58172522ae8346153a3c67a5cKevin Enderby * the call back in the DisInfo parameter.  The instruction containing operand
3993f79364351650b58172522ae8346153a3c67a5cKevin Enderby * is at the PC parameter.  For some instruction sets, there can be more than
4093f79364351650b58172522ae8346153a3c67a5cKevin Enderby * one operand with symbolic information.  To determine the symbolic operand
417a2bdde0a0eebcd2125055e0eacaca040f0b766cChris Lattner * information for each operand, the bytes for the specific operand in the
4293f79364351650b58172522ae8346153a3c67a5cKevin Enderby * instruction are specified by the Offset parameter and its byte widith is the
4393f79364351650b58172522ae8346153a3c67a5cKevin Enderby * size parameter.  For instructions sets with fixed widths and one symbolic
4493f79364351650b58172522ae8346153a3c67a5cKevin Enderby * operand per instruction, the Offset parameter will be zero and Size parameter
45e21c3137e1dfcd9644d3870a0a4528374375271fNAKAMURA Takumi * will be the instruction width.  The information is returned in TagBuf and is
4693f79364351650b58172522ae8346153a3c67a5cKevin Enderby * Triple specific with its specific information defined by the value of
4793f79364351650b58172522ae8346153a3c67a5cKevin Enderby * TagType for that Triple.  If symbolic information is returned the function
481a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * returns 1, otherwise it returns 0.
4993f79364351650b58172522ae8346153a3c67a5cKevin Enderby */
501a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattnertypedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC,
511a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner                                  uint64_t Offset, uint64_t Size,
521a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner                                  int TagType, void *TagBuf);
5393f79364351650b58172522ae8346153a3c67a5cKevin Enderby
5493f79364351650b58172522ae8346153a3c67a5cKevin Enderby/**
55bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * The initial support in LLVM MC for the most general form of a relocatable
56bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * expression is "AddSymbol - SubtractSymbol + Offset".  For some Darwin targets
57bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * this full form is encoded in the relocation information so that AddSymbol and
58bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * SubtractSymbol can be link edited independent of each other.  Many other
59bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * platforms only allow a relocatable expression of the form AddSymbol + Offset
60bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * to be encoded.
61e21c3137e1dfcd9644d3870a0a4528374375271fNAKAMURA Takumi *
62bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct
63bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * LLVMOpInfo1.  The value of the relocatable expression for the operand,
64bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * including any PC adjustment, is passed in to the call back in the Value
65bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * field.  The symbolic information about the operand is returned using all
66bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * the fields of the structure with the Offset of the relocatable expression
67bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * returned in the Value field.  It is possible that some symbols in the
68bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * relocatable expression were assembly temporary symbols, for example
69bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * "Ldata - LpicBase + constant", and only the Values of the symbols without
70bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * symbol names are present in the relocation information.  The VariantKind
71bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * type is one of the Target specific #defines below and is used to print
72bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * operands like "_foo@GOT", ":lower16:_foo", etc.
73bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby */
74bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderbystruct LLVMOpInfoSymbol1 {
751a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner  uint64_t Present;  /* 1 if this symbol is present */
769e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby  const char *Name;  /* symbol name if not NULL */
771a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner  uint64_t Value;    /* symbol value if name is NULL */
78bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby};
791a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner
80bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderbystruct LLVMOpInfo1 {
81bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby  struct LLVMOpInfoSymbol1 AddSymbol;
82bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby  struct LLVMOpInfoSymbol1 SubtractSymbol;
83bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby  uint64_t Value;
84bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby  uint64_t VariantKind;
85bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby};
86bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby
87bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby/**
88bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * The operand VariantKinds for symbolic disassembly.
89bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby */
90bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby#define LLVMDisassembler_VariantKind_None 0 /* all targets */
91bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby
92bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby/**
93bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby * The ARM target VariantKinds.
94bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby */
95bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby#define LLVMDisassembler_VariantKind_ARM_HI16 1 /* :upper16: */
96bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby#define LLVMDisassembler_VariantKind_ARM_LO16 2 /* :lower16: */
97bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby
98bd3327654b5708f1ba92aff3ab25b1bbf5034797Kevin Enderby/**
9936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines * The ARM64 target VariantKinds.
10036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines */
10136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_VariantKind_ARM64_PAGE       1 /* @page */
10236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_VariantKind_ARM64_PAGEOFF    2 /* @pageoff */
10336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_VariantKind_ARM64_GOTPAGE    3 /* @gotpage */
10436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF 4 /* @gotpageoff */
10536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_VariantKind_ARM64_TLVP       5 /* @tvlppage */
10636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_VariantKind_ARM64_TLVOFF     6 /* @tvlppageoff */
10736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
10836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/**
10993f79364351650b58172522ae8346153a3c67a5cKevin Enderby * The type for the symbol lookup function.  This may be called by the
1101a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * disassembler for things like adding a comment for a PC plus a constant
11193f79364351650b58172522ae8346153a3c67a5cKevin Enderby * offset load instruction to use a symbol name instead of a load address value.
11293f79364351650b58172522ae8346153a3c67a5cKevin Enderby * It is passed the block information is saved when the disassembler context is
1139e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * created and the ReferenceValue to look up as a symbol.  If no symbol is found
1149e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * for the ReferenceValue NULL is returned.  The ReferenceType of the
1159e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * instruction is passed indirectly as is the PC of the instruction in
1169e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * ReferencePC.  If the output reference can be determined its type is returned
1179e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * indirectly in ReferenceType along with ReferenceName if any, or that is set
1189e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * to NULL.
11993f79364351650b58172522ae8346153a3c67a5cKevin Enderby */
12093f79364351650b58172522ae8346153a3c67a5cKevin Enderbytypedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
1219e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby                                                uint64_t ReferenceValue,
1228c51e3995d8b8fd1cd88ef18548be4b8f8e3d6f1Bill Wendling                                                uint64_t *ReferenceType,
1238c51e3995d8b8fd1cd88ef18548be4b8f8e3d6f1Bill Wendling                                                uint64_t ReferencePC,
1248c51e3995d8b8fd1cd88ef18548be4b8f8e3d6f1Bill Wendling                                                const char **ReferenceName);
1259e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/**
1269e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby * The reference types on input and output.
1279e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby */
1289e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/* No input reference type or no output reference type. */
1299e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby#define LLVMDisassembler_ReferenceType_InOut_None 0
1309e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby
1319e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/* The input reference is from a branch instruction. */
1329e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby#define LLVMDisassembler_ReferenceType_In_Branch 1
1339e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/* The input reference is from a PC relative load instruction. */
1349e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby#define LLVMDisassembler_ReferenceType_In_PCrel_Load 2
1359e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby
13636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/* The input reference is from an ARM64::ADRP instruction. */
13736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001
13836b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/* The input reference is from an ARM64::ADDXri instruction. */
13936b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002
14036b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/* The input reference is from an ARM64::LDRXui instruction. */
14136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003
14236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/* The input reference is from an ARM64::LDRXl instruction. */
14336b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004
14436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/* The input reference is from an ARM64::ADR instruction. */
14536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005
14636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
1479e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/* The output reference is to as symbol stub. */
1489e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby#define LLVMDisassembler_ReferenceType_Out_SymbolStub 1
1499e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/* The output reference is to a symbol address in a literal pool. */
1509e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr 2
1519e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby/* The output reference is to a cstring address in a literal pool. */
1529e5887b17e634b98f7c1cf0ee4f25c218097d08eKevin Enderby#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3
15393f79364351650b58172522ae8346153a3c67a5cKevin Enderby
1546f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby/* The output reference is to a Objective-C CoreFoundation string. */
1556f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref 4
1566f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby/* The output reference is to a Objective-C message. */
1576f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby#define LLVMDisassembler_ReferenceType_Out_Objc_Message 5
1586f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby/* The output reference is to a Objective-C message ref. */
1596f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref 6
1606f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby/* The output reference is to a Objective-C selector ref. */
1616f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref 7
1626f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby/* The output reference is to a Objective-C class ref. */
1636f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8
1646f45b1f0d689d2cafd3a64be9b548bb8bb0927b0Kevin Enderby
16536b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines/* The output reference is to a C++ symbol name. */
16636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#define LLVMDisassembler_ReferenceType_DeMangled_Name 9
16736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines
16893f79364351650b58172522ae8346153a3c67a5cKevin Enderby#ifdef __cplusplus
16993f79364351650b58172522ae8346153a3c67a5cKevin Enderbyextern "C" {
17093f79364351650b58172522ae8346153a3c67a5cKevin Enderby#endif /* !defined(__cplusplus) */
17193f79364351650b58172522ae8346153a3c67a5cKevin Enderby
17293f79364351650b58172522ae8346153a3c67a5cKevin Enderby/**
17393f79364351650b58172522ae8346153a3c67a5cKevin Enderby * Create a disassembler for the TripleName.  Symbolic disassembly is supported
1741a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * by passing a block of information in the DisInfo parameter and specifying the
1751a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * TagType and callback functions as described above.  These can all be passed
1761a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * as NULL.  If successful, this returns a disassembler context.  If not, it
17768a590df13f47180abd3022aa75f237ae993770fJim Grosbach * returns NULL. This function is equivalent to calling LLVMCreateDisasmCPU()
17868a590df13f47180abd3022aa75f237ae993770fJim Grosbach * with an empty CPU name.
17993f79364351650b58172522ae8346153a3c67a5cKevin Enderby */
1801a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris LattnerLLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
1811a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner                                      int TagType, LLVMOpInfoCallback GetOpInfo,
1821a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner                                      LLVMSymbolLookupCallback SymbolLookUp);
18393f79364351650b58172522ae8346153a3c67a5cKevin Enderby
18493f79364351650b58172522ae8346153a3c67a5cKevin Enderby/**
18568a590df13f47180abd3022aa75f237ae993770fJim Grosbach * Create a disassembler for the TripleName and a specific CPU.  Symbolic
18668a590df13f47180abd3022aa75f237ae993770fJim Grosbach * disassembly is supported by passing a block of information in the DisInfo
18768a590df13f47180abd3022aa75f237ae993770fJim Grosbach * parameter and specifying the TagType and callback functions as described
18868a590df13f47180abd3022aa75f237ae993770fJim Grosbach * above.  These can all be passed * as NULL.  If successful, this returns a
18968a590df13f47180abd3022aa75f237ae993770fJim Grosbach * disassembler context.  If not, it returns NULL.
19068a590df13f47180abd3022aa75f237ae993770fJim Grosbach */
19168a590df13f47180abd3022aa75f237ae993770fJim GrosbachLLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
19268a590df13f47180abd3022aa75f237ae993770fJim Grosbach                                         void *DisInfo, int TagType,
19368a590df13f47180abd3022aa75f237ae993770fJim Grosbach                                         LLVMOpInfoCallback GetOpInfo,
19468a590df13f47180abd3022aa75f237ae993770fJim Grosbach                                         LLVMSymbolLookupCallback SymbolLookUp);
19568a590df13f47180abd3022aa75f237ae993770fJim Grosbach
19668a590df13f47180abd3022aa75f237ae993770fJim Grosbach/**
1973ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby * Set the disassembler's options.  Returns 1 if it can set the Options and 0
1983ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby * otherwise.
1993ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby */
2003ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderbyint LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
2013ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby
2023ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby/* The option to produce marked up assembly. */
2033ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby#define LLVMDisassembler_Option_UseMarkup 1
20414ccc9007a932a23201251ced4be4c898a62d6a5Kevin Enderby/* The option to print immediates as hex. */
20514ccc9007a932a23201251ced4be4c898a62d6a5Kevin Enderby#define LLVMDisassembler_Option_PrintImmHex 2
2065469f605fe86edcfb6d3f0e36f3e3ce0254334ccKevin Enderby/* The option use the other assembler printer variant */
2075469f605fe86edcfb6d3f0e36f3e3ce0254334ccKevin Enderby#define LLVMDisassembler_Option_AsmPrinterVariant 4
20876502a756da8fbc3cf6f2f26bc09cce598a9fc03Quentin Colombet/* The option to set comment on instructions */
20976502a756da8fbc3cf6f2f26bc09cce598a9fc03Quentin Colombet#define LLVMDisassembler_Option_SetInstrComments 8
210797f06e19b6f17217a69dea4d6ce900625432595Quentin Colombet  /* The option to print latency information alongside instructions */
211797f06e19b6f17217a69dea4d6ce900625432595Quentin Colombet#define LLVMDisassembler_Option_PrintLatency 16
2123ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby
2133ed0316f756e2f1730f46654776fcf77f5ace7aaKevin Enderby/**
21493f79364351650b58172522ae8346153a3c67a5cKevin Enderby * Dispose of a disassembler context.
21593f79364351650b58172522ae8346153a3c67a5cKevin Enderby */
2161a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattnervoid LLVMDisasmDispose(LLVMDisasmContextRef DC);
21793f79364351650b58172522ae8346153a3c67a5cKevin Enderby
21893f79364351650b58172522ae8346153a3c67a5cKevin Enderby/**
2191a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * Disassemble a single instruction using the disassembler context specified in
2201a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * the parameter DC.  The bytes of the instruction are specified in the
2211a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * parameter Bytes, and contains at least BytesSize number of bytes.  The
2221a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * instruction is at the address specified by the PC parameter.  If a valid
2231a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * instruction can be disassembled, its string is returned indirectly in
2241a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * OutString whose size is specified in the parameter OutStringSize.  This
2251a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * function returns the number of bytes in the instruction or zero if there was
2261a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner * no valid instruction.
22793f79364351650b58172522ae8346153a3c67a5cKevin Enderby */
2281a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattnersize_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes,
2291a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner                             uint64_t BytesSize, uint64_t PC,
2301a55c419a6427d8bbbdd62212a5cf763a3dcd05dChris Lattner                             char *OutString, size_t OutStringSize);
23193f79364351650b58172522ae8346153a3c67a5cKevin Enderby
2326244b518880842f2c15200ee041e06799e4cc779Gregory Szorc/**
2336244b518880842f2c15200ee041e06799e4cc779Gregory Szorc * @}
2346244b518880842f2c15200ee041e06799e4cc779Gregory Szorc */
2356244b518880842f2c15200ee041e06799e4cc779Gregory Szorc
23693f79364351650b58172522ae8346153a3c67a5cKevin Enderby#ifdef __cplusplus
23793f79364351650b58172522ae8346153a3c67a5cKevin Enderby}
23893f79364351650b58172522ae8346153a3c67a5cKevin Enderby#endif /* !defined(__cplusplus) */
23993f79364351650b58172522ae8346153a3c67a5cKevin Enderby
24093f79364351650b58172522ae8346153a3c67a5cKevin Enderby#endif /* !defined(LLVM_C_DISASSEMBLER_H) */
241