OSDN Git Service

PR target/29777
[pf3gnuchains/gcc-fork.git] / gcc / bitmap.c
index f69fd27..4ac38b0 100644 (file)
@@ -50,7 +50,7 @@ static inline void
 bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
 {
   bitmap_obstack *bit_obstack = head->obstack;
-  
+
   elt->next = NULL;
   if (bit_obstack)
     {
@@ -89,7 +89,7 @@ bitmap_element_free (bitmap head, bitmap_element *elt)
       head->current = next != 0 ? next : prev;
       if (head->current)
        head->indx = head->current->indx;
-      else 
+      else
        head->indx = 0;
     }
   bitmap_elem_to_freelist (head, elt);
@@ -102,11 +102,11 @@ bitmap_element_allocate (bitmap head)
 {
   bitmap_element *element;
   bitmap_obstack *bit_obstack = head->obstack;
-      
+
   if (bit_obstack)
     {
       element = bit_obstack->elements;
-      
+
       if (element)
        /* Use up the inner list first before looking at the next
           element of the outer list.  */
@@ -163,7 +163,7 @@ bitmap_elt_clear_from (bitmap head, bitmap_element *elt)
          head->current = prev;
          head->indx = prev->indx;
        }
-    } 
+    }
   else
     {
       head->first = NULL;
@@ -171,10 +171,10 @@ bitmap_elt_clear_from (bitmap head, bitmap_element *elt)
       head->indx = 0;
     }
 
-  /* Put the entire list onto the free list in one operation. */ 
+  /* Put the entire list onto the free list in one operation. */
   if (bit_obstack)
     {
-      elt->prev = bit_obstack->elements; 
+      elt->prev = bit_obstack->elements;
       bit_obstack->elements = elt;
     }
   else
@@ -222,7 +222,7 @@ bitmap_obstack_release (bitmap_obstack *bit_obstack)
 {
   if (!bit_obstack)
     bit_obstack = &bitmap_default_obstack;
-  
+
   bit_obstack->elements = NULL;
   bit_obstack->heads = NULL;
   obstack_free (&bit_obstack->obstack, NULL);
@@ -529,7 +529,7 @@ bitmap_bit_p (bitmap head, int bit)
 \f
 #if GCC_VERSION < 3400
 /* Table of number of set bits in a character, indexed by value of char.  */
-static unsigned char popcount_table[] = 
+static unsigned char popcount_table[] =
 {
     0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
     1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
@@ -571,13 +571,13 @@ bitmap_count_bits (bitmap a)
         of BITMAP_WORD is not material.  */
          count += __builtin_popcountl (elt->bits[ix]);
 #else
-         count += bitmap_popcount (elt->bits[ix]);       
+         count += bitmap_popcount (elt->bits[ix]);
 #endif
        }
     }
   return count;
 }
-      
+
 
 
 /* Return the bit number of the first set bit in the bitmap.  The
@@ -590,7 +590,7 @@ bitmap_first_set_bit (bitmap a)
   unsigned bit_no;
   BITMAP_WORD word;
   unsigned ix;
-  
+
   gcc_assert (elt);
   bit_no = elt->indx * BITMAP_ELEMENT_ALL_BITS;
   for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
@@ -625,7 +625,7 @@ bitmap_first_set_bit (bitmap a)
     word >>= 2, bit_no += 2;
   if (!(word & 0x1))
     word >>= 1, bit_no += 1;
-  
+
  gcc_assert (word & 1);
 #endif
  return bit_no;
@@ -664,7 +664,7 @@ bitmap_and (bitmap dst, bitmap a, bitmap b)
 
          if (!dst_elt)
            dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
-         else 
+         else
            dst_elt->indx = a_elt->indx;
          for (ix = BITMAP_ELEMENT_WORDS; ix--;)
            {
@@ -697,7 +697,7 @@ bitmap_and_into (bitmap a, bitmap b)
   bitmap_element *b_elt = b->first;
   bitmap_element *next;
 
-  if (a == b) 
+  if (a == b)
     return;
 
   while (a_elt && b_elt)
@@ -746,7 +746,7 @@ bitmap_and_compl (bitmap dst, bitmap a, bitmap b)
   bitmap_element *dst_prev = NULL;
 
   gcc_assert (dst != a && dst != b);
-  
+
   if (a == b)
     {
       bitmap_clear (dst);
@@ -777,7 +777,7 @@ bitmap_and_compl (bitmap dst, bitmap a, bitmap b)
 
          if (!dst_elt)
            dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
-         else 
+         else
            dst_elt->indx = a_elt->indx;
          for (ix = BITMAP_ELEMENT_WORDS; ix--;)
            {
@@ -869,7 +869,7 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
      to the result.  If the current is less than first index, find the
      next one.  Otherwise, just set elt to be current.  */
   if (!elt)
