Signed-off-by: Arthur Huillet <arthur.huil...@free.fr> --- arch/x86/emit-code.c | 18 ++++++++++++++++++ arch/x86/include/arch/instruction.h | 2 ++ arch/x86/insn-selector_32.brg | 34 +++++++++++++++++++++++++++++++++- arch/x86/lir-printer.c | 14 ++++++++++++++ arch/x86/use-def.c | 2 ++ 5 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index bf2b1b7..c664cc0 100644 --- a/arch/x86/emit-code.c +++ b/arch/x86/emit-code.c @@ -874,6 +874,14 @@ static void emit_add_reg_reg(struct buffer *buf, emit_reg_reg(buf, 0x03, dest, src); } +static void emit_fadd_reg_reg(struct buffer *buf, + struct operand *src, struct operand *dest) +{ + emit(buf, 0xf3); + emit(buf, 0x0f); + emit_reg_reg(buf, 0x58, dest, src); +} + static void emit_add_membase_reg(struct buffer *buf, struct operand *src, struct operand *dest) { @@ -1135,6 +1143,14 @@ static void emit_mov_gpr_to_xmm(struct buffer *buf, struct operand *src, emit_reg_reg(buf, 0x2a, dest, src); } +static void emit_mov_xmm_to_gpr(struct buffer *buf, struct operand *src, + struct operand *dest) +{ + emit(buf, 0xf3); + emit(buf, 0x0f); + emit_reg_reg(buf, 0x2d, dest, src); +} + struct emitter emitters[] = { GENERIC_X86_EMITTERS, DECL_EMITTER(INSN_ADC_IMM_REG, emit_adc_imm_reg, TWO_OPERANDS), @@ -1152,7 +1168,9 @@ 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_FADD_REG_REG, emit_fadd_reg_reg, TWO_OPERANDS), DECL_EMITTER(INSN_MOV_GPR_TO_XMM, emit_mov_gpr_to_xmm, TWO_OPERANDS), + DECL_EMITTER(INSN_MOV_XMM_TO_GPR, emit_mov_xmm_to_gpr, 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 0c4d0dd..9d7137a 100644 --- a/arch/x86/include/arch/instruction.h +++ b/arch/x86/include/arch/instruction.h @@ -70,7 +70,9 @@ enum insn_type { INSN_CMP_REG_REG, INSN_DIV_MEMBASE_REG, INSN_DIV_REG_REG, + INSN_FADD_REG_REG, INSN_MOV_GPR_TO_XMM, + INSN_MOV_XMM_TO_GPR, 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 9ca1095..61015ae 100644 --- a/arch/x86/insn-selector_32.brg +++ b/arch/x86/insn-selector_32.brg @@ -142,7 +142,7 @@ static enum insn_type br_binop_to_insn_type(enum binary_operator binop) %start stmt -reg: EXPR_FVALUE 0 +freg: EXPR_FVALUE 0 { struct expression *expr; struct var_info *result, *gpr; @@ -157,6 +157,28 @@ reg: EXPR_FVALUE 0 select_insn(s, tree, reg_reg_insn(INSN_MOV_GPR_TO_XMM, gpr, result)); } +reg: freg 1 +{ + struct var_info *result, *in; + + in = state->reg1; + result = get_var(s->b_parent); + state->reg1 = result; + + select_insn(s, tree, reg_reg_insn(INSN_MOV_XMM_TO_GPR, in, result)); +} + +freg: reg 1 +{ + struct var_info *result, *in; + + in = state->reg1; + result = get_fpu_var(s->b_parent); + state->reg1 = result; + + select_insn(s, tree, reg_reg_insn(INSN_MOV_GPR_TO_XMM, in, result)); +} + reg: EXPR_VALUE 0 { struct expression *expr; @@ -255,6 +277,16 @@ reg: OP_ADD(reg, reg) 1 } } +freg: OP_FADD(freg, freg) 1 +{ + struct expression *expr; + + expr = to_expr(tree); + + state->reg1 = state->left->reg1; + binop_reg_reg_low(state, s, tree, INSN_FADD_REG_REG); +} + reg: OP_SUB(reg, EXPR_LOCAL) 1 { struct expression *expr; diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c index ea39e28..13ce2a7 100644 --- a/arch/x86/lir-printer.c +++ b/arch/x86/lir-printer.c @@ -212,6 +212,12 @@ static int print_add_reg_reg(struct string *str, struct insn *insn) return print_reg_reg(str, insn); } +static int print_fadd_reg_reg(struct string *str, struct insn *insn) +{ + print_func_name(str); + return print_reg_reg(str, insn); +} + static int print_and_membase_reg(struct string *str, struct insn *insn) { print_func_name(str); @@ -280,6 +286,12 @@ static int print_mov_gpr_to_xmm(struct string *str, struct insn *insn) return print_reg_reg(str, insn); } +static int print_mov_xmm_to_gpr(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); @@ -581,7 +593,9 @@ 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_FADD_REG_REG] = print_fadd_reg_reg, [INSN_MOV_GPR_TO_XMM] = print_mov_gpr_to_xmm, + [INSN_MOV_XMM_TO_GPR] = print_mov_xmm_to_gpr, [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 926c3ce..e85769e 100644 --- a/arch/x86/use-def.c +++ b/arch/x86/use-def.c @@ -45,7 +45,9 @@ 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_FADD_REG_REG, USE_SRC | DEF_DST), DECLARE_INFO(INSN_MOV_GPR_TO_XMM, USE_SRC | DEF_DST), + DECLARE_INFO(INSN_MOV_XMM_TO_GPR, 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.3 ------------------------------------------------------------------------------ _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel