Disassembler.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. /*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\
  7. |* *|
  8. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
  9. |* Exceptions. *|
  10. |* See https://llvm.org/LICENSE.txt for license information. *|
  11. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
  12. |* *|
  13. |*===----------------------------------------------------------------------===*|
  14. |* *|
  15. |* This header provides a public interface to a disassembler library. *|
  16. |* LLVM provides an implementation of this interface. *|
  17. |* *|
  18. \*===----------------------------------------------------------------------===*/
  19. #ifndef LLVM_C_DISASSEMBLER_H
  20. #define LLVM_C_DISASSEMBLER_H
  21. #include "llvm-c/DisassemblerTypes.h"
  22. #include "llvm-c/ExternC.h"
  23. /**
  24. * @defgroup LLVMCDisassembler Disassembler
  25. * @ingroup LLVMC
  26. *
  27. * @{
  28. */
  29. LLVM_C_EXTERN_C_BEGIN
  30. /**
  31. * Create a disassembler for the TripleName. Symbolic disassembly is supported
  32. * by passing a block of information in the DisInfo parameter and specifying the
  33. * TagType and callback functions as described above. These can all be passed
  34. * as NULL. If successful, this returns a disassembler context. If not, it
  35. * returns NULL. This function is equivalent to calling
  36. * LLVMCreateDisasmCPUFeatures() with an empty CPU name and feature set.
  37. */
  38. LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
  39. int TagType, LLVMOpInfoCallback GetOpInfo,
  40. LLVMSymbolLookupCallback SymbolLookUp);
  41. /**
  42. * Create a disassembler for the TripleName and a specific CPU. Symbolic
  43. * disassembly is supported by passing a block of information in the DisInfo
  44. * parameter and specifying the TagType and callback functions as described
  45. * above. These can all be passed * as NULL. If successful, this returns a
  46. * disassembler context. If not, it returns NULL. This function is equivalent
  47. * to calling LLVMCreateDisasmCPUFeatures() with an empty feature set.
  48. */
  49. LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
  50. void *DisInfo, int TagType,
  51. LLVMOpInfoCallback GetOpInfo,
  52. LLVMSymbolLookupCallback SymbolLookUp);
  53. /**
  54. * Create a disassembler for the TripleName, a specific CPU and specific feature
  55. * string. Symbolic disassembly is supported by passing a block of information
  56. * in the DisInfo parameter and specifying the TagType and callback functions as
  57. * described above. These can all be passed * as NULL. If successful, this
  58. * returns a disassembler context. If not, it returns NULL.
  59. */
  60. LLVMDisasmContextRef
  61. LLVMCreateDisasmCPUFeatures(const char *Triple, const char *CPU,
  62. const char *Features, void *DisInfo, int TagType,
  63. LLVMOpInfoCallback GetOpInfo,
  64. LLVMSymbolLookupCallback SymbolLookUp);
  65. /**
  66. * Set the disassembler's options. Returns 1 if it can set the Options and 0
  67. * otherwise.
  68. */
  69. int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options);
  70. /* The option to produce marked up assembly. */
  71. #define LLVMDisassembler_Option_UseMarkup 1
  72. /* The option to print immediates as hex. */
  73. #define LLVMDisassembler_Option_PrintImmHex 2
  74. /* The option use the other assembler printer variant */
  75. #define LLVMDisassembler_Option_AsmPrinterVariant 4
  76. /* The option to set comment on instructions */
  77. #define LLVMDisassembler_Option_SetInstrComments 8
  78. /* The option to print latency information alongside instructions */
  79. #define LLVMDisassembler_Option_PrintLatency 16
  80. /**
  81. * Dispose of a disassembler context.
  82. */
  83. void LLVMDisasmDispose(LLVMDisasmContextRef DC);
  84. /**
  85. * Disassemble a single instruction using the disassembler context specified in
  86. * the parameter DC. The bytes of the instruction are specified in the
  87. * parameter Bytes, and contains at least BytesSize number of bytes. The
  88. * instruction is at the address specified by the PC parameter. If a valid
  89. * instruction can be disassembled, its string is returned indirectly in
  90. * OutString whose size is specified in the parameter OutStringSize. This
  91. * function returns the number of bytes in the instruction or zero if there was
  92. * no valid instruction.
  93. */
  94. size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes,
  95. uint64_t BytesSize, uint64_t PC,
  96. char *OutString, size_t OutStringSize);
  97. /**
  98. * @}
  99. */
  100. LLVM_C_EXTERN_C_END
  101. #endif /* LLVM_C_DISASSEMBLER_H */
  102. #ifdef __GNUC__
  103. #pragma GCC diagnostic pop
  104. #endif