LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
X86DisassemblerDecoder.c 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.c:

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)
 

Macro Definition 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; \
}
* if(!EatIfPresent(lltok::kw_thread_local)) return false
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)

Definition at line 212 of file X86DisassemblerDecoder.c.

#define debug (   s)    do { x86DisassemblerDebug(__FILE__, __LINE__, s); } while (0)
#define FALSE   0
#define GENERIC_FIXUP_FUNC (   name,
  base,
  prefix 
)

Definition at line 1280 of file X86DisassemblerDecoder.c.

#define TRUE   1

Function Documentation

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

Definition at line 43 of file X86DisassemblerDecoder.c.

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
int decodeInstruction ( struct InternalInstruction insn,
byteReader_t  reader,
const void *  readerArg,
dlog_t  logger,
void *  loggerArg,
const void *  miiArg,
uint64_t  startLoc,
DisassemblerMode  mode 
)
static int fixupReg ( struct InternalInstruction insn,
const struct OperandSpecifier op 
)
static

Definition at line 1361 of file X86DisassemblerDecoder.c.

References 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,
uint8_t  attrMask 
)
static
static BOOL is16BitEquivalent ( const char *  orig,
const char *  equiv 
)
static

Definition at line 799 of file X86DisassemblerDecoder.c.

References FALSE, and TRUE.

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,
uint8_t  opcode 
)
static
static int readDisplacement ( struct InternalInstruction insn)
static
static int readImmediate ( struct InternalInstruction insn,
uint8_t  size 
)
static
static int readModRM ( struct InternalInstruction insn)
static
static int readOpcode ( struct InternalInstruction insn)
static
static int readOpcodeModifier ( 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
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 const struct InstructionSpecifier* specifierForUID ( InstrUID  uid)
static

Definition at line 174 of file X86DisassemblerDecoder.c.

References INSTRUCTIONS_SYM.

Referenced by getID().

static void unconsumeByte ( struct InternalInstruction insn)
static

Definition at line 208 of file X86DisassemblerDecoder.c.

References InternalInstruction::readerCursor.

Referenced by readPrefixes().