DynamoRIO API
dr_ir_macros.h File Reference

Cross-platform instruction creation convenience macros. More...

#include "dr_ir_macros_x86.h"
#include "dr_ir_opnd.h"
#include "dr_ir_instr.h"
#include "dr_ir_utils.h"

Macros

#define INSTR_XL8(instr_ptr, app_addr)   instr_set_translation((instr_ptr), (app_addr))
 
#define INSTR_PRED(instr_ptr, pred)   instr_set_predicate((instr_ptr), (pred))
 
#define OPND_CREATE_MEM64(base_reg, disp)   opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_8)
 
#define OPND_CREATE_MEM32(base_reg, disp)   opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_4)
 
#define OPND_CREATE_MEM16(base_reg, disp)   opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_2)
 
#define OPND_CREATE_MEM8(base_reg, disp)   opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_1)
 
#define OPND_CREATE_MEMPTR   OPND_CREATE_MEM64
 
#define OPND_CREATE_INT64(val)   opnd_create_immed_int((ptr_int_t)(val), OPSZ_8)
 
#define OPND_CREATE_INTPTR   OPND_CREATE_INT64
 
#define OPND_CREATE_INT32(val)   opnd_create_immed_int((ptr_int_t)(val), OPSZ_4)
 
#define OPND_CREATE_INT16(val)   opnd_create_immed_int((ptr_int_t)(val), OPSZ_2)
 
#define OPND_CREATE_INT8(val)   opnd_create_immed_int((ptr_int_t)(val), OPSZ_1)
 
#define OPND_CREATE_INT_32OR8(val)
 
#define OPND_CREATE_INT_16OR8(val)
 
#define INSTR_CREATE_label(dc)    instr_create_0dst_0src((dc), OP_LABEL)
 

Detailed Description

Cross-platform instruction creation convenience macros.

Macro Definition Documentation

#define INSTR_CREATE_label (   dc)    instr_create_0dst_0src((dc), OP_LABEL)

Creates an instr_t with opcode OP_LABEL. An OP_LABEL instruction can be used as a jump or call instr_t target, and when emitted it will take no space in the resulting machine code.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
#define INSTR_PRED (   instr_ptr,
  pred 
)    instr_set_predicate((instr_ptr), (pred))

Set the predication value for an instruction.

#define INSTR_XL8 (   instr_ptr,
  app_addr 
)    instr_set_translation((instr_ptr), (app_addr))

Set the translation field for an instruction. For example: instr_t *pushf_instr = INSTR_XL8(INSTR_CREATE_pushf(drcontext), addr);

#define OPND_CREATE_INT16 (   val)    opnd_create_immed_int((ptr_int_t)(val), OPSZ_2)

Create a 2-byte immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_INT32 (   val)    opnd_create_immed_int((ptr_int_t)(val), OPSZ_4)

Create a 4-byte immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_INT64 (   val)    opnd_create_immed_int((ptr_int_t)(val), OPSZ_8)

Create an 8-byte immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_INT8 (   val)    opnd_create_immed_int((ptr_int_t)(val), OPSZ_1)

Create a 1-byte immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_INT_16OR8 (   val)
Value:
((val) <= SCHAR_MAX && (ptr_int_t)(val) >= SCHAR_MIN ? \
#define OPND_CREATE_INT8(val)
Definition: dr_ir_macros.h:124
#define OPND_CREATE_INT16(val)
Definition: dr_ir_macros.h:118

Create a 1-byte immediate interger operand if val will fit, else create a 2-byte immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_INT_32OR8 (   val)
Value:
((val) <= SCHAR_MAX && (ptr_int_t)(val) >= SCHAR_MIN ? \
#define OPND_CREATE_INT32(val)
Definition: dr_ir_macros.h:112
#define OPND_CREATE_INT8(val)
Definition: dr_ir_macros.h:124

Create a 1-byte immediate integer operand if val will fit, else create a 4-byte immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_INTPTR   OPND_CREATE_INT64

Create a pointer-sized immediate integer operand.

Note
This is only relevant for x86: for ARM where immediate sizes are ignored, simply use OPND_CREATE_INT().
#define OPND_CREATE_MEM16 (   base_reg,
  disp 
)    opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_2)

Create a base+disp 2-byte operand.

#define OPND_CREATE_MEM32 (   base_reg,
  disp 
)    opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_4)

Create a base+disp 4-byte operand.

#define OPND_CREATE_MEM64 (   base_reg,
  disp 
)    opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_8)

Create a base+disp 8-byte operand.

#define OPND_CREATE_MEM8 (   base_reg,
  disp 
)    opnd_create_base_disp(base_reg, DR_REG_NULL, 0, disp, OPSZ_1)

Create a base+disp 1-byte operand.

#define OPND_CREATE_MEMPTR   OPND_CREATE_MEM64

Create a base+disp pointer-sized operand.