DynamoRIO API
dr_ir_macros_aarch64.h File Reference

AArch64-specific instruction creation convenience macros. More...

Macros

#define OPND_CREATE_ABSMEM(addr, size)   opnd_create_rel_addr(addr, size)
 
#define OPND_CREATE_INT(val)   OPND_CREATE_INTPTR(val)
 
#define OPND_CREATE_ZR(reg)   opnd_create_reg(opnd_get_size(reg) == OPSZ_4 ? DR_REG_WZR : DR_REG_XZR)
 
#define OPND_CREATE_LSL()   opnd_add_flags(OPND_CREATE_INT(DR_SHIFT_LSL), DR_OPND_IS_SHIFT)
 
#define XINST_CREATE_cmp(dc, s1, s2)   INSTR_CREATE_cmp(dc, s1, s2)
 
#define XINST_CREATE_debug_instr(dc)   INSTR_CREATE_brk((dc), OPND_CREATE_INT16(0))
 
#define XINST_CREATE_load(dc, r, m)   INSTR_CREATE_ldr((dc), (r), (m))
 
#define XINST_CREATE_store(dc, m, r)
 
#define XINST_CREATE_store_1byte(dc, m, r)
 
#define XINST_CREATE_store_2bytes(dc, m, r)
 
#define XINST_CREATE_move(dc, d, s)
 
#define XINST_CREATE_load_simd(dc, r, m)   INSTR_CREATE_ldr((dc), (r), (m))
 
#define XINST_CREATE_store_simd(dc, m, r)   INSTR_CREATE_str((dc), (m), (r))
 
#define XINST_CREATE_load_int(dc, r, i)   INSTR_CREATE_movz((dc), (r), (i), OPND_CREATE_INT(0))
 
#define XINST_CREATE_return(dc)   INSTR_CREATE_ret(dc, opnd_create_reg(DR_REG_X30))
 
#define XINST_CREATE_jump(dc, t)   INSTR_CREATE_b((dc), (t))
 
#define XINST_CREATE_jump_reg(dc, r)   INSTR_CREATE_br((dc), (r))
 
#define XINST_CREATE_jump_short(dc, t)   INSTR_CREATE_b((dc), (t))
 
#define XINST_CREATE_add(dc, d, s)   INSTR_CREATE_add_shift(dc, d, d, s, OPND_CREATE_LSL(), OPND_CREATE_INT(0))
 
#define XINST_CREATE_add_2src(dc, d, s1, s2)   INSTR_CREATE_add_shift(dc, d, s1, s2, OPND_CREATE_LSL(), OPND_CREATE_INT(0))
 
#define XINST_CREATE_sub(dc, d, s)   INSTR_CREATE_sub_shift(dc, d, d, s, OPND_CREATE_LSL(), OPND_CREATE_INT(0))
 
#define XINST_CREATE_nop(dc)   INSTR_CREATE_nop(dc)
 

Detailed Description

AArch64-specific instruction creation convenience macros.

Macro Definition Documentation

#define OPND_CREATE_ABSMEM (   addr,
  size 
)    opnd_create_rel_addr(addr, size)

Create an absolute address operand encoded as pc-relative. Encoding will fail if addr is out of the maximum signed displacement reach for the architecture.

#define OPND_CREATE_INT (   val)    OPND_CREATE_INTPTR(val)

Create an immediate integer operand. For AArch64 the size of an immediate is ignored when encoding, so there is no need to specify the final size.

#define OPND_CREATE_LSL ( )    opnd_add_flags(OPND_CREATE_INT(DR_SHIFT_LSL), DR_OPND_IS_SHIFT)

Create an operand specifying LSL, the default shift type when there is no shift.

#define OPND_CREATE_ZR (   reg)    opnd_create_reg(opnd_get_size(reg) == OPSZ_4 ? DR_REG_WZR : DR_REG_XZR)

Create a zero register operand of the same size as reg.

#define XINST_CREATE_add (   dc,
  d,
 
)    INSTR_CREATE_add_shift(dc, d, d, s, OPND_CREATE_LSL(), OPND_CREATE_INT(0))

This platform-independent macro creates an instr_t for an addition instruction that does not affect the status flags.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
dThe opnd_t explicit destination operand for the instruction.
sThe opnd_t explicit source operand for the instruction.
#define XINST_CREATE_add_2src (   dc,
  d,
  s1,
  s2 
)    INSTR_CREATE_add_shift(dc, d, s1, s2, OPND_CREATE_LSL(), OPND_CREATE_INT(0))

This platform-independent macro creates an instr_t for an addition instruction that does not affect the status flags and takes two sources plus a destination.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
dThe opnd_t explicit destination operand for the instruction.
s1The opnd_t explicit first source operand for the instruction. This must be a register.
s2The opnd_t explicit source operand for the instruction. This can be either a register or an immediate integer.
#define XINST_CREATE_cmp (   dc,
  s1,
  s2 
)    INSTR_CREATE_cmp(dc, s1, s2)

This platform-independent macro creates an instr_t for a comparison instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
s1The opnd_t explicit source operand for the instruction.
s2The opnd_t explicit source operand for the instruction.
#define XINST_CREATE_debug_instr (   dc)    INSTR_CREATE_brk((dc), OPND_CREATE_INT16(0))

This platform-independent macro creates an instr_t for a debug trap instruction, automatically supplying any implicit operands.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
#define XINST_CREATE_jump (   dc,
 
)    INSTR_CREATE_b((dc), (t))

This platform-independent macro creates an instr_t for an unconditional branch instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
tThe opnd_t target operand for the instruction, which can be either a pc (opnd_create_pc)()) or an instr_t (opnd_create_instr()). Be sure to ensure that the limited reach of this short branch will reach the target (a pc operand is not suitable for most uses unless you know precisely where this instruction will be encoded).
#define XINST_CREATE_jump_reg (   dc,
 
)    INSTR_CREATE_br((dc), (r))

