2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Some convenience macros for node bitmaps.
23 * @author Sebastian Hack
27 #ifndef FIRM_IR_IRBITSET_H
28 #define FIRM_IR_IRBITSET_H
32 #define bitset_irg_malloc(irg) bitset_malloc(get_irg_last_idx(irg))
33 #define bitset_irg_alloca(irg) bitset_alloca(get_irg_last_idx(irg))
34 #define bitset_irg_obstack_alloc(obst, irg) bitset_obstack_alloc(obst, get_irg_last_idx(irg))
35 #define bitset_add_irn(bs, irn) bitset_set((bs), get_irn_idx(irn))
36 #define bitset_remv_irn(bs, irn) bitset_clear((bs), get_irn_idx(irn))
37 #define bitset_contains_irn(bs, irn) bitset_is_set((bs), get_irn_idx(irn))
41 #define _bsfe_get_irn(irg, elm) (elm == (bitset_pos_t) -1 ? NULL : get_idx_irn((irg), (unsigned) elm))
44 * Iterate over a bitset containing node indexes.
45 * @param irg The graph the nodes are in.
46 * @param bs The bitset containing the indexes.
47 * @param elm A loop variable for the bitset (must be of type bitset_pos_t).
48 * @param irn An ir_node * which is set to the current node.
50 #define bitset_foreach_irn(irg, bs, elm, irn) \
51 for(elm = bitset_next_set(bs, 0), irn = _bsfe_get_irn(irg, elm); elm != (bitset_pos_t) -1; elm = bitset_next_set(bs, elm + 1), irn = _bsfe_get_irn(irg, elm))