X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=gcc%2Febitmap.c;h=c57d141ddb31c327aa99e6e805b3a9f79ef0bbfa;hp=8a7c7cb75421377d951073a6eb053a8a820a3ba6;hb=b64da4ff182b6bde9b96cc5cdbdfa3a955de4d03;hpb=8c4c00c181e6df4f0a9afc76e4c9edbbc1c2fd41 diff --git a/gcc/ebitmap.c b/gcc/ebitmap.c index 8a7c7cb7542..c57d141ddb3 100644 --- a/gcc/ebitmap.c +++ b/gcc/ebitmap.c @@ -1,5 +1,5 @@ /* 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 This file is part of GCC. @@ -21,10 +21,6 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" -#include "rtl.h" -#include "flags.h" -#include "obstack.h" #include "ebitmap.h" /* The ebitmap data structure is a sparse bitmap structure that works @@ -88,7 +84,7 @@ ebitmap_last_set_bit (ebitmap map) 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. */ @@ -96,7 +92,7 @@ ebitmap_last_set_bit (ebitmap map) { foundbit = true; } - + if (foundbit) return i; @@ -118,7 +114,7 @@ ebitmap_array_grow (ebitmap map, unsigned int newsize) newsize += newsize / 4; map->n_elts = newsize; - map->elts = xrealloc (map->elts, sizeof (EBITMAP_ELT_TYPE) * newsize); + map->elts = XRESIZEVEC (EBITMAP_ELT_TYPE, map->elts, newsize); } /* Grow the internal word array for MAP so it is at least SIZE @@ -161,7 +157,7 @@ ebitmap_array_init (ebitmap map, unsigned int size) { if (size > 0) { - map->elts = xmalloc (sizeof (EBITMAP_ELT_TYPE) * size); + map->elts = XNEWVEC (EBITMAP_ELT_TYPE, size); map->n_elts = size; } else @@ -176,7 +172,7 @@ ebitmap_array_init (ebitmap map, unsigned int size) static inline void ebitmap_array_clear (ebitmap map) { - if (map->elts) + if (map->elts) { free (map->elts); map->elts = NULL; @@ -202,7 +198,7 @@ ebitmap_clear (ebitmap map) ebitmap ebitmap_alloc (unsigned int size) { - ebitmap ret = xmalloc (sizeof (struct ebitmap_def)); + ebitmap ret = XNEW (struct ebitmap_def); if (size == 0) size = EBITMAP_ELT_BITS; ebitmap_array_init (ret, (size + EBITMAP_ELT_BITS - 1) / EBITMAP_ELT_BITS); @@ -225,7 +221,7 @@ ebitmap_clear_bit (ebitmap map, unsigned int bit) 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; @@ -233,7 +229,7 @@ ebitmap_clear_bit (ebitmap map, unsigned int bit) if (wordindex >= map->wordmask->n_bits || !TEST_BIT (map->wordmask, wordindex)) return; - + if (map->cache != NULL && map->cacheindex == wordindex) elt_ptr = map->cache; else @@ -242,10 +238,10 @@ ebitmap_clear_bit (ebitmap map, unsigned int bit) 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. */ @@ -253,9 +249,14 @@ ebitmap_clear_bit (ebitmap map, unsigned int bit) { 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); @@ -405,7 +406,7 @@ dump_ebitmap (FILE *file, ebitmap bmap) /* Dump ebitmap BMAP to stderr. */ -void +DEBUG_FUNCTION void debug_ebitmap (ebitmap bmap) { dump_ebitmap (stderr, bmap); @@ -457,7 +458,7 @@ ebitmap_and_into (ebitmap dst, ebitmap src) 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); } @@ -529,7 +530,7 @@ ebitmap_and (ebitmap dst, ebitmap src1, ebitmap src2) 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); } @@ -595,7 +596,7 @@ ebitmap_ior_into (ebitmap dst, ebitmap src) } } newarraysize = src->numwords + dst->numwords; - newarray = xmalloc (newarraysize * sizeof (EBITMAP_ELT_TYPE)); + newarray = XNEWVEC (EBITMAP_ELT_TYPE, newarraysize); EXECUTE_IF_SET_IN_SBITMAP (tempmask, 0, i, sbi) { @@ -652,7 +653,7 @@ ebitmap_ior_into (ebitmap dst, ebitmap src) 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); @@ -704,7 +705,7 @@ ebitmap_ior (ebitmap dst, ebitmap src1, ebitmap src2) } } newarraysize = src1->numwords + src2->numwords; - newarray = xmalloc (newarraysize * sizeof (EBITMAP_ELT_TYPE)); + newarray = XNEWVEC (EBITMAP_ELT_TYPE, newarraysize); EXECUTE_IF_SET_IN_SBITMAP (tempmask, 0, i, sbi) { @@ -772,7 +773,7 @@ ebitmap_ior (ebitmap dst, ebitmap src1, ebitmap src2) 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); @@ -848,7 +849,7 @@ ebitmap_and_compl_into (ebitmap dst, ebitmap src) 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); @@ -883,7 +884,7 @@ ebitmap_and_compl (ebitmap dst, ebitmap src1, ebitmap src2) sbitmap_copy (tempmask, src1->wordmask); newarraysize = src1->numwords; - newarray = xmalloc (newarraysize * sizeof (EBITMAP_ELT_TYPE)); + newarray = XNEWVEC (EBITMAP_ELT_TYPE, newarraysize); EXECUTE_IF_SET_IN_SBITMAP (src1->wordmask, 0, i, sbi) { @@ -950,7 +951,7 @@ ebitmap_and_compl (ebitmap dst, ebitmap src1, ebitmap src2) 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); }