OSDN Git Service

2004-11-16 Eric Christopher <echristo@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / bitmap.h
index f46dcf4..fb466dc 100644 (file)
@@ -24,24 +24,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 /* Fundamental storage type for bitmap.  */
 
-/* typedef unsigned HOST_WIDE_INT BITMAP_WORD; */
-/* #define nBITMAP_WORD_BITS HOST_BITS_PER_WIDE_INT */
 typedef unsigned long BITMAP_WORD;
-#define nBITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG)
-#define BITMAP_WORD_BITS (unsigned) nBITMAP_WORD_BITS
+/* BITMAP_WORD_BITS needs to be unsigned, but cannot contain casts as
+   it is used in preprocessor directives -- hence the 1u.  */
+#define BITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG * 1u)
 
 /* Number of words to use for each element in the linked list.  */
 
 #ifndef BITMAP_ELEMENT_WORDS
-#define BITMAP_ELEMENT_WORDS ((128 + nBITMAP_WORD_BITS - 1) / nBITMAP_WORD_BITS)
+#define BITMAP_ELEMENT_WORDS ((128 + BITMAP_WORD_BITS - 1) / BITMAP_WORD_BITS)
 #endif
 
-/* Number of bits in each actual element of a bitmap.  We get slightly better
-   code for bit % BITMAP_ELEMENT_ALL_BITS and bit / BITMAP_ELEMENT_ALL_BITS if
-   bits is unsigned, assuming it is a power of 2.  */
+/* Number of bits in each actual element of a bitmap.  */
 
-#define BITMAP_ELEMENT_ALL_BITS \
-  ((unsigned) (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS))
+#define BITMAP_ELEMENT_ALL_BITS (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS)
 
 /* Bitmap set element.  We use a linked list to hold only the bits that
    are set.  This allows for use to grow the bitset dynamically without
@@ -66,15 +62,6 @@ typedef struct bitmap_head_def GTY(()) {
 } bitmap_head;
 typedef struct bitmap_head_def *bitmap;
 
-/* Enumeration giving the various operations we support.  */
-enum bitmap_bits {
-  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_element bitmap_zero_bits;        /* Zero bitmap element */
 
@@ -97,23 +84,23 @@ extern bool bitmap_intersect_compl_p (bitmap, bitmap);
 /* True if MAP is an empty bitmap.  */
 #define bitmap_empty_p(MAP) (!(MAP)->first)
 
-/* Perform an operation on two bitmaps, yielding a third.  */
-extern int bitmap_operation (bitmap, bitmap, bitmap, enum bitmap_bits);
-
-#define bitmap_and(DST,A,B) (void)bitmap_operation (DST,A,B,BITMAP_AND)
-#define bitmap_and_into(DST_SRC,B) (void)bitmap_operation (DST_SRC,DST_SRC,B,BITMAP_AND)
-#define bitmap_and_compl(DST,A,B) (void)bitmap_operation (DST,A,B,BITMAP_AND_COMPL)
-#define bitmap_and_compl_into(DST_SRC,B) (void)bitmap_operation (DST_SRC,DST_SRC,B,BITMAP_AND_COMPL)
-#define bitmap_ior(DST,A,B) (void)bitmap_operation (DST,A,B,BITMAP_IOR)
-#define bitmap_ior_into(DST_SRC,B) (void)bitmap_operation (DST_SRC,DST_SRC,B,BITMAP_IOR)
-#define bitmap_ior_compl(DST,A,B) (void)bitmap_operation (DST,A,Br,BITMAP_IOR_COMPL)
-#define bitmap_xor(DST,A,B) (void)bitmap_operation (DST,A,B,BITMAP_XOR)
-#define bitmap_xor_into(DST_SRC,B) (void)bitmap_operation (DST_SRC,DST_SRC,B,BITMAP_XOR)
-
-/* `or' into one bitmap the `and' of a second bitmap witih the complement
-   of a third. Return nonzero if the bitmap changes.  */
-extern bool bitmap_ior_and_compl_into (bitmap, bitmap, bitmap);
-extern bool bitmap_ior_and_compl (bitmap, bitmap, bitmap, bitmap);
+/* Boolean operations on bitmaps.  The _into variants are two operand
+   versions that modify the first source operand.  The other variants
+   are three operand versions that to not destroy the source bitmaps.
+   The operations supported are &, & ~, |, ^.  */
+extern void bitmap_and (bitmap, bitmap, bitmap);
+extern void bitmap_and_into (bitmap, bitmap);
+extern void bitmap_and_compl (bitmap, bitmap, bitmap);
+extern void bitmap_and_compl_into (bitmap, bitmap);
+extern bool bitmap_ior (bitmap, bitmap, bitmap);
+extern bool bitmap_ior_into (bitmap, bitmap);
+extern void bitmap_xor (bitmap, bitmap, bitmap);
+extern void bitmap_xor_into (bitmap, bitmap);
+
+/* DST = A | (B & ~C).  Return true if DST changes.  */
+extern bool bitmap_ior_and_compl (bitmap DST, bitmap A, bitmap B, bitmap C);
+/* A |= (B & ~C).  Return true if A changes.  */
+extern bool bitmap_ior_and_compl_into (bitmap DST, bitmap B, bitmap C);
 
 /* Clear a single register in a register set.  */
 extern void bitmap_clear_bit (bitmap, int);
@@ -141,8 +128,7 @@ extern void bitmap_release_memory (void);
 /* A few compatibility/functions macros for compatibility with sbitmaps */
 #define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n")
 #define bitmap_zero(a) bitmap_clear (a)
-extern int bitmap_first_set_bit (bitmap);
-extern int bitmap_last_set_bit (bitmap);
+extern unsigned bitmap_first_set_bit (bitmap);
 
 /* Allocate a bitmap with oballoc.  */
 #define BITMAP_OBSTACK_ALLOC(OBSTACK)                          \
@@ -280,7 +266,7 @@ bmp_iter_and_init (bitmap_iterator *bi, bitmap map1, bitmap map2,
       bi->elt2 = bi->elt2->next;
     }
 
-  /* If we're at the same index, then we have some intersecting bits.   */
+  /* If we're at the same index, then we have some intersecting bits.  */
   if (bi->elt1->indx == bi->elt2->indx)
     {
       /* We might have advanced beyond the start_bit, so reinitialize
@@ -358,7 +344,7 @@ bmp_iter_and_compl_init (bitmap_iterator *bi, bitmap map1, bitmap map2,
 }
 
 /* Advance to the next bit in BI.  We don't advance to the next
-   non-zero bit yet.  */
+   nonzero bit yet.  */
 
 static inline void
 bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
@@ -367,14 +353,14 @@ bmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)
   *bit_no += 1;
 }
 