This platform-independent macro creates an instr_t for an indirect jump instruction through a register.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
rThe register opnd holding the target.
#define XINST_CREATE_jump_short (   dc,
 
)    INSTR_CREATE_b((dc), (t))

This platform-independent macro creates an instr_t for an unconditional branch instruction with the smallest available reach.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
tThe opnd_t target operand for the instruction, which can be either a pc (opnd_create_pc)()) or an instr_t (opnd_create_instr()). Be sure to ensure that the limited reach of this short branch will reach the target (a pc operand is not suitable for most uses unless you know precisely where this instruction will be encoded).
#define XINST_CREATE_load (   dc,
  r,
 
)    INSTR_CREATE_ldr((dc), (r), (m))

This platform-independent macro creates an instr_t for a 4-byte or 8-byte memory load instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
rThe destination register opnd.
mThe source memory opnd.
#define XINST_CREATE_load_int (   dc,
  r,
 
)    INSTR_CREATE_movz((dc), (r), (i), OPND_CREATE_INT(0))

This platform-independent macro creates an instr_t for an immediate integer load instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
rThe destination register opnd.
iThe source immediate integer opnd.
#define XINST_CREATE_load_simd (   dc,
  r,
 
)    INSTR_CREATE_ldr((dc), (r), (m))

This platform-independent macro creates an instr_t for a multimedia register load instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
rThe destination register opnd.
mThe source memory opnd.
#define XINST_CREATE_move (   dc,
  d,
 
)
Value:
opnd_get_reg(d) == DR_REG_WSP || opnd_get_reg(s) == DR_REG_WSP) ? \
OPND_CREATE_LSL(), OPND_CREATE_INT(0)) : \
OPND_CREATE_LSL(), OPND_CREATE_INT(0)))
instr_t * instr_create_1dst_4src(void *drcontext, int opcode, opnd_t dst, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
Definition: dr_ir_opcodes_aarch64.h:54
reg_id_t opnd_get_reg(opnd_t opnd)
#define OPND_CREATE_INT(val)
Definition: dr_ir_macros_aarch64.h:54
#define OPND_CREATE_ZR(reg)
Definition: dr_ir_macros_aarch64.h:57
#define DR_REG_XSP
Definition: dr_ir_opnd.h:743
Definition: dr_ir_opcodes_aarch64.h:260

This platform-independent macro creates an instr_t for a register to register move instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
dThe destination register opnd.
sThe source register opnd.
#define XINST_CREATE_nop (   dc)    INSTR_CREATE_nop(dc)

This platform-independent macro creates an instr_t for a nop instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
#define XINST_CREATE_return (   dc)    INSTR_CREATE_ret(dc, opnd_create_reg(DR_REG_X30))

This platform-independent macro creates an instr_t for a return instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
#define XINST_CREATE_store (   dc,
  m,
 
)
Value:
opnd_get_disp(m) % opnd_size_in_bytes(opnd_get_size(m)) != 0 ? \
INSTR_CREATE_stur(dc, m, \
INSTR_CREATE_str(dc, m, \
uint opnd_size_in_bytes(opnd_size_t size)
reg_id_t reg_resize_to_opsz(reg_id_t reg, opnd_size_t sz)
INSTR_INLINE opnd_t opnd_create_reg(reg_id_t r)
reg_id_t opnd_get_reg(opnd_t opnd)
opnd_size_t opnd_get_size(opnd_t opnd)
bool opnd_is_base_disp(opnd_t opnd)

This platform-independent macro creates an instr_t for a 4-byte or 8-byte memory store instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
mThe destination memory opnd.
rThe source register opnd.
#define XINST_CREATE_store_1byte (   dc,
  m,
 
)
Value:
reg_id_t reg_resize_to_opsz(reg_id_t reg, opnd_size_t sz)
INSTR_INLINE opnd_t opnd_create_reg(reg_id_t r)
#define INSTR_CREATE_strb(dc, mem, Rt)
Definition: dr_ir_macros_arm.h:1738
reg_id_t opnd_get_reg(opnd_t opnd)
Definition: dr_ir_opnd.h:2421

This platform-independent macro creates an instr_t for a 1-byte memory store instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
mThe destination memory opnd.
rThe source register opnd.
#define XINST_CREATE_store_2bytes (   dc,
  m,
 
)
Value:
reg_id_t reg_resize_to_opsz(reg_id_t reg, opnd_size_t sz)
INSTR_INLINE opnd_t opnd_create_reg(reg_id_t r)
reg_id_t opnd_get_reg(opnd_t opnd)
Definition: dr_ir_opnd.h:2421
#define INSTR_CREATE_strh(dc, mem, Rt)
Definition: dr_ir_macros_arm.h:1742

This platform-independent macro creates an instr_t for a 2-byte memory store instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
mThe destination memory opnd.
rThe source register opnd.
#define XINST_CREATE_store_simd (   dc,
  m,
 
)    INSTR_CREATE_str((dc), (m), (r))

This platform-independent macro creates an instr_t for a multimedia register store instruction.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
mThe destination memory opnd.
rThe source register opnd.
#define XINST_CREATE_sub (   dc,
  d,
 
)    INSTR_CREATE_sub_shift(dc, d, d, s, OPND_CREATE_LSL(), OPND_CREATE_INT(0))

This platform-independent macro creates an instr_t for a subtraction instruction that does not affect the status flags.

Parameters
dcThe void * dcontext used to allocate memory for the instr_t.
dThe opnd_t explicit destination operand for the instruction.
sThe opnd_t explicit source operand for the instruction.