integrate.c (allocate_initial_values): New function.
authorJ"orn Rennecke <amylaar@redhat.com>
Fri, 21 Sep 2001 00:45:30 +0000 (00:45 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Fri, 21 Sep 2001 00:45:30 +0000 (01:45 +0100)
* integrate.c (allocate_initial_values): New function.
* integrate.h (allocate_initial_values): Declare.
* local-alloc.c (local_alloc): Move call to allocate_reg_info from
here...
* reload1.c (reload): And initialization of reg_equiv_memory_loc
from here...
* toplev.c (rest_of_compilation): To here.
Call allocate_initial_values.
* tm.texi: add description for ALLOCATE_INITIAL_VALUE.

From-SVN: r45716

gcc/ChangeLog
gcc/doc/tm.texi
gcc/integrate.c
gcc/integrate.h
gcc/local-alloc.c
gcc/reload1.c
gcc/toplev.c

index bbc7d9eda9e5a7780694ee2c429b766f5cc9d4f0..af47279de4144546b583c61cc584048499bb69b3 100644 (file)
@@ -1,3 +1,15 @@
+Fri Sep 21 01:13:56 2001  J"orn Rennecke <amylaar@redhat.com>
+
+       * integrate.c (allocate_initial_values): New function.
+       * integrate.h (allocate_initial_values): Declare.
+       * local-alloc.c (local_alloc): Move call to allocate_reg_info from
+       here...
+       * reload1.c (reload): And initialization of reg_equiv_memory_loc
+       from here...
+       * toplev.c (rest_of_compilation): To here.
+       Call allocate_initial_values.
+       * tm.texi: add description for ALLOCATE_INITIAL_VALUE.
+
 Thu Sep 20 09:00:27 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * ggc-page.c (ggc_marked_p): Properly convert return to boolean.
index edc2f3c342d1b4df5d5450de84e86a73686ad816..71e4cd953a1815041e1ca3aff9bcf9d830a8f1b0 100644 (file)
@@ -8760,4 +8760,24 @@ On some targets, branches may have a limited range.  Optimizing the
 filling of delay slots can result in branches being redirected, and this
 may in turn cause a branch offset to overflow.
 
+@findex ALLOCATE_INITIAL_VALUE
+@item ALLOCATE_INITIAL_VALUE(@var{hard_reg})
+
+When the initial value of a hard register has been copied in a pseudo
+register, it is often not necessary to actually allocate a another register
+to this pseudo register, because the original hard register or a stack slot
+it has been saved into can be used.  @code{ALLOCATE_INITIAL_VALUE}, if
+defined, is called at the start of register allocation once for each
+hard register that had its initial value copied by using
+@code{get_func_hard_reg_initial_val} or @code{get_hard_reg_initial_val}.
+Possible values are @code{NULL_RTX}, if you don't want
+to do any special allocation, a @code{REG} rtx---that would typically be
+the hard register itself, if it is known not to be clobbered---or a
+@code{MEM}.
+If you are returning a @code{MEM}, this is only a hint for the allocator;
+it might decide to use another register anyways.
+You may use @code{current_function_leaf_function} in the definition of the
+macro, functions that use @code{REG_N_SETS}, to determine if the hard
+register in question will not be clobbered.
+
 @end table
index 0934d769aa8b9a000efaa5a6f5bbde61a27ba9ce..db5993580d367417213a4907585a45433bd81da0 100644 (file)
@@ -3037,3 +3037,37 @@ emit_initial_value_sets ()
 
   emit_insns_after (seq, get_insns ());
 }
+
+/* If the backend knows where to allocate pseudos for hard
+   register initial values, register these allocations now.  */
+void
+allocate_initial_values (reg_equiv_memory_loc)
+     rtx *reg_equiv_memory_loc;
+{
+#ifdef ALLOCATE_INITIAL_VALUE
+  struct initial_value_struct *ivs = cfun->hard_reg_initial_vals;
+  int i;
+
+  if (ivs == 0)
+    return;
+
+  for (i = 0; i < ivs->num_entries; i++)
+    {
+      int regno = REGNO (ivs->entries[i].pseudo);
+      rtx x = ALLOCATE_INITIAL_VALUE (ivs->entries[i].hard_reg);
+
+      if (x == NULL_RTX || REG_N_SETS (REGNO (ivs->entries[i].pseudo)) > 1)
+       ; /* Do nothing.  */
+      else if (GET_CODE (x) == MEM)
+       reg_equiv_memory_loc[regno] = x;
+      else if (GET_CODE (x) == REG)
+       {
+         reg_renumber[regno] = REGNO (x);
+         /* Poke the regno right into regno_reg_rtx
+            so that even fixed regs are accepted.  */
+         REGNO (ivs->entries[i].pseudo) = REGNO (x);
+       }
+      else abort ();
+    }
+#endif
+}
index 66281e81ec7879e0227918dd3fb5918dd2bf85f0..c88e2cd9e0cfc8969d8b15fc0506a647a377e0a4 100644 (file)
@@ -144,6 +144,7 @@ extern rtx has_hard_reg_initial_val         PARAMS ((enum machine_mode, int));
 extern void mark_hard_reg_initial_vals         PARAMS ((struct function *));
 /* Called from rest_of_compilation.  */
 extern void emit_initial_value_sets            PARAMS ((void));
+extern void allocate_initial_values            PARAMS ((rtx *));
 
 /* Copy a declaration when one function is substituted inline into
    another.  */
index f0492c44058fd9b1a9d5687b1e0980bbd70decc9..1df88db3340461146bbfe2391e305b3265ff2255 100644 (file)
@@ -372,9 +372,6 @@ local_alloc ()
   reg_offset = (char *) xmalloc (max_regno * sizeof (char));
   reg_next_in_qty = (int *) xmalloc (max_regno * sizeof (int));
 
-  /* Allocate the reg_renumber array.  */
-  allocate_reg_info (max_regno, FALSE, TRUE);
-
   /* Determine which pseudo-registers can be allocated by local-alloc.
      In general, these are the registers used only in a single block and
      which only die once.
index 32303a562622cedde6428c2892ea1b1633671e68..11010e21738a00830c308f919531c85bf6473b87 100644 (file)
@@ -733,7 +733,6 @@ reload (first, global)
      be substituted eventually by altering the REG-rtx's.  */
 
   reg_equiv_constant = (rtx *) xcalloc (max_regno, sizeof (rtx));
-  reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
   reg_equiv_mem = (rtx *) xcalloc (max_regno, sizeof (rtx));
   reg_equiv_init = (rtx *) xcalloc (max_regno, sizeof (rtx));
   reg_equiv_address = (rtx *) xcalloc (max_regno, sizeof (rtx));
index 63643051639dc98e59794a17275cc7abb1367553..dc3bf74945cdeac1c59e9d75dfd7989f8d3e527a 100644 (file)
@@ -3430,6 +3430,15 @@ rest_of_compilation (decl)
 
   if (! register_life_up_to_date)
     recompute_reg_usage (insns, ! optimize_size);
+
+  /* Allocate the reg_renumber array.  */
+  allocate_reg_info (max_regno, FALSE, TRUE);
+
+  /* And the reg_equiv_memory_loc array.  */
+  reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
+
+  allocate_initial_values (reg_equiv_memory_loc);
+
   regclass (insns, max_reg_num (), rtl_dump_file);
   rebuild_label_notes_after_reload = local_alloc ();