This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] loop-invariant.c: Use VEC instead of VARRAY.


Hi,

Attached is a patch to use VEC instead of VARRAY.

Zdenek, Diego has preapproved this kind of patch, but are you (or
anyone working in this area) OK with this?

Tested on i686-pc-linux-gnu.

Kazu Hirata

2005-04-30  Kazu Hirata  <kazu@cs.umass.edu>

	* loop-invariant.c (invariants, create_new_invariant,
	get_inv_cost, best_gain_for_invariant,
	find_invariants_to_move, move_invariants,
	init_inv_motion_data, free_inv_motion_data): Use VEC instead
	of VARRAY.

Index: loop-invariant.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-invariant.c,v
retrieving revision 2.13
diff -u -d -p -r2.13 loop-invariant.c
--- loop-invariant.c	28 Apr 2005 05:03:07 -0000	2.13
+++ loop-invariant.c	29 Apr 2005 14:10:44 -0000
@@ -118,9 +118,14 @@ struct invariant
 
 static unsigned actual_stamp;
 
+typedef struct invariant *invariant_p;
+
+DEF_VEC_P(invariant_p);
+DEF_VEC_ALLOC_P(invariant_p, heap);
+
 /* The invariants.  */
 
-static varray_type invariants;
+static VEC(invariant_p,heap) *invariants;
 
 /* Test for possibility of invariantness of X.  */
 
@@ -332,10 +337,10 @@ create_new_invariant (struct def *def, r
   inv->stamp = 0;
   inv->insn = insn;
 
-  inv->invno = VARRAY_ACTIVE_SIZE (invariants);
+  inv->invno = VEC_length (invariant_p, invariants);
   if (def)
     def->invno = inv->invno;
-  VARRAY_PUSH_GENERIC_PTR_NOGC (invariants, inv);
+  VEC_safe_push (invariant_p, heap, invariants, inv);
 
   if (dump_file)
     {
@@ -614,7 +619,7 @@ get_inv_cost (struct invariant *inv, int
 
   EXECUTE_IF_SET_IN_BITMAP (inv->depends_on, 0, depno, bi)
     {
-      dep = VARRAY_GENERIC_PTR_NOGC (invariants, depno);
+      dep = VEC_index (invariant_p, invariants, depno);
 
       get_inv_cost (dep, &acomp_cost, &aregs_needed);
 
@@ -673,9 +678,8 @@ best_gain_for_invariant (struct invarian
   int gain = 0, again;
   unsigned aregs_needed, invno;
 
-  for (invno = 0; invno < VARRAY_ACTIVE_SIZE (invariants); invno++)
+  for (invno = 0; VEC_iterate (invariant_p, invariants, invno, inv); invno++)
     {
-      inv = VARRAY_GENERIC_PTR_NOGC (invariants, invno);
       if (inv->move)
 	continue;
 
@@ -697,7 +701,7 @@ best_gain_for_invariant (struct invarian
 static void
 set_move_mark (unsigned invno)
 {
-  struct invariant *inv = VARRAY_GENERIC_PTR_NOGC (invariants, invno);
+  struct invariant *inv = VEC_index (invariant_p, invariants, invno);
   bitmap_iterator bi;
 
   if (inv->move)
@@ -721,7 +725,7 @@ find_invariants_to_move (struct df *df)
   unsigned i, regs_used, n_inv_uses, regs_needed = 0, new_regs;
   struct invariant *inv = NULL;
 
-  if (!VARRAY_ACTIVE_SIZE (invariants))
+  if (!VEC_length (invariant_p, invariants))
     return;
 
   /* Now something slightly more involved.  First estimate the number of used
@@ -741,9 +745,8 @@ find_invariants_to_move (struct df *df)
 	}
     }
 
-  for (i = 0; i < VARRAY_ACTIVE_SIZE (invariants); i++)
+  for (i = 0; VEC_iterate (invariant_p, invariants, i, inv); i++)
     {
-      inv = VARRAY_GENERIC_PTR_NOGC (invariants, i);
       if (inv->def)
 	n_inv_uses += inv->def->n_uses;
     }
@@ -762,7 +765,7 @@ find_invariants_to_move (struct df *df)
 static void
 move_invariant_reg (struct loop *loop, unsigned invno, struct df *df)
 {
-  struct invariant *inv = VARRAY_GENERIC_PTR_NOGC (invariants, invno);
+  struct invariant *inv = VEC_index (invariant_p, invariants, invno);
   unsigned i;
   basic_block preheader = loop_preheader_edge (loop)->src;
   rtx reg, set;
@@ -816,9 +819,8 @@ move_invariants (struct loop *loop, stru
   struct invariant *inv;
   unsigned i;
 
-  for (i = 0; i < VARRAY_ACTIVE_SIZE (invariants); i++)
+  for (i = 0; VEC_iterate (invariant_p, invariants, i, inv); i++)
     {
-      inv = VARRAY_GENERIC_PTR_NOGC (invariants, i);
       if (inv->move)
 	move_invariant_reg (loop, i, df);
     }
@@ -831,8 +833,7 @@ init_inv_motion_data (void)
 {
   actual_stamp = 1;
 
-  if (!invariants)
-    VARRAY_GENERIC_PTR_NOGC_INIT (invariants, 100, "invariants");
+  invariants = VEC_alloc (invariant_p, heap, 100);
 }
 
 /* Frees the data allocated by invariant motion.  DF is the dataflow
@@ -859,13 +860,12 @@ free_inv_motion_data (struct df *df)
       DF_REF_DATA (df->defs[i]) = NULL;
     }
 
-  for (i = 0; i < VARRAY_ACTIVE_SIZE (invariants); i++)
+  for (i = 0; VEC_iterate (invariant_p, invariants, i, inv); i++)
     {
-      inv = VARRAY_GENERIC_PTR_NOGC (invariants, i);
       BITMAP_FREE (inv->depends_on);
       free (inv);
     }
-  VARRAY_POP_ALL (invariants);
+  VEC_free (invariant_p, heap, invariants);
 }
 
 /* Move the invariants out of the LOOP.  DF is the dataflow object.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]