comparison gcc/ebitmap.c @ 55:77e2b8dfacca gcc-4.4.5

update it from 4.4.3 to 4.5.0
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Fri, 12 Feb 2010 23:39:51 +0900
parents a06113de4d67
children b7f97abdc517
comparison
equal deleted inserted replaced
52:c156f1bd5cd9 55:77e2b8dfacca
86 ebitmap_last_set_bit (ebitmap map) 86 ebitmap_last_set_bit (ebitmap map)
87 { 87 {
88 unsigned int i = 0; 88 unsigned int i = 0;
89 ebitmap_iterator ebi; 89 ebitmap_iterator ebi;
90 bool foundbit = false; 90 bool foundbit = false;
91 91
92 /* This is not the fastest way to do this, we could simply look for 92 /* This is not the fastest way to do this, we could simply look for
93 the popcount, and start there, but this function is not used 93 the popcount, and start there, but this function is not used
94 anywhere speed critical. */ 94 anywhere speed critical. */
95 EXECUTE_IF_SET_IN_EBITMAP (map, 0, i, ebi) 95 EXECUTE_IF_SET_IN_EBITMAP (map, 0, i, ebi)
96 { 96 {
97 foundbit = true; 97 foundbit = true;
98 } 98 }
99 99
100 100
101 if (foundbit) 101 if (foundbit)
102 return i; 102 return i;
103 return -1; 103 return -1;
104 } 104 }
174 /* Free the internal word array for MAP. */ 174 /* Free the internal word array for MAP. */
175 175
176 static inline void 176 static inline void
177 ebitmap_array_clear (ebitmap map) 177 ebitmap_array_clear (ebitmap map)
178 { 178 {
179 if (map->elts) 179 if (map->elts)
180 { 180 {
181 free (map->elts); 181 free (map->elts);
182 map->elts = NULL; 182 map->elts = NULL;
183 } 183 }
184 map->n_elts = 0; 184 map->n_elts = 0;
223 unsigned int wordindex = bit / EBITMAP_ELT_BITS; 223 unsigned int wordindex = bit / EBITMAP_ELT_BITS;
224 unsigned int eltwordindex = 0; 224 unsigned int eltwordindex = 0;
225 unsigned int bitindex, shift; 225 unsigned int bitindex, shift;
226 bool have_eltwordindex = false; 226 bool have_eltwordindex = false;
227 EBITMAP_ELT_TYPE *elt_ptr; 227 EBITMAP_ELT_TYPE *elt_ptr;
228 228
229 /* If the bit can't exist in our bitmap, just return. */ 229 /* If the bit can't exist in our bitmap, just return. */
230 if (map->numwords == 0) 230 if (map->numwords == 0)
231 return; 231 return;
232 232
233 if (wordindex >= map->wordmask->n_bits 233 if (wordindex >= map->wordmask->n_bits
234 || !TEST_BIT (map->wordmask, wordindex)) 234 || !TEST_BIT (map->wordmask, wordindex))
235 return; 235 return;
236 236
237 if (map->cache != NULL && map->cacheindex == wordindex) 237 if (map->cache != NULL && map->cacheindex == wordindex)
238 elt_ptr = map->cache; 238 elt_ptr = map->cache;
239 else 239 else
240 { 240 {
241 eltwordindex = sbitmap_popcount (map->wordmask, wordindex); 241 eltwordindex = sbitmap_popcount (map->wordmask, wordindex);
242 elt_ptr = &map->elts[eltwordindex]; 242 elt_ptr = &map->elts[eltwordindex];
243 have_eltwordindex = true; 243 have_eltwordindex = true;
244 } 244 }
245 245
246 bitindex = bit % EBITMAP_ELT_BITS; 246 bitindex = bit % EBITMAP_ELT_BITS;
247 shift = bitindex; 247 shift = bitindex;
248 248
249 *(elt_ptr) &= ~(((EBITMAP_ELT_TYPE)1) << shift); 249 *(elt_ptr) &= ~(((EBITMAP_ELT_TYPE)1) << shift);
250 250
251 /* Clear out the empty words. */ 251 /* Clear out the empty words. */
252 if (*(elt_ptr) == 0) 252 if (*(elt_ptr) == 0)
253 { 253 {
254 if (!have_eltwordindex) 254 if (!have_eltwordindex)
255 eltwordindex = sbitmap_popcount (map->wordmask, wordindex); 255 eltwordindex = sbitmap_popcount (map->wordmask, wordindex);
256 256
257 if (map->cache != NULL && map->cacheindex == eltwordindex) 257 if (map->cache != NULL && map->cacheindex == eltwordindex)
258 map->cache = NULL; 258 map->cache = NULL;
259 259
260 RESET_BIT (map->wordmask, wordindex); 260 RESET_BIT (map->wordmask, wordindex);
261 261