-    { 
+    {
       if (head->current)
        {
          if (head->indx < first_index)
@@ -878,7 +878,7 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
              if (!elt)
                return;
            }
-         else 
+         else
            elt = head->current;
        }
       else
@@ -895,11 +895,11 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
       if (elt_start_bit >= start && elt_end_bit_plus1 <= end_bit_plus1)
        /* Get rid of the entire elt and go to the next one.  */
        bitmap_element_free (head, elt);
-      else 
+      else
        {
          /* Going to have to knock out some bits in this elt.  */
-         unsigned int first_word_to_mod; 
-         BITMAP_WORD first_mask; 
+         unsigned int first_word_to_mod;
+         BITMAP_WORD first_mask;
          unsigned int last_word_to_mod;
          BITMAP_WORD last_mask;
          unsigned int i;
@@ -912,7 +912,7 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
              first_word_to_mod = (start - elt_start_bit) / BITMAP_WORD_BITS;
 
              /* This mask should have 1s in all bits >= start position. */
-             first_mask = 
+             first_mask =
                (((BITMAP_WORD) 1) << ((start % BITMAP_WORD_BITS))) - 1;
              first_mask = ~first_mask;
            }
@@ -922,8 +922,8 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
              first_word_to_mod = 0;
              first_mask = 0;
              first_mask = ~first_mask;
-           }         
-           
+           }
+
          if (elt_end_bit_plus1 <= end_bit_plus1)
            {
              /* The last bit to turn off is beyond this elt.  */
@@ -934,11 +934,11 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
          else
            {
              /* The last bit to turn off is inside to this elt.  */
-             last_word_to_mod = 
+             last_word_to_mod =
                (end_bit_plus1 - elt_start_bit) / BITMAP_WORD_BITS;
 
              /* The last mask should have 1s below the end bit.  */
-             last_mask = 
+             last_mask =
                (((BITMAP_WORD) 1) << (((end_bit_plus1) % BITMAP_WORD_BITS))) - 1;
            }
 
@@ -967,7 +967,7 @@ bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
        }
       elt = next_elt;
     }
-  
+
   if (elt)
     {
       head->current = elt;
@@ -1053,7 +1053,7 @@ bitmap_ior (bitmap dst, bitmap a, bitmap b)
   bitmap_element *a_elt = a->first;
   bitmap_element *b_elt = b->first;
   bitmap_element *dst_prev = NULL;
-  bool changed = false;  
+  bool changed = false;
 
   gcc_assert (dst != a && dst != b);
 
@@ -1063,7 +1063,7 @@ bitmap_ior (bitmap dst, bitmap a, bitmap b)
        {
          /* Matching elts, generate A | B.  */
          unsigned ix;
-             
+
          if (!changed && dst_elt && dst_elt->indx == a_elt->indx)
            {
              for (ix = BITMAP_ELEMENT_WORDS; ix--;)
@@ -1082,12 +1082,12 @@ bitmap_ior (bitmap dst, bitmap a, bitmap b)
              changed = true;
              if (!dst_elt)
                dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
-             else 
+             else
                dst_elt->indx = a_elt->indx;
              for (ix = BITMAP_ELEMENT_WORDS; ix--;)
                {
                  BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
-                 
+
                  dst_elt->bits[ix] = r;
                }
            }
@@ -1115,7 +1115,7 @@ bitmap_ior (bitmap dst, bitmap a, bitmap b)
          if (!changed && dst_elt && dst_elt->indx == src->indx)
            {
              unsigned ix;
-             
+
              for (ix = BITMAP_ELEMENT_WORDS; ix--;)
                if (src->bits[ix] != dst_elt->bits[ix])
                  {
@@ -1128,11 +1128,11 @@ bitmap_ior (bitmap dst, bitmap a, bitmap b)
              changed = true;
              if (!dst_elt)
                dst_elt = bitmap_elt_insert_after (dst, dst_prev, src->indx);
-             else 
+             else
                dst_elt->indx = src->indx;
              memcpy (dst_elt->bits, src->bits, sizeof (dst_elt->bits));
            }
-         
+
          dst_prev = dst_elt;
          dst_elt = dst_elt->next;
        }
@@ -1187,7 +1187,7 @@ bitmap_ior_into (bitmap a, bitmap b)
            for (ix = BITMAP_ELEMENT_WORDS; ix--;)
              {
                BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
-               
+
                a_elt->bits[ix] = r;
              }
          else
@@ -1274,7 +1274,7 @@ bitmap_xor (bitmap dst, bitmap a, bitmap b)
 
          if (!dst_elt)
            dst_elt = bitmap_elt_insert_after (dst, dst_prev, src->indx);
-         else 
+         else
            dst_elt->indx = src->indx;
          memcpy (dst_elt->bits, src->bits, sizeof (dst_elt->bits));
          dst_prev = dst_elt;
@@ -1354,7 +1354,7 @@ bitmap_equal_p (bitmap a, bitmap b)
   bitmap_element *a_elt;
   bitmap_element *b_elt;
   unsigned ix;
-  
+
   for (a_elt = a->first, b_elt = b->first;
        a_elt && b_elt;
        a_elt = a_elt->next, b_elt = b_elt->next)
@@ -1376,7 +1376,7 @@ bitmap_intersect_p (bitmap a, bitmap b)
   bitmap_element *a_elt;
   bitmap_element *b_elt;
   unsigned ix;
-  
+
   for (a_elt = a->first, b_elt = b->first;
        a_elt && b_elt;)
     {
@@ -1447,7 +1447,7 @@ bitmap_ior_and_compl_into (bitmap a, bitmap from1, bitmap from2)
 {
   bitmap_head tmp;
   bool changed;
-  
+
   bitmap_initialize (&tmp, &bitmap_default_obstack);
   bitmap_and_compl (&tmp, from1, from2);
   changed = bitmap_ior_into (a, &tmp);
@@ -1520,4 +1520,21 @@ bitmap_print (FILE *file, bitmap head, const char *prefix, const char *suffix)
   fputs (suffix, file);
 }
 
+/* Compute hash of bitmap (for purposes of hashing).  */
+hashval_t
+bitmap_hash (bitmap head)
+{
+  bitmap_element *ptr;
+  BITMAP_WORD hash = 0;
+  int ix;
+
+  for (ptr = head->first; ptr; ptr = ptr->next)
+    {
+      hash ^= ptr->indx;
+      for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
+       hash ^= ptr->bits[ix];
+    }
+  return (hashval_t)hash;
+}
+
 #include "gt-bitmap.h"