/* Sparse array-based bitmaps.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
This file is part of GCC.
unsigned int i = 0;
ebitmap_iterator ebi;
bool foundbit = false;
-
+
/* This is not the fastest way to do this, we could simply look for
the popcount, and start there, but this function is not used
anywhere speed critical. */
{
foundbit = true;
}
-
+
if (foundbit)
return i;
static inline void
ebitmap_array_clear (ebitmap map)
{
- if (map->elts)
+ if (map->elts)
{
free (map->elts);
map->elts = NULL;
unsigned int bitindex, shift;
bool have_eltwordindex = false;
EBITMAP_ELT_TYPE *elt_ptr;
-
+
/* If the bit can't exist in our bitmap, just return. */
if (map->numwords == 0)
return;
if (wordindex >= map->wordmask->n_bits
|| !TEST_BIT (map->wordmask, wordindex))
return;
-
+
if (map->cache != NULL && map->cacheindex == wordindex)
elt_ptr = map->cache;
else
elt_ptr = &map->elts[eltwordindex];
have_eltwordindex = true;
}
-
+
bitindex = bit % EBITMAP_ELT_BITS;
shift = bitindex;
-
+
*(elt_ptr) &= ~(((EBITMAP_ELT_TYPE)1) << shift);
/* Clear out the empty words. */
{
if (!have_eltwordindex)
eltwordindex = sbitmap_popcount (map->wordmask, wordindex);
-
- if (map->cache != NULL && map->cacheindex == eltwordindex)
- map->cache = NULL;
+
+ if (map->cache != NULL)
+ {
+ if (map->cacheindex == wordindex)
+ map->cache = NULL;
+ else if (map->cacheindex > wordindex)
+ map->cache = map->cache - 1;
+ }
RESET_BIT (map->wordmask, wordindex);
for (i = 0; i < dst->numwords; i++)
gcc_assert (dst->elts[i] != 0);
- verify_popcount (dst->wordmask);
+ sbitmap_verify_popcount (dst->wordmask);
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == dst->numwords);
}
for (i = 0; i < dst->numwords; i++)
gcc_assert (dst->elts[i] != 0);
- verify_popcount (dst->wordmask);
+ sbitmap_verify_popcount (dst->wordmask);
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == dst->numwords);
}
EXECUTE_IF_SET_IN_EBITMAP (dstcopy, 0, i, ebi)
gcc_assert (ebitmap_bit_p (dst, i));
- verify_popcount (dst->wordmask);
+ sbitmap_verify_popcount (dst->wordmask);
gcc_assert (changed == !ebitmap_equal_p (dst, dstcopy));
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == dst->numwords);
EXECUTE_IF_SET_IN_EBITMAP (src2, 0, i, ebi)
gcc_assert (ebitmap_bit_p (dst, i));
}
- verify_popcount (dst->wordmask);
+ sbitmap_verify_popcount (dst->wordmask);
gcc_assert (changed == !ebitmap_equal_p (dst, dstcopy));
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == dst->numwords);
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == neweltindex);
- verify_popcount (dst->wordmask);
+ sbitmap_verify_popcount (dst->wordmask);
gcc_assert (changed == !ebitmap_equal_p (dst, dstcopy));
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == dst->numwords);
for (i = 0; i < dst->numwords; i++)
gcc_assert (dst->elts[i] != 0);
- verify_popcount (dst->wordmask);
+ sbitmap_verify_popcount (dst->wordmask);
gcc_assert (sbitmap_popcount (dst->wordmask,
dst->wordmask->n_bits) == dst->numwords);
}