2006-08-29 Aleksey Demakov <ademakov@gmail.com>
+ * 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.
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;
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 */;
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)
{
}
/* 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 */
}
/*@
}
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();
}
}
(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,