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] gimplify.c: Use VEC instead of VARRAY.


Hi,

Attached is a patch to use VEC instead of VARRAY.

Tested on i686-pc-linux-gnu.  I don't know if anybody is working in
this area, but I'll wait for 24 hours just in case before I check in
this patch.

Kazu Hirata

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

	* gimplify.c (gimplify_ctx): Change the type of case_labels to
	VEC from VARRAY.
	(gimplify_switch_expr, gimplify_case_label_expr): Adjust uses
	of case_labels.

Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.126
diff -u -d -p -r2.126 gimplify.c
--- gimplify.c	1 May 2005 23:23:33 -0000	2.126
+++ gimplify.c	2 May 2005 00:34:07 -0000
@@ -54,7 +54,7 @@ static struct gimplify_ctx
   tree conditional_cleanups;
   tree exit_label;
   tree return_temp;
-  varray_type case_labels;
+  VEC(tree,gc) *case_labels;
   /* The formal temporary table.  Should this be persistent?  */
   htab_t temp_htab;
   int conditions;
@@ -1142,7 +1142,7 @@ gimplify_switch_expr (tree *expr_p, tree
 
   if (SWITCH_BODY (switch_expr))
     {
-      varray_type labels, saved_labels;
+      VEC(tree,gc) *labels, *saved_labels;
       tree label_vec, default_case = NULL_TREE;
       size_t i, len;
 
@@ -1151,23 +1151,23 @@ gimplify_switch_expr (tree *expr_p, tree
       gcc_assert (!SWITCH_LABELS (switch_expr));
 
       saved_labels = gimplify_ctxp->case_labels;
-      VARRAY_TREE_INIT (gimplify_ctxp->case_labels, 8, "case_labels");
+      gimplify_ctxp->case_labels = VEC_alloc (tree, gc, 8);
 
       gimplify_to_stmt_list (&SWITCH_BODY (switch_expr));
 
       labels = gimplify_ctxp->case_labels;
       gimplify_ctxp->case_labels = saved_labels;
 
-      len = VARRAY_ACTIVE_SIZE (labels);
+      len = VEC_length (tree, labels);
 
       for (i = 0; i < len; ++i)
 	{
-	  tree t = VARRAY_TREE (labels, i);
+	  tree t = VEC_index (tree, labels, i);
 	  if (!CASE_LOW (t))
 	    {
 	      /* The default case must be the last label in the list.  */
 	      default_case = t;
-	      VARRAY_TREE (labels, i) = VARRAY_TREE (labels, len - 1);
+	      VEC_replace (tree, labels, i, VEC_index (tree, labels, len - 1));
 	      len--;
 	      break;
 	    }
@@ -1191,7 +1191,7 @@ gimplify_switch_expr (tree *expr_p, tree
 	*expr_p = SWITCH_BODY (switch_expr);
 
       for (i = 0; i < len; ++i)
-	TREE_VEC_ELT (label_vec, i) = VARRAY_TREE (labels, i);
+	TREE_VEC_ELT (label_vec, i) = VEC_index (tree, labels, i);
       TREE_VEC_ELT (label_vec, len) = default_case;
 
       sort_case_labels (label_vec);
@@ -1210,7 +1210,7 @@ gimplify_case_label_expr (tree *expr_p)
   tree expr = *expr_p;
 
   gcc_assert (gimplify_ctxp->case_labels);
-  VARRAY_PUSH_TREE (gimplify_ctxp->case_labels, expr);
+  VEC_safe_push (tree, gc, gimplify_ctxp->case_labels, expr);
   *expr_p = build (LABEL_EXPR, void_type_node, CASE_LABEL (expr));
   return GS_ALL_DONE;
 }


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