Lines Matching refs:set

326 IR_ALWAYS_INLINE void ir_bitset_incl(ir_bitset set, uint32_t n)  in ir_bitset_incl()  argument
328 set[n / IR_BITSET_BITS] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); in ir_bitset_incl()
331 IR_ALWAYS_INLINE void ir_bitset_excl(ir_bitset set, uint32_t n) in ir_bitset_excl() argument
333 set[n / IR_BITSET_BITS] &= ~(IR_BITSET_ONE << (n % IR_BITSET_BITS)); in ir_bitset_excl()
336 IR_ALWAYS_INLINE bool ir_bitset_in(const ir_bitset set, uint32_t n) in ir_bitset_in() argument
338 return (set[(n / IR_BITSET_BITS)] & (IR_BITSET_ONE << (n % IR_BITSET_BITS))) != 0; in ir_bitset_in()
341 IR_ALWAYS_INLINE void ir_bitset_clear(ir_bitset set, uint32_t len) in ir_bitset_clear() argument
343 memset(set, 0, len * (IR_BITSET_BITS / 8)); in ir_bitset_clear()
346 IR_ALWAYS_INLINE void ir_bitset_fill(ir_bitset set, uint32_t len) in ir_bitset_fill() argument
348 memset(set, 0xff, len * (IR_BITSET_BITS / 8)); in ir_bitset_fill()
351 IR_ALWAYS_INLINE bool ir_bitset_empty(const ir_bitset set, uint32_t len) in ir_bitset_empty() argument
355 if (set[i]) { in ir_bitset_empty()
411 IR_ALWAYS_INLINE int ir_bitset_first(const ir_bitset set, uint32_t len) in ir_bitset_first() argument
416 if (set[i]) { in ir_bitset_first()
417 return IR_BITSET_BITS * i + ir_bitset_ntz(set[i]); in ir_bitset_first()
423 IR_ALWAYS_INLINE int ir_bitset_last(const ir_bitset set, uint32_t len) in ir_bitset_last() argument
429 if (set[i]) { in ir_bitset_last()
431 ir_bitset_base_t x = set[i]; in ir_bitset_last()
442 IR_ALWAYS_INLINE int ir_bitset_pop_first(ir_bitset set, uint32_t len) in ir_bitset_pop_first() argument
447 ir_bitset_base_t x = set[i]; in ir_bitset_pop_first()
451 set[i] = x & (x - 1); in ir_bitset_pop_first()
458 #define IR_BITSET_FOREACH(set, len, bit) do { \ argument
459 ir_bitset _set = (set); \
489 #define IR_SPARSE_SET_DENSE(set, n) (set)->data[n] argument
490 #define IR_SPARSE_SET_SPARSE(set, n) (set)->data[-1 - ((int32_t)(n))] argument
492 IR_ALWAYS_INLINE void ir_sparse_set_init(ir_sparse_set *set, uint32_t size) in ir_sparse_set_init() argument
494 set->size = size; in ir_sparse_set_init()
495 set->len = 0; in ir_sparse_set_init()
496 set->data = (uint32_t*)ir_mem_malloc(sizeof(uint32_t) * 2 * size) + size; in ir_sparse_set_init()
499 memset(&IR_SPARSE_SET_SPARSE(set, size - 1), 0, size * sizeof(uint32_t)); in ir_sparse_set_init()
503 IR_ALWAYS_INLINE void ir_sparse_set_clear(ir_sparse_set *set) in ir_sparse_set_clear() argument
505 set->len = 0; in ir_sparse_set_clear()
508 IR_ALWAYS_INLINE void ir_sparse_set_free(ir_sparse_set *set) in ir_sparse_set_free() argument
510 ir_mem_free(set->data - set->size); in ir_sparse_set_free()
513 IR_ALWAYS_INLINE bool ir_sparse_set_empty(const ir_sparse_set *set) in ir_sparse_set_empty() argument
515 return set->len == 0; in ir_sparse_set_empty()
518 IR_ALWAYS_INLINE bool ir_sparse_set_in(const ir_sparse_set *set, uint32_t n) in ir_sparse_set_in() argument
520 uint32_t idx = IR_SPARSE_SET_SPARSE(set, n); in ir_sparse_set_in()
522 return idx < set->len && IR_SPARSE_SET_DENSE(set, idx) == n; in ir_sparse_set_in()
525 IR_ALWAYS_INLINE void ir_sparse_set_add(ir_sparse_set *set, uint32_t n) in ir_sparse_set_add() argument
529 IR_ASSERT(!ir_sparse_set_in(set, n)); in ir_sparse_set_add()
530 idx = set->len++; in ir_sparse_set_add()
531 IR_SPARSE_SET_DENSE(set, idx) = n; in ir_sparse_set_add()
532 IR_SPARSE_SET_SPARSE(set, n) = idx; in ir_sparse_set_add()
535 IR_ALWAYS_INLINE void ir_sparse_set_del(ir_sparse_set *set, uint32_t n) in ir_sparse_set_del() argument
539 IR_ASSERT(ir_sparse_set_in(set, n)); in ir_sparse_set_del()
540 last = IR_SPARSE_SET_DENSE(set, set->len - 1); in ir_sparse_set_del()
542 uint32_t idx = IR_SPARSE_SET_SPARSE(set, n); in ir_sparse_set_del()
544 IR_SPARSE_SET_DENSE(set, idx) = last; in ir_sparse_set_del()
545 IR_SPARSE_SET_SPARSE(set, last) = idx; in ir_sparse_set_del()
548 set->len--; in ir_sparse_set_del()
551 IR_ALWAYS_INLINE uint32_t ir_sparse_set_pop(ir_sparse_set *set) in ir_sparse_set_pop() argument
553 if (set->len > 0) { in ir_sparse_set_pop()
554 set->len--; in ir_sparse_set_pop()
555 return IR_SPARSE_SET_DENSE(set, set->len); in ir_sparse_set_pop()
560 #define IR_SPARSE_SET_FOREACH(set, bit) do { \ argument
561 ir_sparse_set *_set = (set); \
575 ir_bitset set; member
582 q->set = ir_bitset_malloc(n); in ir_bitqueue_init()
590 q->set = ir_mem_realloc(q->set, len * (IR_BITSET_BITS / 8)); in ir_bitqueue_grow()
591 memset(q->set + q->len, 0, (len - q->len) * (IR_BITSET_BITS / 8)); in ir_bitqueue_grow()
598 ir_mem_free(q->set); in ir_bitqueue_free()
604 ir_bitset_clear(q->set, q->len); in ir_bitqueue_clear()
610 ir_bitset_base_t x, *p = q->set + i; in ir_bitqueue_pop()
629 q->set[i] |= IR_BITSET_ONE << (n % IR_BITSET_BITS); in ir_bitqueue_add()
637 ir_bitset_excl(q->set, n); in ir_bitqueue_del()
642 return ir_bitset_in(q->set, n); in ir_bitqueue_in()
1299 # define IR_REGSET_FIRST(set) ((ir_reg)ir_ntzl(set)) argument
1300 # define ir_REGSET_LAST(set) ((ir_reg)(ir_nlzl(set)(set)^63)) argument
1302 # define IR_REGSET_FIRST(set) ((ir_reg)ir_ntz(set)) argument
1303 # define IR_REGSET_LAST(set) ((ir_reg)(ir_nlz(set)^31)) argument
1306 IR_ALWAYS_INLINE ir_reg ir_regset_pop_first(ir_regset *set) in ir_regset_pop_first() argument
1310 IR_ASSERT(!IR_REGSET_IS_EMPTY(*set)); in ir_regset_pop_first()
1311 reg = IR_REGSET_FIRST(*set); in ir_regset_pop_first()
1312 *set = (*set) & ((*set) - 1); in ir_regset_pop_first()
1316 #define IR_REGSET_FOREACH(set, reg) \ argument
1318 ir_regset _tmp = (set); \