This instruction type is created with img_reg_insn(). It's similar to INSN_MOV_MEMBASE_REG but there is no register part in memory addressing, just 32-bit offset. It's useful when we want to load pointer value and we know the absolute memory location of the pointer variable.
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- arch/x86/emit-code_32.c | 20 ++++++++++++++++++++ arch/x86/include/arch/instruction.h | 1 + arch/x86/lir-printer.c | 15 +++++++++++++++ arch/x86/use-def.c | 1 + 4 files changed, 37 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code_32.c b/arch/x86/emit-code_32.c index 2130ed8..c2beebd 100644 --- a/arch/x86/emit-code_32.c +++ b/arch/x86/emit-code_32.c @@ -181,6 +181,19 @@ emit_reg_reg(struct buffer *buf, unsigned char opc, } static void +__emit_memdisp_reg(struct buffer *buf, unsigned char opc, unsigned long disp, + unsigned char reg_opcode) +{ + unsigned char mod_rm; + + mod_rm = encode_modrm(0, __encode_reg(reg_opcode), 5); + + emit(buf, opc); + emit(buf, mod_rm); + emit_imm32(buf, disp); +} + +static void __emit_membase(struct buffer *buf, unsigned char opc, enum machine_reg base_reg, unsigned long disp, unsigned char reg_opcode) @@ -284,6 +297,12 @@ static void emit_mov_membase_reg(struct buffer *buf, emit_membase_reg(buf, 0x8b, src, dest); } +static void emit_mov_memdisp_reg(struct buffer *buf, + struct operand *src, struct operand *dest) +{ + __emit_memdisp_reg(buf, 0x8b, src->imm, mach_reg(&dest->reg)); +} + static void emit_mov_memindex_reg(struct buffer *buf, struct operand *src, struct operand *dest) { @@ -925,6 +944,7 @@ static struct emitter emitters[] = { DECL_EMITTER(INSN_MOV_IMM_REG, emit_mov_imm_reg, TWO_OPERANDS), DECL_EMITTER(INSN_MOV_MEMLOCAL_REG, emit_mov_memlocal_reg, TWO_OPERANDS), DECL_EMITTER(INSN_MOV_MEMBASE_REG, emit_mov_membase_reg, TWO_OPERANDS), + DECL_EMITTER(INSN_MOV_MEMDISP_REG, emit_mov_memdisp_reg, TWO_OPERANDS), DECL_EMITTER(INSN_MOV_MEMINDEX_REG, emit_mov_memindex_reg, TWO_OPERANDS), DECL_EMITTER(INSN_MOV_REG_MEMBASE, emit_mov_reg_membase, TWO_OPERANDS), DECL_EMITTER(INSN_MOV_REG_MEMINDEX, emit_mov_reg_memindex, TWO_OPERANDS), diff --git a/arch/x86/include/arch/instruction.h b/arch/x86/include/arch/instruction.h index f28fd81..4b933d0 100644 --- a/arch/x86/include/arch/instruction.h +++ b/arch/x86/include/arch/instruction.h @@ -79,6 +79,7 @@ enum insn_type { INSN_MOV_IMM_REG, INSN_MOV_MEMLOCAL_REG, INSN_MOV_MEMBASE_REG, + INSN_MOV_MEMDISP_REG, INSN_MOV_MEMINDEX_REG, INSN_MOV_REG_MEMBASE, INSN_MOV_REG_MEMINDEX, diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c index 11b977b..2873e0f 100644 --- a/arch/x86/lir-printer.c +++ b/arch/x86/lir-printer.c @@ -95,6 +95,14 @@ static int print_membase_reg(struct string *str, struct insn *insn) return print_reg(str, &insn->dest); } +static int print_memdisp_reg(struct string *str, struct insn *insn) +{ + str_append(str, "("); + print_imm(str, &insn->src); + str_append(str, "), "); + return print_reg(str, &insn->dest); +} + static int print_reg_membase(struct string *str, struct insn *insn) { print_reg(str, &insn->src); @@ -291,6 +299,12 @@ static int print_mov_membase_reg(struct string *str, struct insn *insn) return print_membase_reg(str, insn); } +static int print_mov_memdisp_reg(struct string *str, struct insn *insn) +{ + print_func_name(str); + return print_memdisp_reg(str, insn); +} + static int print_mov_memindex_reg(struct string *str, struct insn *insn) { print_func_name(str); @@ -492,6 +506,7 @@ static print_insn_fn insn_printers[] = { [INSN_MOV_IMM_REG] = print_mov_imm_reg, [INSN_MOV_MEMLOCAL_REG] = print_mov_memlocal_reg, [INSN_MOV_MEMBASE_REG] = print_mov_membase_reg, + [INSN_MOV_MEMDISP_REG] = print_mov_memdisp_reg, [INSN_MOV_MEMINDEX_REG] = print_mov_memindex_reg, [INSN_MOV_REG_MEMBASE] = print_mov_reg_membase, [INSN_MOV_REG_MEMINDEX] = print_mov_reg_memindex, diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c index 1325494..9a5aded 100644 --- a/arch/x86/use-def.c +++ b/arch/x86/use-def.c @@ -54,6 +54,7 @@ static struct insn_info insn_infos[] = { DECLARE_INFO(INSN_MOV_IMM_REG, DEF_DST), DECLARE_INFO(INSN_MOV_MEMLOCAL_REG, USE_FP | DEF_DST), DECLARE_INFO(INSN_MOV_MEMBASE_REG, USE_SRC | DEF_DST), + DECLARE_INFO(INSN_MOV_MEMDISP_REG, USE_NONE | DEF_DST), DECLARE_INFO(INSN_MOV_MEMINDEX_REG, USE_SRC | USE_IDX_SRC | DEF_DST), DECLARE_INFO(INSN_MOV_REG_MEMINDEX, USE_SRC | USE_DST | USE_IDX_DST | DEF_NONE), DECLARE_INFO(INSN_MOV_REG_MEMLOCAL, USE_SRC), -- 1.6.0.6 ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel