Patchwork [26/27] Call init_reg_sets for each target structure

login
register
mail settings
Submitter Richard Sandiford
Date July 7, 2010, 9:46 p.m.
Message ID <87y6dnq82n.fsf@firetop.home>
Download mbox | patch
Permalink /patch/58197/
State New
Headers show

Comments

Richard Sandiford - July 7, 2010, 9:46 p.m.
If anyone's still reading by this point, thank you!  This is the
final target-independent patch.

At the moment, we call init_reg_sets once per run.  It initialises
various hard-reg-set.h variables from static target-defined arrays.
However, now that these variables are stored in target structures,
we need to call init_reg_sets for each structure.  We then call
init_reg_sets_1 (via target_reinit) to reassert any changes made
on the command line (such as by -ffixed-reg-) and to make any
changes relevant to the new target.

This is a slight change of behaviour from calling target_reinit
every time.  target_reinit effectively recreates some parts of
the register information as a delta from the current one, whereas
save_target_globals creates it all from the same initial point.
This means, for example, that target_reinit preserves any changes made
to the allocation order by things like TARGET_OVERRIDE_OPTIONS, whereas
save_target_globals doesn't.  I think the new behaviour's cleaner
though, since it's easier for the target to predict what state it's
starting with.  Things like the allocation order should really be
changed by TARGET_CONDITIONAL_REGISTER_USAGE rather than T_O_O in
any case.

Richard


gcc/
	* reginfo.c (init_reg_sets): Don't zero globals here.  Update comment
	to say that the function can be called more than once.
	* target-globals.c (save_target_globals): Call init_reg_sets.

Patch

Index: gcc/reginfo.c
===================================================================
--- gcc/reginfo.c	2010-07-07 21:52:27.000000000 +0100
+++ gcc/reginfo.c	2010-07-07 22:32:27.000000000 +0100
@@ -141,8 +141,9 @@  reg_set_to_hard_reg_set (HARD_REG_SET *t
     }
 }
 
-/* Function called only once to initialize the above data on reg usage.
-   Once this is done, various switches may override.  */
+/* Function called only once per target_globals to initialize the
+   target_hard_regs structure.  Once this is done, various switches
+   may override.  */
 void
 init_reg_sets (void)
 {
@@ -185,7 +186,6 @@  init_reg_sets (void)
   memcpy (reg_alloc_order, initial_reg_alloc_order, sizeof reg_alloc_order);
 #endif
   memcpy (reg_names, initial_reg_names, sizeof reg_names);
-  memset (global_regs, 0, sizeof global_regs);
 }
 
 /* Initialize may_move_cost and friends for mode M.  */
Index: gcc/target-globals.c
===================================================================
--- gcc/target-globals.c	2010-07-07 22:30:59.000000000 +0100
+++ gcc/target-globals.c	2010-07-07 22:32:27.000000000 +0100
@@ -80,6 +80,7 @@  save_target_globals (void)
   g->gcse = XCNEW (struct target_gcse);
   g->bb_reorder = XCNEW (struct target_bb_reorder);
   restore_target_globals (g);
+  init_reg_sets ();
   target_reinit ();
   return g;
 }