2 Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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
33 unsigned int n_bits
; /* Number of bits. */
34 unsigned int size
; /* Size in elements. */
35 unsigned int bytes
; /* Size in bytes. */
36 SBITMAP_ELT_TYPE elms
[1]; /* The elements. */
39 typedef SBITMAP_ELT_TYPE
*sbitmap_ptr
;
41 /* Return the set size needed for N elements. */
42 #define SBITMAP_SET_SIZE(N) (((N) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
44 /* Set bit number bitno in the bitmap. */
45 #define SET_BIT(BITMAP, BITNO) \
46 ((BITMAP)->elms [(BITNO) / SBITMAP_ELT_BITS] \
47 |= (SBITMAP_ELT_TYPE) 1 << (BITNO) % SBITMAP_ELT_BITS)
49 /* Test if bit number bitno in the bitmap is set. */
50 #define TEST_BIT(BITMAP, BITNO) \
51 ((BITMAP)->elms [(BITNO) / SBITMAP_ELT_BITS] >> (BITNO) % SBITMAP_ELT_BITS & 1)
53 /* Reset bit number bitno in the bitmap. */
54 #define RESET_BIT(BITMAP, BITNO) \
55 ((BITMAP)->elms [(BITNO) / SBITMAP_ELT_BITS] \
56 &= ~((SBITMAP_ELT_TYPE) 1 << (BITNO) % SBITMAP_ELT_BITS))
58 /* Loop over all elements of SBITSET, starting with MIN. */
59 #define EXECUTE_IF_SET_IN_SBITMAP(SBITMAP, MIN, N, CODE) \
61 unsigned int word_num_; \
62 unsigned int bit_num_ = (MIN) % (unsigned int) SBITMAP_ELT_BITS; \
63 unsigned int size_ = (SBITMAP)->size; \
64 SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms; \
66 for (word_num_ = (MIN) / (unsigned int) SBITMAP_ELT_BITS; \
67 word_num_ < size_; word_num_++, bit_num_ = 0) \
69 SBITMAP_ELT_TYPE word_ = ptr_[word_num_]; \
72 for (; bit_num_ < SBITMAP_ELT_BITS; bit_num_++) \
74 SBITMAP_ELT_TYPE _mask = (SBITMAP_ELT_TYPE) 1 << bit_num_; \
76 if ((word_ & _mask) != 0) \
79 (N) = word_num_ * SBITMAP_ELT_BITS + bit_num_; \
88 #define sbitmap_free(MAP) free(MAP)
89 #define sbitmap_vector_free(VEC) free(VEC)
93 extern void dump_sbitmap
PARAMS ((FILE *, sbitmap
));
94 extern void dump_sbitmap_vector
PARAMS ((FILE *, const char *,
95 const char *, sbitmap
*,
97 extern sbitmap sbitmap_alloc
PARAMS ((unsigned int));
98 extern sbitmap
*sbitmap_vector_alloc
PARAMS ((unsigned int, unsigned int));
99 extern void sbitmap_copy
PARAMS ((sbitmap
, sbitmap
));
100 extern int sbitmap_equal
PARAMS ((sbitmap
, sbitmap
));
101 extern void sbitmap_zero
PARAMS ((sbitmap
));
102 extern void sbitmap_ones
PARAMS ((sbitmap
));
103 extern void sbitmap_vector_zero
PARAMS ((sbitmap
*, unsigned int));
104 extern void sbitmap_vector_ones
PARAMS ((sbitmap
*, unsigned int));
106 extern void sbitmap_union_of_diff
PARAMS ((sbitmap
, sbitmap
, sbitmap
,
108 extern bool sbitmap_union_of_diff_cg
PARAMS ((sbitmap
, sbitmap
, sbitmap
,
110 extern void sbitmap_difference
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
111 extern void sbitmap_not
PARAMS ((sbitmap
, sbitmap
));
112 extern void sbitmap_a_or_b_and_c
PARAMS ((sbitmap
, sbitmap
, sbitmap
,
114 extern bool sbitmap_a_or_b_and_c_cg
PARAMS ((sbitmap
, sbitmap
, sbitmap
,
116 extern void sbitmap_a_and_b_or_c
PARAMS ((sbitmap
, sbitmap
, sbitmap
,
118 extern bool sbitmap_a_and_b_or_c_cg
PARAMS ((sbitmap
, sbitmap
, sbitmap
,
120 extern void sbitmap_a_and_b
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
121 extern bool sbitmap_a_and_b_cg
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
122 extern void sbitmap_a_or_b
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
123 extern bool sbitmap_a_or_b_cg
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
124 extern void sbitmap_a_xor_b
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
125 extern bool sbitmap_a_xor_b_cg
PARAMS ((sbitmap
, sbitmap
, sbitmap
));
126 extern bool sbitmap_a_subset_b_p
PARAMS ((sbitmap
, sbitmap
));
128 extern int sbitmap_first_set_bit
PARAMS ((sbitmap
));
129 extern int sbitmap_last_set_bit
PARAMS ((sbitmap
));
131 extern void sbitmap_intersect_of_predsucc
PARAMS ((sbitmap
, sbitmap
*,
132 int, struct int_list
**));
133 #define sbitmap_intersect_of_predecessors sbitmap_intersect_of_predsucc
134 #define sbitmap_intersect_of_successors sbitmap_intersect_of_predsucc
136 extern void sbitmap_union_of_predsucc
PARAMS ((sbitmap
, sbitmap
*, int,
137 struct int_list
**));
138 #define sbitmap_union_of_predecessors sbitmap_union_of_predsucc
139 #define sbitmap_union_of_successors sbitmap_union_of_predsucc
141 /* Intersection and Union of preds/succs using the new flow graph
142 structure instead of the pred/succ arrays. */
144 extern void sbitmap_intersection_of_succs
PARAMS ((sbitmap
, sbitmap
*, int));
145 extern void sbitmap_intersection_of_preds
PARAMS ((sbitmap
, sbitmap
*, int));
146 extern void sbitmap_union_of_succs
PARAMS ((sbitmap
, sbitmap
*, int));
147 extern void sbitmap_union_of_preds
PARAMS ((sbitmap
, sbitmap
*, int));
149 extern void debug_sbitmap
PARAMS ((sbitmap
));
150 #endif /* ! GCC_SBITMAP_H */