]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
let register allocator free unused values that result from JIT_OP_INCOMING_REG and...
authorAleksey Demakov <ademakov@gmail.com>
Thu, 8 May 2008 06:39:50 +0000 (06:39 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Thu, 8 May 2008 06:39:50 +0000 (06:39 +0000)
ChangeLog
jit/jit-function.c
jit/jit-reg-alloc.c
jit/jit-rules-x86-64.ins
jit/jit-rules-x86.ins

index 7dae313a45bdf31d499f8da5dbcc53fc15b27000..c3581e671f73b53589a3cd6916aafbc6f0bbd645 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-05-08  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-rules-x86.ins: 
+       * jit/jit-rules-x86-64.ins: 
+       * jit/jit-function.c (compile_block): let register allocator see
+       JIT_OP_INCOMING_REG and JIT_OP_RETURN_REG instructions so it can
+       free unused values on these instructions rather than on the block
+       end.
+
+       * jit/jit-reg-alloc.c (_jit_regs_set_incoming): it is not possible
+       to correctly spill the old register value at this point so do not
+       attempt this and do not promise this.
+
 2008-05-04  Klaus Treichel  <ktreichel@web.de>
 
        * jit/jit-reg-alloc.c (_jit_regs_set_outgoing): Set the outgoing
index c34ada13e50fd1f5240545bdea55c759c5b8b437..9df5f7a253ad65a130aaa6f65bc4d0e3f944a62f 100644 (file)
@@ -532,6 +532,7 @@ static void compile_block(jit_gencode_t gen, jit_function_t func,
                                _jit_regs_set_incoming
                                        (gen, (int)jit_value_get_nint_constant(insn->value2),
                                         insn->value1);
+                               _jit_gen_insn(gen, func, block, insn);
                        }
                        break;
 #endif
index d153f5d85c5772ed952746dc6278f3a83822ed47..1394aa4f970a3a8f6c88c732815766f8a239fa53 100644 (file)
@@ -2915,8 +2915,8 @@ _jit_regs_spill_all(jit_gencode_t gen)
 /*@
  * @deftypefun void _jit_regs_set_incoming (jit_gencode_t gen, int reg, jit_value_t value)
  * Set pseudo register @code{reg} to record that it currently holds the
- * contents of @code{value}.  If the register was previously in use,
- * then spill its value first.
+ * contents of @code{value}.  The register must not contain any other
+ * live value at this point.
  * @end deftypefun
 @*/
 void
@@ -2934,12 +2934,18 @@ _jit_regs_set_incoming(jit_gencode_t gen, int reg, jit_value_t value)
                other_reg = -1;
        }
 
+       /* avd: It's too late to spill here, if there was any
+          value it is already cloberred by the incoming value.
+          So for correct code generation the register must be
+          free by now (spilled at some earlier point). */
+#if 0
        /* Eject any values that are currently in the register */
        spill_register(gen, reg);
        if(other_reg >= 0)
        {
                spill_register(gen, other_reg);
        }
+#endif
 
        /* Record that the value is in "reg", but not in the frame */
 #ifdef JIT_REG_STACK
@@ -3018,6 +3024,7 @@ _jit_regs_set_outgoing(jit_gencode_t gen, int reg, jit_value_t value)
 
                _jit_gen_load_value(gen, reg, other_reg, value);
        }
+
        jit_reg_set_used(gen->inhibit, reg);
        if(other_reg >= 0)
        {
index 659e98ff064e402332f08d3e4b70aac5779bab4c..f9b6489f121cda9572d350ec9b0d89ddb42ad1f5 100644 (file)
@@ -263,6 +263,17 @@ JIT_OP_ADDRESS_OF:
  * Stack pushes and pops.
  */
 
+JIT_OP_INCOMING_REG, JIT_OP_RETURN_REG: note
+        [reg] -> {
+               /*
+                * This rule does nothing itself. Also at this point
+                * the value is supposed to be already in the register
+                * so the "reg" pattern does not load it either. But
+                * it allows the allocator to check the liveness flags
+                * and free the register if the value is dead.
+                */
+       }
+
 JIT_OP_PUSH_INT: note
        [imm] -> {
                x86_64_push_imm(inst, $1);
@@ -428,11 +439,6 @@ JIT_OP_RETURN:
                inst = jump_to_epilog(gen, inst, block);
        }
 
-JIT_OP_RETURN_REG: manual
-        [] -> {
-               /* Nothing to do here */;
-       }
-
 JIT_OP_RETURN_INT: note
        [reg("rax")] -> {
                inst = jump_to_epilog(gen, inst, block);
index 4861ffcca7cad6a31a82d03ac3f7a8c19f1d9bc8..b1dfef3c288c4351c43b52620d818ec0c2a1bee0 100644 (file)
@@ -1990,9 +1990,15 @@ JIT_OP_ADDRESS_OF:
  * Stack pushes and pops.
  */
 
-JIT_OP_RETURN_REG: manual
-        [] -> {
-               /* Nothing to do here */;
+JIT_OP_INCOMING_REG, JIT_OP_RETURN_REG: note
+        [reg] -> {
+               /*
+                * This rule does nothing itself. Also at this point
+                * the value is supposed to be already in the register
+                * so the "reg" pattern does not load it either. But
+                * it allows the allocator to check the liveness flags
+                * and free the register if the value is dead.
+                */
        }
 
 JIT_OP_PUSH_INT: note