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


Hi,

Attached is a patch to use the updated VEC API instead of VARRAY.

The conversion was pretty straightforward.  earlyclobber_regclass is
used only by calculate_local_reg_bb_info and its subroutines, so we
allocate the vector at the beginning of calculate_local_reg_bb_info
and free it when we leave the function.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

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

	* global.c (earlyclobber_regclass): Change the type to
	VEC(int,heap).
	(check_earlyclobber): Update uses of earlyclobber_regclass.
	(mark_reg_use_for_earlyclobber): Likewise.
	(calculate_local_reg_bb_info): Allocate and free
	earlyclobber_regclass using the VEC API.

Index: global.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.123
diff -u -d -p -r1.123 global.c
--- global.c	17 Feb 2005 22:41:32 -0000	1.123
+++ global.c	22 Apr 2005 18:44:47 -0000
@@ -2098,7 +2098,10 @@ mark_reg_change (rtx reg, rtx setter, vo
 /* Classes of registers which could be early clobbered in the current
    insn.  */
 
-static varray_type earlyclobber_regclass;
+DEF_VEC_P(int);
+DEF_VEC_ALLOC_P(int,heap);
+
+static VEC(int,heap) *earlyclobber_regclass;
 
 /* This function finds and stores register classes that could be early
    clobbered in INSN.  If any earlyclobber classes are found, the function
@@ -2112,7 +2115,7 @@ check_earlyclobber (rtx insn)
 
   extract_insn (insn);
 
-  VARRAY_POP_ALL (earlyclobber_regclass);
+  VEC_truncate (int, earlyclobber_regclass, 0);
   for (opno = 0; opno < recog_data.n_operands; opno++)
     {
       char c;
@@ -2150,12 +2153,12 @@ check_earlyclobber (rtx insn)
 	      if (amp_p && class != NO_REGS)
 		{
 		  found = true;
-		  for (i = VARRAY_ACTIVE_SIZE (earlyclobber_regclass) - 1;
+		  for (i = VEC_length (int, earlyclobber_regclass) - 1;
 		       i >= 0; i--)
-		    if (VARRAY_INT (earlyclobber_regclass, i) == (int) class)
+		    if (VEC_index (int, earlyclobber_regclass, i) == (int) class)
 		      break;
 		  if (i < 0)
-		    VARRAY_PUSH_INT (earlyclobber_regclass, (int) class);
+		    VEC_safe_push (int, heap, earlyclobber_regclass, (int) class);
 		}
 	      
 	      amp_p = false;
@@ -2200,17 +2203,18 @@ mark_reg_use_for_earlyclobber (rtx *x, v
 	return 0;
       pref_class = reg_preferred_class (regno);
       alt_class = reg_alternate_class (regno);
-      for (i = VARRAY_ACTIVE_SIZE (earlyclobber_regclass) - 1; i >= 0; i--)
-	if (reg_classes_intersect_p (VARRAY_INT (earlyclobber_regclass, i),
-				     pref_class)
-	    || (VARRAY_INT (earlyclobber_regclass, i) != NO_REGS
-		&& reg_classes_intersect_p (VARRAY_INT (earlyclobber_regclass,
-							i),
-					    alt_class)))
-	  {
-	    bitmap_set_bit (bb_info->earlyclobber, regno);
-	    break;
-	  }
+      for (i = VEC_length (int, earlyclobber_regclass) - 1; i >= 0; i--)
+	{
+	  int rc = VEC_index (int, earlyclobber_regclass, i);
+
+	  if (reg_classes_intersect_p (rc, pref_class)
+	      || (rc != NO_REGS
+		  && reg_classes_intersect_p (rc, alt_class)))
+	    {
+	      bitmap_set_bit (bb_info->earlyclobber, regno);
+	      break;
+	    }
+	}
     }
   return 0;
 }
@@ -2232,8 +2236,7 @@ calculate_local_reg_bb_info (void)
   basic_block bb;
   rtx insn, bound;
 
-  VARRAY_INT_INIT (earlyclobber_regclass, 20,
-		   "classes of registers early clobbered in an insn");
+  earlyclobber_regclass = VEC_alloc (int, heap, 20);
   FOR_EACH_BB (bb)
     {
       bound = NEXT_INSN (BB_END (bb));
@@ -2245,6 +2248,7 @@ calculate_local_reg_bb_info (void)
 	      note_uses (&PATTERN (insn), mark_reg_use_for_earlyclobber_1, bb);
 	  }
     }
+  VEC_free (int, heap, earlyclobber_regclass);
 }
 
 /* The function sets up reverse post-order number of each basic


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