OSDN Git Service

* tree-gimple.c (is_gimple_constructor_elt): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / sbitmap.h
1 /* Simple bitmaps.
2    Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
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
9 version.
10
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
14 for more details.
15
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
19 02111-1307, USA.  */
20
21 #ifndef GCC_SBITMAP_H
22 #define GCC_SBITMAP_H
23
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.  */
27
28 #define SBITMAP_ELT_BITS ((unsigned) HOST_BITS_PER_WIDEST_FAST_INT)
29 #define SBITMAP_ELT_TYPE unsigned HOST_WIDEST_FAST_INT
30
31 typedef struct simple_bitmap_def
32 {
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.  */
37 } *sbitmap;
38
39 typedef SBITMAP_ELT_TYPE *sbitmap_ptr;
40
41 /* Return the set size needed for N elements.  */
42 #define SBITMAP_SET_SIZE(N) (((N) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
43
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)
48
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)
52
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))
57
58 /* Loop over all elements of SBITSET, starting with MIN.  */
59 #define EXECUTE_IF_SET_IN_SBITMAP(SBITMAP, MIN, N, CODE)                \
60 do {                                                                    \
61   unsigned int word_num_ = (MIN) / (unsigned int) SBITMAP_ELT_BITS;     \
62   unsigned int bit_num_ = (MIN) % (unsigned int) SBITMAP_ELT_BITS;      \
63   unsigned int size_ = (SBITMAP)->size;                                 \
64   SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms;                             \
65   SBITMAP_ELT_TYPE word_ = ptr_[word_num_] >> bit_num_;                 \
66                                                                         \
67   for (;                                                                \
68        word_num_ < size_;                                               \
69        word_num_++, bit_num_ = 0, word_ = ptr_[word_num_])              \
70     {                                                                   \
71       for (; word_ != 0; word_ >>= 1, bit_num_++)                       \
72         {                                                               \
73           if ((word_ & 1) != 0)                                         \
74             {                                                           \
75               (N) = word_num_ * SBITMAP_ELT_BITS + bit_num_;            \
76               CODE;                                                     \
77             }                                                           \
78         }                                                               \
79     }                                                                   \
80 } while (0)
81
82 #define EXECUTE_IF_SET_IN_SBITMAP_REV(SBITMAP, N, CODE)                 \
83 do {                                                                    \
84   unsigned int word_num_;                                               \
85   unsigned int bit_num_;                                                \
86   unsigned int size_ = (SBITMAP)->size;                                 \
87   SBITMAP_ELT_TYPE *ptr_ = (SBITMAP)->elms;                             \
88                                                                         \
89   for (word_num_ = size_; word_num_ > 0; word_num_--)                   \
90     {                                                                   \
91       SBITMAP_ELT_TYPE word_ = ptr_[word_num_ - 1];                     \
92                                                                         \
93       if (word_ != 0)                                                   \
94         for (bit_num_ = SBITMAP_ELT_BITS; bit_num_ > 0; bit_num_--)     \
95           {                                                             \
96             SBITMAP_ELT_TYPE _mask = (SBITMAP_ELT_TYPE)1 << (bit_num_ - 1);\
97                                                                         \
98             if ((word_ & _mask) != 0)                                   \
99               {                                                         \
100                 word_ &= ~ _mask;                                       \
101                 (N) = (word_num_ - 1) * SBITMAP_ELT_BITS + bit_num_ - 1;\
102                 CODE;                                                   \
103                 if (word_ == 0)                                         \
104                   break;                                                \
105               }                                                         \
106           }                                                             \
107     }                                                                   \
108 } while (0)
109
110 #define sbitmap_free(MAP)               free(MAP)
111 #define sbitmap_vector_free(VEC)        free(VEC)
112
113 struct int_list;
114
115 extern void dump_sbitmap (FILE *, sbitmap);
116 extern void dump_sbitmap_file (FILE *, sbitmap);
117 extern void dump_sbitmap_vector (FILE *, const char *, const char *, sbitmap *,
118                                  int);
119 extern sbitmap sbitmap_alloc (unsigned int);
120 extern sbitmap *sbitmap_vector_alloc (unsigned int, unsigned int);
121 extern sbitmap sbitmap_resize (sbitmap, unsigned int, int);
122 extern void sbitmap_copy (sbitmap, sbitmap);
123 extern int sbitmap_equal (sbitmap, sbitmap);
124 extern void sbitmap_zero (sbitmap);
125 extern void sbitmap_ones (sbitmap);
126 extern void sbitmap_vector_zero (sbitmap *, unsigned int);
127 extern void sbitmap_vector_ones (sbitmap *, unsigned int);
128
129 extern void sbitmap_union_of_diff (sbitmap, sbitmap, sbitmap, sbitmap);
130 extern bool sbitmap_union_of_diff_cg (sbitmap, sbitmap, sbitmap, sbitmap);
131 extern void sbitmap_difference (sbitmap, sbitmap, sbitmap);
132 extern void sbitmap_not (sbitmap, sbitmap);
133 extern void sbitmap_a_or_b_and_c (sbitmap, sbitmap, sbitmap, sbitmap);
134 extern bool sbitmap_a_or_b_and_c_cg (sbitmap, sbitmap, sbitmap, sbitmap);
135 extern void sbitmap_a_and_b_or_c (sbitmap, sbitmap, sbitmap, sbitmap);
136 extern bool sbitmap_a_and_b_or_c_cg (sbitmap, sbitmap, sbitmap, sbitmap);
137 extern void sbitmap_a_and_b (sbitmap, sbitmap, sbitmap);
138 extern bool sbitmap_a_and_b_cg (sbitmap, sbitmap, sbitmap);
139 extern void sbitmap_a_or_b (sbitmap, sbitmap, sbitmap);
140 extern bool sbitmap_a_or_b_cg (sbitmap, sbitmap, sbitmap);
141 extern void sbitmap_a_xor_b (sbitmap, sbitmap, sbitmap);
142 extern bool sbitmap_a_xor_b_cg (sbitmap, sbitmap, sbitmap);
143 extern bool sbitmap_a_subset_b_p (sbitmap, sbitmap);
144
145 extern int sbitmap_first_set_bit (sbitmap);
146 extern int sbitmap_last_set_bit (sbitmap);
147
148 extern void sbitmap_intersect_of_predsucc (sbitmap, sbitmap *, int,
149                                            struct int_list **);
150 #define sbitmap_intersect_of_predecessors  sbitmap_intersect_of_predsucc
151 #define sbitmap_intersect_of_successors    sbitmap_intersect_of_predsucc
152
153 extern void sbitmap_union_of_predsucc (sbitmap, sbitmap *, int,
154                                        struct int_list **);
155 #define sbitmap_union_of_predecessors  sbitmap_union_of_predsucc
156 #define sbitmap_union_of_successors    sbitmap_union_of_predsucc
157
158 /* Intersection and Union of preds/succs using the new flow graph
159    structure instead of the pred/succ arrays.  */
160
161 extern void sbitmap_intersection_of_succs (sbitmap, sbitmap *, int);
162 extern void sbitmap_intersection_of_preds (sbitmap, sbitmap *, int);
163 extern void sbitmap_union_of_succs (sbitmap, sbitmap *, int);
164 extern void sbitmap_union_of_preds (sbitmap, sbitmap *, int);
165
166 extern void debug_sbitmap (sbitmap);
167 extern sbitmap sbitmap_realloc (sbitmap, unsigned int);
168 #endif /* ! GCC_SBITMAP_H */