bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
{
bitmap_obstack *bit_obstack = head->obstack;
-
+
elt->next = NULL;
if (bit_obstack)
{
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);
{
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. */
head->current = prev;
head->indx = prev->indx;
}
- }
+ }
else
{
head->first = NULL;
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
{
if (!bit_obstack)
bit_obstack = &bitmap_default_obstack;
-
+
bit_obstack->elements = NULL;
bit_obstack->heads = NULL;
obstack_free (&bit_obstack->obstack, NULL);
\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,
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
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;
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_element *b_elt = b->first;
bitmap_element *next;
- if (a == b)
+ if (a == b)
return;
while (a_elt && b_elt)
bitmap_element *dst_prev = NULL;
gcc_assert (dst != a && dst != b);
-
+
if (a == b)
{
bitmap_clear (dst);
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--;)
{
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)
if (!elt)
return;
}
- else
+ else
elt = head->current;
}
else
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;
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;
}
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. */
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;
}
}
elt = next_elt;
}
-
+
if (elt)
{
head->current = elt;
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);
{
/* 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, 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;
}
}
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, 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;
}
for (ix = BITMAP_ELEMENT_WORDS; ix--;)
{
BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
-
+
a_elt->bits[ix] = r;
}
else
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;
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);
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"