summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h')
-rw-r--r--llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h69
1 files changed, 6 insertions, 63 deletions
diff --git a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
index 7c0a42c019e35..147fe46d81b9b 100644
--- a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
+++ b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
@@ -19,6 +19,9 @@
#include "llvm/Support/X86DisassemblerDecoderCommon.h"
namespace llvm {
+
+class MCInstrInfo;
+
namespace X86Disassembler {
// Accessor functions for various fields of an Intel instruction
@@ -446,12 +449,12 @@ enum SIBBase {
};
/// Possible displacement types for effective-address computations.
-typedef enum {
+enum EADisplacement {
EA_DISP_NONE,
EA_DISP_8,
EA_DISP_16,
EA_DISP_32
-} EADisplacement;
+};
/// All possible values of the reg field in the ModR/M byte.
enum Reg {
@@ -502,25 +505,6 @@ enum VectorExtensionType {
TYPE_XOP = 0x4
};
-/// Type for the byte reader that the consumer must provide to
-/// the decoder. Reads a single byte from the instruction's address space.
-/// \param arg A baton that the consumer can associate with any internal
-/// state that it needs.
-/// \param byte A pointer to a single byte in memory that should be set to
-/// contain the value at address.
-/// \param address The address in the instruction's address space that should
-/// be read from.
-/// \return -1 if the byte cannot be read for any reason; 0 otherwise.
-typedef int (*byteReader_t)(const void *arg, uint8_t *byte, uint64_t address);
-
-/// Type for the logging function that the consumer can provide to
-/// get debugging output from the decoder.
-/// \param arg A baton that the consumer can associate with any internal
-/// state that it needs.
-/// \param log A string that contains the message. Will be reused after
-/// the logger returns.
-typedef void (*dlog_t)(void *arg, const char *log);
-
/// The specification for how to extract and interpret a full instruction and
/// its operands.
struct InstructionSpecifier {
@@ -529,18 +513,11 @@ struct InstructionSpecifier {
/// The x86 internal instruction, which is produced by the decoder.
struct InternalInstruction {
- // Reader interface (C)
- byteReader_t reader;
// Opaque value passed to the reader
- const void* readerArg;
+ llvm::ArrayRef<uint8_t> bytes;
// The address of the next byte to read via the reader
uint64_t readerCursor;
- // Logger interface (C)
- dlog_t dlog;
- // Opaque value passed to the logger
- void* dlogArg;
-
// General instruction information
// The mode to disassemble for (64-bit, protected, real)
@@ -616,11 +593,9 @@ struct InternalInstruction {
uint8_t modRM;
// The SIB byte, used for more complex 32- or 64-bit memory operands
- bool consumedSIB;
uint8_t sib;
// The displacement, used for memory operands
- bool consumedDisplacement;
int32_t displacement;
// Immediates. There can be two in some cases
@@ -657,38 +632,6 @@ struct InternalInstruction {
ArrayRef<OperandSpecifier> operands;
};
-/// Decode one instruction and store the decoding results in
-/// a buffer provided by the consumer.
-/// \param insn The buffer to store the instruction in. Allocated by the
-/// consumer.
-/// \param reader The byteReader_t for the bytes to be read.
-/// \param readerArg An argument to pass to the reader for storing context
-/// specific to the consumer. May be NULL.
-/// \param logger The dlog_t to be used in printing status messages from the
-/// disassembler. May be NULL.
-/// \param loggerArg An argument to pass to the logger for storing context
-/// specific to the logger. May be NULL.
-/// \param startLoc The address (in the reader's address space) of the first
-/// byte in the instruction.
-/// \param mode The mode (16-bit, 32-bit, 64-bit) to decode in.
-/// \return Nonzero if there was an error during decode, 0 otherwise.
-int decodeInstruction(InternalInstruction *insn,
- byteReader_t reader,
- const void *readerArg,
- dlog_t logger,
- void *loggerArg,
- const void *miiArg,
- uint64_t startLoc,
- DisassemblerMode mode);
-
-/// Print a message to debugs()
-/// \param file The name of the file printing the debug message.
-/// \param line The line number that printed the debug message.
-/// \param s The message to print.
-void Debug(const char *file, unsigned line, const char *s);
-
-StringRef GetInstrName(unsigned Opcode, const void *mii);
-
} // namespace X86Disassembler
} // namespace llvm