LLVM API Documentation
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "X86DisassemblerDecoder.h"
#include "X86GenDisassemblerTables.inc"
Go to the source code of this file.
Macros | |
#define | TRUE 1 |
#define | FALSE 0 |
#define | debug(s) do { x86DisassemblerDebug(__FILE__, __LINE__, s); } while (0) |
#define | CONSUME_FUNC(name, type) |
#define | GENERIC_FIXUP_FUNC(name, base, prefix) |
Functions | |
static InstructionContext | contextForAttrs (uint8_t attrMask) |
static int | modRMRequired (OpcodeType type, InstructionContext insnContext, uint8_t opcode) |
static InstrUID | decode (OpcodeType type, InstructionContext insnContext, uint8_t opcode, uint8_t modRM) |
static const struct InstructionSpecifier * | specifierForUID (InstrUID uid) |
static int | consumeByte (struct InternalInstruction *insn, uint8_t *byte) |
static int | lookAtByte (struct InternalInstruction *insn, uint8_t *byte) |
static void | unconsumeByte (struct InternalInstruction *insn) |
static void | dbgprintf (struct InternalInstruction *insn, const char *format,...) |
static void | setPrefixPresent (struct InternalInstruction *insn, uint8_t prefix, uint64_t location) |
static BOOL | isPrefixAtLocation (struct InternalInstruction *insn, uint8_t prefix, uint64_t location) |
static int | readPrefixes (struct InternalInstruction *insn) |
static int | readOpcode (struct InternalInstruction *insn) |
static int | readModRM (struct InternalInstruction *insn) |
static int | getIDWithAttrMask (uint16_t *instructionID, struct InternalInstruction *insn, uint8_t attrMask) |
static BOOL | is16BitEquivalent (const char *orig, const char *equiv) |
static int | getID (struct InternalInstruction *insn, const void *miiArg) |
static int | readSIB (struct InternalInstruction *insn) |
static int | readDisplacement (struct InternalInstruction *insn) |
static int | fixupReg (struct InternalInstruction *insn, const struct OperandSpecifier *op) |
static int | readOpcodeModifier (struct InternalInstruction *insn) |
static int | readOpcodeRegister (struct InternalInstruction *insn, uint8_t size) |
static int | readImmediate (struct InternalInstruction *insn, uint8_t size) |
static int | readVVVV (struct InternalInstruction *insn) |
static int | readOperands (struct InternalInstruction *insn) |
int | decodeInstruction (struct InternalInstruction *insn, byteReader_t reader, const void *readerArg, dlog_t logger, void *loggerArg, const void *miiArg, uint64_t startLoc, DisassemblerMode mode) |
#define CONSUME_FUNC | ( | name, | |
type | |||
) |
Definition at line 212 of file X86DisassemblerDecoder.c.
#define debug | ( | s | ) | do { x86DisassemblerDebug(__FILE__, __LINE__, s); } while (0) |
Definition at line 29 of file X86DisassemblerDecoder.c.
Referenced by decode(), fixupReg(), readImmediate(), readOpcodeModifier(), readPrefixes(), and readSIB().
#define FALSE 0 |
Definition at line 26 of file X86DisassemblerDecoder.c.
Referenced by is16BitEquivalent(), isPrefixAtLocation(), readDisplacement(), and readPrefixes().
#define GENERIC_FIXUP_FUNC | ( | name, | |
base, | |||
prefix | |||
) |
Definition at line 1280 of file X86DisassemblerDecoder.c.
#define TRUE 1 |
Definition at line 25 of file X86DisassemblerDecoder.c.
Referenced by is16BitEquivalent(), isPrefixAtLocation(), readDisplacement(), readModRM(), readOpcodeModifier(), readPrefixes(), and readSIB().
|
static |
Definition at line 188 of file X86DisassemblerDecoder.c.
References InternalInstruction::reader, InternalInstruction::readerArg, and InternalInstruction::readerCursor.
Referenced by readImmediate(), readModRM(), readOpcode(), readPrefixes(), and readSIB().
|
static |
Definition at line 43 of file X86DisassemblerDecoder.c.
References CONTEXTS_SYM.
Referenced by getIDWithAttrMask().
|
static |
Definition at line 255 of file X86DisassemblerDecoder.c.
References llvm::format(), and llvm::LibFunc::vsnprintf.
Referenced by decodeInstruction(), fixupReg(), getID(), readDisplacement(), readImmediate(), readModRM(), readOpcode(), readOpcodeModifier(), readOpcodeRegister(), readOperands(), readPrefixes(), readSIB(), and readVVVV().
|
static |
Definition at line 107 of file X86DisassemblerDecoder.c.
References debug, modFromModRM, ModRMDecision::modrm_type, ONEBYTE, ONEBYTE_SYM, THREEBYTE38_SYM, THREEBYTE3A_SYM, THREEBYTE_38, THREEBYTE_3A, THREEBYTE_A6, THREEBYTE_A7, THREEBYTEA6_SYM, THREEBYTEA7_SYM, TWOBYTE, TWOBYTE_SYM, XOP8_MAP, XOP8_MAP_SYM, XOP9_MAP, XOP9_MAP_SYM, XOPA_MAP, and XOPA_MAP_SYM.
Referenced by getIDWithAttrMask().
int decodeInstruction | ( | struct InternalInstruction * | insn, |
byteReader_t | reader, | ||
const void * | readerArg, | ||
dlog_t | logger, | ||
void * | loggerArg, | ||
const void * | miiArg, | ||
uint64_t | startLoc, | ||
DisassemblerMode | mode | ||
) |
Definition at line 1712 of file X86DisassemblerDecoder.c.
References dbgprintf(), InternalInstruction::dlog, InternalInstruction::dlogArg, getID(), InternalInstruction::instructionID, InternalInstruction::length, logger(), llvm::Intrinsic::memset, InternalInstruction::mode, InternalInstruction::numImmediatesConsumed, InternalInstruction::operands, InternalInstruction::reader, InternalInstruction::readerArg, InternalInstruction::readerCursor, readOpcode(), readOperands(), readPrefixes(), InternalInstruction::spec, and InternalInstruction::startLocation.
Referenced by llvm::X86Disassembler::X86GenericDisassembler::getInstruction().
|
static |
Definition at line 1361 of file X86DisassemblerDecoder.c.
References dbgprintf(), and debug.
Referenced by readOperands().
|
static |
Definition at line 828 of file X86DisassemblerDecoder.c.
References dbgprintf(), getIDWithAttrMask(), InternalInstruction::instructionID, is16BitEquivalent(), isPrefixAtLocation(), lFromVEX2of2, lFromVEX3of3, lFromXOP3of3, InternalInstruction::mode, MODE_64BIT, InternalInstruction::necessaryPrefixLocation, ONEBYTE, InternalInstruction::opcode, InternalInstruction::opcodeType, ppFromVEX2of2, ppFromVEX3of3, ppFromXOP3of3, InternalInstruction::prefixPresent, InternalInstruction::rexPrefix, InternalInstruction::spec, specifierForUID(), TYPE_NO_VEX_XOP, TYPE_VEX_2B, TYPE_VEX_3B, TYPE_XOP, VEX_PREFIX_66, VEX_PREFIX_F2, VEX_PREFIX_F3, InternalInstruction::vexXopPrefix, InternalInstruction::vexXopType, and x86DisassemblerGetInstrName().
Referenced by decodeInstruction().
|
static |
Definition at line 761 of file X86DisassemblerDecoder.c.
References contextForAttrs(), decode(), InternalInstruction::modRM, modRMRequired(), InternalInstruction::opcode, InternalInstruction::opcodeType, and readModRM().
Referenced by getID().
|
static |
Definition at line 799 of file X86DisassemblerDecoder.c.
Referenced by getID().
|
static |
Definition at line 299 of file X86DisassemblerDecoder.c.
References FALSE, InternalInstruction::prefixLocations, InternalInstruction::prefixPresent, and TRUE.
Referenced by getID().
|
static |
Definition at line 204 of file X86DisassemblerDecoder.c.
References InternalInstruction::reader, InternalInstruction::readerArg, and InternalInstruction::readerCursor.
Referenced by readPrefixes().
|
static |
Definition at line 58 of file X86DisassemblerDecoder.c.
References OpcodeDecision::modRMDecisions, ONEBYTE, ONEBYTE_SYM, ContextDecision::opcodeDecisions, THREEBYTE38_SYM, THREEBYTE3A_SYM, THREEBYTE_38, THREEBYTE_3A, THREEBYTE_A6, THREEBYTE_A7, THREEBYTEA6_SYM, THREEBYTEA7_SYM, TWOBYTE, TWOBYTE_SYM, XOP8_MAP, XOP8_MAP_SYM, XOP9_MAP, XOP9_MAP_SYM, XOPA_MAP, and XOPA_MAP_SYM.
Referenced by getIDWithAttrMask().
|
static |
Definition at line 1103 of file X86DisassemblerDecoder.c.
References InternalInstruction::consumedDisplacement, dbgprintf(), InternalInstruction::displacement, InternalInstruction::displacementOffset, EA_DISP_16, EA_DISP_32, EA_DISP_8, EA_DISP_NONE, InternalInstruction::eaDisplacement, FALSE, InternalInstruction::readerCursor, InternalInstruction::startLocation, and TRUE.
Referenced by readModRM().
|
static |
Definition at line 1496 of file X86DisassemblerDecoder.c.
References consumeByte(), dbgprintf(), debug, InternalInstruction::immediateOffset, InternalInstruction::immediates, InternalInstruction::immediateSize, InternalInstruction::numImmediatesConsumed, InternalInstruction::readerCursor, and InternalInstruction::startLocation.
Referenced by readOperands().
|
static |
Definition at line 1148 of file X86DisassemblerDecoder.c.
References InternalInstruction::addressSize, bFromREX, consumeByte(), InternalInstruction::consumedModRM, dbgprintf(), EA_BASE_NONE, EA_DISP_16, EA_DISP_32, EA_DISP_8, EA_DISP_NONE, InternalInstruction::eaBase, InternalInstruction::eaBaseBase, InternalInstruction::eaDisplacement, InternalInstruction::eaRegBase, modFromModRM, InternalInstruction::modRM, readDisplacement(), readSIB(), InternalInstruction::reg, InternalInstruction::regBase, regFromModRM, InternalInstruction::registerSize, InternalInstruction::rexPrefix, rFromREX, rmFromModRM, and TRUE.
Referenced by getIDWithAttrMask(), and readOperands().
|
static |
Definition at line 640 of file X86DisassemblerDecoder.c.
References consumeByte(), dbgprintf(), mmmmmFromVEX2of3, mmmmmFromXOP2of3, ONEBYTE, InternalInstruction::opcode, InternalInstruction::opcodeType, THREEBYTE_38, THREEBYTE_3A, THREEBYTE_A6, THREEBYTE_A7, TWOBYTE, TYPE_VEX_2B, TYPE_VEX_3B, TYPE_XOP, VEX_LOB_0F, VEX_LOB_0F38, VEX_LOB_0F3A, InternalInstruction::vexXopPrefix, InternalInstruction::vexXopType, XOP8_MAP, XOP9_MAP, XOP_MAP_SELECT_8, XOP_MAP_SELECT_9, XOP_MAP_SELECT_A, and XOPA_MAP.
Referenced by decodeInstruction().
|
static |
Definition at line 1411 of file X86DisassemblerDecoder.c.
References InternalInstruction::consumedOpcodeModifier, dbgprintf(), debug, InstructionSpecifier::modifierBase, InstructionSpecifier::modifierType, InternalInstruction::modRM, InternalInstruction::opcode, InternalInstruction::opcodeModifier, InternalInstruction::spec, and TRUE.
Referenced by readOpcodeRegister(), and readOperands().
|
static |
Definition at line 1446 of file X86DisassemblerDecoder.c.
References bFromREX, dbgprintf(), InternalInstruction::opcodeModifier, InternalInstruction::opcodeRegister, readOpcodeModifier(), InternalInstruction::registerSize, and InternalInstruction::rexPrefix.
Referenced by readOperands().
|
static |
Definition at line 1575 of file X86DisassemblerDecoder.c.
References InternalInstruction::addressSize, dbgprintf(), fixupReg(), InternalInstruction::immediates, InternalInstruction::immediateSize, InternalInstruction::numImmediatesConsumed, readImmediate(), readModRM(), readOpcodeModifier(), readOpcodeRegister(), readVVVV(), InternalInstruction::spec, InternalInstruction::vvvv, and X86_MAX_OPERANDS.
Referenced by decodeInstruction().
|
static |
Definition at line 319 of file X86DisassemblerDecoder.c.
References InternalInstruction::addressSize, bFromVEX2of3, bFromXOP2of3, consumeByte(), dbgprintf(), debug, InternalInstruction::displacementSize, FALSE, InternalInstruction::immediateSize, lookAtByte(), InternalInstruction::mode, MODE_16BIT, MODE_32BIT, MODE_64BIT, InternalInstruction::necessaryPrefixLocation, ppFromVEX2of2, ppFromVEX3of3, ppFromXOP3of3, InternalInstruction::readerCursor, InternalInstruction::registerSize, InternalInstruction::rexPrefix, rFromVEX2of2, rFromVEX2of3, rFromXOP2of3, SEG_OVERRIDE_CS, SEG_OVERRIDE_DS, SEG_OVERRIDE_ES, SEG_OVERRIDE_FS, SEG_OVERRIDE_GS, SEG_OVERRIDE_SS, InternalInstruction::segmentOverride, setPrefixPresent(), InternalInstruction::startLocation, TRUE, TYPE_NO_VEX_XOP, TYPE_VEX_2B, TYPE_VEX_3B, TYPE_XOP, unconsumeByte(), VEX_PREFIX_66, InternalInstruction::vexXopPrefix, InternalInstruction::vexXopType, wFromREX, wFromVEX3of3, wFromXOP3of3, InternalInstruction::xAcquireRelease, xFromVEX2of3, and xFromXOP2of3.
Referenced by decodeInstruction().
|
static |
Definition at line 1005 of file X86DisassemblerDecoder.c.
References InternalInstruction::addressSize, baseFromSIB, bFromREX, consumeByte(), InternalInstruction::consumedSIB, dbgprintf(), debug, EA_DISP_32, EA_DISP_8, InternalInstruction::eaDisplacement, indexFromSIB, modFromModRM, InternalInstruction::modRM, InternalInstruction::rexPrefix, scaleFromSIB, InternalInstruction::sib, SIB_BASE_NONE, SIB_INDEX_NONE, InternalInstruction::sibBase, InternalInstruction::sibIndex, InternalInstruction::sibScale, TRUE, and xFromREX.
Referenced by readModRM().
|
static |
Definition at line 1550 of file X86DisassemblerDecoder.c.
References dbgprintf(), InternalInstruction::mode, MODE_64BIT, TYPE_VEX_2B, TYPE_VEX_3B, TYPE_XOP, InternalInstruction::vexXopPrefix, InternalInstruction::vexXopType, InternalInstruction::vvvv, vvvvFromVEX2of2, vvvvFromVEX3of3, and vvvvFromXOP3of3.
Referenced by readOperands().
|
static |
Definition at line 282 of file X86DisassemblerDecoder.c.
References llvm::cl::location(), InternalInstruction::prefixLocations, and InternalInstruction::prefixPresent.
Referenced by readPrefixes().
|
static |
Definition at line 174 of file X86DisassemblerDecoder.c.
References INSTRUCTIONS_SYM.
Referenced by getID().
|
static |
Definition at line 208 of file X86DisassemblerDecoder.c.
References InternalInstruction::readerCursor.
Referenced by readPrefixes().