OSDN Git Service

Widen some short fields to int; Use allocate_reg_info to allocate the reg_renumber...
authormeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 2 Jun 1997 22:05:38 +0000 (22:05 +0000)
committermeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 2 Jun 1997 22:05:38 +0000 (22:05 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@14142 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/flow.c
gcc/local-alloc.c
gcc/loop.c
gcc/regclass.c
gcc/regs.h
gcc/sched.c
gcc/stupid.c

index 12a9bf9..355a35e 100644 (file)
@@ -1286,7 +1286,7 @@ allocate_for_life_analysis ()
      information, explicitly reset it here.  The allocation should have
      already happened on the previous reg_scan pass.  Make sure in case
      some more registers were allocated.  */
-  allocate_reg_info (max_regno, FALSE);
+  allocate_reg_info (max_regno, FALSE, FALSE);
 
   for (i = 0; i < max_regno; i++)
     REG_N_SETS (i) = 0;
index 8b36f5f..3603e53 100644 (file)
@@ -453,9 +453,8 @@ local_alloc ()
   reg_offset = (char *) alloca (max_regno * sizeof (char));
   reg_next_in_qty = (int *) alloca (max_regno * sizeof (int));
 
-  reg_renumber = (short *) oballoc (max_regno * sizeof (short));
-  for (i = 0; i < max_regno; i++)
-    reg_renumber[i] = -1;
+  /* 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
index fd7c289..92eab1f 100644 (file)
@@ -139,13 +139,13 @@ static rtx loop_continue;
    Therefore, at all times, == 0 indicates an invariant register;
    < 0 a conditionally invariant one.  */
 
-static short *n_times_set;
+static int *n_times_set;
 
 /* Original value of n_times_set; same except that this value
    is not set negative for a reg whose sets have been made candidates
    and not set to 0 for a reg that is moved.  */
 
-static short *n_times_used;
+static int *n_times_used;
 
 /* Index by register number, 1 indicates that the register
    cannot be moved or strength reduced.  */
@@ -497,8 +497,8 @@ scan_loop (loop_start, end, nregs)
   /* Nonzero if we are scanning instructions in a sub-loop.  */
   int loop_depth = 0;
 
-  n_times_set = (short *) alloca (nregs * sizeof (short));
-  n_times_used = (short *) alloca (nregs * sizeof (short));
+  n_times_set = (int *) alloca (nregs * sizeof (int));
+  n_times_used = (int *) alloca (nregs * sizeof (int));
   may_not_optimize = (char *) alloca (nregs);
 
   /* Determine whether this loop starts with a jump down to a test at
@@ -581,7 +581,7 @@ scan_loop (loop_start, end, nregs)
      the setting of register I.  If this loop has calls, set
      reg_single_usage[I].  */
 
-  bzero ((char *) n_times_set, nregs * sizeof (short));
+  bzero ((char *) n_times_set, nregs * sizeof (int));
   bzero (may_not_optimize, nregs);
 
   if (loop_has_call)
@@ -595,7 +595,7 @@ scan_loop (loop_start, end, nregs)
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     may_not_optimize[i] = 1, n_times_set[i] = 1;
-  bcopy ((char *) n_times_set, (char *) n_times_used, nregs * sizeof (short));
+  bcopy ((char *) n_times_set, (char *) n_times_used, nregs * sizeof (int));
 
   if (loop_dump_stream)
     {
index 2f73a3d..358b7bb 100644 (file)
@@ -1,5 +1,5 @@
 /* Compute register class preferences for pseudo-registers.
-   Copyright (C) 1987, 88, 91, 92, 93, 94, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 91, 92, 93, 94, 96, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -1651,37 +1651,84 @@ auto_inc_dec_reg_p (reg, mode)
 \f
 /* Allocate enough space to hold NUM_REGS registers for the tables used for
    reg_scan and flow_analysis that are indexed by the register number.  If
-   NEW_P is set, initialize all of the registers, otherwise only initialize the
-   new registers allocated.  The same table is kept from function to function,
-   only reallocating it when we need more room.  */
+   NEW_P is non zero, initialize all of the registers, otherwise only
+   initialize the new registers allocated.  The same table is kept from
+   function to function, only reallocating it when we need more room.  If
+   RENUMBER_P is non zero, allocate the reg_renumber array also.  */
 
 void
-allocate_reg_info (num_regs, new_p)
+allocate_reg_info (num_regs, new_p, renumber_p)
      int num_regs;
      int new_p;
+     int renumber_p;
 {
   static int regno_allocated = 0;
   static int regno_max = 0;
+  static short *renumber = (short *)0;
   int i;
-  int size;
+  int size_info;
+  int size_renumber;
   int min = (new_p) ? 0 : regno_max+1;
 
+  /* If this message come up, and you want to fix it, then all of the tables
+     like reg_renumber, etc. that use short will have to be found and lengthed
+     to int or HOST_WIDE_INT.  */
+
+  /* Free up all storage allocated */
+  if (num_regs < 0)
+    {
+      if (reg_n_info)
+       {
+         free ((char *)reg_n_info);
+         free ((char *)renumber);
+         reg_n_info = (reg_info *)0;
+         renumber = (short *)0;
+       }
+      regno_allocated = 0;
+      regno_max = 0;
+      return;
+    }
+
   if (num_regs > regno_allocated)
     {
       regno_allocated = num_regs + (num_regs / 20);    /* add some slop space */
-      size = regno_allocated * sizeof (reg_info);
-      reg_n_info = ((reg_n_info)
-                   ? (reg_info *) xrealloc ((char *)reg_n_info, size)
-                   : (reg_info *) xmalloc (size));
+      size_info = regno_allocated * sizeof (reg_info);
+      size_renumber = regno_allocated * sizeof (short);
+
+      if (!reg_n_info)
+       {
+         reg_n_info = (reg_info *) xmalloc (size_info);
+         renumber = (short *) xmalloc (size_renumber);
+       }
+
+      else if (new_p)          /* if we're zapping everything, no need to realloc */
+       {
+         free ((char *)reg_n_info);
+         free ((char *)renumber);
+         reg_n_info = (reg_info *) xmalloc (size_info);
+         renumber = (short *) xmalloc (size_renumber);
+       }
+
+      else
+       {
+         reg_n_info = (reg_info *) xrealloc ((char *)reg_n_info, size_info);
+         renumber = (short *) xrealloc ((char *)renumber, size_renumber);
+       }
     }
 
   if (min < num_regs)
     {
       bzero ((char *) &reg_n_info[min], (num_regs - min) * sizeof (reg_info));
       for (i = min; i < num_regs; i++)
-       REG_BASIC_BLOCK (i) = REG_BLOCK_UNKNOWN;
+       {
+         REG_BASIC_BLOCK (i) = REG_BLOCK_UNKNOWN;
+         renumber[i] = -1;
+       }
     }
 
+  if (renumber_p)
+    reg_renumber = renumber;
+
   regno_max = num_regs;
 }
 
@@ -1709,7 +1756,7 @@ reg_scan (f, nregs, repeat)
 {
   register rtx insn;
 
-  allocate_reg_info (nregs, TRUE);
+  allocate_reg_info (nregs, TRUE, FALSE);
   max_parallel = 3;
 
   for (insn = f; insn; insn = NEXT_INSN (insn))
index 0091b88..5089553 100644 (file)
@@ -1,5 +1,5 @@
 /* Define per-register tables for data flow info and register allocation.
-   Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -124,7 +124,7 @@ extern reg_info *reg_n_info;
 
    This can't be folded into reg_n_info without changing all of the
    machine dependent directories, since the reload functions
-   access it.  */
+   in the machine dependent files access it.  */
 
 extern short *reg_renumber;
 
@@ -214,4 +214,4 @@ extern int *scratch_block;
 extern int scratch_list_length;
 
 /* Allocate reg_n_info tables */
-extern void allocate_reg_info PROTO((int, int));
+extern void allocate_reg_info PROTO((int, int, int));
index ae873fa..2627968 100644 (file)
@@ -135,7 +135,6 @@ Boston, MA 02111-1307, USA.  */
 
    Values of these arrays are copied at the end of this pass into the
    arrays set up by flow analysis.  */
-static short *sched_reg_n_deaths;
 static int *sched_reg_n_calls_crossed;
 static int *sched_reg_live_length;
 
@@ -290,8 +289,10 @@ static int *insn_tick;
 
 struct sometimes
 {
-  short offset; short bit;
-  short live_length; short calls_crossed;
+  int offset;
+  int bit;
+  int live_length;
+  int calls_crossed;
 };
 
 /* Forward declarations.  */
@@ -4872,20 +4873,16 @@ schedule_insns (dump_file)
 
   if (reload_completed == 0)
     {
-      sched_reg_n_deaths = (short *) alloca (max_regno * sizeof (short));
       sched_reg_n_calls_crossed = (int *) alloca (max_regno * sizeof (int));
       sched_reg_live_length = (int *) alloca (max_regno * sizeof (int));
       bb_dead_regs = (regset) alloca (regset_bytes);
       bb_live_regs = (regset) alloca (regset_bytes);
       bzero ((char *) sched_reg_n_calls_crossed, max_regno * sizeof (int));
       bzero ((char *) sched_reg_live_length, max_regno * sizeof (int));
-      for (i = 0; i < max_regno; i++)
-       sched_reg_n_deaths[i] = REG_N_DEATHS (i);
       init_alias_analysis ();
     }
   else
     {
-      sched_reg_n_deaths = 0;
       sched_reg_n_calls_crossed = 0;
       sched_reg_live_length = 0;
       bb_dead_regs = 0;
index 72e94d6..396799e 100644 (file)
@@ -1,5 +1,5 @@
 /* Dummy data flow analysis for GNU compiler in nonoptimizing mode.
-   Copyright (C) 1987, 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -179,13 +179,11 @@ stupid_life_analysis (f, nregs, file)
   regs_crosses_setjmp = (char *) alloca (nregs * sizeof (char));
   bzero ((char *) regs_crosses_setjmp, nregs * sizeof (char));
 
-  reg_renumber = (short *) oballoc (nregs * sizeof (short));
+  /* Allocate the reg_renumber array */
+  allocate_reg_info (max_regno, FALSE, TRUE);
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     reg_renumber[i] = i;
 
-  for (i = FIRST_VIRTUAL_REGISTER; i < max_regno; i++)
-    reg_renumber[i] = -1;
-
   after_insn_hard_regs
     = (HARD_REG_SET *) alloca (max_suid * sizeof (HARD_REG_SET));