]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Implement global register allocation for parameters in stack slots.
authorRhys Weatherley <rweather@southern-storm.com.au>
Fri, 11 Jun 2004 02:01:18 +0000 (02:01 +0000)
committerRhys Weatherley <rweather@southern-storm.com.au>
Fri, 11 Jun 2004 02:01:18 +0000 (02:01 +0000)
ChangeLog
jit/jit-function.c
jit/jit-reg-alloc.c
jit/jit-rules-arm.c
jit/jit-rules-interp.c
jit/jit-rules-x86.c
jit/jit-rules.h

index bdd5019faa5a02536df28064827cca07674ec9d8..964f22005c643ed4520fe3e053dabc531bf718c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,10 @@
        tutorial/t2.c, tutorial/t5.c: implement tail calls from a
        function to itself.
 
+       * jit/jit-function.c, jit/jit-reg-alloc.c, jit/jit-rules-arm.c,
+       jit/jit-rules-interp.c, jit/jit-rules-x86.c, jit/jit-rules.h:
+       implement global register allocation for parameters in stack slots.
+
 2004-06-10  Rhys Weatherley  <rweather@southern-storm.com.au>
 
        * jit/jit-apply-arm.c, jit/jit-gen-arm.c, jit/jit-gen-arm.h,
index 8eef76f9443d0140b2382c54d7571c8790bc5296..a8212c8315605beb95dd08af659110c4f44941c9 100644 (file)
@@ -473,9 +473,16 @@ static void compile_block(jit_gencode_t gen, jit_function_t func,
                                insn->value1->frame_offset =
                                        jit_value_get_nint_constant(insn->value2);
                                insn->value1->in_register = 0;
-                               insn->value1->in_frame = 1;
                                insn->value1->has_frame_offset = 1;
-                               insn->value1->has_global_register = 0;  /* Disable globals */
+                               if(insn->value1->has_global_register)
+                               {
+                                       insn->value1->in_global_register = 1;
+                                       _jit_gen_load_global(gen, insn->value1);
+                               }
+                               else
+                               {
+                                       insn->value1->in_frame = 1;
+                               }
                        }
                        break;
 
index 39ea14be01b45ae4001e172eef65c3262e195de2..3487f6405faec72c88d5cd22622919f254c7802f 100644 (file)
@@ -1489,8 +1489,7 @@ void _jit_regs_alloc_global(jit_gencode_t gen, jit_function_t func)
                        value = (jit_value_t)(block->data + posn *
                                                                  sizeof(struct _jit_value));
                        if(value->global_candidate && value->usage_count >= JIT_MIN_USED &&
-                          !(value->is_addressable) && !(value->is_volatile) &&
-                          (!(value->is_parameter) || value->is_reg_parameter))
+                          !(value->is_addressable) && !(value->is_volatile))
                        {
                                /* Insert this candidate into the list, ordered on count */
                                index = 0;
index 61a08aa1c650806983c1671ef6be9e46c1ad9906..24e36c5647d34019bf0990636035cfb5045069b4 100644 (file)
@@ -1084,6 +1084,14 @@ void _jit_gen_load_value
        jit_cache_end_output();
 }
 
+void _jit_gen_load_global(jit_gencode_t gen, jit_value_t value)
+{
+       jit_cache_setup_output(32);
+       arm_load_membase(inst, _jit_reg_info[value->global_reg].cpu_reg,
+                                        ARM_FP, value->frame_offset);
+       jit_cache_end_output();
+}
+
 void _jit_gen_fix_value(jit_value_t value)
 {
        if(!(value->has_frame_offset) && !(value->is_constant))
index 75162c902d0b4a774e80eb33345e6762063d1adb..4d3d5e19ab6c6e29724c2f79d1538f4158380b53 100644 (file)
@@ -825,6 +825,18 @@ void _jit_gen_load_value
        adjust_working(gen, 1);
 }
 
+/*@
+ * @deftypefun void _jit_gen_load_global (jit_gencode_t gen, jit_value_t value)
+ * Load the contents of @code{value} into its corresponding global register.
+ * This is used at the head of a function to pull parameters out of stack
+ * slots into their global register copies.
+ * @end deftypefun
+@*/
+void _jit_gen_load_global(jit_gencode_t gen, jit_value_t value)
+{
+       /* Global registers are not used in the interpreted back end */
+}
+
 /*@
  * @deftypefun void _jit_gen_fix_value (jit_value_t value)
  * Fix the position of a value within the local variable frame.
index bc683dbf58a4340501ee0e72dcaa7160a10daa40..bbe9a607b176cf666a7ec27aa79ec6ba92e0f128 100644 (file)
@@ -1146,6 +1146,14 @@ void _jit_gen_load_value
        jit_cache_end_output();
 }
 
+void _jit_gen_load_global(jit_gencode_t gen, jit_value_t value)
+{
+       jit_cache_setup_output(16);
+       x86_mov_reg_membase(inst, _jit_reg_info[value->global_reg].cpu_reg,
+                                               X86_EBP, value->frame_offset, sizeof(void *));
+       jit_cache_end_output();
+}
+
 void _jit_gen_fix_value(jit_value_t value)
 {
        if(!(value->has_frame_offset) && !(value->is_constant))
index 43b604fe04fb45387368f95430221810e28fbb38..3a70175a61cffc4174ad00a65a80628b10102b03 100644 (file)
@@ -186,6 +186,7 @@ void _jit_gen_free_reg(jit_gencode_t gen, int reg,
                                           int other_reg, int value_used);
 void _jit_gen_load_value
        (jit_gencode_t gen, int reg, int other_reg, jit_value_t value);
+void _jit_gen_load_global(jit_gencode_t gen, jit_value_t value);
 void _jit_gen_fix_value(jit_value_t value);
 void _jit_gen_insn(jit_gencode_t gen, jit_function_t func,
                                   jit_block_t block, jit_insn_t insn);