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]

[PATCH] Add more sbitmap compatibility to bitmaps


When i replaced sbitmaps with bitmaps in the about to be submitted
df.[ch], i noticed some missing functions/macros on bitmaps that exist for
sbitmaps.

This patch adds some of them (obviously, those that i needed for df.[ch]),
which makes it easier to use bitmaps where sbitmaps are curently used.

2001-02-03  Daniel Berlin  <dan@cgsoftware.com>

	* bitmap.h : Add dump_bitmap, bitmap_zero, bitmap_union_of_diffs,
	bitmap_a_or_b, bitmap_a_and_b, bitmap_first_set_bit,
	bitmap_last_set_bit. All for compatibility with sbitmap's.

	* bitmap.c (bitmap_zero): New function.
	(bitmap_union_of_diffs): New function.
	(bitmap_first_set_bit): New function.
	(bitmap_last_set_bit): New function.

Index: bitmap.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/bitmap.c,v
retrieving revision 1.23
diff -c -3 -p -w -B -b -r1.23 bitmap.c
*** bitmap.c	2000/07/23 16:25:06	1.23
--- bitmap.c	2001/04/24 16:46:13
*************** bitmap_operation (to, from1, from2, oper
*** 507,513 ****
  	case BITMAP_IOR:
  	  DOIT (|);
  	  break;
!
  	case BITMAP_XOR:
  	  DOIT (^);
  	  break;
--- 507,515 ----
  	case BITMAP_IOR:
  	  DOIT (|);
  	  break;
! 	case BITMAP_IOR_COMPL:
! 	  DOIT (|~);
! 	  break;
  	case BITMAP_XOR:
  	  DOIT (^);
  	  break;
*************** bitmap_release_memory ()
*** 675,678 ****
--- 677,714 ----
        bitmap_obstack_init = FALSE;
        obstack_free (&bitmap_obstack, NULL_PTR);
      }
+ }
+
+ int
+ bitmap_union_of_diff (dst, a, b, c)
+      bitmap dst;
+      bitmap a;
+      bitmap b;
+      bitmap c;
+ {
+   int changed = 0;
+   bitmap temp = BITMAP_ALLOCA ();
+   bitmap_operation (temp, b, c, BITMAP_AND_COMPL);
+   changed = bitmap_operation (dst, temp, a, BITMAP_IOR);
+   return changed;
+ }
+
+ int
+ bitmap_first_set_bit (a)
+      bitmap a;
+ {
+   int i;
+   EXECUTE_IF_SET_IN_BITMAP (a, 0, i, return i;);
+   return -1;
+ }
+
+ int
+ bitmap_last_set_bit (a)
+      bitmap a;
+ {
+   int i;
+   EXECUTE_IF_SET_IN_BITMAP (a, 0, i, );
+   if (bitmap_bit_p (a, i))
+     return i;
+   return -1;
  }
Index: bitmap.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/bitmap.h,v
retrieving revision 1.18
diff -c -3 -p -w -B -b -r1.18 bitmap.h
*** bitmap.h	2001/04/12 22:27:22	1.18
--- bitmap.h	2001/04/24 16:46:13
*************** enum bitmap_bits {
*** 59,65 ****
    BITMAP_AND,			/* TO = FROM1 & FROM2 */
    BITMAP_AND_COMPL,		/* TO = FROM1 & ~ FROM2 */
    BITMAP_IOR,			/* TO = FROM1 | FROM2 */
!   BITMAP_XOR			/* TO = FROM1 ^ FROM2 */
  };

  /* Global data */
--- 60,67 ----
    BITMAP_AND,			/* TO = FROM1 & FROM2 */
    BITMAP_AND_COMPL,		/* TO = FROM1 & ~ FROM2 */
    BITMAP_IOR,			/* TO = FROM1 | FROM2 */
!   BITMAP_XOR,			/* TO = FROM1 ^ FROM2 */
!   BITMAP_IOR_COMPL			/* TO = FROM1 | ~FROM2 */
  };

  /* Global data */
*************** extern bitmap bitmap_initialize PARAMS (
*** 103,108 ****
--- 105,119 ----

  /* Release all memory held by bitmaps.  */
  extern void bitmap_release_memory PARAMS ((void));
+
+ /* A few compatibility/functions macros for compatibility with sbitmaps */
+ #define dump_bitmap(a, b) bitmap_print (a,b,"","\n")
+ #define bitmap_zero(a) bitmap_clear (a)
+ #define bitmap_a_or_b(a,b,c) bitmap_operation (a, b, c, BITMAP_IOR)
+ #define bitmap_a_and_b(a,b,c) bitmap_operation (a, b, c, BITMAP_AND)
+ extern int bitmap_union_of_diff PARAMS((bitmap, bitmap, bitmap, bitmap));
+ extern int bitmap_first_set_bit PARAMS((bitmap));
+ extern int bitmap_last_set_bit PARAMS((bitmap));

  /* Allocate a bitmap with oballoc.  */
  #define BITMAP_OBSTACK_ALLOC(OBSTACK)				\


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