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]

Create and use const_sbitmap in GCC sources


This patch creates and uses "const_sbitmap" in GCC sources.  (The patch
doesn't rely on any changes to coretypes.h since sbitmap is defined in
sbitmap.h).

Tested on sparc-sun-solaris2.10, no regressions.

Preapproved by Mark and awaiting gcc-4.3 stage2.

		--Kaveh



2006-07-28  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* sbitmap.c (sbitmap_copy, sbitmap_equal,
	sbitmap_union_of_diff_cg, sbitmap_union_of_diff, sbitmap_not,
	sbitmap_difference, sbitmap_any_common_bits, sbitmap_a_and_b_cg,
	sbitmap_a_and_b, sbitmap_a_xor_b_cg, sbitmap_a_xor_b,
	sbitmap_a_or_b_cg, sbitmap_a_or_b, sbitmap_a_subset_b_p,
	sbitmap_a_or_b_and_c_cg, sbitmap_a_or_b_and_c,
	sbitmap_a_and_b_or_c_cg, sbitmap_a_and_b_or_c,
	sbitmap_first_set_bit, sbitmap_last_set_bit, dump_sbitmap,
	dump_sbitmap_file, debug_sbitmap, dump_sbitmap_vector): Constify.

	* sbitmap.h (const_sbitmap, const_sbitmap_ptr): New.
	(sbitmap_iterator, sbitmap_iter_init, dump_sbitmap,
	dump_sbitmap_file, dump_sbitmap_vector, sbitmap_copy,
	sbitmap_equal, sbitmap_union_of_diff, sbitmap_union_of_diff_cg,
	sbitmap_difference, sbitmap_not, sbitmap_a_or_b_and_c,
	sbitmap_a_or_b_and_c_cg, sbitmap_a_and_b_or_c,
	sbitmap_a_and_b_or_c_cg, sbitmap_any_common_bits, sbitmap_a_and_b,
	sbitmap_a_and_b_cg, sbitmap_a_or_b, sbitmap_a_or_b_cg,
	sbitmap_a_xor_b, sbitmap_a_xor_b_cg, sbitmap_a_subset_b_p,
	sbitmap_first_set_bit, sbitmap_last_set_bit, debug_sbitmap):
	Constify.
	
