get_fpu_var() allocates register of type J_FLOAT but we will want to allocate J_DOUBLE in the future. There is no point in having a separate function for that.
Signed-off-by: Tomek Grabiec <tgrab...@gmail.com> --- arch/x86/insn-selector.brg | 22 ++++++++++++++-------- include/jit/compilation-unit.h | 1 - jit/compilation-unit.c | 8 +++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg index 31f8602..d6b608a 100644 --- a/arch/x86/insn-selector.brg +++ b/arch/x86/insn-selector.brg @@ -139,7 +139,7 @@ freg: EXPR_FVALUE 0 expr = to_expr(tree); esp = get_fixed_var(s->b_parent, REG_xSP); - result = get_fpu_var(s->b_parent); + result = get_var(s->b_parent, expr->vm_type); state->reg1 = result; select_insn(s, tree, imm_membase_insn(INSN_MOV_IMM_MEMBASE, float_to_uint32(expr->fvalue), esp, -4)); @@ -165,7 +165,7 @@ freg: reg 1 struct var_info *result, *in, *esp; in = state->reg1; - result = get_fpu_var(s->b_parent); + result = get_var(s->b_parent, J_FLOAT); state->reg1 = result; esp = get_fixed_var(s->b_parent, REG_xSP); @@ -257,7 +257,7 @@ freg: EXPR_LOCAL 0 expr = to_expr(tree); slot = get_local_slot(cu->stack_frame, expr->local_index); - result = get_fpu_var(s->b_parent); + result = get_var(s->b_parent, expr->vm_type); state->reg1 = result; select_insn(s, tree, memlocal_reg_insn(INSN_MOV_MEMLOCAL_FREG, slot, result)); @@ -435,7 +435,7 @@ freg: OP_FREM(freg, freg) 1 { struct var_info *esp, *eax; - state->reg1 = get_fpu_var(s->b_parent); + state->reg1 = get_var(s->b_parent, state->left->reg1->vm_type); esp = get_fixed_var(s->b_parent, REG_xSP); eax = get_fixed_var(s->b_parent, REG_xAX); @@ -483,7 +483,7 @@ freg: OP_FNEG(freg) 1 esp = get_fixed_var(s->b_parent, REG_xSP); - result = get_fpu_var(s->b_parent); + result = get_var(s->b_parent, state->left->reg1->vm_type); select_insn(s, tree, imm_membase_insn(INSN_MOV_IMM_MEMBASE, 0x80000000, esp, -4)); select_insn(s, tree, membase_reg_insn(INSN_MOV_MEMBASE_XMM, esp, -4, result)); @@ -682,6 +682,7 @@ reg: EXPR_INVOKEINTERFACE(arg) 1 freg: EXPR_FINVOKE(arg) 1 { struct compilation_unit *cu; + enum vm_type ret_vm_type; struct vm_method *method; struct expression *expr; struct var_info *esp; @@ -690,7 +691,8 @@ freg: EXPR_FINVOKE(arg) 1 method = expr->target_method; cu = method->compilation_unit; - state->reg1 = get_fpu_var(s->b_parent); + ret_vm_type = method_return_type(method); + state->reg1 = get_var(s->b_parent, ret_vm_type); invoke(s, tree, cu, method); @@ -725,12 +727,16 @@ reg: EXPR_INVOKEVIRTUAL(arg) 1 freg: EXPR_FINVOKEVIRTUAL(arg) 1 { + enum vm_type ret_vm_type; struct var_info *esp; struct expression *expr; + struct vm_method *method; expr = to_expr(tree); + method = expr->target_method; - state->reg1 = get_fpu_var(s->b_parent); + ret_vm_type = method_return_type(method); + state->reg1 = get_var(s->b_parent, ret_vm_type); invokevirtual(state, s, tree); @@ -1245,7 +1251,7 @@ freg: EXPR_CONVERSION_TO_FLOAT(reg) src = to_expr(expr->from_expression); if (src->vm_type == J_INT && expr->vm_type == J_FLOAT) { - state->reg1 = get_fpu_var(s->b_parent); + state->reg1 = get_var(s->b_parent, J_FLOAT); select_insn(s, tree, reg_reg_insn(INSN_CONV_GPR_TO_FPU, state->left->reg1, state->reg1)); } else { diff --git a/include/jit/compilation-unit.h b/include/jit/compilation-unit.h index 58354dd..4b4c2e4 100644 --- a/include/jit/compilation-unit.h +++ b/include/jit/compilation-unit.h @@ -76,7 +76,6 @@ struct compilation_unit *compilation_unit_alloc(struct vm_method *); int init_stack_slots(struct compilation_unit *cu); void free_compilation_unit(struct compilation_unit *); struct var_info *get_var(struct compilation_unit *, enum vm_type); -struct var_info *get_fpu_var(struct compilation_unit *); struct var_info *get_fixed_var(struct compilation_unit *, enum machine_reg); struct basic_block *find_bb(struct compilation_unit *, unsigned long); unsigned long nr_bblocks(struct compilation_unit *); diff --git a/jit/compilation-unit.c b/jit/compilation-unit.c index db39104..fb35195 100644 --- a/jit/compilation-unit.c +++ b/jit/compilation-unit.c @@ -157,12 +157,10 @@ do_get_var(struct compilation_unit *cu, enum vm_type vm_type, enum machine_reg_t struct var_info *get_var(struct compilation_unit *cu, enum vm_type vm_type) { - return do_get_var(cu, vm_type, REG_TYPE_GPR); -} + if (vm_type == J_FLOAT || vm_type == J_DOUBLE) + return do_get_var(cu, vm_type, REG_TYPE_FPU); -struct var_info *get_fpu_var(struct compilation_unit *cu) -{ - return do_get_var(cu, J_FLOAT, REG_TYPE_FPU); + return do_get_var(cu, vm_type, REG_TYPE_GPR); } struct var_info *get_fixed_var(struct compilation_unit *cu, enum machine_reg reg) -- 1.6.0.6 ------------------------------------------------------------------------------ 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