LLVM API Documentation

Classes | Defines | Functions
X86DisassemblerDecoder.cpp File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "X86DisassemblerDecoder.h"
#include "X86GenDisassemblerTables.inc"
Include dependency graph for X86DisassemblerDecoder.cpp:

Go to the source code of this file.

Classes

struct  ModRMDecision
struct  OpcodeDecision
struct  ContextDecision

Defines

#define debug(s)   do { Debug(__FILE__, __LINE__, s); } while (0)
#define CONSUME_FUNC(name, type)
#define GENERIC_FIXUP_FUNC(name, base, prefix)

Functions

static InstructionContext contextForAttrs (uint16_t attrMask)
static int modRMRequired (OpcodeType type, InstructionContext insnContext, uint16_t opcode)
static InstrUID decode (OpcodeType type, InstructionContext insnContext, uint8_t opcode, uint8_t modRM)
static 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, uint16_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 readOpcodeRegister (struct InternalInstruction *insn, uint8_t size)
static int readImmediate (struct InternalInstruction *insn, uint8_t size)
static int readVVVV (struct InternalInstruction *insn)
static int readMaskRegister (struct InternalInstruction *insn)
static int readOperands (struct InternalInstruction *insn)

Define Documentation

#define CONSUME_FUNC (   name,
  type 
)
Value:
static int name(struct InternalInstruction* insn, type* ptr) {  \
    type combined = 0;                                            \
    unsigned offset;                                              \
    for (offset = 0; offset < sizeof(type); ++offset) {           \
      uint8_t byte;                                               \
      int ret = insn->reader(insn->readerArg,                     \
                             &byte,                               \
                             insn->readerCursor + offset);        \
      if (ret)                                                    \
        return ret;                                               \
      combined = combined | ((uint64_t)byte << (offset * 8));     \
    }                                                             \
    *ptr = combined;                                              \
    insn->readerCursor += sizeof(type);                           \
    return 0;                                                     \
  }

Definition at line 222 of file X86DisassemblerDecoder.cpp.

#define debug (   s)    do { Debug(__FILE__, __LINE__, s); } while (0)

Definition at line 51 of file X86DisassemblerDecoder.cpp.

Referenced by decode(), fixupReg(), readImmediate(), readPrefixes(), and readSIB().

#define GENERIC_FIXUP_FUNC (   name,
  base,
  prefix 
)

Definition at line 1380 of file X86DisassemblerDecoder.cpp.


Function Documentation

static int consumeByte ( struct InternalInstruction insn,
uint8_t *  byte 
) [static]
static InstructionContext contextForAttrs ( uint16_t  attrMask) [static]

Definition at line 65 of file X86DisassemblerDecoder.cpp.

References CONTEXTS_SYM.

Referenced by getIDWithAttrMask().

static void dbgprintf ( struct InternalInstruction insn,
const char *  format,
  ... 
) [static]
static InstrUID decode ( OpcodeType  type,
InstructionContext  insnContext,
uint8_t  opcode,
uint8_t  modRM 
) [static]
static int fixupReg ( struct InternalInstruction insn,
const struct OperandSpecifier op 
) [static]

Definition at line 1465 of file X86DisassemblerDecoder.cpp.

References CASE_ENCODING_RM, dbgprintf(), and debug.

Referenced by readOperands().

static int getID ( struct InternalInstruction insn,
const void *  miiArg 
) [static]
static int getIDWithAttrMask ( uint16_t *  instructionID,
struct InternalInstruction insn,
uint16_t  attrMask 
) [static]
static bool is16BitEquivalent ( const char *  orig,
const char *  equiv 
) [static]

Definition at line 848 of file X86DisassemblerDecoder.cpp.

Referenced by getID().

static bool isPrefixAtLocation ( struct InternalInstruction insn,
uint8_t  prefix,
uint64_t  location 
) [static]
static int lookAtByte ( struct InternalInstruction insn,
uint8_t *  byte 
) [static]
static int modRMRequired ( OpcodeType  type,
InstructionContext  insnContext,
uint16_t  opcode 
) [static]
static int readDisplacement ( struct InternalInstruction insn) [static]
static int readImmediate ( struct InternalInstruction insn,
uint8_t  size 
) [static]
static int readMaskRegister ( struct InternalInstruction insn) [static]
static int readModRM ( struct InternalInstruction insn) [static]
static int readOpcode ( struct InternalInstruction insn) [static]
static int readOpcodeRegister ( struct InternalInstruction insn,
uint8_t  size 
) [static]
static int readOperands ( struct InternalInstruction insn) [static]
static int readPrefixes ( struct InternalInstruction insn) [static]

Definition at line 329 of file X86DisassemblerDecoder.cpp.

References llvm::X86Disassembler::InternalInstruction::addressSize, bFromEVEX2of4, bFromVEX2of3, bFromXOP2of3, consumeByte(), dbgprintf(), debug, llvm::X86Disassembler::InternalInstruction::displacementSize, llvm::X86Disassembler::InternalInstruction::immediateSize, lookAtByte(), llvm::X86Disassembler::InternalInstruction::mode, llvm::X86Disassembler::MODE_16BIT, llvm::X86Disassembler::MODE_32BIT, llvm::X86Disassembler::MODE_64BIT, llvm::X86Disassembler::InternalInstruction::necessaryPrefixLocation, ppFromVEX2of2, ppFromXOP3of3, llvm::X86Disassembler::InternalInstruction::readerCursor, llvm::X86Disassembler::InternalInstruction::registerSize, llvm::X86Disassembler::InternalInstruction::rexPrefix, rFromEVEX2of4, rFromVEX2of2, rFromVEX2of3, rFromXOP2of3, llvm::X86Disassembler::SEG_OVERRIDE_CS, llvm::X86Disassembler::SEG_OVERRIDE_DS, llvm::X86Disassembler::SEG_OVERRIDE_ES, llvm::X86Disassembler::SEG_OVERRIDE_FS, llvm::X86Disassembler::SEG_OVERRIDE_GS, llvm::X86Disassembler::SEG_OVERRIDE_SS, llvm::X86Disassembler::InternalInstruction::segmentOverride, setPrefixPresent(), llvm::X86Disassembler::InternalInstruction::startLocation, llvm::X86Disassembler::TYPE_EVEX, llvm::X86Disassembler::TYPE_NO_VEX_XOP, llvm::X86Disassembler::TYPE_VEX_2B, llvm::X86Disassembler::TYPE_VEX_3B, llvm::X86Disassembler::TYPE_XOP, unconsumeByte(), llvm::X86Disassembler::InternalInstruction::vectorExtensionPrefix, llvm::X86Disassembler::InternalInstruction::vectorExtensionType, llvm::X86Disassembler::VEX_PREFIX_66, wFromEVEX3of4, wFromREX, wFromVEX3of3, wFromXOP3of3, llvm::X86Disassembler::InternalInstruction::xAcquireRelease, xFromEVEX2of4, xFromVEX2of3, and xFromXOP2of3.

Referenced by llvm::X86Disassembler::decodeInstruction().

static int readSIB ( struct InternalInstruction insn) [static]
static int readVVVV ( struct InternalInstruction insn) [static]
static void setPrefixPresent ( struct InternalInstruction insn,
uint8_t  prefix,
uint64_t  location 
) [static]
static struct InstructionSpecifier* specifierForUID ( InstrUID  uid) [static, read]

Definition at line 184 of file X86DisassemblerDecoder.cpp.

References INSTRUCTIONS_SYM.

Referenced by getID().

static void unconsumeByte ( struct InternalInstruction insn) [static]