00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GCC_BITMAP_H
00023 #define GCC_BITMAP_H
00024
00025
00026
00027
00028
00029 typedef unsigned long BITMAP_WORD;
00030 #define nBITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG)
00031 #define BITMAP_WORD_BITS (unsigned) nBITMAP_WORD_BITS
00032
00033
00034
00035 #ifndef BITMAP_ELEMENT_WORDS
00036 #define BITMAP_ELEMENT_WORDS ((128 + nBITMAP_WORD_BITS - 1) / nBITMAP_WORD_BITS)
00037 #endif
00038
00039
00040
00041
00042
00043 #define BITMAP_ELEMENT_ALL_BITS \
00044 ((unsigned) (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS))
00045
00046
00047
00048
00049
00050
00051 typedef struct bitmap_element_def GTY(())
00052 {
00053 struct bitmap_element_def *next;
00054 struct bitmap_element_def *prev;
00055 unsigned int indx;
00056 BITMAP_WORD bits[BITMAP_ELEMENT_WORDS];
00057 } bitmap_element;
00058
00059
00060 typedef struct bitmap_head_def GTY(()) {
00061 bitmap_element *first;
00062 bitmap_element *current;
00063 unsigned int indx;
00064 int using_obstack;
00065
00066 } bitmap_head;
00067 typedef struct bitmap_head_def *bitmap;
00068
00069
00070 enum bitmap_bits {
00071 BITMAP_AND,
00072 BITMAP_AND_COMPL,
00073 BITMAP_IOR,
00074 BITMAP_XOR,
00075 BITMAP_IOR_COMPL
00076 };
00077
00078
00079 extern bitmap_element bitmap_zero_bits;
00080
00081
00082 extern void bitmap_clear PARAMS ((bitmap));
00083
00084
00085 extern void bitmap_copy PARAMS ((bitmap, bitmap));
00086
00087
00088 extern int bitmap_equal_p PARAMS ((bitmap, bitmap));
00089
00090
00091 extern int bitmap_operation PARAMS ((bitmap, bitmap, bitmap, enum bitmap_bits));
00092
00093
00094
00095 extern void bitmap_ior_and_compl PARAMS ((bitmap, bitmap, bitmap));
00096
00097
00098 extern void bitmap_clear_bit PARAMS ((bitmap, int));
00099
00100
00101 extern void bitmap_set_bit PARAMS ((bitmap, int));
00102
00103
00104 extern int bitmap_bit_p PARAMS ((bitmap, int));
00105
00106
00107 extern void debug_bitmap PARAMS ((bitmap));
00108 extern void debug_bitmap_file PARAMS ((FILE *, bitmap));
00109
00110
00111 extern void bitmap_print PARAMS ((FILE *, bitmap, const char *, const char *));
00112
00113
00114
00115 extern bitmap bitmap_initialize PARAMS ((bitmap head,
00116 int using_obstack));
00117
00118
00119 extern void bitmap_release_memory PARAMS ((void));
00120
00121
00122 #define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n")
00123 #define bitmap_zero(a) bitmap_clear (a)
00124 #define bitmap_a_or_b(a,b,c) bitmap_operation (a, b, c, BITMAP_IOR)
00125 #define bitmap_a_and_b(a,b,c) bitmap_operation (a, b, c, BITMAP_AND)
00126 extern int bitmap_union_of_diff PARAMS((bitmap, bitmap, bitmap, bitmap));
00127 extern int bitmap_first_set_bit PARAMS((bitmap));
00128 extern int bitmap_last_set_bit PARAMS((bitmap));
00129
00130
00131 #define BITMAP_OBSTACK_ALLOC(OBSTACK) \
00132 bitmap_initialize ((bitmap) obstack_alloc (OBSTACK, sizeof (bitmap_head)), 1)
00133
00134
00135 #define BITMAP_GGC_ALLOC() \
00136 bitmap_initialize (NULL, 0)
00137
00138
00139 #define BITMAP_XMALLOC() \
00140 bitmap_initialize ((bitmap) xmalloc (sizeof (bitmap_head)), 1)
00141
00142
00143 #define BITMAP_FREE(BITMAP) \
00144 do { \
00145 if (BITMAP) \
00146 { \
00147 bitmap_clear (BITMAP); \
00148 (BITMAP) = 0; \
00149 } \
00150 } while (0)
00151
00152
00153 #define BITMAP_XFREE(BITMAP) \
00154 do { \
00155 if (BITMAP) \
00156 { \
00157 bitmap_clear (BITMAP); \
00158 free (BITMAP); \
00159 (BITMAP) = 0; \
00160 } \
00161 } while (0)
00162
00163
00164 #define BITMAP_INIT_ONCE()
00165
00166
00167
00168
00169 #define EXECUTE_IF_SET_IN_BITMAP(BITMAP, MIN, BITNUM, CODE) \
00170 do { \
00171 bitmap_element *ptr_ = (BITMAP)->first; \
00172 unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS; \
00173 unsigned bit_num_ = (MIN) % BITMAP_WORD_BITS; \
00174 unsigned word_num_ = (MIN) / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS; \
00175 \
00176 \
00177 \
00178 while (ptr_ != 0 && ptr_->indx < indx_) \
00179 ptr_ = ptr_->next; \
00180 \
00181 if (ptr_ != 0 && ptr_->indx != indx_) \
00182 { \
00183 bit_num_ = 0; \
00184 word_num_ = 0; \
00185 } \
00186 \
00187 for (; ptr_ != 0; ptr_ = ptr_->next) \
00188 { \
00189 for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++) \
00190 { \
00191 BITMAP_WORD word_ = ptr_->bits[word_num_]; \
00192 \
00193 if (word_ != 0) \
00194 { \
00195 for (; bit_num_ < BITMAP_WORD_BITS; bit_num_++) \
00196 { \
00197 BITMAP_WORD mask_ = ((BITMAP_WORD) 1) << bit_num_; \
00198 \
00199 if ((word_ & mask_) != 0) \
00200 { \
00201 word_ &= ~ mask_; \
00202 (BITNUM) = (ptr_->indx * BITMAP_ELEMENT_ALL_BITS \
00203 + word_num_ * BITMAP_WORD_BITS \
00204 + bit_num_); \
00205 CODE; \
00206 \
00207 if (word_ == 0) \
00208 break; \
00209 } \
00210 } \
00211 } \
00212 \
00213 bit_num_ = 0; \
00214 } \
00215 \
00216 word_num_ = 0; \
00217 } \
00218 } while (0)
00219
00220
00221
00222
00223
00224 #define EXECUTE_IF_AND_COMPL_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, CODE) \
00225 do { \
00226 bitmap_element *ptr1_ = (BITMAP1)->first; \
00227 bitmap_element *ptr2_ = (BITMAP2)->first; \
00228 unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS; \
00229 unsigned bit_num_ = (MIN) % BITMAP_WORD_BITS; \
00230 unsigned word_num_ = (MIN) / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS; \
00231 \
00232 \
00233 while (ptr1_ != 0 && ptr1_->indx < indx_) \
00234 ptr1_ = ptr1_->next; \
00235 \
00236 if (ptr1_ != 0 && ptr1_->indx != indx_) \
00237 { \
00238 bit_num_ = 0; \
00239 word_num_ = 0; \
00240 } \
00241 \
00242 for (; ptr1_ != 0 ; ptr1_ = ptr1_->next) \
00243 { \
00244
00245 \
00246 bitmap_element *tmp2_; \
00247 \
00248 while (ptr2_ != 0 && ptr2_->indx < ptr1_->indx) \
00249 ptr2_ = ptr2_->next; \
00250 \
00251 tmp2_ = ((ptr2_ != 0 && ptr2_->indx == ptr1_->indx) \
00252 ? ptr2_ : &bitmap_zero_bits); \
00253 \
00254 for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++) \
00255 { \
00256 BITMAP_WORD word_ = (ptr1_->bits[word_num_] \
00257 & ~ tmp2_->bits[word_num_]); \
00258 if (word_ != 0) \
00259 { \
00260 for (; bit_num_ < BITMAP_WORD_BITS; bit_num_++) \
00261 { \
00262 BITMAP_WORD mask_ = ((BITMAP_WORD) 1) << bit_num_; \
00263 \
00264 if ((word_ & mask_) != 0) \
00265 { \
00266 word_ &= ~ mask_; \
00267 (BITNUM) = (ptr1_->indx * BITMAP_ELEMENT_ALL_BITS \
00268 + word_num_ * BITMAP_WORD_BITS \
00269 + bit_num_); \
00270 \
00271 CODE; \
00272 if (word_ == 0) \
00273 break; \
00274 } \
00275 } \
00276 } \
00277 \
00278 bit_num_ = 0; \
00279 } \
00280 \
00281 word_num_ = 0; \
00282 } \
00283 } while (0)
00284
00285
00286
00287
00288
00289 #define EXECUTE_IF_AND_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, CODE) \
00290 do { \
00291 bitmap_element *ptr1_ = (BITMAP1)->first; \
00292 bitmap_element *ptr2_ = (BITMAP2)->first; \
00293 unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS; \
00294 unsigned bit_num_ = (MIN) % BITMAP_WORD_BITS; \
00295 unsigned word_num_ = (MIN) / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS; \
00296 \
00297 \
00298 while (ptr1_ != 0 && ptr1_->indx < indx_) \
00299 ptr1_ = ptr1_->next; \
00300 \
00301 if (ptr1_ != 0 && ptr1_->indx != indx_) \
00302 { \
00303 bit_num_ = 0; \
00304 word_num_ = 0; \
00305 } \
00306 \
00307 for (; ptr1_ != 0 ; ptr1_ = ptr1_->next) \
00308 { \
00309 \
00310 while (ptr2_ != 0 && ptr2_->indx < ptr1_->indx) \
00311 ptr2_ = ptr2_->next; \
00312 \
00313 if (ptr2_ == 0) \
00314 { \
00315 \
00316 ptr1_ = (bitmap_element *)0; \
00317 break; \
00318 } \
00319 else if (ptr2_->indx > ptr1_->indx) \
00320 { \
00321 bit_num_ = word_num_ = 0; \
00322 continue; \
00323 } \
00324 \
00325 for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++) \
00326 { \
00327 BITMAP_WORD word_ = (ptr1_->bits[word_num_] \
00328 & ptr2_->bits[word_num_]); \
00329 if (word_ != 0) \
00330 { \
00331 for (; bit_num_ < BITMAP_WORD_BITS; bit_num_++) \
00332 { \
00333 BITMAP_WORD mask_ = ((BITMAP_WORD) 1) << bit_num_; \
00334 \
00335 if ((word_ & mask_) != 0) \
00336 { \
00337 word_ &= ~ mask_; \
00338 (BITNUM) = (ptr1_->indx * BITMAP_ELEMENT_ALL_BITS \
00339 + word_num_ * BITMAP_WORD_BITS \
00340 + bit_num_); \
00341 \
00342 CODE; \
00343 if (word_ == 0) \
00344 break; \
00345 } \
00346 } \
00347 } \
00348 \
00349 bit_num_ = 0; \
00350 } \
00351 \
00352 word_num_ = 0; \
00353 } \
00354 } while (0)
00355
00356 #endif