2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
24 /* It's not clear yet whether using bitmap.[ch] will be a win.
25 It should be straightforward to convert so for now we keep things simple
26 while more important issues are dealt with. */
28 #define SBITMAP_ELT_BITS ((unsigned) HOST_BITS_PER_WIDE_INT)
29 #define SBITMAP_ELT_TYPE unsigned HOST_WIDE_INT
31 typedef struct simple_bitmap_def
{
34 /* Size in elements. */
39 SBITMAP_ELT_TYPE elms
[1];
42 typedef SBITMAP_ELT_TYPE
*sbitmap_ptr
;
44 /* Return the set size needed for N elements. */
45 #define SBITMAP_SET_SIZE(n) (((n) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
47 /* set bit number bitno in the bitmap */
48 #define SET_BIT(bitmap, bitno) \
49 ((bitmap)->elms [(bitno) / SBITMAP_ELT_BITS] \
50 |= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS)
52 /* test if bit number bitno in the bitmap is set */
53 #define TEST_BIT(bitmap, bitno) \
54 ((bitmap)->elms [(bitno) / SBITMAP_ELT_BITS] >> (bitno) % SBITMAP_ELT_BITS & 1)
56 /* reset bit number bitno in the bitmap */
57 #define RESET_BIT(bitmap, bitno) \
58 ((bitmap)->elms [(bitno) / SBITMAP_ELT_BITS] \
59 &= ~((SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS))
61 /* Loop over all elements of SBITSET, starting with MIN. */
62 #define EXECUTE_IF_SET_IN_SBITMAP(SBITMAP, MIN, N, CODE) \
64 unsigned int bit_num_ = (MIN) % (unsigned) SBITMAP_ELT_BITS; \
65 unsigned int word_num_ = (MIN) / (unsigned) SBITMAP_ELT_BITS; \
66 unsigned int size_ = (SBITMAP)->size; \
67 SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms; \
69 while (word_num_ < size_) \
71 SBITMAP_ELT_TYPE word_ = ptr_[word_num_]; \
74 for (; bit_num_ < SBITMAP_ELT_BITS; ++bit_num_) \
76 SBITMAP_ELT_TYPE mask_ = (SBITMAP_ELT_TYPE)1 << bit_num_; \
77 if ((word_ & mask_) != 0) \
80 (N) = word_num_ * SBITMAP_ELT_BITS + bit_num_; \
92 #define sbitmap_free(map) free(map)
93 #define sbitmap_vector_free(vec) free(vec)
95 extern void dump_sbitmap
PARAMS ((FILE *, sbitmap
));
96 extern void dump_sbitmap_vector
PARAMS ((FILE *, const char *, const char *,
99 extern sbitmap sbitmap_alloc
PARAMS ((int));
100 extern sbitmap
*sbitmap_vector_alloc
PARAMS ((int, int));
102 extern void sbitmap_copy
PARAMS ((sbitmap
, sbitmap
));
103 extern void sbitmap_zero
PARAMS ((sbitmap
));
104 extern void sbitmap_ones
PARAMS ((sbitmap
));
105 extern void sbitmap_vector_zero
PARAMS ((sbitmap
*, int));
106 extern void sbitmap_vector_ones
PARAMS ((sbitmap
*, int));
108 extern int sbitmap_union_of_diff
PARAMS ((sbitmap
, sbitmap
, sbitmap
, sbitmap
));
109 extern void sbitmap_difference
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
110 extern void sbitmap_not
PARAMS ((sbitmap
, sbitmap
));
111 extern int sbitmap_a_or_b_and_c
PARAMS ((sbitmap
, sbitmap
, sbitmap
, sbitmap
));
112 extern int sbitmap_a_and_b_or_c
PARAMS ((sbitmap
, sbitmap
, sbitmap
, sbitmap
));
113 extern int sbitmap_a_and_b
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
114 extern int sbitmap_a_or_b
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
115 extern int sbitmap_a_subset_b_p
PARAMS ((sbitmap
, sbitmap
));
117 extern int sbitmap_first_set_bit
PARAMS ((sbitmap
));
118 extern int sbitmap_last_set_bit
PARAMS ((sbitmap
));
121 extern void sbitmap_intersect_of_predsucc
PARAMS ((sbitmap
, sbitmap
*,
122 int, struct int_list
**));
123 #define sbitmap_intersect_of_predecessors sbitmap_intersect_of_predsucc
124 #define sbitmap_intersect_of_successors sbitmap_intersect_of_predsucc
126 extern void sbitmap_union_of_predsucc
PARAMS ((sbitmap
, sbitmap
*, int,
127 struct int_list
**));
128 #define sbitmap_union_of_predecessors sbitmap_union_of_predsucc
129 #define sbitmap_union_of_successors sbitmap_union_of_predsucc
131 /* Intersection and Union of preds/succs using the new flow graph
132 structure instead of the pred/succ arrays. */
134 extern void sbitmap_intersection_of_succs
PARAMS ((sbitmap
, sbitmap
*, int));
135 extern void sbitmap_intersection_of_preds
PARAMS ((sbitmap
, sbitmap
*, int));
136 extern void sbitmap_union_of_succs
PARAMS ((sbitmap
, sbitmap
*, int));
137 extern void sbitmap_union_of_preds
PARAMS ((sbitmap
, sbitmap
*, int));
139 #endif /* _SBITMAP_H */