From 385b6e2d89aafa6135634bf661b1b559dedc8de8 Mon Sep 17 00:00:00 2001 From: "J\"orn Rennecke" Date: Fri, 21 Sep 2001 00:45:30 +0000 Subject: [PATCH] integrate.c (allocate_initial_values): New function. * 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 | 12 ++++++++++++ gcc/doc/tm.texi | 20 ++++++++++++++++++++ gcc/integrate.c | 34 ++++++++++++++++++++++++++++++++++ gcc/integrate.h | 1 + gcc/local-alloc.c | 3 --- gcc/reload1.c | 1 - gcc/toplev.c | 9 +++++++++ 7 files changed, 76 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bbc7d9eda9e..af47279de41 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +Fri Sep 21 01:13:56 2001 J"orn Rennecke + + * 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 * ggc-page.c (ggc_marked_p): Properly convert return to boolean. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index edc2f3c342d..71e4cd953a1 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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 diff --git a/gcc/integrate.c b/gcc/integrate.c index 0934d769aa8..db5993580d3 100644 --- a/gcc/integrate.c +++ b/gcc/integrate.c @@ -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 +} diff --git a/gcc/integrate.h b/gcc/integrate.h index 66281e81ec7..c88e2cd9e0c 100644 --- a/gcc/integrate.h +++ b/gcc/integrate.h @@ -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. */ diff --git a/gcc/local-alloc.c b/gcc/local-alloc.c index f0492c44058..1df88db3340 100644 --- a/gcc/local-alloc.c +++ b/gcc/local-alloc.c @@ -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. diff --git a/gcc/reload1.c b/gcc/reload1.c index 32303a56262..11010e21738 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -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)); diff --git a/gcc/toplev.c b/gcc/toplev.c index 63643051639..dc3bf74945c 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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 (); -- 2.30.2