summaryrefslogtreecommitdiff
path: root/gcc/bitmap.h
diff options
context:
space:
mode:
authormeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-09-04 15:12:20 +0000
committermeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-09-04 15:12:20 +0000
commit23ec99a1993dd93385bd55a191fcefe643e9546a (patch)
treede700dc0cf119390613c23ee4b4497363513c8c2 /gcc/bitmap.h
parentc01db9d6a3df1551a2f994b2f2dad5e5842c55ff (diff)
downloadgcc-23ec99a1993dd93385bd55a191fcefe643e9546a.tar.gz
Add EXECUTE_IF_AND_IN_{BITMAP,REG_SET}, and bitmap_print
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@15071 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/bitmap.h')
-rw-r--r--gcc/bitmap.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/gcc/bitmap.h b/gcc/bitmap.h
index a01e398c287..343b24911c0 100644
--- a/gcc/bitmap.h
+++ b/gcc/bitmap.h
@@ -88,6 +88,9 @@ extern int bitmap_bit_p PROTO((bitmap, int));
extern void bitmap_debug PROTO((bitmap));
extern void bitmap_debug_file STDIO_PROTO((FILE *, bitmap));
+/* Print a bitmap */
+extern void bitmap_print STDIO_PROTO((FILE *, bitmap, char *, char *));
+
/* Initialize a bitmap header. */
extern bitmap bitmap_initialize PROTO((bitmap));
@@ -237,3 +240,76 @@ do { \
word_num_ = 0; \
} \
} while (0)
+
+/* Loop over all bits in BITMAP1 and BITMAP2, starting with MIN, setting
+ BITNUM to the bit number and executing CODE for all bits that are set in
+ the both bitmaps. */
+
+#define EXECUTE_IF_AND_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, CODE) \
+do { \
+ bitmap_element *ptr1_ = (BITMAP1)->first; \
+ bitmap_element *ptr2_ = (BITMAP2)->first; \
+ unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS; \
+ unsigned bit_num_ = (MIN) % ((unsigned) HOST_BITS_PER_WIDE_INT); \
+ unsigned word_num_ = (((MIN) / ((unsigned) HOST_BITS_PER_WIDE_INT)) \
+ % BITMAP_ELEMENT_WORDS); \
+ \
+ /* Find the block the minimum bit is in in the first bitmap. */ \
+ while (ptr1_ != 0 && ptr1_->indx < indx_) \
+ ptr1_ = ptr1_->next; \
+ \
+ if (ptr1_ != 0 && ptr1_->indx != indx_) \
+ { \
+ bit_num_ = 0; \
+ word_num_ = 0; \
+ } \
+ \
+ for (; ptr1_ != 0 ; ptr1_ = ptr1_->next) \
+ { \
+ /* Advance BITMAP2 to the equivalent link */ \
+ while (ptr2_ != 0 && ptr2_->indx < ptr1_->indx) \
+ ptr2_ = ptr2_->next; \
+ \
+ if (ptr2_ == 0) \
+ { \
+ /* If there are no more elements in BITMAP2, exit loop now.*/ \
+ ptr1_ = (bitmap_element *)0; \
+ break; \
+ } \
+ else if (ptr2_->indx > ptr1_->indx) \
+ { \
+ bit_num_ = word_num_ = 0; \
+ continue; \
+ } \
+ \
+ for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++) \
+ { \
+ unsigned HOST_WIDE_INT word_ = (ptr1_->bits[word_num_] \
+ & ptr2_->bits[word_num_]); \
+ if (word_ != 0) \
+ { \
+ for (; bit_num_ < HOST_BITS_PER_WIDE_INT; bit_num_++) \
+ { \
+ unsigned HOST_WIDE_INT mask_ \
+ = ((unsigned HOST_WIDE_INT)1) << bit_num_; \
+ \
+ if ((word_ & mask_) != 0) \
+ { \
+ word_ &= ~ mask_; \
+ (BITNUM) = (ptr1_->indx * BITMAP_ELEMENT_ALL_BITS \
+ + word_num_ * HOST_BITS_PER_WIDE_INT \
+ + bit_num_); \
+ \
+ CODE; \
+ if (word_ == 0) \
+ break; \
+ } \
+ } \
+ } \
+ \
+ bit_num_ = 0; \
+ } \
+ \
+ word_num_ = 0; \
+ } \
+} while (0)