forgot this
[libfirm] / ir / ir / irbitset.h
1 /**
2  * Some convenience macros for node bitmaps.
3  * @author Sebastian Hack
4  * @date   10.05.2006
5  */
6
7 #ifndef __FIRM_IRBITSET_H
8 #define __FIRM_IRBITSET_H
9
10 #include "bitset.h"
11
12 #define bitset_irg_malloc(irg)                bitset_malloc(get_irg_last_idx(irg))
13 #define bitset_irg_alloca(irg)                bitset_alloca(get_irg_last_idx(irg))
14 #define bitset_irg_obstack_alloc(obst, irg)   bitset_obstack_alloc(obst, get_irg_last_idx(irg))
15 #define bitset_add_irn(bs, irn)               bitset_set((bs), get_irn_idx(irn))
16 #define bitset_remv_irn(bs, irn)              bitset_clear((bs), get_irn_idx(irn))
17 #define bitset_contains_irn(bs, irn)          bitset_is_set((bs), get_irn_idx(irn))
18
19
20 /* Internal use. */
21 #define _bsfe_get_irn(irg, elm) (elm == -1 ? NULL : get_idx_irn((irg), (unsigned) elm))
22
23 /**
24  * Iterate over a bitset containing node indexes.
25  * @param irg The graph the nodes are in.
26  * @param bs  The bitset containing the indexes.
27  * @param elm A loop variable for the bitset (must be of type bitset_pos_t).
28  * @param irn An ir_node * which is set to the current node.
29  */
30 #define bitset_foreach_irn(irg, bs, elm, irn) \
31         for(elm = bitset_next_set(bs, 0), irn = _bsfe_get_irn(irg, elm); elm != -1; elm = bitset_next_set(bs, elm + 1), irn = _bsfe_get_irn(irg, elm))
32
33
34 #endif /* __FIRM_IRBITSET_H */