diff -rup orig/egcc-SVN20060728/gcc/sbitmap.c egcc-SVN20060728/gcc/sbitmap.c
--- orig/egcc-SVN20060728/gcc/sbitmap.c	2006-01-23 00:23:55.000000000 -0500
+++ egcc-SVN20060728/gcc/sbitmap.c	2006-07-29 09:38:14.382020128 -0400
@@ -175,14 +175,14 @@ sbitmap_vector_alloc (unsigned int n_vec
 /* Copy sbitmap SRC to DST.  */
 
 void
-sbitmap_copy (sbitmap dst, sbitmap src)
+sbitmap_copy (sbitmap dst, const_sbitmap src)
 {
   memcpy (dst->elms, src->elms, sizeof (SBITMAP_ELT_TYPE) * dst->size);
 }
 
 /* Determine if a == b.  */
 int
-sbitmap_equal (sbitmap a, sbitmap b)
+sbitmap_equal (const_sbitmap a, const_sbitmap b)
 {
   return !memcmp (a->elms, b->elms, sizeof (SBITMAP_ELT_TYPE) * a->size);
 }
@@ -237,7 +237,7 @@ sbitmap_vector_ones (sbitmap *bmap, unsi
    Returns true if any change is made.  */
 
 bool
-sbitmap_union_of_diff_cg (sbitmap dst, sbitmap a, sbitmap b, sbitmap c)
+sbitmap_union_of_diff_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -257,7 +257,7 @@ sbitmap_union_of_diff_cg (sbitmap dst, s
 }
 
 void
-sbitmap_union_of_diff (sbitmap dst, sbitmap a, sbitmap b, sbitmap c)
+sbitmap_union_of_diff (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -272,7 +272,7 @@ sbitmap_union_of_diff (sbitmap dst, sbit
 /* Set bitmap DST to the bitwise negation of the bitmap SRC.  */
 
 void
-sbitmap_not (sbitmap dst, sbitmap src)
+sbitmap_not (sbitmap dst, const_sbitmap src)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -293,7 +293,7 @@ sbitmap_not (sbitmap dst, sbitmap src)
    in A and the bits in B. i.e. dst = a & (~b).  */
 
 void
-sbitmap_difference (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_difference (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, dst_size = dst->size;
   unsigned int min_size = dst->size;
@@ -320,7 +320,7 @@ sbitmap_difference (sbitmap dst, sbitmap
    Return false otherwise.  */
 
 bool
-sbitmap_any_common_bits (sbitmap a, sbitmap b)
+sbitmap_any_common_bits (const_sbitmap a, const_sbitmap b)
 {
   sbitmap_ptr ap = a->elms;
   sbitmap_ptr bp = b->elms;
@@ -338,7 +338,7 @@ sbitmap_any_common_bits (sbitmap a, sbit
    Return nonzero if any change is made.  */
 
 bool
-sbitmap_a_and_b_cg (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_a_and_b_cg (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -357,7 +357,7 @@ sbitmap_a_and_b_cg (sbitmap dst, sbitmap
 }
 
 void
-sbitmap_a_and_b (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_a_and_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -372,7 +372,7 @@ sbitmap_a_and_b (sbitmap dst, sbitmap a,
    Return nonzero if any change is made.  */
 
 bool
-sbitmap_a_xor_b_cg (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_a_xor_b_cg (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -391,7 +391,7 @@ sbitmap_a_xor_b_cg (sbitmap dst, sbitmap
 }
 
 void
-sbitmap_a_xor_b (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_a_xor_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -406,7 +406,7 @@ sbitmap_a_xor_b (sbitmap dst, sbitmap a,
    Return nonzero if any change is made.  */
 
 bool
-sbitmap_a_or_b_cg (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_a_or_b_cg (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -425,7 +425,7 @@ sbitmap_a_or_b_cg (sbitmap dst, sbitmap 
 }
 
 void
-sbitmap_a_or_b (sbitmap dst, sbitmap a, sbitmap b)
+sbitmap_a_or_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -439,10 +439,10 @@ sbitmap_a_or_b (sbitmap dst, sbitmap a, 
 /* Return nonzero if A is a subset of B.  */
 
 bool
-sbitmap_a_subset_b_p (sbitmap a, sbitmap b)
+sbitmap_a_subset_b_p (const_sbitmap a, const_sbitmap b)
 {
   unsigned int i, n = a->size;
-  sbitmap_ptr ap, bp;
+  const_sbitmap_ptr ap, bp;
 
   for (ap = a->elms, bp = b->elms, i = 0; i < n; i++, ap++, bp++)
     if ((*ap | *bp) != *bp)
@@ -455,7 +455,7 @@ sbitmap_a_subset_b_p (sbitmap a, sbitmap
    Return nonzero if any change is made.  */
 
 bool
-sbitmap_a_or_b_and_c_cg (sbitmap dst, sbitmap a, sbitmap b, sbitmap c)
+sbitmap_a_or_b_and_c_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -475,7 +475,7 @@ sbitmap_a_or_b_and_c_cg (sbitmap dst, sb
 }
 
 void
-sbitmap_a_or_b_and_c (sbitmap dst, sbitmap a, sbitmap b, sbitmap c)
+sbitmap_a_or_b_and_c (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -491,7 +491,7 @@ sbitmap_a_or_b_and_c (sbitmap dst, sbitm
    Return nonzero if any change is made.  */
 
 bool
-sbitmap_a_and_b_or_c_cg (sbitmap dst, sbitmap a, sbitmap b, sbitmap c)
+sbitmap_a_and_b_or_c_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -511,7 +511,7 @@ sbitmap_a_and_b_or_c_cg (sbitmap dst, sb
 }
 
 void
-sbitmap_a_and_b_or_c (sbitmap dst, sbitmap a, sbitmap b, sbitmap c)
+sbitmap_a_and_b_or_c (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
 {
   unsigned int i, n = dst->size;
   sbitmap_ptr dstp = dst->elms;
@@ -688,7 +688,7 @@ sbitmap_union_of_preds (sbitmap dst, sbi
 /* Return number of first bit set in the bitmap, -1 if none.  */
 
 int
-sbitmap_first_set_bit (sbitmap bmap)
+sbitmap_first_set_bit (const_sbitmap bmap)
 {
   unsigned int n = 0;
   sbitmap_iterator sbi;
@@ -701,7 +701,7 @@ sbitmap_first_set_bit (sbitmap bmap)
 /* Return number of last bit set in the bitmap, -1 if none.  */
 
 int
-sbitmap_last_set_bit (sbitmap bmap)
+sbitmap_last_set_bit (const_sbitmap bmap)
 {
   int i;
   SBITMAP_ELT_TYPE *ptr = bmap->elms;
@@ -731,7 +731,7 @@ sbitmap_last_set_bit (sbitmap bmap)
 }
 
 void
-dump_sbitmap (FILE *file, sbitmap bmap)
+dump_sbitmap (FILE *file, const_sbitmap bmap)
 {
   unsigned int i, n, j;
   unsigned int set_size = bmap->size;
@@ -752,7 +752,7 @@ dump_sbitmap (FILE *file, sbitmap bmap)
 }
 
 void
-dump_sbitmap_file (FILE *file, sbitmap bmap)
+dump_sbitmap_file (FILE *file, const_sbitmap bmap)
 {
   unsigned int i, pos;
 
@@ -775,7 +775,7 @@ dump_sbitmap_file (FILE *file, sbitmap b
 }
 
 void
-debug_sbitmap (sbitmap bmap)
+debug_sbitmap (const_sbitmap bmap)
 {
   dump_sbitmap_file (stderr, bmap);
 }
diff -rup orig/egcc-SVN20060728/gcc/sbitmap.h egcc-SVN20060728/gcc/sbitmap.h
--- orig/egcc-SVN20060728/gcc/sbitmap.h	2006-01-23 00:23:55.000000000 -0500
+++ egcc-SVN20060728/gcc/sbitmap.h	2006-07-29 09:38:14.383990558 -0400
@@ -35,8 +35,10 @@ typedef struct simple_bitmap_def
   unsigned int bytes;		/* Size in bytes.  */
   SBITMAP_ELT_TYPE elms[1];	/* The elements.  */
 } *sbitmap;
+typedef const struct simple_bitmap_def *const_sbitmap;
 
 typedef SBITMAP_ELT_TYPE *sbitmap_ptr;
+typedef const SBITMAP_ELT_TYPE *const_sbitmap_ptr;
 
 /* Return the set size needed for N elements.  */
 #define SBITMAP_SET_SIZE(N) (((N) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
@@ -58,7 +60,7 @@ typedef SBITMAP_ELT_TYPE *sbitmap_ptr;
 /* The iterator for sbitmap.  */
 typedef struct {
   /* The pointer to the first word of the bitmap.  */
-  SBITMAP_ELT_TYPE *ptr;
+  const SBITMAP_ELT_TYPE *ptr;
 
   /* The size of the bitmap.  */
   unsigned int size;
@@ -77,7 +79,7 @@ typedef struct {
    MIN.  */
 
 static inline void
-sbitmap_iter_init (sbitmap_iterator *i, sbitmap bmp, unsigned int min)
+sbitmap_iter_init (sbitmap_iterator *i, const_sbitmap bmp, unsigned int min)
 {
   i->word_num = min / (unsigned int) SBITMAP_ELT_BITS;
   i->bit_num = min;
@@ -170,39 +172,39 @@ do {									\
 
 struct int_list;
 
-extern void dump_sbitmap (FILE *, sbitmap);
-extern void dump_sbitmap_file (FILE *, sbitmap);
+extern void dump_sbitmap (FILE *, const_sbitmap);
+extern void dump_sbitmap_file (FILE *, const_sbitmap);
 extern void dump_sbitmap_vector (FILE *, const char *, const char *, sbitmap *,
 				 int);
 extern sbitmap sbitmap_alloc (unsigned int);
 extern sbitmap *sbitmap_vector_alloc (unsigned int, unsigned int);
 extern sbitmap sbitmap_resize (sbitmap, unsigned int, int);
-extern void sbitmap_copy (sbitmap, sbitmap);
-extern int sbitmap_equal (sbitmap, sbitmap);
+extern void sbitmap_copy (sbitmap, const_sbitmap);
+extern int sbitmap_equal (const_sbitmap, const_sbitmap);
 extern void sbitmap_zero (sbitmap);
 extern void sbitmap_ones (sbitmap);
 extern void sbitmap_vector_zero (sbitmap *, unsigned int);
 extern void sbitmap_vector_ones (sbitmap *, unsigned int);
 
-extern void sbitmap_union_of_diff (sbitmap, sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_union_of_diff_cg (sbitmap, sbitmap, sbitmap, sbitmap);
-extern void sbitmap_difference (sbitmap, sbitmap, sbitmap);
-extern void sbitmap_not (sbitmap, sbitmap);
-extern void sbitmap_a_or_b_and_c (sbitmap, sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_a_or_b_and_c_cg (sbitmap, sbitmap, sbitmap, sbitmap);
-extern void sbitmap_a_and_b_or_c (sbitmap, sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_a_and_b_or_c_cg (sbitmap, sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_any_common_bits (sbitmap, sbitmap);
-extern void sbitmap_a_and_b (sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_a_and_b_cg (sbitmap, sbitmap, sbitmap);
-extern void sbitmap_a_or_b (sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_a_or_b_cg (sbitmap, sbitmap, sbitmap);
-extern void sbitmap_a_xor_b (sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_a_xor_b_cg (sbitmap, sbitmap, sbitmap);
-extern bool sbitmap_a_subset_b_p (sbitmap, sbitmap);
+extern void sbitmap_union_of_diff (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_union_of_diff_cg (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap);
+extern void sbitmap_difference (sbitmap, const_sbitmap, const_sbitmap);
+extern void sbitmap_not (sbitmap, const_sbitmap);
+extern void sbitmap_a_or_b_and_c (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_a_or_b_and_c_cg (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap);
+extern void sbitmap_a_and_b_or_c (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_a_and_b_or_c_cg (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_any_common_bits (const_sbitmap, const_sbitmap);
+extern void sbitmap_a_and_b (sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_a_and_b_cg (sbitmap, const_sbitmap, const_sbitmap);
+extern void sbitmap_a_or_b (sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_a_or_b_cg (sbitmap, const_sbitmap, const_sbitmap);
+extern void sbitmap_a_xor_b (sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_a_xor_b_cg (sbitmap, const_sbitmap, const_sbitmap);
+extern bool sbitmap_a_subset_b_p (const_sbitmap, const_sbitmap);
 
-extern int sbitmap_first_set_bit (sbitmap);
-extern int sbitmap_last_set_bit (sbitmap);
+extern int sbitmap_first_set_bit (const_sbitmap);
+extern int sbitmap_last_set_bit (const_sbitmap);
 
 extern void sbitmap_intersect_of_predsucc (sbitmap, sbitmap *, int,
 					   struct int_list **);
@@ -222,6 +224,6 @@ extern void sbitmap_intersection_of_pred
 extern void sbitmap_union_of_succs (sbitmap, sbitmap *, int);
 extern void sbitmap_union_of_preds (sbitmap, sbitmap *, int);
 
-extern void debug_sbitmap (sbitmap);
+extern void debug_sbitmap (const_sbitmap);
 extern sbitmap sbitmap_realloc (sbitmap, unsigned int);
 #endif /* ! GCC_SBITMAP_H */


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