emit-rtl.c (static_regno_reg_rtx): Define.
authorJeff Law <law@redhat.com>
Thu, 13 Jun 2002 16:14:55 +0000 (10:14 -0600)
committerJeff Law <law@gcc.gnu.org>
Thu, 13 Jun 2002 16:14:55 +0000 (10:14 -0600)
        * emit-rtl.c (static_regno_reg_rtx): Define.
        (init_emit_once): Initialize static_regno_reg_rtx.
        (init_emit): Copy static_regno_reg_rtx into regno_reg_rtx instead
        of building new hard reg objects once per function.
        (gen_rtx_REG): Try to share hard regs.
* regclass.c (init_fake_stack_mems): New function broken out from
init_regs.
* rtl.h (init_fake_stack_mems): Declare.
* toplev.c (lang_independent_init): Call init_regs before
init_emit_once.  Call init_fake_stack_mems after init_emit_once.

From-SVN: r54588

gcc/ChangeLog
gcc/emit-rtl.c
gcc/regclass.c
gcc/rtl.h
gcc/toplev.c

index 2fffb42..1136809 100644 (file)
 
 2002-06-13  Jeffrey Law  <law@redhat.com>
 
+       * emit-rtl.c (static_regno_reg_rtx): Define.
+       (init_emit_once): Initialize static_regno_reg_rtx.
+       (init_emit): Copy static_regno_reg_rtx into regno_reg_rtx instead
+       of building new hard reg objects once per function.
+       (gen_rtx_REG): Try to share hard regs.
+       * regclass.c (init_fake_stack_mems): New function broken out from
+       init_regs.
+       * rtl.h (init_fake_stack_mems): Declare.
+       * toplev.c (lang_independent_init): Call init_regs before
+       init_emit_once.  Call init_fake_stack_mems after init_emit_once.
+
        * i386.md (extenddfxf2, extenddftf2): Fix typo/thinko.
 
        * alias.c (argument_registers): Remove.
index 27a511f..5186c85 100644 (file)
@@ -92,6 +92,12 @@ static int no_line_numbers;
 
 rtx global_rtl[GR_MAX];
 
+/* Commonly used RTL for hard registers.  These objects are not necessarily
+   unique, so we allocate them separately from global_rtl.  They are
+   initialized once per compilation unit, then copied into regno_reg_rtx
+   at the beginning of each function.  */
+static GTY(()) rtx static_regno_reg_rtx[FIRST_PSEUDO_REGISTER];
+
 /* We record floating-point CONST_DOUBLEs in each floating-point mode for
    the values of 0, 1, and 2.  For the integer entries and VOIDmode, we
    record a copy of const[012]_rtx.  */
@@ -527,6 +533,15 @@ gen_rtx_REG (mode, regno)
        return stack_pointer_rtx;
     }
 
+  /* If the per-function register table has been set up, try to re-use
+     an existing entry in that table to avoid useless generation of RTL.  */
+  if (cfun
+      && cfun->emit
+      && regno_reg_rtx
+      && regno < FIRST_PSEUDO_REGISTER
+      && reg_raw_mode[regno] == mode)
+    return regno_reg_rtx[regno];
+
   return gen_raw_REG (mode, regno);
 }
 
@@ -5067,7 +5082,6 @@ void
 init_emit ()
 {
   struct function *f = cfun;
-  int i;
 
   f->emit = (struct emit_status *) ggc_alloc (sizeof (struct emit_status));
   first_insn = NULL;
@@ -5098,13 +5112,13 @@ init_emit ()
                                  * sizeof (tree));
 
   /* Put copies of all the hard registers into regno_reg_rtx.  */
-  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-    regno_reg_rtx[i] = gen_raw_REG (reg_raw_mode[i], i);
+  memcpy (regno_reg_rtx,
+         static_regno_reg_rtx,
+         FIRST_PSEUDO_REGISTER * sizeof (rtx));
 
   /* Put copies of all the virtual register rtx into regno_reg_rtx.  */
   init_virtual_regs (f->emit);
 
-
   /* Indicate that the virtual registers and stack locations are
      all pointers.  */
   REG_POINTER (stack_pointer_rtx) = 1;
@@ -5238,6 +5252,11 @@ init_emit_once (line_numbers)
     gen_raw_REG (Pmode, VIRTUAL_OUTGOING_ARGS_REGNUM);
   virtual_cfa_rtx = gen_raw_REG (Pmode, VIRTUAL_CFA_REGNUM);
 
+  /* Initialize RTL for commonly used hard registers.  These are
+     copied into regno_reg_rtx as we begin to compile each function.  */
+  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+    static_regno_reg_rtx[i] = gen_raw_REG (reg_raw_mode[i], i);
+
 #ifdef INIT_EXPANDERS
   /* This is to initialize {init|mark|free}_machine_status before the first
      call to push_function_context_to.  This is needed by the Chill front
index 84c7ba3..6a7acb9 100644 (file)
@@ -601,11 +601,16 @@ init_regs ()
   init_reg_sets_1 ();
 
   init_reg_modes ();
+}
+
+/* Initialize some fake stack-frame MEM references for use in
+   memory_move_secondary_cost.  */
 
+void
+init_fake_stack_mems ()
+{
 #ifdef HAVE_SECONDARY_RELOADS
   {
-    /* Make some fake stack-frame MEM references for use in
-       memory_move_secondary_cost.  */
     int i;
 
     for (i = 0; i < MAX_MACHINE_MODE; i++)
index 57a0be4..f198c8d 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2026,6 +2026,7 @@ extern int reg_classes_intersect_p        PARAMS ((enum reg_class, enum reg_class));
 extern int reg_class_subset_p          PARAMS ((enum reg_class, enum reg_class));
 extern void globalize_reg              PARAMS ((int));
 extern void init_regs                  PARAMS ((void));
+extern void init_fake_stack_mems       PARAMS ((void));
 extern void init_reg_sets              PARAMS ((void));
 extern void regset_release_memory      PARAMS ((void));
 extern void regclass_init              PARAMS ((void));
index 5105ec8..388954e 100644 (file)
@@ -5035,6 +5035,9 @@ lang_independent_init ()
   init_stringpool ();
   init_obstacks ();
 
+  /* init_emit_once uses reg_raw_mode and therefore must be called
+     after init_regs which initialized reg_raw_mode.  */
+  init_regs ();
   init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
                  || debug_info_level == DINFO_LEVEL_VERBOSE
 #ifdef VMS_DEBUGGING_INFO
@@ -5043,7 +5046,7 @@ lang_independent_init ()
 #endif
                    || flag_test_coverage
                    || warn_notreached);
-  init_regs ();
+  init_fake_stack_mems ();
   init_alias_once ();
   init_loop ();
   init_reload ();