This patch removes the unused ebitmap, and then removes some sbitmap functions only used by ebitmap.

This patch removes the unused ebitmap, and then removes some sbitmap functions
only used by ebitmap.  The functions removed are:

SET_BIT_WITH_POPCOUNT
RESET_BIT_WITH_POPCOUNT
bitmap_copy_n
bitmap_range_empty_p
sbitmap_popcount

In addition, two functions have been made private to the implementation file:

SBITMAP_SIZE_BYTES
sbitmap_verify_popcount

Tested on x86-64.


Index: gcc/ChangeLog

2012-11-01  Lawrence Crowl  <crowl@google.com>

	* ebitmap.h: Remove unused.
	* ebitmap.c: Remove unused.
	* Makefile.in: Remove ebitmap.h and ebitmap.c.
	* sbitmap.h (SBITMAP_SIZE_BYTES): Move to source file.
	(SET_BIT_WITH_POPCOUNT): Remove unused.
	(RESET_BIT_WITH_POPCOUNT): Remove unused.
	(bitmap_copy_n): Remove unused.
	(bitmap_range_empty_p): Remove unused.
	(sbitmap_popcount): Remove unused.
	(sbitmap_verify_popcount): Make private to source file.
	* sbitmap.c (SBITMAP_SIZE_BYTES): Move here from header.
	(bitmap_copy_n): Remove unused.
	(bitmap_range_empty_p): Remove unused.
	(sbitmap_popcount): Remove unused.
	(sbitmap_verify_popcount): Make private to source file.

2012-11-01  Lawrence Crowl  <crowl@google.com>

From-SVN: r193072
This commit is contained in:
Lawrence Crowl 2012-11-01 22:39:26 +00:00 committed by Lawrence Crowl
parent c291b2adc6
commit 5fd39ce63c
6 changed files with 34 additions and 1346 deletions

View File

@ -1,4 +1,22 @@
2012-10-31 Lawrence Crowl <crowl@google.com>
2012-11-01 Lawrence Crowl <crowl@google.com>
* ebitmap.h: Remove unused.
* ebitmap.c: Remove unused.
* Makefile.in: Remove ebitmap.h and ebitmap.c.
* sbitmap.h (SBITMAP_SIZE_BYTES): Move to source file.
(SET_BIT_WITH_POPCOUNT): Remove unused.
(RESET_BIT_WITH_POPCOUNT): Remove unused.
(bitmap_copy_n): Remove unused.
(bitmap_range_empty_p): Remove unused.
(sbitmap_popcount): Remove unused.
(sbitmap_verify_popcount): Make private to source file.
* sbitmap.c (SBITMAP_SIZE_BYTES): Move here from header.
(bitmap_copy_n): Remove unused.
(bitmap_range_empty_p): Remove unused.
(sbitmap_popcount): Remove unused.
(sbitmap_verify_popcount): Make private to source file.
2012-11-01 Lawrence Crowl <crowl@google.com>
* sbitmap.h (sbitmap_iter_init): Rename bmp_iter_set_init and add
unused parameter to match bitmap iterator. Update callers.

View File

@ -942,7 +942,6 @@ REAL_H = real.h $(MACHMODE_H)
IRA_INT_H = ira.h ira-int.h $(CFGLOOP_H) alloc-pool.h
LRA_INT_H = lra.h $(BITMAP_H) $(RECOG_H) $(INSN_ATTR_H) insn-codes.h lra-int.h
DBGCNT_H = dbgcnt.h dbgcnt.def
EBITMAP_H = ebitmap.h sbitmap.h
LTO_STREAMER_H = lto-streamer.h $(LINKER_PLUGIN_API_H) $(TARGET_H) \
$(CGRAPH_H) $(VEC_H) vecprim.h $(TREE_H) $(GIMPLE_H) \
$(GCOV_IO_H) $(DIAGNOSTIC_H) alloc-pool.h
@ -1200,7 +1199,6 @@ OBJS = \
dwarf2asm.o \
dwarf2cfi.o \
dwarf2out.o \
ebitmap.o \
emit-rtl.o \
et-forest.o \
except.o \
@ -1833,7 +1831,6 @@ graph.o: graph.c $(SYSTEM_H) coretypes.h $(TM_H) toplev.h $(DIAGNOSTIC_CORE_H) $
$(CONFIG_H) $(EMIT_RTL_H)
sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h
ebitmap.o: ebitmap.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(EBITMAP_H)
sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H)
AR_LIBS = @COLLECT2_LIBS@

