beifg: Let be_ifg_foreach_node() declare the node variable.
[libfirm] / ir / be / beifg.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       Interface for interference graphs.
23  * @author      Sebastian Hack
24  * @date        18.11.2005
25  */
26 #ifndef FIRM_BE_BEIFG_H
27 #define FIRM_BE_BEIFG_H
28
29 #include "be_types.h"
30 #include "bechordal.h"
31 #include "irnodeset.h"
32 #include "pset.h"
33
34 struct be_ifg_t {
35         const be_chordal_env_t *env;
36 };
37
38 typedef struct nodes_iter_t {
39         const be_chordal_env_t *env;
40         struct obstack         obst;
41         int                    n;
42         int                    curr;
43         ir_node                **nodes;
44 } nodes_iter_t;
45
46 typedef struct neighbours_iter_t {
47         const be_chordal_env_t *env;
48         const ir_node        *irn;
49         int                   valid;
50         ir_nodeset_t          neighbours;
51         ir_nodeset_iterator_t iter;
52 } neighbours_iter_t;
53
54 typedef struct cliques_iter_t {
55         struct obstack ob;
56         const be_chordal_env_t *cenv;
57         ir_node **buf;
58         ir_node **blocks;
59         int n_blocks, blk;
60         struct list_head *bor;
61         pset *living;
62 } cliques_iter_t;
63
64 void     be_ifg_free(be_ifg_t *ifg);
65 int      be_ifg_connected(const be_ifg_t *ifg, const ir_node *a,
66                           const ir_node *b);
67 ir_node *be_ifg_neighbours_begin(const be_ifg_t *ifg, neighbours_iter_t *iter,
68                                  const ir_node *irn);
69 ir_node *be_ifg_neighbours_next(neighbours_iter_t *iter);
70 void     be_ifg_neighbours_break(neighbours_iter_t *iter);
71 ir_node *be_ifg_nodes_begin(const be_ifg_t *ifg, nodes_iter_t *iter);
72 ir_node *be_ifg_nodes_next(nodes_iter_t *iter);
73 void     be_ifg_nodes_break(nodes_iter_t *iter);
74 int      be_ifg_cliques_begin(const be_ifg_t *ifg, cliques_iter_t *iter,
75                               ir_node **buf);
76 int      be_ifg_cliques_next(cliques_iter_t *iter);
77 void     be_ifg_cliques_break(cliques_iter_t *iter);
78 int      be_ifg_degree(const be_ifg_t *ifg, const ir_node *irn);
79
80 #define be_ifg_foreach_neighbour(ifg, iter, irn, pos) \
81         for (ir_node *pos = be_ifg_neighbours_begin(ifg, iter, irn); pos; pos = be_ifg_neighbours_next(iter))
82
83 #define be_ifg_foreach_node(ifg, iter, pos) \
84         for (ir_node *pos = be_ifg_nodes_begin(ifg, iter); pos; pos = be_ifg_nodes_next(iter))
85
86 #define be_ifg_foreach_clique(ifg, iter, buf, count) \
87         for(*(count) = be_ifg_cliques_begin(ifg, iter, buf); \
88         *(count) != -1 ; \
89         *(count) = be_ifg_cliques_next(iter))
90
91 typedef struct {
92         int n_nodes;
93         int n_edges;
94         int n_comps;
95 } be_ifg_stat_t;
96
97 void be_ifg_stat(ir_graph *irg, be_ifg_t *ifg, be_ifg_stat_t *stat);
98
99 be_ifg_t *be_create_ifg(const be_chordal_env_t *env);
100
101 #endif