Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 arch/x86/emit-code.c                |    9 ++++++++-
 arch/x86/include/arch/instruction.h |    2 ++
 arch/x86/instruction.c              |   12 ++++++++++++
 arch/x86/lir-printer.c              |   14 ++++++++++++++
 arch/x86/use-def.c                  |    1 +
 5 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 5e9a21c..a99296c 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -569,7 +569,7 @@ __emit_membase(struct buffer *buf, unsigned char opc,
        else
                rm = __encode_reg(base_reg);
 
-       if (disp == 0)
+       if (disp == 0 && base_reg != MACH_REG_EBP)
                mod = 0x00;
        else if (is_imm_8(disp))
                mod = 0x01;
@@ -832,6 +832,12 @@ static void emit_mov_imm_membase(struct buffer *buf, 
struct operand *src,
                               dest->disp);
 }
 
+static void emit_mov_imm_memlocal(struct buffer *buf, struct operand *src,
+                                 struct operand *dest)
+{
+       __emit_mov_imm_membase(buf, src->imm, MACH_REG_EBP, 
slot_offset(dest->slot));
+}
+
 static void __emit_mov_reg_membase(struct buffer *buf, enum machine_reg src,
                                   enum machine_reg base, unsigned long disp)
 {
@@ -1708,6 +1714,7 @@ struct emitter emitters[] = {
        DECL_EMITTER(INSN_MOV_XMM_MEMBASE, emit_mov_xmm_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_64_XMM_MEMBASE, emit_mov_64_xmm_membase, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_MEMBASE, emit_mov_imm_membase, TWO_OPERANDS),
+       DECL_EMITTER(INSN_MOV_IMM_MEMLOCAL, emit_mov_imm_memlocal, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_REG, emit_mov_imm_reg, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_THREAD_LOCAL_MEMBASE, 
emit_mov_imm_thread_local_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IP_THREAD_LOCAL_MEMBASE, 
emit_mov_ip_thread_local_membase, SINGLE_OPERAND),
diff --git a/arch/x86/include/arch/instruction.h 
b/arch/x86/include/arch/instruction.h
index 063e857..0186745 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -110,6 +110,7 @@ enum insn_type {
        INSN_JMP_BRANCH,
        INSN_JNE_BRANCH,
        INSN_MOV_IMM_MEMBASE,
+       INSN_MOV_IMM_MEMLOCAL,
        INSN_MOV_IMM_REG,
        INSN_MOV_IMM_THREAD_LOCAL_MEMBASE,
        INSN_MOV_IP_REG,
@@ -229,6 +230,7 @@ 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_memdisp_insn(enum insn_type, long, long);
 struct insn *imm_membase_insn(enum insn_type, unsigned long, struct var_info 
*, long);
+struct insn *imm_memlocal_insn(enum insn_type, unsigned long, struct 
stack_slot *);
 struct insn *imm_insn(enum insn_type, unsigned long);
 struct insn *rel_insn(enum insn_type, unsigned long);
 struct insn *branch_insn(enum insn_type, struct basic_block *);
diff --git a/arch/x86/instruction.c b/arch/x86/instruction.c
index acf994b..710af52 100644
--- a/arch/x86/instruction.c
+++ b/arch/x86/instruction.c
@@ -385,6 +385,18 @@ struct insn *membase_insn(enum insn_type insn_type, struct 
var_info *src_base_re
        return insn;
 }
 
+struct insn *imm_memlocal_insn(enum insn_type insn_type,
+                              unsigned long imm,
+                              struct stack_slot *dst_slot)
+{
+       struct insn *insn = alloc_insn(insn_type);
+       if (insn) {
+               init_imm_operand(insn, 0, imm);
+               init_memlocal_operand(insn, 1, dst_slot);
+       }
+       return insn;
+}
+
 int insert_copy_slot_32_insns(struct stack_slot *from, struct stack_slot *to,
                              struct list_head *add_before, unsigned long 
bc_offset)
 {
diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c
index d688f78..2980771 100644
--- a/arch/x86/lir-printer.c
+++ b/arch/x86/lir-printer.c
@@ -109,6 +109,13 @@ static int print_imm_membase(struct string *str, struct 
insn *insn)
        return print_membase(str, &insn->dest);
 }
 
+static int print_imm_memlocal(struct string *str, struct insn *insn)
+{
+       print_imm(str, &insn->src);
+       str_append(str, ", ");
+       return print_memlocal(str, &insn->dest);
+}
+
 static int print_imm_memdisp(struct string *str, struct insn *insn)
 {
        print_imm(str, &insn->operands[0]);
@@ -552,6 +559,12 @@ static int print_mov_imm_membase(struct string *str, 
struct insn *insn)
        return print_imm_membase(str, insn);
 }
 
+static int print_mov_imm_memlocal(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       return print_imm_memlocal(str, insn);
+}
+
 static int print_mov_imm_reg(struct string *str, struct insn *insn)
 {
        print_func_name(str);
@@ -989,6 +1002,7 @@ static print_insn_fn insn_printers[] = {
        [INSN_JMP_MEMINDEX] = print_jmp_memindex,
        [INSN_JNE_BRANCH] = print_jne_branch,
        [INSN_MOV_IMM_MEMBASE] = print_mov_imm_membase,
+       [INSN_MOV_IMM_MEMLOCAL] = print_mov_imm_memlocal,
        [INSN_MOV_IMM_REG] = print_mov_imm_reg,
        [INSN_MOV_IMM_THREAD_LOCAL_MEMBASE] = print_mov_imm_tlmembase,
        [INSN_MOV_IP_THREAD_LOCAL_MEMBASE] = print_mov_ip_tlmembase,
diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c
index 1653195..feffb5a 100644
--- a/arch/x86/use-def.c
+++ b/arch/x86/use-def.c
@@ -95,6 +95,7 @@ static struct insn_info insn_infos[] = {
        DECLARE_INFO(INSN_JMP_MEMINDEX, USE_IDX_SRC | USE_SRC | DEF_NONE),
        DECLARE_INFO(INSN_JNE_BRANCH, USE_NONE | DEF_NONE),
        DECLARE_INFO(INSN_MOV_IMM_MEMBASE, USE_DST),
+       DECLARE_INFO(INSN_MOV_IMM_MEMLOCAL, USE_FP | DEF_NONE),
        DECLARE_INFO(INSN_MOV_IMM_REG, DEF_DST),
        DECLARE_INFO(INSN_MOV_IMM_THREAD_LOCAL_MEMBASE, USE_DST | DEF_NONE),
        DECLARE_INFO(INSN_MOV_IP_THREAD_LOCAL_MEMBASE, USE_NONE | DEF_NONE),
-- 
1.6.3.3


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to