File diff suppressed because it is too large Load Diff

View File

@ -1,175 +0,0 @@
/* Sparse array based bitmaps.
Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_EBITMAP_H
#define GCC_EBITMAP_H
#include "sbitmap.h"
#define EBITMAP_ELT_BITS ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
#define EBITMAP_ELT_TYPE unsigned HOST_WIDEST_FAST_INT
typedef struct ebitmap_def
{
unsigned int n_elts; /* number of elements in the array. */
sbitmap wordmask; /* wordmask saying which words are
nonzero. */
unsigned int numwords; /* number of nonzero words. */
unsigned int cacheindex; /* which word cache is. */
EBITMAP_ELT_TYPE *elts; /* nonzero element array. */
EBITMAP_ELT_TYPE *cache; /* last tested element, or NULL. */
} *ebitmap;
inline bool bitmap_empty_p (ebitmap map)
{
return map->numwords == 0;
}
#define ebitmap_free(MAP) (free((MAP)->elts), \
sbitmap_free ((MAP)->wordmask), \
free((MAP)))
extern void bitmap_set_bit (ebitmap, unsigned int);
extern void bitmap_clear_bit (ebitmap, unsigned int);
extern bool bitmap_bit_p (ebitmap, unsigned int);
extern void dump_bitmap (FILE *, ebitmap);
extern void dump_bitmap_file (FILE *, ebitmap);
extern void dump_bitmap_vector (FILE *, const char *, const char *, ebitmap *,
int);
extern ebitmap ebitmap_alloc (unsigned int);
extern ebitmap *ebitmap_vector_alloc (unsigned int, unsigned int);
extern void bitmap_copy (ebitmap, ebitmap);
extern void bitmap_and (ebitmap, ebitmap, ebitmap);
extern void bitmap_and_into (ebitmap, ebitmap);
extern bool bitmap_and_compl (ebitmap, ebitmap, ebitmap);
extern bool bitmap_and_compl_into (ebitmap, ebitmap);
extern bool bitmap_ior_into (ebitmap, ebitmap);
extern bool bitmap_ior (ebitmap, ebitmap, ebitmap);
extern bool bitmap_ior_and_compl (ebitmap, ebitmap, ebitmap, ebitmap);
extern bool bitmap_ior_and_compl_into (ebitmap, ebitmap, ebitmap);
extern bool bitmap_equal_p (ebitmap, ebitmap);
extern void bitmap_clear (ebitmap);
extern int bitmap_last_set_bit (ebitmap);
extern void debug_bitmap (ebitmap);
extern unsigned long bitmap_popcount(ebitmap, unsigned long);
/* The iterator for ebitmap. */
typedef struct {
/* The pointer to the first word of the bitmap. */
EBITMAP_ELT_TYPE *ptr;
/* Element number inside ptr that we are at. */
unsigned int eltnum;
/* The size of the bitmap. */
unsigned int size;
/* Current bit index. */
unsigned int bit_num;
/* The words currently visited. */
EBITMAP_ELT_TYPE word;
/* The word mask iterator. */
sbitmap_iterator maskiter;
} ebitmap_iterator;
static inline void
ebitmap_iter_init (ebitmap_iterator *i, ebitmap bmp, unsigned int min)
{
unsigned unused;
bmp_iter_set_init (&i->maskiter, bmp->wordmask,
min / EBITMAP_ELT_BITS, &unused);
i->size = bmp->numwords;
if (i->size == 0)
{
i->ptr = NULL;
i->eltnum = 0;
i->bit_num = 0;
i->word = 0;
return;
}
i->ptr = bmp->elts;
i->bit_num = min;
i->eltnum = 0;
if ((min / EBITMAP_ELT_BITS) >= bmp->wordmask->n_bits)
{
i->word = 0;
}
else
{
if (bitmap_bit_p (bmp->wordmask, min / EBITMAP_ELT_BITS) == 0)
i->word = 0;
else
{
unsigned int wordindex = min / EBITMAP_ELT_BITS;
unsigned int count = sbitmap_popcount (bmp->wordmask, wordindex);
i->word = i->ptr[count] >> (i->bit_num % (unsigned int)EBITMAP_ELT_BITS);
i->eltnum = count + 1;
}
}
}
static inline bool
ebitmap_iter_cond (ebitmap_iterator *i, unsigned int *n)
{
unsigned int ourn = 0;
unsigned unused;
if (i->size == 0)
return false;
if (i->word == 0)
{
bmp_iter_next (&i->maskiter, &unused);
if (!bmp_iter_set (&i->maskiter, &ourn))
return false;
i->bit_num = ourn * EBITMAP_ELT_BITS;
i->word = i->ptr[i->eltnum++];
}
/* Skip bits that are zero. */
for (; (i->word & 1) == 0; i->word >>= 1)
i->bit_num++;
*n = i->bit_num;
return true;
}
static inline void
ebitmap_iter_next (ebitmap_iterator *i)
{
i->word >>= 1;
i->bit_num++;
}
/* Loop over all elements of EBITMAP, starting with MIN. In each
iteration, N is set to the index of the bit being visited. ITER is
an instance of ebitmap_iterator used to iterate the bitmap. */
#define EXECUTE_IF_SET_IN_EBITMAP(EBITMAP, MIN, N, ITER) \
for (ebitmap_iter_init (&(ITER), (EBITMAP), (MIN)); \
ebitmap_iter_cond (&(ITER), &(N)); \
ebitmap_iter_next (&(ITER)))
#endif /* ! GCC_EBITMAP_H */

