added new licence header
[libfirm] / ir / be / beifg.h
1 /*
2  * Copyright (C) 1995-2007 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   beifg.h
22  * @date   18.11.2005
23  * @author Sebastian Hack
24  *
25  * Copyright (C) 2005 Universitaet Karlsruhe
26  * Released under the GPL
27  */
28
29 #ifndef _BEIFG_H
30 #define _BEIFG_H
31
32 #include "becopyopt.h"
33
34 #include "firm_types.h"
35
36 typedef struct _be_ifg_impl_t   be_ifg_impl_t;
37 typedef struct _be_ifg_t        be_ifg_t;
38
39 #define be_ifg_nodes_iter_alloca(self)          (alloca(be_ifg_nodes_iter_size(self)))
40 #define be_ifg_neighbours_iter_alloca(self)     (alloca(be_ifg_neighbours_iter_size(self)))
41 #define be_ifg_cliques_iter_alloca(self)        (alloca(be_ifg_cliques_iter_size(self)))
42
43 size_t   (be_ifg_nodes_iter_size)(const be_ifg_t *self);
44 size_t   (be_ifg_neighbours_iter_size)(const be_ifg_t *self);
45 size_t   (be_ifg_cliques_iter_size)(const be_ifg_t *self);
46 void     (be_ifg_free)(be_ifg_t *self);
47 int      (be_ifg_connected)(const be_ifg_t *self, const ir_node *a, const ir_node *b);
48 ir_node *(be_ifg_neighbours_begin)(const be_ifg_t *self, void *iter, const ir_node *irn);
49 ir_node *(be_ifg_neighbours_next)(const be_ifg_t *self, void *iter);
50 void     (be_ifg_neighbours_break)(const be_ifg_t *self, void *iter);
51 ir_node *(be_ifg_nodes_begin)(const be_ifg_t *self, void *iter);
52 ir_node *(be_ifg_nodes_next)(const be_ifg_t *self, void *iter);
53 void     (be_ifg_nodes_break)(const be_ifg_t *self, void *iter);
54 int      (be_ifg_cliques_begin)(const be_ifg_t *self, void *iter, ir_node **buf);
55 int      (be_ifg_cliques_next)(const be_ifg_t *self, void *iter);
56 void     (be_ifg_cliques_break)(const be_ifg_t *self, void *iter);
57 int      (be_ifg_degree)(const be_ifg_t *self, const ir_node *irn);
58
59 #define be_ifg_foreach_neighbour(self, iter, irn, pos) \
60         for(pos = be_ifg_neighbours_begin(self, iter, irn); (pos); pos = be_ifg_neighbours_next(self, iter))
61
62 #define be_ifg_foreach_node(self, iter, pos) \
63         for(pos = be_ifg_nodes_begin(self, iter); (pos); pos = be_ifg_nodes_next(self, iter))
64
65 #define be_ifg_foreach_clique(self, iter, buf, count) \
66         for(*(count) = be_ifg_cliques_begin(self, iter, buf); \
67         *(count) != -1 ; \
68         *(count) = be_ifg_cliques_next(self, iter))
69
70 typedef struct {
71         int n_nodes;
72         int n_edges;
73         int n_comps;
74 } be_ifg_stat_t;
75
76 void be_ifg_stat(be_irg_t *birg, be_ifg_t *ifg, be_ifg_stat_t *stat);
77
78 be_ifg_t *be_create_ifg(const be_chordal_env_t *env);
79
80 /*
81      ____                        _
82     |  _ \ _   _ _ __ ___  _ __ (_)_ __   __ _
83     | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` |
84     | |_| | |_| | | | | | | |_) | | | | | (_| |
85     |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, |
86                           |_|            |___/
87 */
88
89 typedef struct _be_ifg_dump_dot_cb_t {
90         int  (*is_dump_node)(void *self, ir_node *irn);
91         void (*graph_attr)(FILE *f, void *self);
92         void (*node_attr)(FILE *f, void *self, ir_node *irn);
93         void (*edge_attr)(FILE *f, void *self, ir_node *from, ir_node *to);
94         void (*at_begin)(FILE *file, void *self);
95         void (*at_end)(FILE *file, void *self);
96 } be_ifg_dump_dot_cb_t;
97
98 void be_ifg_dump_dot(be_ifg_t *ifg, ir_graph *irg, FILE *file, const be_ifg_dump_dot_cb_t *cb, void *self);
99 void be_ifg_check_sorted(const be_ifg_t *ifg);
100 void be_ifg_check_sorted_to_file(const be_ifg_t *ifg, FILE *f);
101 void be_ifg_check_performance(be_chordal_env_t *chordal_env);
102
103
104 #endif /* _BEIFG_H */