Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 arch/x86/emit-code.c                |   15 +++++++++++++++
 arch/x86/include/arch/instruction.h |    3 +++
 arch/x86/instruction.c              |   22 ++++++++++++++++++++++
 arch/x86/lir-printer.c              |   27 +++++++++++++++++++++------
 arch/x86/use-def.c                  |    1 +
 5 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 499bff4..88c24bc 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -425,6 +425,13 @@ __emit_memdisp_reg(struct buffer *buf, unsigned char opc, 
unsigned long disp,
 }
 
 static void
+__emit_reg_memdisp(struct buffer *buf, unsigned char opc, enum machine_reg reg,
+                  unsigned long disp)
+{
+       __emit_memdisp(buf, opc, disp, __encode_reg(reg));
+}
+
+static void
 __emit_membase(struct buffer *buf, unsigned char opc,
               enum machine_reg base_reg, unsigned long disp,
               unsigned char reg_opcode)
@@ -550,6 +557,13 @@ static void emit_mov_memdisp_reg(struct buffer *buf,
        __emit_memdisp_reg(buf, 0x8b, src->imm, mach_reg(&dest->reg));
 }
 
+static void emit_mov_reg_memdisp(struct buffer *buf,
+                                struct operand *src,
+                                struct operand *dest)
+{
+       __emit_reg_memdisp(buf, 0x89, mach_reg(&src->reg), dest->imm);
+}
+
 static void emit_mov_memindex_reg(struct buffer *buf,
                                  struct operand *src, struct operand *dest)
 {
@@ -1044,6 +1058,7 @@ struct emitter emitters[] = {
        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_REG_MEMDISP, emit_mov_reg_memdisp, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_THREAD_LOCAL_MEMDISP_REG, 
emit_mov_thread_local_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),
diff --git a/arch/x86/include/arch/instruction.h 
b/arch/x86/include/arch/instruction.h
index 2af92c7..0bee5a9 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -82,6 +82,7 @@ enum insn_type {
        INSN_MOV_MEMLOCAL_REG,
        INSN_MOV_MEMBASE_REG,
        INSN_MOV_MEMDISP_REG,
+       INSN_MOV_REG_MEMDISP,
        INSN_MOV_THREAD_LOCAL_MEMDISP_REG,
        INSN_MOV_MEMINDEX_REG,
        INSN_MOV_REG_MEMBASE,
@@ -178,6 +179,8 @@ struct insn *reg_memlocal_insn(enum insn_type, struct 
var_info *, struct stack_s
 struct insn *reg_insn(enum insn_type, struct var_info *);
 struct insn *reg_reg_insn(enum insn_type, struct var_info *, struct var_info 
*);
 struct insn *imm_reg_insn(enum insn_type, unsigned long, struct var_info *);
+struct insn *memdisp_reg_insn(enum insn_type, unsigned long, struct var_info 
*);
+struct insn *reg_memdisp_insn(enum insn_type, struct var_info *, unsigned 
long);
 struct insn *imm_membase_insn(enum insn_type, unsigned long, struct var_info 
*, long);
 struct insn *imm_insn(enum insn_type, unsigned long);
 struct insn *rel_insn(enum insn_type, unsigned long);
diff --git a/arch/x86/instruction.c b/arch/x86/instruction.c
index d3ce609..cf43c87 100644
--- a/arch/x86/instruction.c
+++ b/arch/x86/instruction.c
@@ -246,6 +246,28 @@ struct insn *imm_reg_insn(enum insn_type insn_type, 
unsigned long imm,
        return insn;
 }
 
+struct insn *memdisp_reg_insn(enum insn_type insn_type, unsigned long imm,
+                             struct var_info *dest_reg)
+{
+       struct insn *insn = alloc_insn(insn_type);
+       if (insn) {
+               init_imm_operand(insn, 0, imm);
+               init_reg_operand(insn, 1, dest_reg);
+       }
+       return insn;
+}
+
+struct insn *reg_memdisp_insn(enum insn_type insn_type,
+                             struct var_info *src_reg, unsigned long imm)
+{
+       struct insn *insn = alloc_insn(insn_type);
+       if (insn) {
+               init_reg_operand(insn, 0, src_reg);
+               init_imm_operand(insn, 1, imm);
+       }
+       return insn;
+}
+
 struct insn *imm_membase_insn(enum insn_type insn_type, unsigned long imm,
                              struct var_info *base_reg, long disp)
 {
diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c
index d0871fd..2dc2cc5 100644
--- a/arch/x86/lir-printer.c
+++ b/arch/x86/lir-printer.c
@@ -110,6 +110,14 @@ static int print_memdisp_reg(struct string *str, struct 
insn *insn)
        return print_reg(str, &insn->dest);
 }
 
+static int print_reg_memdisp(struct string *str, struct insn *insn)
+{
+       print_reg(str, &insn->src);
+       str_append(str, ", (");
+       print_imm(str, &insn->dest);
+       return str_append(str, ")");
+}
+
 static int print_tlmemdisp_reg(struct string *str, struct insn *insn)
 {
        str_append(str, "gs:(");
@@ -314,12 +322,6 @@ static int print_mov_imm_reg(struct string *str, struct 
insn *insn)
        return print_imm_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_memlocal_reg(struct string *str, struct insn *insn)
 {
        print_func_name(str);
@@ -332,6 +334,18 @@ 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_reg_memdisp(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       return print_reg_memdisp(str, insn);
+}
+
 static int print_mov_tlmemdisp_reg(struct string *str, struct insn *insn)
 {
        print_func_name(str);
@@ -555,6 +569,7 @@ static print_insn_fn insn_printers[] = {
        [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_REG_MEMDISP] = print_mov_reg_memdisp,
        [INSN_MOV_THREAD_LOCAL_MEMDISP_REG] = print_mov_tlmemdisp_reg,
        [INSN_MOV_MEMINDEX_REG] = print_mov_memindex_reg,
        [INSN_MOV_REG_MEMBASE] = print_mov_reg_membase,
diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c
index 696edbe..f077f91 100644
--- a/arch/x86/use-def.c
+++ b/arch/x86/use-def.c
@@ -57,6 +57,7 @@ static struct insn_info insn_infos[] = {
        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_REG_MEMDISP, USE_NONE | DEF_SRC),
        DECLARE_INFO(INSN_MOV_THREAD_LOCAL_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),
-- 
1.6.0.4


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to