introduce Switch node
[libfirm] / ir / ir / irbitset.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Some convenience macros for node bitmaps.
23  * @author  Sebastian Hack
24  * @date    10.05.2006
25  * @version $Id$
26  */
27 #ifndef FIRM_IR_IRBITSET_H
28 #define FIRM_IR_IRBITSET_H
29
30 #include "bitset.h"
31
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))
38
39
40 /* Internal use. */
41 #define bsfe_get_irn_(irg, elm) (elm == (unsigned) -1 ? NULL : get_idx_irn((irg), (unsigned) elm))
42
43 /**
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
48  * @param irn An ir_node * which is set to the current node.
49  */
50 #define bitset_foreach_irn(irg, bs, elm, irn) \
51         for(elm = bitset_next_set(bs, 0), irn = bsfe_get_irn_(irg, elm); elm != (unsigned) -1; elm = bitset_next_set(bs, elm + 1), irn = bsfe_get_irn_(irg, elm))
52
53
54 #endif