Signed-off-by: Arthur HUILLET <arthur.huil...@free.fr>
---
 arch/x86/emit-code.c                |    9 +++++++++
 arch/x86/include/arch/instruction.h |    1 +
 arch/x86/insn-selector_32.brg       |   13 +++++++++++--
 arch/x86/lir-printer.c              |    7 +++++++
 arch/x86/use-def.c                  |    1 +
 5 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index 88ec334..dfc92ca 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -1091,6 +1091,14 @@ static void emit_exception_test(struct buffer *buf, enum 
machine_reg reg)
        __emit_test_membase_reg(buf, reg, 0, reg);
 }
 
+static void emit_gpr_to_xmm(struct buffer *buf, struct operand *src,
+                               struct operand *dest)
+{
+       emit(buf, 0xf3);
+       emit(buf, 0x0f);
+       emit_reg_reg(buf, 0x2a, dest, src);
+}
+
 struct emitter emitters[] = {
        GENERIC_X86_EMITTERS,
        DECL_EMITTER(INSN_ADC_IMM_REG, emit_adc_imm_reg, TWO_OPERANDS),
@@ -1108,6 +1116,7 @@ struct emitter emitters[] = {
        DECL_EMITTER(INSN_CMP_REG_REG, emit_cmp_reg_reg, TWO_OPERANDS),
        DECL_EMITTER(INSN_DIV_MEMBASE_REG, emit_div_membase_reg, TWO_OPERANDS),
        DECL_EMITTER(INSN_DIV_REG_REG, emit_div_reg_reg, TWO_OPERANDS),
+       DECL_EMITTER(INSN_GPR_TO_XMM, emit_gpr_to_xmm, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_MEMBASE, emit_mov_imm_membase, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_IMM_REG, emit_mov_imm_reg, TWO_OPERANDS),
        DECL_EMITTER(INSN_MOV_MEMLOCAL_REG, emit_mov_memlocal_reg, 
TWO_OPERANDS),
diff --git a/arch/x86/include/arch/instruction.h 
b/arch/x86/include/arch/instruction.h
index 0bee5a9..ebaeea3 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -70,6 +70,7 @@ enum insn_type {
        INSN_CMP_REG_REG,
        INSN_DIV_MEMBASE_REG,
        INSN_DIV_REG_REG,
+       INSN_GPR_TO_XMM,
        INSN_JE_BRANCH,
        INSN_JGE_BRANCH,
        INSN_JG_BRANCH,
diff --git a/arch/x86/insn-selector_32.brg b/arch/x86/insn-selector_32.brg
index ed1334f..655a10a 100644
--- a/arch/x86/insn-selector_32.brg
+++ b/arch/x86/insn-selector_32.brg
@@ -144,8 +144,17 @@ static enum insn_type br_binop_to_insn_type(enum 
binary_operator binop)
 
 reg:   EXPR_FVALUE     0
 {
-       NOT_IMPLEMENTED;
-       state->reg1 = get_var(s->b_parent);
+       struct expression *expr;
+       struct var_info *result, *gpr;
+
+       expr = to_expr(tree);
+
+       gpr = get_var(s->b_parent);
+       result = get_fpu_var(s->b_parent);
+       state->reg1 = result;
+
+       select_insn(s, tree, imm_reg_insn(INSN_MOV_IMM_REG, 
float_to_uint32(expr->fvalue), gpr));
+       select_insn(s, tree, reg_reg_insn(INSN_GPR_TO_XMM, gpr, result));
 }
 
 reg:   EXPR_VALUE      0
diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c
index 7f5558d..96b19db 100644
--- a/arch/x86/lir-printer.c
+++ b/arch/x86/lir-printer.c
@@ -274,6 +274,12 @@ static int print_div_reg_reg(struct string *str, struct 
insn *insn)
        return print_reg_reg(str, insn);
 }
 
+static int print_gpr_to_xmm(struct string *str, struct insn *insn)
+{
+       print_func_name(str);
+       return print_reg_reg(str, insn);
+}
+
 static int print_je_branch(struct string *str, struct insn *insn)
 {
        print_func_name(str);
@@ -563,6 +569,7 @@ static print_insn_fn insn_printers[] = {
        [INSN_CMP_REG_REG] = print_cmp_reg_reg,
        [INSN_DIV_MEMBASE_REG] = print_div_membase_reg,
        [INSN_DIV_REG_REG] = print_div_reg_reg,
+       [INSN_GPR_TO_XMM] = print_gpr_to_xmm,
        [INSN_JE_BRANCH] = print_je_branch,
        [INSN_JGE_BRANCH] = print_jge_branch,
        [INSN_JG_BRANCH] = print_jg_branch,
diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c
index f077f91..88a0c4f 100644
--- a/arch/x86/use-def.c
+++ b/arch/x86/use-def.c
@@ -45,6 +45,7 @@ static struct insn_info insn_infos[] = {
        DECLARE_INFO(INSN_CMP_MEMBASE_REG, USE_SRC | DEF_DST),
        DECLARE_INFO(INSN_DIV_MEMBASE_REG, USE_SRC | DEF_DST | DEF_EAX | 
DEF_EDX),
        DECLARE_INFO(INSN_DIV_REG_REG, USE_SRC | DEF_DST | DEF_EAX | DEF_EDX),
+       DECLARE_INFO(INSN_GPR_TO_XMM, USE_SRC | DEF_DST),
        DECLARE_INFO(INSN_JE_BRANCH, USE_NONE | DEF_NONE),
        DECLARE_INFO(INSN_JGE_BRANCH, USE_NONE | DEF_NONE),
        DECLARE_INFO(INSN_JG_BRANCH, USE_NONE | DEF_NONE),
-- 
1.6.3.2



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

Reply via email to