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 (Take 2)


Hi,

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

Nathan, could you take a look at this patch?  I used VEC_iterate as
suggested.  I am pretty sure you'll be happy with this one, but just
in case.

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

Kazu Hirata

2005-04-27  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	26 Apr 2005 16:16:03 -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;
@@ -2149,13 +2152,20 @@ check_earlyclobber (rtx insn)
 	    case ',':
 	      if (amp_p && class != NO_REGS)
 		{
+		  int rc;
+
 		  found = true;
-		  for (i = VARRAY_ACTIVE_SIZE (earlyclobber_regclass) - 1;
-		       i >= 0; i--)
-		    if (VARRAY_INT (earlyclobber_regclass, i) == (int) class)
-		      break;
-		  if (i < 0)
-		    VARRAY_PUSH_INT (earlyclobber_regclass, (int) class);
+		  for (i = 0;
+		       VEC_iterate (int, earlyclobber_regclass, i, rc);
+		       i++)
+		    {
+		      if (rc == (int) class)
+			goto found_rc;
+		    }
+		  VEC_safe_push (int, heap, earlyclobber_regclass,
+				 (int) class);
+		found_rc:
+		  ;
 		}
 	      
 	      amp_p = false;
@@ -2194,23 +2204,24 @@ mark_reg_use_for_earlyclobber (rtx *x, v
 
   if (GET_CODE (*x) == REG && REGNO (*x) >= FIRST_PSEUDO_REGISTER)
     {
+      int rc;
+
       regno = REGNO (*x);
       if (bitmap_bit_p (bb_info->killed, regno)
 	  || bitmap_bit_p (bb_info->avloc, regno))
 	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 = 0; VEC_iterate (int, earlyclobber_regclass, i, rc); 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 +2243,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 +2255,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]