View File

@ -44,6 +44,13 @@ static unsigned long sbitmap_elt_popcount (SBITMAP_ELT_TYPE);
typedef SBITMAP_ELT_TYPE *sbitmap_ptr;
typedef const SBITMAP_ELT_TYPE *const_sbitmap_ptr;
/* Return the size in bytes of a bitmap MAP. */
static inline unsigned int sbitmap_size_bytes (const_sbitmap map)
{
return map->size * sizeof (SBITMAP_ELT_TYPE);
}
/* This macro controls debugging that is as expensive as the
operations it verifies. */
@ -53,7 +60,7 @@ typedef const SBITMAP_ELT_TYPE *const_sbitmap_ptr;
/* Verify the population count of sbitmap A matches the cached value,
if there is a cached value. */
void
static void
sbitmap_verify_popcount (const_sbitmap a)
{
unsigned ix;
@ -111,7 +118,7 @@ sbitmap_resize (sbitmap bmap, unsigned int n_elms, int def)
size = SBITMAP_SET_SIZE (n_elms);
bytes = size * sizeof (SBITMAP_ELT_TYPE);
if (bytes > SBITMAP_SIZE_BYTES (bmap))
if (bytes > sbitmap_size_bytes (bmap))
{
amt = (sizeof (struct simple_bitmap_def)
+ bytes - sizeof (SBITMAP_ELT_TYPE));
@ -125,7 +132,7 @@ sbitmap_resize (sbitmap bmap, unsigned int n_elms, int def)
if (def)
{
memset (bmap->elms + bmap->size, -1,
bytes - SBITMAP_SIZE_BYTES (bmap));
bytes - sbitmap_size_bytes (bmap));
/* Set the new bits if the original last element. */
last_bit = bmap->n_bits % SBITMAP_ELT_BITS;
@ -142,7 +149,7 @@ sbitmap_resize (sbitmap bmap, unsigned int n_elms, int def)
else
{
memset (bmap->elms + bmap->size, 0,
bytes - SBITMAP_SIZE_BYTES (bmap));
bytes - sbitmap_size_bytes (bmap));
if (bmap->popcount)
memset (bmap->popcount + bmap->size, 0,
(size * sizeof (unsigned char))
@ -181,7 +188,7 @@ sbitmap_realloc (sbitmap src, unsigned int n_elms)
amt = (sizeof (struct simple_bitmap_def)
+ bytes - sizeof (SBITMAP_ELT_TYPE));
if (SBITMAP_SIZE_BYTES (src) >= bytes)
if (sbitmap_size_bytes (src) >= bytes)
{
src->n_bits = n_elms;
return src;
@ -245,16 +252,6 @@ bitmap_copy (sbitmap dst, const_sbitmap src)
memcpy (dst->popcount, src->popcount, sizeof (unsigned char) * dst->size);
}
/* Copy the first N elements of sbitmap SRC to DST. */
void
bitmap_copy_n (sbitmap dst, const_sbitmap src, unsigned int n)
{
memcpy (dst->elms, src->elms, sizeof (SBITMAP_ELT_TYPE) * n);
if (dst->popcount)
memcpy (dst->popcount, src->popcount, sizeof (unsigned char) * n);
}
/* Determine if a == b. */
int
bitmap_equal_p (const_sbitmap a, const_sbitmap b)
@ -275,63 +272,13 @@ bitmap_empty_p (const_sbitmap bmap)
return true;
}
/* Return false if any of the N bits are set in MAP starting at
START. */
bool
bitmap_range_empty_p (const_sbitmap bmap, unsigned int start, unsigned int n)
{
unsigned int i = start / SBITMAP_ELT_BITS;
SBITMAP_ELT_TYPE elm;
unsigned int shift = start % SBITMAP_ELT_BITS;
gcc_assert (bmap->n_bits >= start + n);
elm = bmap->elms[i];
elm = elm >> shift;
if (shift + n <= SBITMAP_ELT_BITS)
{
/* The bits are totally contained in a single element. */
if (shift + n < SBITMAP_ELT_BITS)
elm &= ((1 << n) - 1);
return (elm == 0);
}
if (elm)
return false;
n -= SBITMAP_ELT_BITS - shift;
i++;
/* Deal with full elts. */
while (n >= SBITMAP_ELT_BITS)
{
if (bmap->elms[i])
return false;
i++;
n -= SBITMAP_ELT_BITS;
}
/* The leftover bits. */
if (n)
{
elm = bmap->elms[i];
elm &= ((1 << n) - 1);
return (elm == 0);
}
return true;
}
/* Zero all elements in a bitmap. */
void
bitmap_clear (sbitmap bmap)
{
memset (bmap->elms, 0, SBITMAP_SIZE_BYTES (bmap));
memset (bmap->elms, 0, sbitmap_size_bytes (bmap));
if (bmap->popcount)
memset (bmap->popcount, 0, bmap->size * sizeof (unsigned char));
}
@ -343,7 +290,7 @@ bitmap_ones (sbitmap bmap)
{
unsigned int last_bit;
memset (bmap->elms, -1, SBITMAP_SIZE_BYTES (bmap));
memset (bmap->elms, -1, sbitmap_size_bytes (bmap));
if (bmap->popcount)
memset (bmap->popcount, -1, bmap->size * sizeof (unsigned char));
@ -790,50 +737,3 @@ sbitmap_elt_popcount (SBITMAP_ELT_TYPE a)
return ret;
}
#endif
/* Count the number of bits in SBITMAP a, up to bit MAXBIT. */
unsigned long
sbitmap_popcount (const_sbitmap a, unsigned long maxbit)
{
unsigned long count = 0;
unsigned ix;
unsigned int lastword;
if (maxbit == 0)
return 0;
if (maxbit >= a->n_bits)
maxbit = a->n_bits;
/* Count the bits in the full word. */
lastword = MIN (a->size, SBITMAP_SET_SIZE (maxbit + 1) - 1);
for (ix = 0; ix < lastword; ix++)
{
if (a->popcount)
{
count += a->popcount[ix];
#ifdef BITMAP_DEBUGGING
gcc_assert (a->popcount[ix] == do_popcount (a->elms[ix]));
#endif
}
else
count += do_popcount (a->elms[ix]);
}
/* Count the remaining bits. */
if (lastword < a->size)
{
unsigned int bitindex;
SBITMAP_ELT_TYPE theword = a->elms[lastword];
bitindex = maxbit % SBITMAP_ELT_BITS;
if (bitindex != 0)
{
theword &= (SBITMAP_ELT_TYPE)-1 >> (SBITMAP_ELT_BITS - bitindex);
count += do_popcount (theword);
}
}
return count;
}

View File

@ -42,11 +42,10 @@ along with GCC; see the file COPYING3. If not see
the size of the set universe:
* clear : bitmap_clear
* cardinality : sbitmap_popcount
* choose_one : bitmap_first_set_bit /
bitmap_last_set_bit
* forall : EXECUTE_IF_SET_IN_BITMAP
* set_copy : bitmap_copy / bitmap_copy_n
* set_copy : bitmap_copy
* set_intersection : bitmap_and
* set_union : bitmap_ior
* set_difference : bitmap_and_compl
@ -93,7 +92,6 @@ struct simple_bitmap_def
/* Return the set size needed for N elements. */
#define SBITMAP_SET_SIZE(N) (((N) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
#define SBITMAP_SIZE_BYTES(BITMAP) ((BITMAP)->size * sizeof (SBITMAP_ELT_TYPE))
/* Return the number of bits in BITMAP. */
#define SBITMAP_SIZE(BITMAP) ((BITMAP)->n_bits)
@ -117,20 +115,6 @@ bitmap_set_bit (sbitmap map, int bitno)
|= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS;
}
/* Like bitmap_set_bit, but updates population count. */
static inline void
bitmap_set_bit_with_popcount (sbitmap map, int bitno)
{
bool oldbit;
gcc_checking_assert (map->popcount);
oldbit = bitmap_bit_p (map, bitno);
if (!oldbit)
map->popcount[bitno / SBITMAP_ELT_BITS]++;
map->elms[bitno / SBITMAP_ELT_BITS]
|= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS;
}
/* Reset bit number BITNO in the sbitmap MAP. */
static inline void
@ -141,20 +125,6 @@ bitmap_clear_bit (sbitmap map, int bitno)
&= ~((SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS);
}
/* Like bitmap_clear_bit, but updates population count. */
static inline void
bitmap_clear_bit_with_popcount (sbitmap map, int bitno)
{
bool oldbit;
gcc_checking_assert (map->popcount);
oldbit = bitmap_bit_p (map, bitno);
if (oldbit)
map->popcount[bitno / SBITMAP_ELT_BITS]--;
map->elms[bitno / SBITMAP_ELT_BITS]
&= ~((SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS);
}
/* The iterator for sbitmap. */
typedef struct {
/* The pointer to the first word of the bitmap. */
@ -261,10 +231,8 @@ extern sbitmap sbitmap_alloc_with_popcount (unsigned int);
extern sbitmap *sbitmap_vector_alloc (unsigned int, unsigned int);
extern sbitmap sbitmap_resize (sbitmap, unsigned int, int);
extern void bitmap_copy (sbitmap, const_sbitmap);
extern void bitmap_copy_n (sbitmap, const_sbitmap, unsigned int);
extern int bitmap_equal_p (const_sbitmap, const_sbitmap);
extern bool bitmap_empty_p (const_sbitmap);
extern bool bitmap_range_empty_p (const_sbitmap, unsigned int, unsigned int);
extern void bitmap_clear (sbitmap);
extern void bitmap_ones (sbitmap);
extern void bitmap_vector_clear (sbitmap *, unsigned int);
@ -290,5 +258,4 @@ extern int bitmap_last_set_bit (const_sbitmap);
extern void debug_bitmap (const_sbitmap);
extern sbitmap sbitmap_realloc (sbitmap, unsigned int);
extern unsigned long sbitmap_popcount (const_sbitmap, unsigned long);
extern void sbitmap_verify_popcount (const_sbitmap);
#endif /* ! GCC_SBITMAP_H */