-/* Advance to the next non-zero bit of a single bitmap, we will have
+/* Advance to the next nonzero bit of a single bitmap, we will have
    already advanced past the just iterated bit.  Return true if there
    is a bit to iterate.  */
 
 static inline bool
 bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
 {
-  /* If our current word is non-zero, it contains the bit we want.  */
+  /* If our current word is nonzero, it contains the bit we want.  */
   if (bi->bits)
     {
     next_bit:
@@ -395,7 +381,7 @@ bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
 
   while (1)
     {
-      /* Find the next non-zero word in this elt.  */
+      /* Find the next nonzero word in this elt.  */
       while (bi->word_no != BITMAP_ELEMENT_WORDS)
        {
          bi->bits = bi->elt1->bits[bi->word_no];
@@ -414,14 +400,14 @@ bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
     }
 }
 
-/* Advance to the next non-zero bit of an intersecting pair of
-   bitmaps.  We will have alreadt advanced past the just iterated bit.
+/* Advance to the next nonzero bit of an intersecting pair of
+   bitmaps.  We will have already advanced past the just iterated bit.
    Return true if there is a bit to iterate.  */
 
 static inline bool
 bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no)
 {
-  /* If our current word is non-zero, it contains the bit we want.  */
+  /* If our current word is nonzero, it contains the bit we want.  */
   if (bi->bits)
     {
     next_bit:
@@ -442,7 +428,7 @@ bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no)
   
   while (1)
     {
-      /* Find the next non-zero word in this elt.  */
+      /* Find the next nonzero word in this elt.  */
       while (bi->word_no != BITMAP_ELEMENT_WORDS)
        {
          bi->bits = bi->elt1->bits[bi->word_no] & bi->elt2->bits[bi->word_no];
@@ -481,14 +467,14 @@ bmp_iter_and (bitmap_iterator *bi, unsigned *bit_no)
     }
 }
 
-/* Advance to the next non-zero bit in the intersection of
+/* Advance to the next nonzero bit in the intersection of
    complemented bitmaps.  We will have already advanced past the just
    iterated bit.  */
 
 static inline bool
 bmp_iter_and_compl (bitmap_iterator *bi, unsigned *bit_no)
 {
-  /* If our current word is non-zero, it contains the bit we want.  */
+  /* If our current word is nonzero, it contains the bit we want.  */
   if (bi->bits)
     {
     next_bit:
@@ -509,7 +495,7 @@ bmp_iter_and_compl (bitmap_iterator *bi, unsigned *bit_no)
 
   while (1)
     {
-      /* Find the next non-zero word in this elt.  */
+      /* Find the next nonzero word in this elt.  */
       while (bi->word_no != BITMAP_ELEMENT_WORDS)
        {
          bi->bits = bi->elt1->bits[bi->word_no];