diff options
author | crowl <crowl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-01 21:02:15 +0000 |
---|---|---|
committer | crowl <crowl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-11-01 21:02:15 +0000 |
commit | 0d21196387a8566f0b98f35adc355932393b670e (patch) | |
tree | 6a2b07bcbe69d6025168367c7ef581e376cca84c /gcc/sbitmap.h | |
parent | 41f4033b94a7a17e766e29386542f087ae0e2dfa (diff) | |
download | gcc-0d21196387a8566f0b98f35adc355932393b670e.tar.gz |
This patch renames sbitmap iterators to unify them with the bitmap iterators.
Remove the unused EXECUTE_IF_SET_IN_SBITMAP_REV, which has an unconventional
interface.
Rename the sbitmap_iter_* functions to match bitmap's bmp_iter_* functions.
Add an additional parameter to the initialization and next functions to
match the interface in bmp_iter_*. This extra parameter is mostly hidden
by the use of the EXECUTE_IF macros.
Rename the EXECUTE_IF_SET_IN_SBITMAP macro to EXECUTE_IF_SET_IN_BITMAP. Its
implementation is now identical to that in bitmap.h. To prevent redefinition
errors, both definitions are now guarded by #ifndef. An alternate strategy
is to simply include bitmap.h from sbitmap.h. As this would increase build
time, I have elected to use the #ifndef version. I do not have a strong
preference here.
The sbitmap_iterator type is still distinctly named because it is often
declared in contexts where the bitmap type is not obvious. There are less
than 40 uses of this type, so the burden to modify it when changing bitmap
types is not large.
Tested on x86-64, config-list.mk testing.
Index: gcc/ChangeLog
2012-10-31 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.
(sbitmap_iter_cond): Rename bmp_iter_set. Update callers.
(sbitmap_iter_next): Rename bmp_iter_next and add unused parameter to
match bitmap iterator. Update callers.
(EXECUTE_IF_SET_IN_SBITMAP_REV): Remove unused.
(EXECUTE_IF_SET_IN_SBITMAP): Rename EXECUTE_IF_SET_IN_BITMAP and
adjust to be identical to the definition in bitmap.h. Conditionalize
the definition based on not having been defined. Update callers.
* bitmap.h (EXECUTE_IF_SET_IN_BITMAP): Conditionalize the definition
based on not having been defined. (To match the above.)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193069 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/sbitmap.h')
-rw-r--r-- | gcc/sbitmap.h | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index 02e3c8147c8..96590d4e176 100644 --- a/gcc/sbitmap.h +++ b/gcc/sbitmap.h @@ -45,7 +45,7 @@ along with GCC; see the file COPYING3. If not see * cardinality : sbitmap_popcount * choose_one : bitmap_first_set_bit / bitmap_last_set_bit - * forall : EXECUTE_IF_SET_IN_SBITMAP + * forall : EXECUTE_IF_SET_IN_BITMAP * set_copy : bitmap_copy / bitmap_copy_n * set_intersection : bitmap_and * set_union : bitmap_ior @@ -177,7 +177,8 @@ typedef struct { MIN. */ static inline void -sbitmap_iter_init (sbitmap_iterator *i, const_sbitmap bmp, unsigned int min) +bmp_iter_set_init (sbitmap_iterator *i, const_sbitmap bmp, + unsigned int min, unsigned *bit_no ATTRIBUTE_UNUSED) { i->word_num = min / (unsigned int) SBITMAP_ELT_BITS; i->bit_num = min; @@ -196,7 +197,7 @@ sbitmap_iter_init (sbitmap_iterator *i, const_sbitmap bmp, unsigned int min) false. */ static inline bool -sbitmap_iter_cond (sbitmap_iterator *i, unsigned int *n) +bmp_iter_set (sbitmap_iterator *i, unsigned int *n) { /* Skip words that are zeros. */ for (; i->word == 0; i->word = i->ptr[i->word_num]) @@ -222,7 +223,7 @@ sbitmap_iter_cond (sbitmap_iterator *i, unsigned int *n) /* Advance to the next bit. */ static inline void -sbitmap_iter_next (sbitmap_iterator *i) +bmp_iter_next (sbitmap_iterator *i, unsigned *bit_no ATTRIBUTE_UNUSED) { i->word >>= 1; i->bit_num++; @@ -232,38 +233,13 @@ sbitmap_iter_next (sbitmap_iterator *i) iteration, N is set to the index of the bit being visited. ITER is an instance of sbitmap_iterator used to iterate the bitmap. */ -#define EXECUTE_IF_SET_IN_SBITMAP(SBITMAP, MIN, N, ITER) \ - for (sbitmap_iter_init (&(ITER), (SBITMAP), (MIN)); \ - sbitmap_iter_cond (&(ITER), &(N)); \ - sbitmap_iter_next (&(ITER))) - -#define EXECUTE_IF_SET_IN_SBITMAP_REV(SBITMAP, N, CODE) \ -do { \ - unsigned int word_num_; \ - unsigned int bit_num_; \ - unsigned int size_ = (SBITMAP)->size; \ - SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms; \ - \ - for (word_num_ = size_; word_num_ > 0; word_num_--) \ - { \ - SBITMAP_ELT_TYPE word_ = ptr_[word_num_ - 1]; \ - \ - if (word_ != 0) \ - for (bit_num_ = SBITMAP_ELT_BITS; bit_num_ > 0; bit_num_--) \ - { \ - SBITMAP_ELT_TYPE _mask = (SBITMAP_ELT_TYPE)1 << (bit_num_ - 1);\ - \ - if ((word_ & _mask) != 0) \ - { \ - word_ &= ~ _mask; \ - (N) = (word_num_ - 1) * SBITMAP_ELT_BITS + bit_num_ - 1;\ - CODE; \ - if (word_ == 0) \ - break; \ - } \ - } \ - } \ -} while (0) +#ifndef EXECUTE_IF_SET_IN_BITMAP +/* See bitmap.h for the other definition of EXECUTE_IF_SET_IN_BITMAP. */ +#define EXECUTE_IF_SET_IN_BITMAP(BITMAP, MIN, BITNUM, ITER) \ + for (bmp_iter_set_init (&(ITER), (BITMAP), (MIN), &(BITNUM)); \ + bmp_iter_set (&(ITER), &(BITNUM)); \ + bmp_iter_next (&(ITER), &(BITNUM))) +#endif inline void sbitmap_free (sbitmap map) { |