/* Functions to support general ended bitmaps.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GCC.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA. */
#include "config.h"
#include "system.h"
static bitmap_element *bitmap_element_allocate (bitmap);
static int bitmap_element_zerop (bitmap_element *);
static void bitmap_element_link (bitmap, bitmap_element *);
-static bitmap_element *bitmap_elt_insert_after (bitmap, bitmap_element *);
+static bitmap_element *bitmap_elt_insert_after (bitmap, bitmap_element *, unsigned int);
static void bitmap_elt_clear_from (bitmap, bitmap_element *);
static bitmap_element *bitmap_find_bit (bitmap, unsigned int);
\f
bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
{
bitmap_obstack *bit_obstack = head->obstack;
-
+
+ elt->next = NULL;
if (bit_obstack)
{
- elt->next = bit_obstack->elements;
+ elt->prev = bit_obstack->elements;
bit_obstack->elements = elt;
}
else
{
- elt->next = bitmap_ggc_free;
+ elt->prev = bitmap_ggc_free;
bitmap_ggc_free = elt;
}
}
head->current = next != 0 ? next : prev;
if (head->current)
head->indx = head->current->indx;
+ else
+ head->indx = 0;
}
bitmap_elem_to_freelist (head, elt);
}
{
bitmap_element *element;
bitmap_obstack *bit_obstack = head->obstack;
-
+
if (bit_obstack)
{
element = bit_obstack->elements;
-
+
if (element)
- bit_obstack->elements = element->next;
+ /* Use up the inner list first before looking at the next
+ element of the outer list. */
+ if (element->next)
+ {
+ bit_obstack->elements = element->next;
+ bit_obstack->elements->prev = element->prev;
+ }
+ else
+ /* Inner list was just a singleton. */
+ bit_obstack->elements = element->prev;
else
element = XOBNEW (&bit_obstack->obstack, bitmap_element);
}
{
element = bitmap_ggc_free;
if (element)
- bitmap_ggc_free = element->next;
+ /* Use up the inner list first before looking at the next
+ element of the outer list. */
+ if (element->next)
+ {
+ bitmap_ggc_free = element->next;
+ bitmap_ggc_free->prev = element->prev;
+ }
+ else
+ /* Inner list was just a singleton. */
+ bitmap_ggc_free = element->prev;
else
element = GGC_NEW (bitmap_element);
}
void
bitmap_elt_clear_from (bitmap head, bitmap_element *elt)
{
- bitmap_element *next;
+ bitmap_element *prev;
+ bitmap_obstack *bit_obstack = head->obstack;
+
+ if (!elt) return;
- while (elt)
+ prev = elt->prev;
+ if (prev)
{
- next = elt->next;
- bitmap_element_free (head, elt);
- elt = next;
+ prev->next = NULL;
+ if (head->current->indx > prev->indx)
+ {
+ head->current = prev;
+ head->indx = prev->indx;
+ }
+ }
+ else
+ {
+ head->first = NULL;
+ head->current = NULL;
+ head->indx = 0;
+ }
+
+ /* Put the entire list onto the free list in one operation. */
+ if (bit_obstack)
+ {
+ elt->prev = bit_obstack->elements;
+ bit_obstack->elements = elt;
+ }
+ else
+ {
+ elt->prev = bitmap_ggc_free;
+ bitmap_ggc_free = elt;
}
}
inline void
bitmap_clear (bitmap head)
{
- bitmap_element *element, *next;
-
- for (element = head->first; element != 0; element = next)
- {
- next = element->next;
- bitmap_elem_to_freelist (head, element);
- }
-
- head->first = head->current = 0;
+ if (head->first)
+ bitmap_elt_clear_from (head, head->first);
}
\f
/* Initialize a bitmap obstack. If BIT_OBSTACK is NULL, initialize
{
if (!bit_obstack)
bit_obstack = &bitmap_default_obstack;
-
+
bit_obstack->elements = NULL;
bit_obstack->heads = NULL;
obstack_free (&bit_obstack->obstack, NULL);
new element. */
static bitmap_element *
-bitmap_elt_insert_after (bitmap head, bitmap_element *elt)
+bitmap_elt_insert_after (bitmap head, bitmap_element *elt, unsigned int indx)
{
bitmap_element *node = bitmap_element_allocate (head);
+ node->indx = indx;
if (!elt)
{
if (!head->current)
- head->current = node;
+ {
+ head->current = node;
+ head->indx = indx;
+ }
node->next = head->first;
if (node->next)
node->next->prev = node;
bitmap_copy (bitmap to, bitmap from)
{
bitmap_element *from_ptr, *to_ptr = 0;
-#if BITMAP_ELEMENT_WORDS != 2
- unsigned i;
-#endif
bitmap_clear (to);
bitmap_element *to_elt = bitmap_element_allocate (to);
to_elt->indx = from_ptr->indx;
-
-#if BITMAP_ELEMENT_WORDS == 2
- to_elt->bits[0] = from_ptr->bits[0];
- to_elt->bits[1] = from_ptr->bits[1];
-#else
- for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
- to_elt->bits[i] = from_ptr->bits[i];
-#endif
+ memcpy (to_elt->bits, from_ptr->bits, sizeof (to_elt->bits));
/* Here we have a special case of bitmap_element_link, for the case
where we know the links are being entered in sequence. */
|| head->indx == indx)
return head->current;
- if (head->indx > indx)
+ if (head->indx < indx)
+ /* INDX is beyond head->indx. Search from head->current
+ forward. */
+ for (element = head->current;
+ element->next != 0 && element->indx < indx;
+ element = element->next)
+ ;
+
+ else if (head->indx / 2 < indx)
+ /* INDX is less than head->indx and closer to head->indx than to
+ 0. Search from head->current backward. */
for (element = head->current;
element->prev != 0 && element->indx > indx;
element = element->prev)
;
else
- for (element = head->current;
+ /* INDX is less than head->indx and closer to 0 than to
+ head->indx. Search from head->first forward. */
+ for (element = head->first;
element->next != 0 && element->indx < indx;
element = element->next)
;
return (ptr->bits[word_num] >> bit_num) & 1;
}
\f
+#if GCC_VERSION < 3400
+/* Table of number of set bits in a character, indexed by value of char. */
+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,
+ 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,
+ 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
+ 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,
+ 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
+ 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
+ 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
+};
+
+static unsigned long
+bitmap_popcount (BITMAP_WORD a)
+{
+ unsigned long ret = 0;
+ unsigned i;
+
+ /* Just do this the table way for now */
+ for (i = 0; i < BITMAP_WORD_BITS; i+= 8)
+ ret += popcount_table[(a >> i) & 0xff];
+ return ret;
+}
+#endif
+/* Count the number of bits set in the bitmap, and return it. */
+
+unsigned long
+bitmap_count_bits (bitmap a)
+{
+ unsigned long count = 0;
+ bitmap_element *elt;
+ unsigned ix;
+
+ for (elt = a->first; elt; elt = elt->next)
+ {
+ for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
+ {
+#if GCC_VERSION >= 3400
+ /* Note that popcountl matches BITMAP_WORD in type, so the actual size
+ of BITMAP_WORD is not material. */
+ count += __builtin_popcountl (elt->bits[ix]);
+#else
+ count += bitmap_popcount (elt->bits[ix]);
+#endif
+ }
+ }
+ return count;
+}
+
+
+
/* Return the bit number of the first set bit in the bitmap. The
bitmap must be non-empty. */
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++)
word >>= 2, bit_no += 2;
if (!(word & 0x1))
word >>= 1, bit_no += 1;
-
+
gcc_assert (word & 1);
#endif
return bit_no;
bitmap_element *b_elt = b->first;
bitmap_element *dst_prev = NULL;
- gcc_assert (dst != a && dst != b && a != b);
+ gcc_assert (dst != a && dst != b);
+
+ if (a == b)
+ {
+ bitmap_copy (dst, a);
+ return;
+ }
+
while (a_elt && b_elt)
{
if (a_elt->indx < b_elt->indx)
BITMAP_WORD ior = 0;
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
-
- dst_elt->indx = a_elt->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
+ else
+ dst_elt->indx = a_elt->indx;
for (ix = BITMAP_ELEMENT_WORDS; ix--;)
{
BITMAP_WORD r = a_elt->bits[ix] & b_elt->bits[ix];
bitmap_element *b_elt = b->first;
bitmap_element *next;
- gcc_assert (a != b);
+ if (a == b)
+ return;
+
while (a_elt && b_elt)
{
if (a_elt->indx < b_elt->indx)
bitmap_element *b_elt = b->first;
bitmap_element *dst_prev = NULL;
- gcc_assert (dst != a && dst != b && a != b);
-
+ gcc_assert (dst != a && dst != b);
+
+ if (a == b)
+ {
+ bitmap_clear (dst);
+ return;
+ }
+
while (a_elt)
{
if (!b_elt || a_elt->indx < b_elt->indx)
{
/* Copy a_elt. */
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
-
- dst_elt->indx = a_elt->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
+ else
+ dst_elt->indx = a_elt->indx;
memcpy (dst_elt->bits, a_elt->bits, sizeof (dst_elt->bits));
dst_prev = dst_elt;
dst_elt = dst_elt->next;
BITMAP_WORD ior = 0;
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
-
- dst_elt->indx = a_elt->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
+ 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->indx = dst->current->indx;
}
-/* A &= ~B */
+/* A &= ~B. Returns true if A changes */
-void
+bool
bitmap_and_compl_into (bitmap a, bitmap b)
{
bitmap_element *a_elt = a->first;
bitmap_element *b_elt = b->first;
bitmap_element *next;
+ BITMAP_WORD changed = 0;
+
+ if (a == b)
+ {
+ if (bitmap_empty_p (a))
+ return false;
+ else
+ {
+ bitmap_clear (a);
+ return true;
+ }
+ }
- gcc_assert (a != b);
while (a_elt && b_elt)
{
if (a_elt->indx < b_elt->indx)
for (ix = BITMAP_ELEMENT_WORDS; ix--;)
{
- BITMAP_WORD r = a_elt->bits[ix] & ~b_elt->bits[ix];
+ BITMAP_WORD cleared = a_elt->bits[ix] & b_elt->bits[ix];
+ BITMAP_WORD r = a_elt->bits[ix] ^ cleared;
+
+ a_elt->bits[ix] = r;
+ changed |= cleared;
+ ior |= r;
+ }
+ next = a_elt->next;
+ if (!ior)
+ bitmap_element_free (a, a_elt);
+ a_elt = next;
+ b_elt = b_elt->next;
+ }
+ }
+ gcc_assert (!a->current == !a->first);
+ gcc_assert (!a->current || a->indx == a->current->indx);
+ return changed != 0;
+}
+
+/* Clear COUNT bits from START in HEAD. */
+void
+bitmap_clear_range (bitmap head, unsigned int start, unsigned int count)
+{
+ unsigned int first_index = start / BITMAP_ELEMENT_ALL_BITS;
+ unsigned int end_bit_plus1 = start + count;
+ unsigned int end_bit = end_bit_plus1 - 1;
+ unsigned int last_index = (end_bit) / BITMAP_ELEMENT_ALL_BITS;
+ bitmap_element *elt = bitmap_find_bit (head, start);
+
+ /* If bitmap_find_bit returns zero, the current is the closest block
+ 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)
+ {
+ elt = head->current->next;
+ if (!elt)
+ return;
+ }
+ else
+ elt = head->current;
+ }
+ else
+ return;
+ }
+
+ while (elt && (elt->indx <= last_index))
+ {
+ bitmap_element * next_elt = elt->next;
+ unsigned elt_start_bit = (elt->indx) * BITMAP_ELEMENT_ALL_BITS;
+ unsigned elt_end_bit_plus1 = elt_start_bit + BITMAP_ELEMENT_ALL_BITS;
+
+
+ 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
+ {
+ /* Going to have to knock out some bits in this elt. */
+ unsigned int first_word_to_mod;
+ BITMAP_WORD first_mask;
+ unsigned int last_word_to_mod;
+ BITMAP_WORD last_mask;
+ unsigned int i;
+ bool clear = true;
+
+ if (elt_start_bit <= start)
+ {
+ /* The first bit to turn off is somewhere inside this
+ elt. */
+ first_word_to_mod = (start - elt_start_bit) / BITMAP_WORD_BITS;
+
+ /* This mask should have 1s in all bits >= start position. */
+ first_mask =
+ (((BITMAP_WORD) 1) << ((start % BITMAP_WORD_BITS))) - 1;
+ first_mask = ~first_mask;
+ }
+ else
+ {
+ /* The first bit to turn off is below this start of this elt. */
+ 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. */
+ last_word_to_mod = BITMAP_ELEMENT_WORDS - 1;
+ last_mask = 0;
+ last_mask = ~last_mask;
+ }
+ else
+ {
+ /* The last bit to turn off is inside to this elt. */
+ 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 =
+ (((BITMAP_WORD) 1) << (((end_bit_plus1) % BITMAP_WORD_BITS))) - 1;
+ }
+
+
+ if (first_word_to_mod == last_word_to_mod)
+ {
+ BITMAP_WORD mask = first_mask & last_mask;
+ elt->bits[first_word_to_mod] &= ~mask;
+ }
+ else
+ {
+ elt->bits[first_word_to_mod] &= ~first_mask;
+ for (i = first_word_to_mod + 1; i < last_word_to_mod; i++)
+ elt->bits[i] = 0;
+ elt->bits[last_word_to_mod] &= ~last_mask;
+ }
+ for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
+ if (elt->bits[i])
+ {
+ clear = false;
+ break;
+ }
+ /* Check to see if there are any bits left. */
+ if (clear)
+ bitmap_element_free (head, elt);
+ }
+ elt = next_elt;
+ }
+
+ if (elt)
+ {
+ head->current = elt;
+ head->indx = head->current->indx;
+ }
+}
+
+/* A = ~A & B. */
+
+void
+bitmap_compl_and_into (bitmap a, bitmap b)
+{
+ bitmap_element *a_elt = a->first;
+ bitmap_element *b_elt = b->first;
+ bitmap_element *a_prev = NULL;
+ bitmap_element *next;
+
+ gcc_assert (a != b);
+
+ if (bitmap_empty_p (a))
+ {
+ bitmap_copy (a, b);
+ return;
+ }
+ if (bitmap_empty_p (b))
+ {
+ bitmap_clear (a);
+ return;
+ }
+
+ while (a_elt || b_elt)
+ {
+ if (!b_elt || (a_elt && a_elt->indx < b_elt->indx))
+ {
+ /* A is before B. Remove A */
+ next = a_elt->next;
+ a_prev = a_elt->prev;
+ bitmap_element_free (a, a_elt);
+ a_elt = next;
+ }
+ else if (!a_elt || b_elt->indx < a_elt->indx)
+ {
+ /* B is before A. Copy B. */
+ next = bitmap_elt_insert_after (a, a_prev, b_elt->indx);
+ memcpy (next->bits, b_elt->bits, sizeof (next->bits));
+ a_prev = next;
+ b_elt = b_elt->next;
+ }
+ else
+ {
+ /* Matching elts, generate A = ~A & B. */
+ unsigned ix;
+ BITMAP_WORD ior = 0;
+
+ for (ix = BITMAP_ELEMENT_WORDS; ix--;)
+ {
+ BITMAP_WORD cleared = a_elt->bits[ix] & b_elt->bits[ix];
+ BITMAP_WORD r = b_elt->bits[ix] ^ cleared;
a_elt->bits[ix] = r;
ior |= r;
next = a_elt->next;
if (!ior)
bitmap_element_free (a, a_elt);
+ else
+ a_prev = a_elt;
a_elt = next;
b_elt = b_elt->next;
}
}
gcc_assert (!a->current == !a->first);
gcc_assert (!a->current || a->indx == a->current->indx);
+ return;
}
/* DST = A | B. Return true if DST changes. */
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);
- gcc_assert (dst != a && dst != b && a != b);
while (a_elt || b_elt)
{
if (a_elt && b_elt && a_elt->indx == b_elt->indx)
{
/* Matching elts, generate A | B. */
unsigned ix;
-
+
if (!changed && dst_elt && dst_elt->indx == a_elt->indx)
{
for (ix = BITMAP_ELEMENT_WORDS; ix--;)
{
changed = true;
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
- dst_elt->indx = a_elt->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
+ 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;
}
}
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])
{
{
changed = true;
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
- dst_elt->indx = src->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, src->indx);
+ 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;
}
bitmap_element *a_prev = NULL;
bool changed = false;
- gcc_assert (a != b);
+ if (a == b)
+ return false;
+
while (b_elt)
{
if (!a_elt || b_elt->indx < a_elt->indx)
{
/* Copy b_elt. */
- bitmap_element *dst = bitmap_elt_insert_after (a, a_prev);
-
- dst->indx = b_elt->indx;
+ bitmap_element *dst = bitmap_elt_insert_after (a, a_prev, b_elt->indx);
memcpy (dst->bits, b_elt->bits, sizeof (dst->bits));
a_prev = dst;
b_elt = b_elt->next;
for (ix = BITMAP_ELEMENT_WORDS; ix--;)
{
BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
-
+
a_elt->bits[ix] = r;
}
else
bitmap_element *b_elt = b->first;
bitmap_element *dst_prev = NULL;
- gcc_assert (dst != a && dst != b && a != b);
+ gcc_assert (dst != a && dst != b);
+ if (a == b)
+ {
+ bitmap_clear (dst);
+ return;
+ }
+
while (a_elt || b_elt)
{
if (a_elt && b_elt && a_elt->indx == b_elt->indx)
BITMAP_WORD ior = 0;
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
-
- dst_elt->indx = a_elt->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, a_elt->indx);
+ else
+ dst_elt->indx = a_elt->indx;
for (ix = BITMAP_ELEMENT_WORDS; ix--;)
{
BITMAP_WORD r = a_elt->bits[ix] ^ b_elt->bits[ix];
}
if (!dst_elt)
- dst_elt = bitmap_elt_insert_after (dst, dst_prev);
-
- dst_elt->indx = src->indx;
+ dst_elt = bitmap_elt_insert_after (dst, dst_prev, src->indx);
+ 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;
bitmap_element *b_elt = b->first;
bitmap_element *a_prev = NULL;
- gcc_assert (a != b);
+ if (a == b)
+ {
+ bitmap_clear (a);
+ return;
+ }
+
while (b_elt)
{
if (!a_elt || b_elt->indx < a_elt->indx)
{
/* Copy b_elt. */
- bitmap_element *dst = bitmap_elt_insert_after (a, a_prev);
-
- dst->indx = b_elt->indx;
+ bitmap_element *dst = bitmap_elt_insert_after (a, a_prev, b_elt->indx);
memcpy (dst->bits, b_elt->bits, sizeof (dst->bits));
a_prev = dst;
b_elt = b_elt->next;
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)
bitmap_element *a_elt;
bitmap_element *b_elt;
unsigned ix;
-
+
for (a_elt = a->first, b_elt = b->first;
a_elt && b_elt;)
{
{
bitmap_head tmp;
bool changed;
-
+
bitmap_initialize (&tmp, &bitmap_default_obstack);
bitmap_and_compl (&tmp, from1, from2);
changed = bitmap_ior_into (a, &tmp);
{
bitmap_element *ptr;
- fprintf (file, "\nfirst = " HOST_PTR_PRINTF
- " current = " HOST_PTR_PRINTF " indx = %u\n",
+ fprintf (file, "\nfirst = %p current = %p indx = %u\n",
(void *) head->first, (void *) head->current, head->indx);
for (ptr = head->first; ptr; ptr = ptr->next)
{
unsigned int i, j, col = 26;
- fprintf (file, "\t" HOST_PTR_PRINTF " next = " HOST_PTR_PRINTF
- " prev = " HOST_PTR_PRINTF " indx = %u\n\t\tbits = {",
+ fprintf (file, "\t%p next = %p prev = %p indx = %u\n\t\tbits = {",
(void*) ptr, (void*) ptr->next, (void*) ptr->prev, ptr->indx);
for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
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"