Commit 65a6f342 by Nathan Sidwell Committed by Nathan Sidwell

bitmap.h (nBITMAP_WORD_BITS): Remove.

	* bitmap.h (nBITMAP_WORD_BITS): Remove.
	(BITMAP_WORD_BITS): Force unsigned by use of 1u.
	(BITMAP_ELEMENT_WORDS, BITMAP_ELEMENT_ALL_BITS): Remove
	unnecessary casts.
	(bitmap_first_set_bit): Return unsigned, use ctzl.
	(bitmap_last_set_bit): Remove.
	* bitmap.c (bitmap_element_zerop, bitmap_copy): Make iterator
	unsigned.
	(bitmap_first_set_bit): Return unsigned, require non-empty bitmap,
	remove special case code for two word elements.
	(bitmap_last_set_bit): Remove.
	* ra-build.c (livethrough_conflicts_bb): Replace unnecessary use of
	bitmap_first_set_bit with bitmap_empty_p.
	* tree-outof-ssa.c (analyze_edges_for_bb): Likewise.
	* tree-ssa-pre.c (bitmap_print_value): Use simple flag rather than
	bitmap_last_bit_set.

From-SVN: r90478
parent af2a91bd
2004-11-11 Nathan Sidwell <nathan@codesourcery.com> 2004-11-11 Nathan Sidwell <nathan@codesourcery.com>
* bitmap.h (nBITMAP_WORD_BITS): Remove.
(BITMAP_WORD_BITS): Force unsigned by use of 1u.
(BITMAP_ELEMENT_WORDS, BITMAP_ELEMENT_ALL_BITS): Remove
unnecessary casts.
(bitmap_first_set_bit): Return unsigned, use ctzl.
(bitmap_last_set_bit): Remove.
* bitmap.c (bitmap_element_zerop, bitmap_copy): Make iterator
unsigned.
(bitmap_first_set_bit): Return unsigned, require non-empty bitmap,
remove special case code for two word elements.
(bitmap_last_set_bit): Remove.
* ra-build.c (livethrough_conflicts_bb): Replace unnecessary use of
bitmap_first_set_bit with bitmap_empty_p.
* tree-outof-ssa.c (analyze_edges_for_bb): Likewise.
* tree-ssa-pre.c (bitmap_print_value): Use simple flag rather than
bitmap_last_bit_set.
2004-11-11 Nathan Sidwell <nathan@codesourcery.com>
PR target/16796 PR target/16796
* config/rs6000/rs6000.md: Add DF & SF reg move peepholes. * config/rs6000/rs6000.md: Add DF & SF reg move peepholes.
......
...@@ -174,7 +174,7 @@ bitmap_element_zerop (bitmap_element *element) ...@@ -174,7 +174,7 @@ bitmap_element_zerop (bitmap_element *element)
#if BITMAP_ELEMENT_WORDS == 2 #if BITMAP_ELEMENT_WORDS == 2
return (element->bits[0] | element->bits[1]) == 0; return (element->bits[0] | element->bits[1]) == 0;
#else #else
int i; unsigned i;
for (i = 0; i < BITMAP_ELEMENT_WORDS; i++) for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
if (element->bits[i] != 0) if (element->bits[i] != 0)
...@@ -309,7 +309,7 @@ bitmap_copy (bitmap to, bitmap from) ...@@ -309,7 +309,7 @@ bitmap_copy (bitmap to, bitmap from)
{ {
bitmap_element *from_ptr, *to_ptr = 0; bitmap_element *from_ptr, *to_ptr = 0;
#if BITMAP_ELEMENT_WORDS != 2 #if BITMAP_ELEMENT_WORDS != 2
int i; unsigned i;
#endif #endif
bitmap_clear (to); bitmap_clear (to);
...@@ -444,112 +444,55 @@ bitmap_bit_p (bitmap head, int bit) ...@@ -444,112 +444,55 @@ bitmap_bit_p (bitmap head, int bit)
return (ptr->bits[word_num] >> bit_num) & 1; return (ptr->bits[word_num] >> bit_num) & 1;
} }
/* Return the bit number of the first set bit in the bitmap, or -1 /* Return the bit number of the first set bit in the bitmap. The
if the bitmap is empty. */ bitmap must be non-empty. */
int unsigned
bitmap_first_set_bit (bitmap a) bitmap_first_set_bit (bitmap a)
{ {
bitmap_element *ptr = a->first; bitmap_element *elt = a->first;
unsigned bit_no;
BITMAP_WORD word; BITMAP_WORD word;
unsigned word_num, bit_num; unsigned ix;
if (ptr == NULL)
return -1;
#if BITMAP_ELEMENT_WORDS == 2 gcc_assert (elt);
word_num = 0, word = ptr->bits[0]; bit_no = elt->indx * BITMAP_ELEMENT_ALL_BITS;
if (word == 0) for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
word_num = 1, word = ptr->bits[1]; {
#else word = elt->bits[ix];
for (word_num = 0; word_num < BITMAP_ELEMENT_WORDS; ++word_num) if (word)
if ((word = ptr->bits[word_num]) != 0) goto found_bit;
goto word_found; }
gcc_unreachable (); gcc_unreachable ();
word_found: found_bit:
#endif bit_no += ix * BITMAP_WORD_BITS;
/* Binary search for the first set bit. */
/* ??? It'd be nice to know if ffs or ffsl was available. */
bit_num = 0; #if GCC_VERSION >= 3004
word = word & -word; gcc_assert (sizeof(long) == sizeof (word));
bit_no += __builtin_ctzl (word);
#if nBITMAP_WORD_BITS > 64
#error "Fill out the table."
#endif
#if nBITMAP_WORD_BITS > 32
if ((word & 0xffffffff) == 0)
word >>= 32, bit_num += 32;
#endif
if ((word & 0xffff) == 0)
word >>= 16, bit_num += 16;
if ((word & 0xff) == 0)
word >>= 8, bit_num += 8;
if (word & 0xf0)
bit_num += 4;
if (word & 0xcc)
bit_num += 2;
if (word & 0xaa)
bit_num += 1;
return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
+ word_num * BITMAP_WORD_BITS
+ bit_num);
}
/* Return the bit number of the last set bit in the bitmap, or -1
if the bitmap is empty. */
int
bitmap_last_set_bit (bitmap a)
{
bitmap_element *ptr = a->first;
BITMAP_WORD word;
unsigned word_num, bit_num;
if (ptr == NULL)
return -1;
while (ptr->next != NULL)
ptr = ptr->next;
#if BITMAP_ELEMENT_WORDS == 2
word_num = 1, word = ptr->bits[1];
if (word == 0)
word_num = 0, word = ptr->bits[0];
#else #else
for (word_num = BITMAP_ELEMENT_WORDS; word_num-- > 0; ) /* Binary search for the first set bit. */
if ((word = ptr->bits[word_num]) != 0) #if BITMAP_WORD_BITS > 64
goto word_found; #error "Fill out the table."
gcc_unreachable ();
word_found:
#endif #endif
#if BITMAP_WORD_BITS > 32
/* Binary search for the last set bit. */ if (!(word & 0xffffffff))
word >>= 32, bit_no += 32;
bit_num = 0;
#if nBITMAP_WORD_BITS > 64
#error "Fill out the table."
#endif #endif
#if nBITMAP_WORD_BITS > 32 if (!(word & 0xffff))
if (word & ~(BITMAP_WORD)0xffffffff) word >>= 16, bit_no += 16;
word >>= 32, bit_num += 32; if (!(word & 0xff))
word >>= 8, bit_no += 8;
if (!(word & 0xf))
word >>= 4, bit_no += 4;
if (!(word & 0x3))
word >>= 2, bit_no += 2;
if (!(word & 0x1))
word >>= 1, bit_no += 1;
gcc_assert (word & 1);
#endif #endif
if (word & 0xffff0000) return bit_no;
word >>= 16, bit_num += 16;
if (word & 0xff00)
word >>= 8, bit_num += 8;
if (word & 0xf0)
word >>= 4, bit_num += 4;
if (word & 0xc)
word >>= 2, bit_num += 2;
if (word & 0x2)
bit_num += 1;
return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
+ word_num * BITMAP_WORD_BITS
+ bit_num);
} }
......
...@@ -24,24 +24,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -24,24 +24,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* Fundamental storage type for bitmap. */ /* Fundamental storage type for bitmap. */
/* typedef unsigned HOST_WIDE_INT BITMAP_WORD; */
/* #define nBITMAP_WORD_BITS HOST_BITS_PER_WIDE_INT */
typedef unsigned long BITMAP_WORD; typedef unsigned long BITMAP_WORD;
#define nBITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG) /* BITMAP_WORD_BITS needs to be unsigned, but cannot contain casts as
#define BITMAP_WORD_BITS (unsigned) nBITMAP_WORD_BITS it is used in preprocessor directives -- hence the 1u. */
#define BITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG * 1u)
/* Number of words to use for each element in the linked list. */ /* Number of words to use for each element in the linked list. */
#ifndef BITMAP_ELEMENT_WORDS #ifndef BITMAP_ELEMENT_WORDS
#define BITMAP_ELEMENT_WORDS ((128 + nBITMAP_WORD_BITS - 1) / nBITMAP_WORD_BITS) #define BITMAP_ELEMENT_WORDS ((128 + BITMAP_WORD_BITS - 1) / BITMAP_WORD_BITS)
#endif #endif
/* Number of bits in each actual element of a bitmap. We get slightly better /* Number of bits in each actual element of a bitmap. */
code for bit % BITMAP_ELEMENT_ALL_BITS and bit / BITMAP_ELEMENT_ALL_BITS if
bits is unsigned, assuming it is a power of 2. */
#define BITMAP_ELEMENT_ALL_BITS \ #define BITMAP_ELEMENT_ALL_BITS (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS)
((unsigned) (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS))
/* Bitmap set element. We use a linked list to hold only the bits that /* Bitmap set element. We use a linked list to hold only the bits that
are set. This allows for use to grow the bitset dynamically without are set. This allows for use to grow the bitset dynamically without
...@@ -132,8 +128,7 @@ extern void bitmap_release_memory (void); ...@@ -132,8 +128,7 @@ extern void bitmap_release_memory (void);
/* A few compatibility/functions macros for compatibility with sbitmaps */ /* A few compatibility/functions macros for compatibility with sbitmaps */
#define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n") #define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n")
#define bitmap_zero(a) bitmap_clear (a) #define bitmap_zero(a) bitmap_clear (a)
extern int bitmap_first_set_bit (bitmap); extern unsigned bitmap_first_set_bit (bitmap);
extern int bitmap_last_set_bit (bitmap);
/* Allocate a bitmap with oballoc. */ /* Allocate a bitmap with oballoc. */
#define BITMAP_OBSTACK_ALLOC(OBSTACK) \ #define BITMAP_OBSTACK_ALLOC(OBSTACK) \
......
...@@ -1022,13 +1022,12 @@ livethrough_conflicts_bb (basic_block bb) ...@@ -1022,13 +1022,12 @@ livethrough_conflicts_bb (basic_block bb)
struct ra_bb_info *info = (struct ra_bb_info *) bb->aux; struct ra_bb_info *info = (struct ra_bb_info *) bb->aux;
rtx insn; rtx insn;
bitmap all_defs; bitmap all_defs;
int first;
unsigned use_id; unsigned use_id;
unsigned int deaths = 0; unsigned int deaths = 0;
unsigned int contains_call = 0; unsigned int contains_call = 0;
/* If there are no deferred uses, just return. */ /* If there are no deferred uses, just return. */
if ((first = bitmap_first_set_bit (info->live_throughout)) < 0) if (bitmap_empty_p (info->live_throughout))
return; return;
/* First collect the IDs of all defs, count the number of death /* First collect the IDs of all defs, count the number of death
...@@ -1061,7 +1060,7 @@ livethrough_conflicts_bb (basic_block bb) ...@@ -1061,7 +1060,7 @@ livethrough_conflicts_bb (basic_block bb)
{ {
bitmap_iterator bi; bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (info->live_throughout, first, use_id, bi) EXECUTE_IF_SET_IN_BITMAP (info->live_throughout, 0, use_id, bi)
{ {
struct web_part *wp = &web_parts[df->def_id + use_id]; struct web_part *wp = &web_parts[df->def_id + use_id];
unsigned int bl = rtx_to_bits (DF_REF_REG (wp->ref)); unsigned int bl = rtx_to_bits (DF_REF_REG (wp->ref));
......
...@@ -2094,7 +2094,7 @@ analyze_edges_for_bb (basic_block bb, FILE *debug_file) ...@@ -2094,7 +2094,7 @@ analyze_edges_for_bb (basic_block bb, FILE *debug_file)
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
gcc_assert (VARRAY_ACTIVE_SIZE (edge_leader) == 0); gcc_assert (VARRAY_ACTIVE_SIZE (edge_leader) == 0);
gcc_assert (VARRAY_ACTIVE_SIZE (stmt_list) == 0); gcc_assert (VARRAY_ACTIVE_SIZE (stmt_list) == 0);
gcc_assert (bitmap_first_set_bit (leader_has_match) == -1); gcc_assert (bitmap_empty_p (leader_has_match));
#endif #endif
} }
......
...@@ -768,18 +768,20 @@ bitmap_print_value_set (FILE *outfile, bitmap_set_t set, ...@@ -768,18 +768,20 @@ bitmap_print_value_set (FILE *outfile, bitmap_set_t set,
fprintf (outfile, "%s[%d] := { ", setname, blockindex); fprintf (outfile, "%s[%d] := { ", setname, blockindex);
if (set) if (set)
{ {
bool first;
unsigned i; unsigned i;
bitmap_iterator bi; bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (set->expressions, 0, i, bi) EXECUTE_IF_SET_IN_BITMAP (set->expressions, 0, i, bi)
{ {
if (!first)
fprintf (outfile, ", ");
first = false;
print_generic_expr (outfile, ssa_name (i), 0); print_generic_expr (outfile, ssa_name (i), 0);
fprintf (outfile, " ("); fprintf (outfile, " (");
print_generic_expr (outfile, get_value_handle (ssa_name (i)), 0); print_generic_expr (outfile, get_value_handle (ssa_name (i)), 0);
fprintf (outfile, ") "); fprintf (outfile, ") ");
if (bitmap_last_set_bit (set->expressions) != (int)i)
fprintf (outfile, ", ");
} }
} }
fprintf (outfile, " }\n"); fprintf (outfile, " }\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment