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] tree-data-ref.[ch]: Use VEC instead of VARRAY.


Hi,

Attached is a patch to use VEC instead of VARRAY.

This patch is pretty straightforward.  Since data_reference does not
have GTY(()), I used VEC(tree,heap) rather than VEC(tree,gc).

Tested on i686-pc-linux-gnu.  Sebastian, Diego has preapproved this
kind of patch, but does this look reasonable to you?

Kazu Hirata

2005-05-09  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-data-ref.c (analyze_array_indexes, analyze_array,
	init_data_ref, access_functions_are_affine_or_constant_p,
	free_data_refs): Use VEC instead of VARRAY.
	* tree-data-ref.h (data_reference): Change the type of
	access_fns to VEC(tree,gc)*.
	(DR_ACCESS_FN, DR_NUM_DIMENSIONS): Use VEC instead of VARRAY.

Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 2.26
diff -u -d -p -r2.26 tree-data-ref.c
--- tree-data-ref.c	3 May 2005 12:19:36 -0000	2.26
+++ tree-data-ref.c	9 May 2005 16:47:42 -0000
@@ -523,7 +523,7 @@ estimate_niter_from_size_of_data (struct
 
 static tree
 analyze_array_indexes (struct loop *loop,
-		       varray_type *access_fns, 
+		       VEC(tree,heap) **access_fns, 
 		       tree ref, tree stmt)
 {
   tree opnd0, opnd1;
@@ -542,7 +542,7 @@ analyze_array_indexes (struct loop *loop
   if (loop->estimated_nb_iterations == NULL_TREE)
     estimate_niter_from_size_of_data (loop, opnd0, access_fn, stmt);
   
-  VARRAY_PUSH_TREE (*access_fns, access_fn);
+  VEC_safe_push (tree, heap, *access_fns, access_fn);
   
   /* Recursively record other array access functions.  */
   if (TREE_CODE (opnd0) == ARRAY_REF)
@@ -575,7 +575,7 @@ analyze_array (tree stmt, tree ref, bool
   
   DR_STMT (res) = stmt;
   DR_REF (res) = ref;
-  VARRAY_TREE_INIT (DR_ACCESS_FNS (res), 3, "access_fns");
+  DR_ACCESS_FNS (res) = VEC_alloc (tree, heap, 3);
   DR_BASE_NAME (res) = analyze_array_indexes 
     (loop_containing_stmt (stmt), &(DR_ACCESS_FNS (res)), ref, stmt);
   DR_IS_READ (res) = is_read;
@@ -610,9 +610,9 @@ init_data_ref (tree stmt, 
   
   DR_STMT (res) = stmt;
   DR_REF (res) = ref;
-  VARRAY_TREE_INIT (DR_ACCESS_FNS (res), 5, "access_fns");
+  DR_ACCESS_FNS (res) = VEC_alloc (tree, heap, 5);
   DR_BASE_NAME (res) = base;
-  VARRAY_PUSH_TREE (DR_ACCESS_FNS (res), access_fn);
+  VEC_quick_push (tree, DR_ACCESS_FNS (res), access_fn);
   DR_IS_READ (res) = is_read;
   
   if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2124,11 +2124,12 @@ static bool 
 access_functions_are_affine_or_constant_p (struct data_reference *a)
 {
   unsigned int i;
-  varray_type fns = DR_ACCESS_FNS (a);
+  VEC(tree,heap) **fns = &DR_ACCESS_FNS (a);
+  tree t;
   
-  for (i = 0; i < VARRAY_ACTIVE_SIZE (fns); i++)
-    if (!evolution_function_is_constant_p (VARRAY_TREE (fns, i))
-	&& !evolution_function_is_affine_multivariate_p (VARRAY_TREE (fns, i)))
+  for (i = 0; VEC_iterate (tree, *fns, i, t); i++)
+    if (!evolution_function_is_constant_p (t)
+	&& !evolution_function_is_affine_multivariate_p (t))
       return false;
   
   return true;
@@ -2457,8 +2458,7 @@ free_data_refs (varray_type datarefs)
 	VARRAY_GENERIC_PTR (datarefs, i);
       if (dr)
 	{
-	  if (DR_ACCESS_FNS (dr))
-	    varray_clear (DR_ACCESS_FNS (dr));
+	  VEC_free (tree, heap, DR_ACCESS_FNS (dr));
 	  free (dr);
 	}
     }
Index: tree-data-ref.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.h,v
retrieving revision 2.7
diff -u -d -p -r2.7 tree-data-ref.h
--- tree-data-ref.h	28 Apr 2005 05:38:35 -0000	2.7
+++ tree-data-ref.h	9 May 2005 16:47:42 -0000
@@ -36,7 +36,7 @@ struct data_reference
   tree base_name;
   
   /* A list of chrecs.  */
-  varray_type access_fns;
+  VEC(tree,heap) *access_fns;
 
   /* Auxiliary info specific to a pass.  */
   int aux;
@@ -50,8 +50,8 @@ struct data_reference
 #define DR_REF(DR) DR->ref
 #define DR_BASE_NAME(DR) DR->base_name
 #define DR_ACCESS_FNS(DR) DR->access_fns
-#define DR_ACCESS_FN(DR, I) VARRAY_TREE (DR_ACCESS_FNS (DR), I)
-#define DR_NUM_DIMENSIONS(DR) VARRAY_ACTIVE_SIZE (DR_ACCESS_FNS (DR))
+#define DR_ACCESS_FN(DR, I) VEC_index (tree, DR_ACCESS_FNS (DR), I)
+#define DR_NUM_DIMENSIONS(DR) VEC_length (tree, DR_ACCESS_FNS (DR))
 #define DR_IS_READ(DR) DR->is_read
 
 enum data_dependence_direction {


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