summaryrefslogtreecommitdiff
path: root/gcc/sbitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/sbitmap.c')
-rw-r--r--gcc/sbitmap.c188
1 files changed, 48 insertions, 140 deletions
diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c
index 6aac459f826..737b0cd7fa7 100644
--- a/gcc/sbitmap.c
+++ b/gcc/sbitmap.c
@@ -238,7 +238,7 @@ sbitmap_vector_alloc (unsigned int n_vecs, unsigned int n_elms)
/* Copy sbitmap SRC to DST. */
void
-sbitmap_copy (sbitmap dst, const_sbitmap src)
+bitmap_copy (sbitmap dst, const_sbitmap src)
{
memcpy (dst->elms, src->elms, sizeof (SBITMAP_ELT_TYPE) * dst->size);
if (dst->popcount)
@@ -248,7 +248,7 @@ sbitmap_copy (sbitmap dst, const_sbitmap src)
/* Copy the first N elements of sbitmap SRC to DST. */
void
-sbitmap_copy_n (sbitmap dst, const_sbitmap src, unsigned int n)
+bitmap_copy_n (sbitmap dst, const_sbitmap src, unsigned int n)
{
memcpy (dst->elms, src->elms, sizeof (SBITMAP_ELT_TYPE) * n);
if (dst->popcount)
@@ -257,7 +257,7 @@ sbitmap_copy_n (sbitmap dst, const_sbitmap src, unsigned int n)
/* Determine if a == b. */
int
-sbitmap_equal (const_sbitmap a, const_sbitmap b)
+bitmap_equal_p (const_sbitmap a, const_sbitmap b)
{
return !memcmp (a->elms, b->elms, sizeof (SBITMAP_ELT_TYPE) * a->size);
}
@@ -265,7 +265,7 @@ sbitmap_equal (const_sbitmap a, const_sbitmap b)
/* Return true if the bitmap is empty. */
bool
-sbitmap_empty_p (const_sbitmap bmap)
+bitmap_empty_p (const_sbitmap bmap)
{
unsigned int i;
for (i=0; i<bmap->size; i++)
@@ -279,7 +279,7 @@ sbitmap_empty_p (const_sbitmap bmap)
START. */
bool
-sbitmap_range_empty_p (const_sbitmap bmap, unsigned int start, unsigned int n)
+bitmap_range_empty_p (const_sbitmap bmap, unsigned int start, unsigned int n)
{
unsigned int i = start / SBITMAP_ELT_BITS;
SBITMAP_ELT_TYPE elm;
@@ -329,7 +329,7 @@ sbitmap_range_empty_p (const_sbitmap bmap, unsigned int start, unsigned int n)
/* Zero all elements in a bitmap. */
void
-sbitmap_zero (sbitmap bmap)
+bitmap_clear (sbitmap bmap)
{
memset (bmap->elms, 0, SBITMAP_SIZE_BYTES (bmap));
if (bmap->popcount)
@@ -339,7 +339,7 @@ sbitmap_zero (sbitmap bmap)
/* Set all elements in a bitmap to ones. */
void
-sbitmap_ones (sbitmap bmap)
+bitmap_ones (sbitmap bmap)
{
unsigned int last_bit;
@@ -361,23 +361,23 @@ sbitmap_ones (sbitmap bmap)
/* Zero a vector of N_VECS bitmaps. */
void
-sbitmap_vector_zero (sbitmap *bmap, unsigned int n_vecs)
+bitmap_vector_clear (sbitmap *bmap, unsigned int n_vecs)
{
unsigned int i;
for (i = 0; i < n_vecs; i++)
- sbitmap_zero (bmap[i]);
+ bitmap_clear (bmap[i]);
}
/* Set a vector of N_VECS bitmaps to ones. */
void
-sbitmap_vector_ones (sbitmap *bmap, unsigned int n_vecs)
+bitmap_vector_ones (sbitmap *bmap, unsigned int n_vecs)
{
unsigned int i;
for (i = 0; i < n_vecs; i++)
- sbitmap_ones (bmap[i]);
+ bitmap_ones (bmap[i]);
}
/* Set DST to be A union (B - C).
@@ -385,7 +385,7 @@ sbitmap_vector_ones (sbitmap *bmap, unsigned int n_vecs)
Returns true if any change is made. */
bool
-sbitmap_union_of_diff_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
+bitmap_ior_and_compl (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -406,26 +406,10 @@ sbitmap_union_of_diff_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_s
return changed != 0;
}
-void
-sbitmap_union_of_diff (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
-{
- unsigned int i, n = dst->size;
- sbitmap_ptr dstp = dst->elms;
- const_sbitmap_ptr ap = a->elms;
- const_sbitmap_ptr bp = b->elms;
- const_sbitmap_ptr cp = c->elms;
-
- gcc_assert (!dst->popcount && !a->popcount
- && !b->popcount && !c->popcount);
-
- for (i = 0; i < n; i++)
- *dstp++ = *ap++ | (*bp++ & ~*cp++);
-}
-
/* Set bitmap DST to the bitwise negation of the bitmap SRC. */
void
-sbitmap_not (sbitmap dst, const_sbitmap src)
+bitmap_not (sbitmap dst, const_sbitmap src)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -437,7 +421,7 @@ sbitmap_not (sbitmap dst, const_sbitmap src)
for (i = 0; i < n; i++)
*dstp++ = ~*srcp++;
- /* Zero all bits past n_bits, by ANDing dst with sbitmap_ones. */
+ /* Zero all bits past n_bits, by ANDing dst with bitmap_ones. */
last_bit = src->n_bits % SBITMAP_ELT_BITS;
if (last_bit)
dst->elms[n-1] = dst->elms[n-1]
@@ -448,7 +432,7 @@ sbitmap_not (sbitmap dst, const_sbitmap src)
in A and the bits in B. i.e. dst = a & (~b). */
void
-sbitmap_difference (sbitmap dst, const_sbitmap a, const_sbitmap b)
+bitmap_and_compl (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
unsigned int i, dst_size = dst->size;
unsigned int min_size = dst->size;
@@ -477,7 +461,7 @@ sbitmap_difference (sbitmap dst, const_sbitmap a, const_sbitmap b)
Return false otherwise. */
bool
-sbitmap_any_common_bits (const_sbitmap a, const_sbitmap b)
+bitmap_intersect_p (const_sbitmap a, const_sbitmap b)
{
const_sbitmap_ptr ap = a->elms;
const_sbitmap_ptr bp = b->elms;
@@ -495,28 +479,7 @@ sbitmap_any_common_bits (const_sbitmap a, const_sbitmap b)
Return nonzero if any change is made. */
bool
-sbitmap_a_and_b_cg (sbitmap dst, const_sbitmap a, const_sbitmap b)
-{
- unsigned int i, n = dst->size;
- sbitmap_ptr dstp = dst->elms;
- const_sbitmap_ptr ap = a->elms;
- const_sbitmap_ptr bp = b->elms;
- SBITMAP_ELT_TYPE changed = 0;
-
- gcc_assert (!dst->popcount);
-
- for (i = 0; i < n; i++)
- {
- const SBITMAP_ELT_TYPE tmp = *ap++ & *bp++;
- changed |= *dstp ^ tmp;
- *dstp++ = tmp;
- }
-
- return changed != 0;
-}
-
-void
-sbitmap_a_and_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
+bitmap_and (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -524,6 +487,7 @@ sbitmap_a_and_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
const_sbitmap_ptr bp = b->elms;
bool has_popcount = dst->popcount != NULL;
unsigned char *popcountp = dst->popcount;
+ bool anychange = false;
for (i = 0; i < n; i++)
{
@@ -532,7 +496,10 @@ sbitmap_a_and_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
bool wordchanged = (*dstp ^ tmp) != 0;
if (wordchanged)
- *popcountp = do_popcount (tmp);
+ {
+ *popcountp = do_popcount (tmp);
+ anychange = true;
+ }
popcountp++;
}
*dstp++ = tmp;
@@ -541,34 +508,14 @@ sbitmap_a_and_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
if (has_popcount)
sbitmap_verify_popcount (dst);
#endif
+ return anychange;
}
/* Set DST to be (A xor B)).
Return nonzero if any change is made. */
bool
-sbitmap_a_xor_b_cg (sbitmap dst, const_sbitmap a, const_sbitmap b)
-{
- unsigned int i, n = dst->size;
- sbitmap_ptr dstp = dst->elms;
- const_sbitmap_ptr ap = a->elms;
- const_sbitmap_ptr bp = b->elms;
- SBITMAP_ELT_TYPE changed = 0;
-
- gcc_assert (!dst->popcount);
-
- for (i = 0; i < n; i++)
- {
- const SBITMAP_ELT_TYPE tmp = *ap++ ^ *bp++;
- changed |= *dstp ^ tmp;
- *dstp++ = tmp;
- }
-
- return changed != 0;
-}
-
-void
-sbitmap_a_xor_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
+bitmap_xor (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -576,6 +523,7 @@ sbitmap_a_xor_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
const_sbitmap_ptr bp = b->elms;
bool has_popcount = dst->popcount != NULL;
unsigned char *popcountp = dst->popcount;
+ bool anychange = false;
for (i = 0; i < n; i++)
{
@@ -584,7 +532,10 @@ sbitmap_a_xor_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
bool wordchanged = (*dstp ^ tmp) != 0;
if (wordchanged)
- *popcountp = do_popcount (tmp);
+ {
+ *popcountp = do_popcount (tmp);
+ anychange = true;
+ }
popcountp++;
}
*dstp++ = tmp;
@@ -593,34 +544,14 @@ sbitmap_a_xor_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
if (has_popcount)
sbitmap_verify_popcount (dst);
#endif
+ return anychange;
}
/* Set DST to be (A or B)).
Return nonzero if any change is made. */
bool
-sbitmap_a_or_b_cg (sbitmap dst, const_sbitmap a, const_sbitmap b)
-{
- unsigned int i, n = dst->size;
- sbitmap_ptr dstp = dst->elms;
- const_sbitmap_ptr ap = a->elms;
- const_sbitmap_ptr bp = b->elms;
- SBITMAP_ELT_TYPE changed = 0;
-
- gcc_assert (!dst->popcount);
-
- for (i = 0; i < n; i++)
- {
- const SBITMAP_ELT_TYPE tmp = *ap++ | *bp++;
- changed |= *dstp ^ tmp;
- *dstp++ = tmp;
- }
-
- return changed != 0;
-}
-
-void
-sbitmap_a_or_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
+bitmap_ior (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -628,6 +559,7 @@ sbitmap_a_or_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
const_sbitmap_ptr bp = b->elms;
bool has_popcount = dst->popcount != NULL;
unsigned char *popcountp = dst->popcount;
+ bool anychange = false;
for (i = 0; i < n; i++)
{
@@ -636,7 +568,10 @@ sbitmap_a_or_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
{
bool wordchanged = (*dstp ^ tmp) != 0;
if (wordchanged)
- *popcountp = do_popcount (tmp);
+ {
+ *popcountp = do_popcount (tmp);
+ anychange = true;
+ }
popcountp++;
}
*dstp++ = tmp;
@@ -645,12 +580,13 @@ sbitmap_a_or_b (sbitmap dst, const_sbitmap a, const_sbitmap b)
if (has_popcount)
sbitmap_verify_popcount (dst);
#endif
+ return anychange;
}
/* Return nonzero if A is a subset of B. */
bool
-sbitmap_a_subset_b_p (const_sbitmap a, const_sbitmap b)
+bitmap_subset_p (const_sbitmap a, const_sbitmap b)
{
unsigned int i, n = a->size;
const_sbitmap_ptr ap, bp;
@@ -666,7 +602,7 @@ sbitmap_a_subset_b_p (const_sbitmap a, const_sbitmap b)
Return nonzero if any change is made. */
bool
-sbitmap_a_or_b_and_c_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
+bitmap_or_and (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -687,26 +623,11 @@ sbitmap_a_or_b_and_c_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sb
return changed != 0;
}
-void
-sbitmap_a_or_b_and_c (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
-{
- unsigned int i, n = dst->size;
- sbitmap_ptr dstp = dst->elms;
- const_sbitmap_ptr ap = a->elms;
- const_sbitmap_ptr bp = b->elms;
- const_sbitmap_ptr cp = c->elms;
-
- gcc_assert (!dst->popcount);
-
- for (i = 0; i < n; i++)
- *dstp++ = *ap++ | (*bp++ & *cp++);
-}
-
/* Set DST to be (A and (B or C)).
Return nonzero if any change is made. */
bool
-sbitmap_a_and_b_or_c_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
+bitmap_and_or (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
{
unsigned int i, n = dst->size;
sbitmap_ptr dstp = dst->elms;
@@ -727,23 +648,10 @@ sbitmap_a_and_b_or_c_cg (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sb
return changed != 0;
}
-void
-sbitmap_a_and_b_or_c (sbitmap dst, const_sbitmap a, const_sbitmap b, const_sbitmap c)
-{
- unsigned int i, n = dst->size;
- sbitmap_ptr dstp = dst->elms;
- const_sbitmap_ptr ap = a->elms;
- const_sbitmap_ptr bp = b->elms;
- const_sbitmap_ptr cp = c->elms;
-
- for (i = 0; i < n; i++)
- *dstp++ = *ap++ & (*bp++ | *cp++);
-}
-
/* Return number of first bit set in the bitmap, -1 if none. */
int
-sbitmap_first_set_bit (const_sbitmap bmap)
+bitmap_first_set_bit (const_sbitmap bmap)
{
unsigned int n = 0;
sbitmap_iterator sbi;
@@ -756,7 +664,7 @@ sbitmap_first_set_bit (const_sbitmap bmap)
/* Return number of last bit set in the bitmap, -1 if none. */
int
-sbitmap_last_set_bit (const_sbitmap bmap)
+bitmap_last_set_bit (const_sbitmap bmap)
{
int i;
const SBITMAP_ELT_TYPE *const ptr = bmap->elms;
@@ -786,7 +694,7 @@ sbitmap_last_set_bit (const_sbitmap bmap)
}
void
-dump_sbitmap (FILE *file, const_sbitmap bmap)
+dump_bitmap (FILE *file, const_sbitmap bmap)
{
unsigned int i, n, j;
unsigned int set_size = bmap->size;
@@ -807,7 +715,7 @@ dump_sbitmap (FILE *file, const_sbitmap bmap)
}
void
-dump_sbitmap_file (FILE *file, const_sbitmap bmap)
+dump_bitmap_file (FILE *file, const_sbitmap bmap)
{
unsigned int i, pos;
@@ -830,13 +738,13 @@ dump_sbitmap_file (FILE *file, const_sbitmap bmap)
}
DEBUG_FUNCTION void
-debug_sbitmap (const_sbitmap bmap)
+debug_bitmap (const_sbitmap bmap)
{
- dump_sbitmap_file (stderr, bmap);
+ dump_bitmap_file (stderr, bmap);
}
void
-dump_sbitmap_vector (FILE *file, const char *title, const char *subtitle,
+dump_bitmap_vector (FILE *file, const char *title, const char *subtitle,
sbitmap *bmaps, int n_maps)
{
int i;
@@ -845,7 +753,7 @@ dump_sbitmap_vector (FILE *file, const char *title, const char *subtitle,
for (i = 0; i < n_maps; i++)
{
fprintf (file, "%s %d\n", subtitle, i);
- dump_sbitmap (file, bmaps[i]);
+ dump_bitmap (file, bmaps[i]);
}
fprintf (file, "\n");