From: Aleksey Demakov Date: Tue, 29 Aug 2006 11:57:12 +0000 (+0000) Subject: add _jit_gen_move_top() to take part of the _jit_gen_exch_top() functionality X-Git-Tag: before.move.to.git~202 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=62c4a16438181d1abec5361ebf2cb3e16ad57fd2;p=francis%2Flibjit.git add _jit_gen_move_top() to take part of the _jit_gen_exch_top() functionality thus making the interface cleaner --- diff --git a/ChangeLog b/ChangeLog index b444d69..a39fd3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-08-29 Aleksey Demakov + * jit/jit-rules.h, jit/jit-rules-alpha.c, jit/jit-rules-arm.c, + * jit/jit-rules-interp.c, jit/jit-rules-x86.c, jit/jit-reg-alloc.c: + move part of the _jit_gen_exch_top() functionality into a separate + _jit_gen_move_top() function. + * include/jit/jit-opcode.h: * jit/jit-opcode.c: add JIT_OPCODE_IS_JUMP_TABLE flag to mark the JIT_OP_JUMP_TABLE opcode. diff --git a/jit/jit-reg-alloc.c b/jit/jit-reg-alloc.c index aaa669f..01328fb 100644 --- a/jit/jit-reg-alloc.c +++ b/jit/jit-reg-alloc.c @@ -3341,12 +3341,17 @@ exch_stack_top(jit_gencode_t gen, int reg, int pop) stack_start = get_stack_start(reg); top = get_stack_top(gen, stack_start); - /* Generate exchange instruction. */ - _jit_gen_exch_top(gen, reg, pop); if(pop) { + /* Generate move/pop-top instruction. */ + _jit_gen_move_top(gen, reg); remap_stack_down(gen, stack_start, top); } + else + { + /* Generate exchange instruction. */ + _jit_gen_exch_top(gen, reg); + } /* Update information about the contents of the registers. */ for(index = 0; diff --git a/jit/jit-rules-alpha.c b/jit/jit-rules-alpha.c index d9c7371..733347d 100644 --- a/jit/jit-rules-alpha.c +++ b/jit/jit-rules-alpha.c @@ -267,10 +267,13 @@ int _jit_setup_indirect_pointer(jit_function_t func, jit_value_t value) { return 0; } -void _jit_gen_exch_top(jit_gencode_t gen, int reg, int pop) { +void _jit_gen_exch_top(jit_gencode_t gen, int reg) { /* not used by alpha */; } +void _jit_gen_move_top(jit_gencode_t gen, int reg) { + /* not used by alpha */; +} void _jit_gen_spill_top(jit_gencode_t gen, int reg, jit_value_t value, int pop) { /* not used by alpha */; diff --git a/jit/jit-rules-arm.c b/jit/jit-rules-arm.c index dbff5df..8adc869 100644 --- a/jit/jit-rules-arm.c +++ b/jit/jit-rules-arm.c @@ -774,7 +774,11 @@ void _jit_gen_load_global(jit_gencode_t gen, int reg, jit_value_t value) jit_cache_end_output(); } -void _jit_gen_exch_top(jit_gencode_t gen, int reg, int pop) +void _jit_gen_exch_top(jit_gencode_t gen, int reg) +{ +} + +void _jit_gen_move_top(jit_gencode_t gen, int reg) { } diff --git a/jit/jit-rules-interp.c b/jit/jit-rules-interp.c index 759ad6e..28bd821 100644 --- a/jit/jit-rules-interp.c +++ b/jit/jit-rules-interp.c @@ -932,12 +932,46 @@ void _jit_gen_load_global(jit_gencode_t gen, int reg, jit_value_t value) /* Global registers are not used in the interpreted back end */ } -void _jit_gen_exch_top(jit_gencode_t gen, int reg, int pop) +/*@ + * @deftypefun void _jit_gen_exch_top (jit_gencode_t gen, int reg) + * Generate instructions to exchange the contents of the top stack register + * with a stack register specified by the @code{reg} argument. + * + * It needs to be implemented only by backends that support stack registers. + * @end deftypefun +@*/ +void _jit_gen_exch_top(jit_gencode_t gen, int reg) { + /* Stack registers are not used in the interpreted back end */ } +/*@ + * @deftypefun void _jit_gen_move_top (jit_gencode_t gen, int reg) + * Generate instructions to copy the contents of the top stack register + * into a stack register specified by the @code{reg} argument and pop + * the top register after this. If @code{reg} is equal to the top register + * then the top register is just popped without copying it. + * + * It needs to be implemented only by backends that support stack registers. + * @end deftypefun +@*/ +void _jit_gen_move_top(jit_gencode_t gen, int reg) +{ + /* Stack registers are not used in the interpreted back end */ +} + +/*@ + * @deftypefun _jit_gen_spill_top (jit_gencode_t gen, int reg, jit_value_t value, int pop) + * Generate instructions to spill the top stack register to the local + * variable frame. The @code{pop} argument indicates if the top register + * is popped from the stack. + * + * It needs to be implemented only by backends that support stack registers. + * @end deftypefun +@*/ void _jit_gen_spill_top(jit_gencode_t gen, int reg, jit_value_t value, int pop) { + /* Stack registers are not used in the interpreted back end */ } /*@ diff --git a/jit/jit-rules-x86.c b/jit/jit-rules-x86.c index 57fcf8e..c90a375 100644 --- a/jit/jit-rules-x86.c +++ b/jit/jit-rules-x86.c @@ -778,19 +778,23 @@ fp_stack_index(jit_gencode_t gen, int reg) } void -_jit_gen_exch_top(jit_gencode_t gen, int reg, int pop) +_jit_gen_exch_top(jit_gencode_t gen, int reg) { if(IS_FLOAT_REG(reg)) { jit_cache_setup_output(2); - if(pop) - { - x86_fstp(inst, fp_stack_index(gen, reg)); - } - else - { - x86_fxch(inst, fp_stack_index(gen, reg)); - } + x86_fxch(inst, fp_stack_index(gen, reg)); + jit_cache_end_output(); + } +} + +void + _jit_gen_move_top(jit_gencode_t gen, int reg) +{ + if(IS_FLOAT_REG(reg)) + { + jit_cache_setup_output(2); + x86_fstp(inst, fp_stack_index(gen, reg)); jit_cache_end_output(); } } diff --git a/jit/jit-rules.h b/jit/jit-rules.h index 444a4e4..d3050e1 100644 --- a/jit/jit-rules.h +++ b/jit/jit-rules.h @@ -200,7 +200,8 @@ void _jit_gen_load_value (jit_gencode_t gen, int reg, int other_reg, jit_value_t value); void _jit_gen_spill_global(jit_gencode_t gen, int reg, jit_value_t value); void _jit_gen_load_global(jit_gencode_t gen, int reg, jit_value_t value); -void _jit_gen_exch_top(jit_gencode_t gen, int reg, int pop); +void _jit_gen_exch_top(jit_gencode_t gen, int reg); +void _jit_gen_move_top(jit_gencode_t gen, int reg); void _jit_gen_spill_top(jit_gencode_t gen, int reg, jit_value_t value, int pop); void _jit_gen_fix_value(jit_value_t value); void _jit_gen_insn(jit_gencode_t gen, jit_function_t func,