Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 arch/x86/emit-code.c                |   12 ++++++++++--
 arch/x86/include/arch/instruction.h |    3 ++-
 arch/x86/insn-selector_32.brg       |    6 +++++-
 arch/x86/lir-printer.c              |   12 ++++++++++--
 arch/x86/use-def.c                  |    3 ++-
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 2a63e50..20fc9a8 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -604,13 +604,20 @@ static void emit_mov_reg_reg(struct buffer *buf, struct 
operand *src,
        __emit_mov_reg_reg(buf, mach_reg(&src->reg), mach_reg(&dest->reg));
 }
 
-static void emit_movsx_reg_reg(struct buffer *buf, struct operand *src,
+static void emit_movsx_8_reg_reg(struct buffer *buf, struct operand *src,
                             struct operand *dest)
 {
        emit(buf, 0x0f);
        __emit_reg_reg(buf, 0xbe, mach_reg(&dest->reg), mach_reg(&src->reg));
 }
 
+static void emit_movsx_16_reg_reg(struct buffer *buf, struct operand *src,
+                            struct operand *dest)
+{
+       emit(buf, 0x0f);
+       __emit_reg_reg(buf, 0xbf, mach_reg(&dest->reg), mach_reg(&src->reg));
+}
+
 static void
 emit_mov_memlocal_reg(struct buffer *buf, struct operand *src, struct operand 
*dest)
 {
@@ -1237,7 +1244,8 @@ struct emitter emitters[] = {
        DECL_EMITTER(INSN_MOV_REG_MEMLOCAL, emit_mov_reg_memlocal, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_FREG_MEMLOCAL, emit_mov_freg_memlocal, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_REG_REG, emit_mov_reg_reg, TWO_OPERANDS),
-       DECL_EMITTER(INSN_MOVSX_REG_REG, emit_movsx_reg_reg, TWO_OPERANDS),
+       DECL_EMITTER(INSN_MOVSX_8_REG_REG, emit_movsx_8_reg_reg, TWO_OPERANDS),
+       DECL_EMITTER(INSN_MOVSX_16_REG_REG, emit_movsx_16_reg_reg, 
TWO_OPERANDS),
        DECL_EMITTER(INSN_MUL_MEMBASE_EAX, emit_mul_membase_eax, TWO_OPERANDS),
        DECL_EMITTER(INSN_MUL_REG_EAX, emit_mul_reg_eax, TWO_OPERANDS),
        DECL_EMITTER(INSN_MUL_REG_REG, emit_mul_reg_reg, TWO_OPERANDS),
diff --git a/arch/x86/include/arch/instruction.h 
b/arch/x86/include/arch/instruction.h
index 42c3fbb..c852bd3 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -101,7 +101,8 @@ enum insn_type {
        INSN_MOV_REG_REG,
        INSN_MOV_MEMBASE_XMM,
        INSN_MOV_XMM_MEMBASE,
-       INSN_MOVSX_REG_REG,
+       INSN_MOVSX_8_REG_REG,
+       INSN_MOVSX_16_REG_REG,
        INSN_MUL_MEMBASE_EAX,
        INSN_MUL_REG_EAX,
        INSN_MUL_REG_REG,
diff --git a/arch/x86/insn-selector_32.brg b/arch/x86/insn-selector_32.brg
index 4d582a0..02e0cf2 100644
--- a/arch/x86/insn-selector_32.brg
+++ b/arch/x86/insn-selector_32.brg
@@ -1291,7 +1291,11 @@ reg:     EXPR_CONVERSION(reg)
        } else if (src->vm_type == J_INT && expr->vm_type == J_BYTE) {
                state->reg1 = get_var(s->b_parent);
 
-               select_insn(s, tree, reg_reg_insn(INSN_MOVSX_REG_REG, 
state->left->reg1, state->reg1));
+               select_insn(s, tree, reg_reg_insn(INSN_MOVSX_8_REG_REG, 
state->left->reg1, state->reg1));
+       } else if (src->vm_type == J_INT && expr->vm_type == J_CHAR) {
+               state->reg1 = get_var(s->b_parent);
+
+               select_insn(s, tree, reg_reg_insn(INSN_MOVSX_16_REG_REG, 
state->left->reg1, state->reg1));
        } else {
                printf("%d to %d\n", src->vm_type, expr->vm_type);
                assert(!"conversion not implemented");
diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c
index ba0d276..b5abf63 100644
--- a/arch/x86/lir-printer.c
+++ b/arch/x86/lir-printer.c
@@ -460,13 +460,20 @@ static int print_mov_reg_reg(struct string *str, struct 
insn *insn)
        return print_reg_reg(str, insn);
 }
 
-static int print_movsx_reg_reg(struct string *str, struct insn *insn)
+static int print_movsx_8_reg_reg(struct string *str, struct insn *insn)
 {
        print_func_name(str);
        print_reg_reg(str, insn);
        return str_append(str, "(8bit->32bit)");
 }
 
+static int print_movsx_16_reg_reg(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       print_reg_reg(str, insn);
+       return str_append(str, "(16bit->32bit)");
+}
+
 static int print_mul_membase_eax(struct string *str, struct insn *insn)
 {
        print_func_name(str);
@@ -672,7 +679,8 @@ static print_insn_fn insn_printers[] = {
        [INSN_MOV_REG_MEMLOCAL] = print_mov_reg_memlocal,
        [INSN_MOV_FREG_MEMLOCAL] = print_mov_freg_memlocal,
        [INSN_MOV_REG_REG] = print_mov_reg_reg,
-       [INSN_MOVSX_REG_REG] = print_movsx_reg_reg,
+       [INSN_MOVSX_8_REG_REG] = print_movsx_8_reg_reg,
+       [INSN_MOVSX_16_REG_REG] = print_movsx_16_reg_reg,
        [INSN_MUL_MEMBASE_EAX] = print_mul_membase_eax,
        [INSN_MUL_REG_EAX] = print_mul_reg_eax,
        [INSN_MUL_REG_REG] = print_mul_reg_reg,
diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c
index 6e5a02c..10c2dcf 100644
--- a/arch/x86/use-def.c
+++ b/arch/x86/use-def.c
@@ -75,7 +75,8 @@ static struct insn_info insn_infos[] = {
        DECLARE_INFO(INSN_MOV_REG_MEMLOCAL, USE_SRC),
        DECLARE_INFO(INSN_MOV_FREG_MEMLOCAL, USE_SRC),
        DECLARE_INFO(INSN_MOV_REG_REG, USE_SRC | DEF_DST),
-       DECLARE_INFO(INSN_MOVSX_REG_REG, USE_SRC | DEF_DST),
+       DECLARE_INFO(INSN_MOVSX_8_REG_REG, USE_SRC | DEF_DST),
+       DECLARE_INFO(INSN_MOVSX_16_REG_REG, USE_SRC | DEF_DST),
        DECLARE_INFO(INSN_MUL_MEMBASE_EAX, USE_SRC | DEF_DST | DEF_EDX | 
DEF_EAX),
        DECLARE_INFO(INSN_MUL_REG_EAX, USE_SRC | DEF_DST | DEF_EDX | DEF_EAX),
        DECLARE_INFO(INSN_MUL_REG_REG, USE_SRC | DEF_DST),
-- 
1.6.0.6


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

Reply via email to