1 /* Functions to support general ended bitmaps.
2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include "coretypes.h"
32 /* Obstack to allocate bitmap elements from. */
33 static struct obstack bitmap_obstack;
34 static int bitmap_obstack_init = FALSE;
40 #define INLINE __inline__
45 bitmap_element bitmap_zero_bits; /* An element of all zero bits. */
46 static bitmap_element *bitmap_free; /* Freelist of bitmap elements. */
47 static GTY((deletable)) bitmap_element *bitmap_ggc_free;
49 static void bitmap_elem_to_freelist (bitmap, bitmap_element *);
50 static void bitmap_element_free (bitmap, bitmap_element *);
51 static bitmap_element *bitmap_element_allocate (bitmap);
52 static int bitmap_element_zerop (bitmap_element *);
53 static void bitmap_element_link (bitmap, bitmap_element *);
54 static bitmap_element *bitmap_elt_insert_after (bitmap, bitmap_element *);
55 static void bitmap_elt_clear_from (bitmap, bitmap_element *);
56 static bitmap_element *bitmap_find_bit (bitmap, unsigned int);
59 /* Add ELEM to the appropriate freelist. */
61 bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
63 if (head->using_obstack)
65 elt->next = bitmap_free;
70 elt->next = bitmap_ggc_free;
71 bitmap_ggc_free = elt;
75 /* Free a bitmap element. Since these are allocated off the
76 bitmap_obstack, "free" actually means "put onto the freelist". */
79 bitmap_element_free (bitmap head, bitmap_element *elt)
81 bitmap_element *next = elt->next;
82 bitmap_element *prev = elt->prev;
90 if (head->first == elt)
93 /* Since the first thing we try is to insert before current,
94 make current the next entry in preference to the previous. */
95 if (head->current == elt)
97 head->current = next != 0 ? next : prev;
99 head->indx = head->current->indx;
101 bitmap_elem_to_freelist (head, elt);
104 /* Allocate a bitmap element. The bits are cleared, but nothing else is. */
106 static INLINE bitmap_element *
107 bitmap_element_allocate (bitmap head)
109 bitmap_element *element;
111 if (head->using_obstack)
113 if (bitmap_free != 0)
115 element = bitmap_free;
116 bitmap_free = element->next;
120 /* We can't use gcc_obstack_init to initialize the obstack since
121 print-rtl.c now calls bitmap functions, and bitmap is linked
122 into the gen* functions. */
123 if (!bitmap_obstack_init)
125 bitmap_obstack_init = TRUE;
127 #if !defined(__GNUC__) || (__GNUC__ < 2)
128 #define __alignof__(type) 0
131 obstack_specify_allocation (&bitmap_obstack, OBSTACK_CHUNK_SIZE,
132 __alignof__ (bitmap_element),
137 element = XOBNEW (&bitmap_obstack, bitmap_element);
142 if (bitmap_ggc_free != NULL)
144 element = bitmap_ggc_free;
145 bitmap_ggc_free = element->next;
148 element = GGC_NEW (bitmap_element);
151 memset (element->bits, 0, sizeof (element->bits));
156 /* Release any memory allocated by bitmaps. */
159 bitmap_release_memory (void)
162 if (bitmap_obstack_init)
164 bitmap_obstack_init = FALSE;
165 obstack_free (&bitmap_obstack, NULL);
169 /* Return nonzero if all bits in an element are zero. */
172 bitmap_element_zerop (bitmap_element *element)
174 #if BITMAP_ELEMENT_WORDS == 2
175 return (element->bits[0] | element->bits[1]) == 0;
179 for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
180 if (element->bits[i] != 0)
187 /* Link the bitmap element into the current bitmap linked list. */
190 bitmap_element_link (bitmap head, bitmap_element *element)
192 unsigned int indx = element->indx;
195 /* If this is the first and only element, set it in. */
196 if (head->first == 0)
198 element->next = element->prev = 0;
199 head->first = element;
202 /* If this index is less than that of the current element, it goes someplace
203 before the current element. */
204 else if (indx < head->indx)
206 for (ptr = head->current;
207 ptr->prev != 0 && ptr->prev->indx > indx;
212 ptr->prev->next = element;
214 head->first = element;
216 element->prev = ptr->prev;
221 /* Otherwise, it must go someplace after the current element. */
224 for (ptr = head->current;
225 ptr->next != 0 && ptr->next->indx < indx;
230 ptr->next->prev = element;
232 element->next = ptr->next;
237 /* Set up so this is the first element searched. */
238 head->current = element;
242 /* Insert a new uninitialized element into bitmap HEAD after element
243 ELT. If ELT is NULL, insert the element at the start. Return the
246 static bitmap_element *
247 bitmap_elt_insert_after (bitmap head, bitmap_element *elt)
249 bitmap_element *node = bitmap_element_allocate (head);
254 head->current = node;
255 node->next = head->first;
257 node->next->prev = node;
263 gcc_assert (head->current);
264 node->next = elt->next;
266 node->next->prev = node;
273 /* Remove ELT and all following elements from bitmap HEAD. */
276 bitmap_elt_clear_from (bitmap head, bitmap_element *elt)
278 bitmap_element *next;
283 bitmap_element_free (head, elt);
289 /* Clear a bitmap by freeing the linked list. */
292 bitmap_clear (bitmap head)
294 bitmap_element *element, *next;
296 for (element = head->first; element != 0; element = next)
298 next = element->next;
299 bitmap_elem_to_freelist (head, element);
302 head->first = head->current = 0;
305 /* Copy a bitmap to another bitmap. */
308 bitmap_copy (bitmap to, bitmap from)
310 bitmap_element *from_ptr, *to_ptr = 0;
311 #if BITMAP_ELEMENT_WORDS != 2
317 /* Copy elements in forward direction one at a time. */
318 for (from_ptr = from->first; from_ptr; from_ptr = from_ptr->next)
320 bitmap_element *to_elt = bitmap_element_allocate (to);
322 to_elt->indx = from_ptr->indx;
324 #if BITMAP_ELEMENT_WORDS == 2
325 to_elt->bits[0] = from_ptr->bits[0];
326 to_elt->bits[1] = from_ptr->bits[1];
328 for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
329 to_elt->bits[i] = from_ptr->bits[i];
332 /* Here we have a special case of bitmap_element_link, for the case
333 where we know the links are being entered in sequence. */
336 to->first = to->current = to_elt;
337 to->indx = from_ptr->indx;
338 to_elt->next = to_elt->prev = 0;
342 to_elt->prev = to_ptr;
344 to_ptr->next = to_elt;
351 /* Find a bitmap element that would hold a bitmap's bit.
352 Update the `current' field even if we can't find an element that
353 would hold the bitmap's bit to make eventual allocation
356 static INLINE bitmap_element *
357 bitmap_find_bit (bitmap head, unsigned int bit)
359 bitmap_element *element;
360 unsigned int indx = bit / BITMAP_ELEMENT_ALL_BITS;
362 if (head->current == 0
363 || head->indx == indx)
364 return head->current;
366 if (head->indx > indx)
367 for (element = head->current;
368 element->prev != 0 && element->indx > indx;
369 element = element->prev)
373 for (element = head->current;
374 element->next != 0 && element->indx < indx;
375 element = element->next)
378 /* `element' is the nearest to the one we want. If it's not the one we
379 want, the one we want doesn't exist. */
380 head->current = element;
381 head->indx = element->indx;
382 if (element != 0 && element->indx != indx)
388 /* Clear a single bit in a bitmap. */
391 bitmap_clear_bit (bitmap head, int bit)
393 bitmap_element *ptr = bitmap_find_bit (head, bit);
397 unsigned bit_num = bit % BITMAP_WORD_BITS;
398 unsigned word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS;
399 ptr->bits[word_num] &= ~ (((BITMAP_WORD) 1) << bit_num);
401 /* If we cleared the entire word, free up the element. */
402 if (bitmap_element_zerop (ptr))
403 bitmap_element_free (head, ptr);
407 /* Set a single bit in a bitmap. */
410 bitmap_set_bit (bitmap head, int bit)
412 bitmap_element *ptr = bitmap_find_bit (head, bit);
413 unsigned word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS;
414 unsigned bit_num = bit % BITMAP_WORD_BITS;
415 BITMAP_WORD bit_val = ((BITMAP_WORD) 1) << bit_num;
419 ptr = bitmap_element_allocate (head);
420 ptr->indx = bit / BITMAP_ELEMENT_ALL_BITS;
421 ptr->bits[word_num] = bit_val;
422 bitmap_element_link (head, ptr);
425 ptr->bits[word_num] |= bit_val;
428 /* Return whether a bit is set within a bitmap. */
431 bitmap_bit_p (bitmap head, int bit)
437 ptr = bitmap_find_bit (head, bit);
441 bit_num = bit % BITMAP_WORD_BITS;
442 word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS;
444 return (ptr->bits[word_num] >> bit_num) & 1;
447 /* Return the bit number of the first set bit in the bitmap, or -1
448 if the bitmap is empty. */
451 bitmap_first_set_bit (bitmap a)
453 bitmap_element *ptr = a->first;
455 unsigned word_num, bit_num;
460 #if BITMAP_ELEMENT_WORDS == 2
461 word_num = 0, word = ptr->bits[0];
463 word_num = 1, word = ptr->bits[1];
465 for (word_num = 0; word_num < BITMAP_ELEMENT_WORDS; ++word_num)
466 if ((word = ptr->bits[word_num]) != 0)
472 /* Binary search for the first set bit. */
473 /* ??? It'd be nice to know if ffs or ffsl was available. */
478 #if nBITMAP_WORD_BITS > 64
479 #error "Fill out the table."
481 #if nBITMAP_WORD_BITS > 32
482 if ((word & 0xffffffff) == 0)
483 word >>= 32, bit_num += 32;
485 if ((word & 0xffff) == 0)
486 word >>= 16, bit_num += 16;
487 if ((word & 0xff) == 0)
488 word >>= 8, bit_num += 8;
496 return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
497 + word_num * BITMAP_WORD_BITS
501 /* Return the bit number of the last set bit in the bitmap, or -1
502 if the bitmap is empty. */
505 bitmap_last_set_bit (bitmap a)
507 bitmap_element *ptr = a->first;
509 unsigned word_num, bit_num;
514 while (ptr->next != NULL)
517 #if BITMAP_ELEMENT_WORDS == 2
518 word_num = 1, word = ptr->bits[1];
520 word_num = 0, word = ptr->bits[0];
522 for (word_num = BITMAP_ELEMENT_WORDS; word_num-- > 0; )
523 if ((word = ptr->bits[word_num]) != 0)
529 /* Binary search for the last set bit. */
532 #if nBITMAP_WORD_BITS > 64
533 #error "Fill out the table."
535 #if nBITMAP_WORD_BITS > 32
536 if (word & ~(BITMAP_WORD)0xffffffff)
537 word >>= 32, bit_num += 32;
539 if (word & 0xffff0000)
540 word >>= 16, bit_num += 16;
542 word >>= 8, bit_num += 8;
544 word >>= 4, bit_num += 4;
546 word >>= 2, bit_num += 2;
550 return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
551 + word_num * BITMAP_WORD_BITS
559 bitmap_and (bitmap dst, bitmap a, bitmap b)
561 bitmap_element *dst_elt = dst->first;
562 bitmap_element *a_elt = a->first;
563 bitmap_element *b_elt = b->first;
564 bitmap_element *dst_prev = NULL;
566 gcc_assert (dst != a && dst != b && a != b);
567 while (a_elt && b_elt)
569 if (a_elt->indx < b_elt->indx)
571 else if (b_elt->indx < a_elt->indx)
575 /* Matching elts, generate A & B. */
580 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
582 dst_elt->indx = a_elt->indx;
583 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
585 BITMAP_WORD r = a_elt->bits[ix] & b_elt->bits[ix];
587 dst_elt->bits[ix] = r;
593 dst_elt = dst_elt->next;
599 bitmap_elt_clear_from (dst, dst_elt);
600 gcc_assert (!dst->current == !dst->first);
602 dst->indx = dst->current->indx;
608 bitmap_and_into (bitmap a, bitmap b)
610 bitmap_element *a_elt = a->first;
611 bitmap_element *b_elt = b->first;
612 bitmap_element *next;
615 while (a_elt && b_elt)
617 if (a_elt->indx < b_elt->indx)
620 bitmap_element_free (a, a_elt);
623 else if (b_elt->indx < a_elt->indx)
627 /* Matching elts, generate A &= B. */
631 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
633 BITMAP_WORD r = a_elt->bits[ix] & b_elt->bits[ix];
640 bitmap_element_free (a, a_elt);
645 bitmap_elt_clear_from (a, a_elt);
646 gcc_assert (!a->current == !a->first);
647 gcc_assert (!a->current || a->indx == a->current->indx);
653 bitmap_and_compl (bitmap dst, bitmap a, bitmap b)
655 bitmap_element *dst_elt = dst->first;
656 bitmap_element *a_elt = a->first;
657 bitmap_element *b_elt = b->first;
658 bitmap_element *dst_prev = NULL;
660 gcc_assert (dst != a && dst != b && a != b);
664 if (!b_elt || a_elt->indx < b_elt->indx)
668 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
670 dst_elt->indx = a_elt->indx;
671 memcpy (dst_elt->bits, a_elt->bits, sizeof (dst_elt->bits));
673 dst_elt = dst_elt->next;
676 else if (b_elt->indx < a_elt->indx)
680 /* Matching elts, generate A & ~B. */
685 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
687 dst_elt->indx = a_elt->indx;
688 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
690 BITMAP_WORD r = a_elt->bits[ix] & ~b_elt->bits[ix];
692 dst_elt->bits[ix] = r;
698 dst_elt = dst_elt->next;
704 bitmap_elt_clear_from (dst, dst_elt);
705 gcc_assert (!dst->current == !dst->first);
707 dst->indx = dst->current->indx;
713 bitmap_and_compl_into (bitmap a, bitmap b)
715 bitmap_element *a_elt = a->first;
716 bitmap_element *b_elt = b->first;
717 bitmap_element *next;
720 while (a_elt && b_elt)
722 if (a_elt->indx < b_elt->indx)
724 else if (b_elt->indx < a_elt->indx)
728 /* Matching elts, generate A &= ~B. */
732 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
734 BITMAP_WORD r = a_elt->bits[ix] & ~b_elt->bits[ix];
741 bitmap_element_free (a, a_elt);
746 gcc_assert (!a->current == !a->first);
747 gcc_assert (!a->current || a->indx == a->current->indx);
750 /* DST = A | B. Return true if DST changes. */
753 bitmap_ior (bitmap dst, bitmap a, bitmap b)
755 bitmap_element *dst_elt = dst->first;
756 bitmap_element *a_elt = a->first;
757 bitmap_element *b_elt = b->first;
758 bitmap_element *dst_prev = NULL;
759 bool changed = false;
761 gcc_assert (dst != a && dst != b && a != b);
762 while (a_elt || b_elt)
764 if (a_elt && b_elt && a_elt->indx == b_elt->indx)
766 /* Matching elts, generate A | B. */
769 if (!changed && dst_elt && dst_elt->indx == a_elt->indx)
771 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
773 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
775 if (r != dst_elt->bits[ix])
777 dst_elt->bits[ix] = r;
786 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
787 dst_elt->indx = a_elt->indx;
788 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
790 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
792 dst_elt->bits[ix] = r;
798 dst_elt = dst_elt->next;
802 /* Copy a single element. */
805 if (!b_elt || (a_elt && a_elt->indx < b_elt->indx))
816 if (!changed && dst_elt && dst_elt->indx == src->indx)
820 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
821 if (src->bits[ix] != dst_elt->bits[ix])
823 dst_elt->bits[ix] = src->bits[ix];
831 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
832 dst_elt->indx = src->indx;
833 memcpy (dst_elt->bits, src->bits, sizeof (dst_elt->bits));
837 dst_elt = dst_elt->next;
844 bitmap_elt_clear_from (dst, dst_elt);
846 gcc_assert (!dst->current == !dst->first);
848 dst->indx = dst->current->indx;
852 /* A |= B. Return true if A changes. */
855 bitmap_ior_into (bitmap a, bitmap b)
857 bitmap_element *a_elt = a->first;
858 bitmap_element *b_elt = b->first;
859 bitmap_element *a_prev = NULL;
860 bool changed = false;
865 if (!a_elt || b_elt->indx < a_elt->indx)
868 bitmap_element *dst = bitmap_elt_insert_after (a, a_prev);
870 dst->indx = b_elt->indx;
871 memcpy (dst->bits, b_elt->bits, sizeof (dst->bits));
876 else if (a_elt->indx < b_elt->indx)
883 /* Matching elts, generate A |= B. */
887 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
889 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
894 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
896 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
898 if (a_elt->bits[ix] != r)
909 gcc_assert (!a->current == !a->first);
911 a->indx = a->current->indx;
918 bitmap_xor (bitmap dst, bitmap a, bitmap b)
920 bitmap_element *dst_elt = dst->first;
921 bitmap_element *a_elt = a->first;
922 bitmap_element *b_elt = b->first;
923 bitmap_element *dst_prev = NULL;
925 gcc_assert (dst != a && dst != b && a != b);
926 while (a_elt || b_elt)
928 if (a_elt && b_elt && a_elt->indx == b_elt->indx)
930 /* Matching elts, generate A ^ B. */
935 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
937 dst_elt->indx = a_elt->indx;
938 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
940 BITMAP_WORD r = a_elt->bits[ix] ^ b_elt->bits[ix];
943 dst_elt->bits[ix] = r;
950 dst_elt = dst_elt->next;
955 /* Copy a single element. */
958 if (!b_elt || (a_elt && a_elt->indx < b_elt->indx))
970 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
972 dst_elt->indx = src->indx;
973 memcpy (dst_elt->bits, src->bits, sizeof (dst_elt->bits));
975 dst_elt = dst_elt->next;
978 bitmap_elt_clear_from (dst, dst_elt);
979 gcc_assert (!dst->current == !dst->first);
981 dst->indx = dst->current->indx;
987 bitmap_xor_into (bitmap a, bitmap b)
989 bitmap_element *a_elt = a->first;
990 bitmap_element *b_elt = b->first;
991 bitmap_element *a_prev = NULL;
996 if (!a_elt || b_elt->indx < a_elt->indx)
999 bitmap_element *dst = bitmap_elt_insert_after (a, a_prev);
1001 dst->indx = b_elt->indx;
1002 memcpy (dst->bits, b_elt->bits, sizeof (dst->bits));
1004 b_elt = b_elt->next;
1006 else if (a_elt->indx < b_elt->indx)
1009 a_elt = a_elt->next;
1013 /* Matching elts, generate A ^= B. */
1015 BITMAP_WORD ior = 0;
1016 bitmap_element *next = a_elt->next;
1018 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1020 BITMAP_WORD r = a_elt->bits[ix] ^ b_elt->bits[ix];
1023 a_elt->bits[ix] = r;
1025 b_elt = b_elt->next;
1029 bitmap_element_free (a, a_elt);
1033 gcc_assert (!a->current == !a->first);
1035 a->indx = a->current->indx;
1038 /* Return true if two bitmaps are identical.
1039 We do not bother with a check for pointer equality, as that never
1040 occurs in practice. */
1043 bitmap_equal_p (bitmap a, bitmap b)
1045 bitmap_element *a_elt;
1046 bitmap_element *b_elt;
1049 for (a_elt = a->first, b_elt = b->first;
1051 a_elt = a_elt->next, b_elt = b_elt->next)
1053 if (a_elt->indx != b_elt->indx)
1055 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1056 if (a_elt->bits[ix] != b_elt->bits[ix])
1059 return !a_elt && !b_elt;
1062 /* Return true if A AND B is not empty. */
1065 bitmap_intersect_p (bitmap a, bitmap b)
1067 bitmap_element *a_elt;
1068 bitmap_element *b_elt;
1071 for (a_elt = a->first, b_elt = b->first;
1074 if (a_elt->indx < b_elt->indx)
1075 a_elt = a_elt->next;
1076 else if (b_elt->indx < a_elt->indx)
1077 b_elt = b_elt->next;
1080 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1081 if (a_elt->bits[ix] & b_elt->bits[ix])
1083 a_elt = a_elt->next;
1084 b_elt = b_elt->next;
1090 /* Return true if A AND NOT B is not empty. */
1093 bitmap_intersect_compl_p (bitmap a, bitmap b)
1095 bitmap_element *a_elt;
1096 bitmap_element *b_elt;
1098 for (a_elt = a->first, b_elt = b->first;
1101 if (a_elt->indx < b_elt->indx)
1103 else if (b_elt->indx < a_elt->indx)
1104 b_elt = b_elt->next;
1107 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1108 if (a_elt->bits[ix] & ~b_elt->bits[ix])
1110 a_elt = a_elt->next;
1111 b_elt = b_elt->next;
1114 return a_elt != NULL;
1118 /* DST = A | (FROM1 & ~FROM2). Return true if DST changes. */
1121 bitmap_ior_and_compl (bitmap dst, bitmap a, bitmap from1, bitmap from2)
1126 tmp.first = tmp.current = 0;
1127 tmp.using_obstack = 0;
1128 bitmap_and_compl (&tmp, from1, from2);
1129 changed = bitmap_ior (dst, a, &tmp);
1130 bitmap_clear (&tmp);
1135 /* A |= (FROM1 & ~FROM2). Return true if A changes. */
1138 bitmap_ior_and_compl_into (bitmap a, bitmap from1, bitmap from2)
1143 tmp.first = tmp.current = 0;
1144 tmp.using_obstack = 0;
1145 bitmap_and_compl (&tmp, from1, from2);
1146 changed = bitmap_ior_into (a, &tmp);
1147 bitmap_clear (&tmp);
1152 /* Initialize a bitmap header. */
1155 bitmap_initialize (bitmap head, int using_obstack)
1157 if (head == NULL && ! using_obstack)
1158 head = GGC_NEW (struct bitmap_head_def);
1160 head->first = head->current = 0;
1161 head->using_obstack = using_obstack;
1166 /* Debugging function to print out the contents of a bitmap. */
1169 debug_bitmap_file (FILE *file, bitmap head)
1171 bitmap_element *ptr;
1173 fprintf (file, "\nfirst = " HOST_PTR_PRINTF
1174 " current = " HOST_PTR_PRINTF " indx = %u\n",
1175 (void *) head->first, (void *) head->current, head->indx);
1177 for (ptr = head->first; ptr; ptr = ptr->next)
1179 unsigned int i, j, col = 26;
1181 fprintf (file, "\t" HOST_PTR_PRINTF " next = " HOST_PTR_PRINTF
1182 " prev = " HOST_PTR_PRINTF " indx = %u\n\t\tbits = {",
1183 (void*) ptr, (void*) ptr->next, (void*) ptr->prev, ptr->indx);
1185 for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
1186 for (j = 0; j < BITMAP_WORD_BITS; j++)
1187 if ((ptr->bits[i] >> j) & 1)
1191 fprintf (file, "\n\t\t\t");
1195 fprintf (file, " %u", (ptr->indx * BITMAP_ELEMENT_ALL_BITS
1196 + i * BITMAP_WORD_BITS + j));
1200 fprintf (file, " }\n");
1204 /* Function to be called from the debugger to print the contents
1208 debug_bitmap (bitmap head)
1210 debug_bitmap_file (stdout, head);
1213 /* Function to print out the contents of a bitmap. Unlike debug_bitmap_file,
1214 it does not print anything but the bits. */
1217 bitmap_print (FILE *file, bitmap head, const char *prefix, const char *suffix)
1219 const char *comma = "";
1223 fputs (prefix, file);
1224 EXECUTE_IF_SET_IN_BITMAP (head, 0, i, bi)
1226 fprintf (file, "%s%d", comma, i);
1229 fputs (suffix, file);
1232 #include "gt-bitmap.h"