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"
33 bitmap_element bitmap_zero_bits; /* An element of all zero bits. */
34 bitmap_obstack bitmap_default_obstack; /* The default bitmap obstack. */
35 static GTY((deletable)) bitmap_element *bitmap_ggc_free; /* Freelist of
38 static void bitmap_elem_to_freelist (bitmap, bitmap_element *);
39 static void bitmap_element_free (bitmap, bitmap_element *);
40 static bitmap_element *bitmap_element_allocate (bitmap);
41 static int bitmap_element_zerop (bitmap_element *);
42 static void bitmap_element_link (bitmap, bitmap_element *);
43 static bitmap_element *bitmap_elt_insert_after (bitmap, bitmap_element *);
44 static void bitmap_elt_clear_from (bitmap, bitmap_element *);
45 static bitmap_element *bitmap_find_bit (bitmap, unsigned int);
48 /* Add ELEM to the appropriate freelist. */
50 bitmap_elem_to_freelist (bitmap head, bitmap_element *elt)
52 bitmap_obstack *bit_obstack = head->obstack;
56 elt->next = bit_obstack->elements;
57 bit_obstack->elements = elt;
61 elt->next = bitmap_ggc_free;
62 bitmap_ggc_free = elt;
66 /* Free a bitmap element. Since these are allocated off the
67 bitmap_obstack, "free" actually means "put onto the freelist". */
70 bitmap_element_free (bitmap head, bitmap_element *elt)
72 bitmap_element *next = elt->next;
73 bitmap_element *prev = elt->prev;
81 if (head->first == elt)
84 /* Since the first thing we try is to insert before current,
85 make current the next entry in preference to the previous. */
86 if (head->current == elt)
88 head->current = next != 0 ? next : prev;
90 head->indx = head->current->indx;
92 bitmap_elem_to_freelist (head, elt);
95 /* Allocate a bitmap element. The bits are cleared, but nothing else is. */
97 static inline bitmap_element *
98 bitmap_element_allocate (bitmap head)
100 bitmap_element *element;
101 bitmap_obstack *bit_obstack = head->obstack;
105 element = bit_obstack->elements;
108 bit_obstack->elements = element->next;
110 element = XOBNEW (&bit_obstack->obstack, bitmap_element);
114 element = bitmap_ggc_free;
116 bitmap_ggc_free = element->next;
118 element = GGC_NEW (bitmap_element);
121 memset (element->bits, 0, sizeof (element->bits));
126 /* Remove ELT and all following elements from bitmap HEAD. */
129 bitmap_elt_clear_from (bitmap head, bitmap_element *elt)
131 bitmap_element *next;
136 bitmap_element_free (head, elt);
141 /* Clear a bitmap by freeing the linked list. */
144 bitmap_clear (bitmap head)
146 bitmap_element *element, *next;
148 for (element = head->first; element != 0; element = next)
150 next = element->next;
151 bitmap_elem_to_freelist (head, element);
154 head->first = head->current = 0;
157 /* Initialize a bitmap obstack. If BIT_OBSTACK is NULL, initialize
158 the default bitmap obstack. */
161 bitmap_obstack_initialize (bitmap_obstack *bit_obstack)
164 bit_obstack = &bitmap_default_obstack;
166 #if !defined(__GNUC__) || (__GNUC__ < 2)
167 #define __alignof__(type) 0
170 bit_obstack->elements = NULL;
171 bit_obstack->heads = NULL;
172 obstack_specify_allocation (&bit_obstack->obstack, OBSTACK_CHUNK_SIZE,
173 __alignof__ (bitmap_element),
178 /* Release the memory from a bitmap obstack. If BIT_OBSTACK is NULL,
179 release the default bitmap obstack. */
182 bitmap_obstack_release (bitmap_obstack *bit_obstack)
185 bit_obstack = &bitmap_default_obstack;
187 bit_obstack->elements = NULL;
188 bit_obstack->heads = NULL;
189 obstack_free (&bit_obstack->obstack, NULL);
192 /* Create a new bitmap on an obstack. If BIT_OBSTACK is NULL, create
193 it on the default bitmap obstack. */
196 bitmap_obstack_alloc (bitmap_obstack *bit_obstack)
201 bit_obstack = &bitmap_default_obstack;
202 map = bit_obstack->heads;
204 bit_obstack->heads = (void *)map->first;
206 map = XOBNEW (&bit_obstack->obstack, bitmap_head);
207 bitmap_initialize (map, bit_obstack);
212 /* Create a new GCd bitmap. */
215 bitmap_gc_alloc (void)
219 map = GGC_NEW (struct bitmap_head_def);
220 bitmap_initialize (map, NULL);
225 /* Create a new malloced bitmap. Elements will be allocated from the
226 default bitmap obstack. */
229 bitmap_malloc_alloc (void)
233 map = xmalloc (sizeof (bitmap_head));
234 bitmap_initialize (map, &bitmap_default_obstack);
239 /* Release an obstack allocated bitmap. */
242 bitmap_obstack_free (bitmap map)
245 map->first = (void *)map->obstack->heads;
246 map->obstack->heads = map;
249 /* Release a malloc allocated bitmap. */
252 bitmap_malloc_free (bitmap map)
259 /* Return nonzero if all bits in an element are zero. */
262 bitmap_element_zerop (bitmap_element *element)
264 #if BITMAP_ELEMENT_WORDS == 2
265 return (element->bits[0] | element->bits[1]) == 0;
269 for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
270 if (element->bits[i] != 0)
277 /* Link the bitmap element into the current bitmap linked list. */
280 bitmap_element_link (bitmap head, bitmap_element *element)
282 unsigned int indx = element->indx;
285 /* If this is the first and only element, set it in. */
286 if (head->first == 0)
288 element->next = element->prev = 0;
289 head->first = element;
292 /* If this index is less than that of the current element, it goes someplace
293 before the current element. */
294 else if (indx < head->indx)
296 for (ptr = head->current;
297 ptr->prev != 0 && ptr->prev->indx > indx;
302 ptr->prev->next = element;
304 head->first = element;
306 element->prev = ptr->prev;
311 /* Otherwise, it must go someplace after the current element. */
314 for (ptr = head->current;
315 ptr->next != 0 && ptr->next->indx < indx;
320 ptr->next->prev = element;
322 element->next = ptr->next;
327 /* Set up so this is the first element searched. */
328 head->current = element;
332 /* Insert a new uninitialized element into bitmap HEAD after element
333 ELT. If ELT is NULL, insert the element at the start. Return the
336 static bitmap_element *
337 bitmap_elt_insert_after (bitmap head, bitmap_element *elt)
339 bitmap_element *node = bitmap_element_allocate (head);
344 head->current = node;
345 node->next = head->first;
347 node->next->prev = node;
353 gcc_assert (head->current);
354 node->next = elt->next;
356 node->next->prev = node;
363 /* Copy a bitmap to another bitmap. */
366 bitmap_copy (bitmap to, bitmap from)
368 bitmap_element *from_ptr, *to_ptr = 0;
369 #if BITMAP_ELEMENT_WORDS != 2
375 /* Copy elements in forward direction one at a time. */
376 for (from_ptr = from->first; from_ptr; from_ptr = from_ptr->next)
378 bitmap_element *to_elt = bitmap_element_allocate (to);
380 to_elt->indx = from_ptr->indx;
382 #if BITMAP_ELEMENT_WORDS == 2
383 to_elt->bits[0] = from_ptr->bits[0];
384 to_elt->bits[1] = from_ptr->bits[1];
386 for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
387 to_elt->bits[i] = from_ptr->bits[i];
390 /* Here we have a special case of bitmap_element_link, for the case
391 where we know the links are being entered in sequence. */
394 to->first = to->current = to_elt;
395 to->indx = from_ptr->indx;
396 to_elt->next = to_elt->prev = 0;
400 to_elt->prev = to_ptr;
402 to_ptr->next = to_elt;
409 /* Find a bitmap element that would hold a bitmap's bit.
410 Update the `current' field even if we can't find an element that
411 would hold the bitmap's bit to make eventual allocation
414 static inline bitmap_element *
415 bitmap_find_bit (bitmap head, unsigned int bit)
417 bitmap_element *element;
418 unsigned int indx = bit / BITMAP_ELEMENT_ALL_BITS;
420 if (head->current == 0
421 || head->indx == indx)
422 return head->current;
424 if (head->indx > indx)
425 for (element = head->current;
426 element->prev != 0 && element->indx > indx;
427 element = element->prev)
431 for (element = head->current;
432 element->next != 0 && element->indx < indx;
433 element = element->next)
436 /* `element' is the nearest to the one we want. If it's not the one we
437 want, the one we want doesn't exist. */
438 head->current = element;
439 head->indx = element->indx;
440 if (element != 0 && element->indx != indx)
446 /* Clear a single bit in a bitmap. */
449 bitmap_clear_bit (bitmap head, int bit)
451 bitmap_element *ptr = bitmap_find_bit (head, bit);
455 unsigned bit_num = bit % BITMAP_WORD_BITS;
456 unsigned word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS;
457 ptr->bits[word_num] &= ~ (((BITMAP_WORD) 1) << bit_num);
459 /* If we cleared the entire word, free up the element. */
460 if (bitmap_element_zerop (ptr))
461 bitmap_element_free (head, ptr);
465 /* Set a single bit in a bitmap. */
468 bitmap_set_bit (bitmap head, int bit)
470 bitmap_element *ptr = bitmap_find_bit (head, bit);
471 unsigned word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS;
472 unsigned bit_num = bit % BITMAP_WORD_BITS;
473 BITMAP_WORD bit_val = ((BITMAP_WORD) 1) << bit_num;
477 ptr = bitmap_element_allocate (head);
478 ptr->indx = bit / BITMAP_ELEMENT_ALL_BITS;
479 ptr->bits[word_num] = bit_val;
480 bitmap_element_link (head, ptr);
483 ptr->bits[word_num] |= bit_val;
486 /* Return whether a bit is set within a bitmap. */
489 bitmap_bit_p (bitmap head, int bit)
495 ptr = bitmap_find_bit (head, bit);
499 bit_num = bit % BITMAP_WORD_BITS;
500 word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS;
502 return (ptr->bits[word_num] >> bit_num) & 1;
505 /* Return the bit number of the first set bit in the bitmap. The
506 bitmap must be non-empty. */
509 bitmap_first_set_bit (bitmap a)
511 bitmap_element *elt = a->first;
517 bit_no = elt->indx * BITMAP_ELEMENT_ALL_BITS;
518 for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
520 word = elt->bits[ix];
526 bit_no += ix * BITMAP_WORD_BITS;
528 #if GCC_VERSION >= 3004
529 gcc_assert (sizeof(long) == sizeof (word));
530 bit_no += __builtin_ctzl (word);
532 /* Binary search for the first set bit. */
533 #if BITMAP_WORD_BITS > 64
534 #error "Fill out the table."
536 #if BITMAP_WORD_BITS > 32
537 if (!(word & 0xffffffff))
538 word >>= 32, bit_no += 32;
540 if (!(word & 0xffff))
541 word >>= 16, bit_no += 16;
543 word >>= 8, bit_no += 8;
545 word >>= 4, bit_no += 4;
547 word >>= 2, bit_no += 2;
549 word >>= 1, bit_no += 1;
551 gcc_assert (word & 1);
560 bitmap_and (bitmap dst, bitmap a, bitmap b)
562 bitmap_element *dst_elt = dst->first;
563 bitmap_element *a_elt = a->first;
564 bitmap_element *b_elt = b->first;
565 bitmap_element *dst_prev = NULL;
567 gcc_assert (dst != a && dst != b && a != b);
568 while (a_elt && b_elt)
570 if (a_elt->indx < b_elt->indx)
572 else if (b_elt->indx < a_elt->indx)
576 /* Matching elts, generate A & B. */
581 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
583 dst_elt->indx = a_elt->indx;
584 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
586 BITMAP_WORD r = a_elt->bits[ix] & b_elt->bits[ix];
588 dst_elt->bits[ix] = r;
594 dst_elt = dst_elt->next;
600 bitmap_elt_clear_from (dst, dst_elt);
601 gcc_assert (!dst->current == !dst->first);
603 dst->indx = dst->current->indx;
609 bitmap_and_into (bitmap a, bitmap b)
611 bitmap_element *a_elt = a->first;
612 bitmap_element *b_elt = b->first;
613 bitmap_element *next;
616 while (a_elt && b_elt)
618 if (a_elt->indx < b_elt->indx)
621 bitmap_element_free (a, a_elt);
624 else if (b_elt->indx < a_elt->indx)
628 /* Matching elts, generate A &= B. */
632 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
634 BITMAP_WORD r = a_elt->bits[ix] & b_elt->bits[ix];
641 bitmap_element_free (a, a_elt);
646 bitmap_elt_clear_from (a, a_elt);
647 gcc_assert (!a->current == !a->first);
648 gcc_assert (!a->current || a->indx == a->current->indx);
654 bitmap_and_compl (bitmap dst, bitmap a, bitmap b)
656 bitmap_element *dst_elt = dst->first;
657 bitmap_element *a_elt = a->first;
658 bitmap_element *b_elt = b->first;
659 bitmap_element *dst_prev = NULL;
661 gcc_assert (dst != a && dst != b && a != b);
665 if (!b_elt || a_elt->indx < b_elt->indx)
669 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
671 dst_elt->indx = a_elt->indx;
672 memcpy (dst_elt->bits, a_elt->bits, sizeof (dst_elt->bits));
674 dst_elt = dst_elt->next;
677 else if (b_elt->indx < a_elt->indx)
681 /* Matching elts, generate A & ~B. */
686 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
688 dst_elt->indx = a_elt->indx;
689 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
691 BITMAP_WORD r = a_elt->bits[ix] & ~b_elt->bits[ix];
693 dst_elt->bits[ix] = r;
699 dst_elt = dst_elt->next;
705 bitmap_elt_clear_from (dst, dst_elt);
706 gcc_assert (!dst->current == !dst->first);
708 dst->indx = dst->current->indx;
714 bitmap_and_compl_into (bitmap a, bitmap b)
716 bitmap_element *a_elt = a->first;
717 bitmap_element *b_elt = b->first;
718 bitmap_element *next;
721 while (a_elt && b_elt)
723 if (a_elt->indx < b_elt->indx)
725 else if (b_elt->indx < a_elt->indx)
729 /* Matching elts, generate A &= ~B. */
733 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
735 BITMAP_WORD r = a_elt->bits[ix] & ~b_elt->bits[ix];
742 bitmap_element_free (a, a_elt);
747 gcc_assert (!a->current == !a->first);
748 gcc_assert (!a->current || a->indx == a->current->indx);
751 /* DST = A | B. Return true if DST changes. */
754 bitmap_ior (bitmap dst, bitmap a, bitmap b)
756 bitmap_element *dst_elt = dst->first;
757 bitmap_element *a_elt = a->first;
758 bitmap_element *b_elt = b->first;
759 bitmap_element *dst_prev = NULL;
760 bool changed = false;
762 gcc_assert (dst != a && dst != b && a != b);
763 while (a_elt || b_elt)
765 if (a_elt && b_elt && a_elt->indx == b_elt->indx)
767 /* Matching elts, generate A | B. */
770 if (!changed && dst_elt && dst_elt->indx == a_elt->indx)
772 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
774 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
776 if (r != dst_elt->bits[ix])
778 dst_elt->bits[ix] = r;
787 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
788 dst_elt->indx = a_elt->indx;
789 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
791 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
793 dst_elt->bits[ix] = r;
799 dst_elt = dst_elt->next;
803 /* Copy a single element. */
806 if (!b_elt || (a_elt && a_elt->indx < b_elt->indx))
817 if (!changed && dst_elt && dst_elt->indx == src->indx)
821 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
822 if (src->bits[ix] != dst_elt->bits[ix])
824 dst_elt->bits[ix] = src->bits[ix];
832 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
833 dst_elt->indx = src->indx;
834 memcpy (dst_elt->bits, src->bits, sizeof (dst_elt->bits));
838 dst_elt = dst_elt->next;
845 bitmap_elt_clear_from (dst, dst_elt);
847 gcc_assert (!dst->current == !dst->first);
849 dst->indx = dst->current->indx;
853 /* A |= B. Return true if A changes. */
856 bitmap_ior_into (bitmap a, bitmap b)
858 bitmap_element *a_elt = a->first;
859 bitmap_element *b_elt = b->first;
860 bitmap_element *a_prev = NULL;
861 bool changed = false;
866 if (!a_elt || b_elt->indx < a_elt->indx)
869 bitmap_element *dst = bitmap_elt_insert_after (a, a_prev);
871 dst->indx = b_elt->indx;
872 memcpy (dst->bits, b_elt->bits, sizeof (dst->bits));
877 else if (a_elt->indx < b_elt->indx)
884 /* Matching elts, generate A |= B. */
888 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
890 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
895 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
897 BITMAP_WORD r = a_elt->bits[ix] | b_elt->bits[ix];
899 if (a_elt->bits[ix] != r)
910 gcc_assert (!a->current == !a->first);
912 a->indx = a->current->indx;
919 bitmap_xor (bitmap dst, bitmap a, bitmap b)
921 bitmap_element *dst_elt = dst->first;
922 bitmap_element *a_elt = a->first;
923 bitmap_element *b_elt = b->first;
924 bitmap_element *dst_prev = NULL;
926 gcc_assert (dst != a && dst != b && a != b);
927 while (a_elt || b_elt)
929 if (a_elt && b_elt && a_elt->indx == b_elt->indx)
931 /* Matching elts, generate A ^ B. */
936 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
938 dst_elt->indx = a_elt->indx;
939 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
941 BITMAP_WORD r = a_elt->bits[ix] ^ b_elt->bits[ix];
944 dst_elt->bits[ix] = r;
951 dst_elt = dst_elt->next;
956 /* Copy a single element. */
959 if (!b_elt || (a_elt && a_elt->indx < b_elt->indx))
971 dst_elt = bitmap_elt_insert_after (dst, dst_prev);
973 dst_elt->indx = src->indx;
974 memcpy (dst_elt->bits, src->bits, sizeof (dst_elt->bits));
976 dst_elt = dst_elt->next;
979 bitmap_elt_clear_from (dst, dst_elt);
980 gcc_assert (!dst->current == !dst->first);
982 dst->indx = dst->current->indx;
988 bitmap_xor_into (bitmap a, bitmap b)
990 bitmap_element *a_elt = a->first;
991 bitmap_element *b_elt = b->first;
992 bitmap_element *a_prev = NULL;
997 if (!a_elt || b_elt->indx < a_elt->indx)
1000 bitmap_element *dst = bitmap_elt_insert_after (a, a_prev);
1002 dst->indx = b_elt->indx;
1003 memcpy (dst->bits, b_elt->bits, sizeof (dst->bits));
1005 b_elt = b_elt->next;
1007 else if (a_elt->indx < b_elt->indx)
1010 a_elt = a_elt->next;
1014 /* Matching elts, generate A ^= B. */
1016 BITMAP_WORD ior = 0;
1017 bitmap_element *next = a_elt->next;
1019 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1021 BITMAP_WORD r = a_elt->bits[ix] ^ b_elt->bits[ix];
1024 a_elt->bits[ix] = r;
1026 b_elt = b_elt->next;
1030 bitmap_element_free (a, a_elt);
1034 gcc_assert (!a->current == !a->first);
1036 a->indx = a->current->indx;
1039 /* Return true if two bitmaps are identical.
1040 We do not bother with a check for pointer equality, as that never
1041 occurs in practice. */
1044 bitmap_equal_p (bitmap a, bitmap b)
1046 bitmap_element *a_elt;
1047 bitmap_element *b_elt;
1050 for (a_elt = a->first, b_elt = b->first;
1052 a_elt = a_elt->next, b_elt = b_elt->next)
1054 if (a_elt->indx != b_elt->indx)
1056 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1057 if (a_elt->bits[ix] != b_elt->bits[ix])
1060 return !a_elt && !b_elt;
1063 /* Return true if A AND B is not empty. */
1066 bitmap_intersect_p (bitmap a, bitmap b)
1068 bitmap_element *a_elt;
1069 bitmap_element *b_elt;
1072 for (a_elt = a->first, b_elt = b->first;
1075 if (a_elt->indx < b_elt->indx)
1076 a_elt = a_elt->next;
1077 else if (b_elt->indx < a_elt->indx)
1078 b_elt = b_elt->next;
1081 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1082 if (a_elt->bits[ix] & b_elt->bits[ix])
1084 a_elt = a_elt->next;
1085 b_elt = b_elt->next;
1091 /* Return true if A AND NOT B is not empty. */
1094 bitmap_intersect_compl_p (bitmap a, bitmap b)
1096 bitmap_element *a_elt;
1097 bitmap_element *b_elt;
1099 for (a_elt = a->first, b_elt = b->first;
1102 if (a_elt->indx < b_elt->indx)
1104 else if (b_elt->indx < a_elt->indx)
1105 b_elt = b_elt->next;
1108 for (ix = BITMAP_ELEMENT_WORDS; ix--;)
1109 if (a_elt->bits[ix] & ~b_elt->bits[ix])
1111 a_elt = a_elt->next;
1112 b_elt = b_elt->next;
1115 return a_elt != NULL;
1119 /* DST = A | (FROM1 & ~FROM2). Return true if DST changes. */
1122 bitmap_ior_and_compl (bitmap dst, bitmap a, bitmap from1, bitmap from2)
1127 bitmap_initialize (&tmp, &bitmap_default_obstack);
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 bitmap_initialize (&tmp, &bitmap_default_obstack);
1144 bitmap_and_compl (&tmp, from1, from2);
1145 changed = bitmap_ior_into (a, &tmp);
1146 bitmap_clear (&tmp);
1151 /* Debugging function to print out the contents of a bitmap. */
1154 debug_bitmap_file (FILE *file, bitmap head)
1156 bitmap_element *ptr;
1158 fprintf (file, "\nfirst = " HOST_PTR_PRINTF
1159 " current = " HOST_PTR_PRINTF " indx = %u\n",
1160 (void *) head->first, (void *) head->current, head->indx);
1162 for (ptr = head->first; ptr; ptr = ptr->next)
1164 unsigned int i, j, col = 26;
1166 fprintf (file, "\t" HOST_PTR_PRINTF " next = " HOST_PTR_PRINTF
1167 " prev = " HOST_PTR_PRINTF " indx = %u\n\t\tbits = {",
1168 (void*) ptr, (void*) ptr->next, (void*) ptr->prev, ptr->indx);
1170 for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
1171 for (j = 0; j < BITMAP_WORD_BITS; j++)
1172 if ((ptr->bits[i] >> j) & 1)
1176 fprintf (file, "\n\t\t\t");
1180 fprintf (file, " %u", (ptr->indx * BITMAP_ELEMENT_ALL_BITS
1181 + i * BITMAP_WORD_BITS + j));
1185 fprintf (file, " }\n");
1189 /* Function to be called from the debugger to print the contents
1193 debug_bitmap (bitmap head)
1195 debug_bitmap_file (stdout, head);
1198 /* Function to print out the contents of a bitmap. Unlike debug_bitmap_file,
1199 it does not print anything but the bits. */
1202 bitmap_print (FILE *file, bitmap head, const char *prefix, const char *suffix)
1204 const char *comma = "";
1208 fputs (prefix, file);
1209 EXECUTE_IF_SET_IN_BITMAP (head, 0, i, bi)
1211 fprintf (file, "%s%d", comma, i);
1214 fputs (suffix, file);
1217 #include "gt-bitmap.h"