unified 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 <stdio.h>
33
34 #include "irnode.h"
35
36 #include "becopyopt.h"
37 #include "beirg.h"
38
39 typedef struct _be_ifg_impl_t   be_ifg_impl_t;
40 typedef struct _be_ifg_t        be_ifg_t;
41
42 #define be_ifg_nodes_iter_alloca(self)          (alloca(be_ifg_nodes_iter_size(self)))
43 #define be_ifg_neighbours_iter_alloca(self)     (alloca(be_ifg_neighbours_iter_size(self)))
44 #define be_ifg_cliques_iter_alloca(self)        (alloca(be_ifg_cliques_iter_size(self)))
45
46 size_t   (be_ifg_nodes_iter_size)(const be_ifg_t *self);
47 size_t   (be_ifg_neighbours_iter_size)(const be_ifg_t *self);
48 size_t   (be_ifg_cliques_iter_size)(const be_ifg_t *self);
49 void     (be_ifg_free)(be_ifg_t *self);
50 int      (be_ifg_connected)(const be_ifg_t *self, const ir_node *a, const ir_node *b);
51 ir_node *(be_ifg_neighbours_begin)(const be_ifg_t *self, void *iter, const ir_node *irn);
52 ir_node *(be_ifg_neighbours_next)(const be_ifg_t *self, void *iter);
53 void     (be_ifg_neighbours_break)(const be_ifg_t *self, void *iter);
54 ir_node *(be_ifg_nodes_begin)(const be_ifg_t *self, void *iter);
55 ir_node *(be_ifg_nodes_next)(const be_ifg_t *self, void *iter);
56 void     (be_ifg_nodes_break)(const be_ifg_t *self, void *iter);
57 int      (be_ifg_cliques_begin)(const be_ifg_t *self, void *iter, ir_node **buf);
58 int      (be_ifg_cliques_next)(const be_ifg_t *self, void *iter);
59 void     (be_ifg_cliques_break)(const be_ifg_t *self, void *iter);
60 int      (be_ifg_degree)(const be_ifg_t *self, const ir_node *irn);
61
62 #define be_ifg_foreach_neighbour(self, iter, irn, pos) \
63         for(pos = be_ifg_neighbours_begin(self, iter, irn); (pos); pos = be_ifg_neighbours_next(self, iter))
64
65 #define be_ifg_foreach_node(self, iter, pos) \
66         for(pos = be_ifg_nodes_begin(self, iter); (pos); pos = be_ifg_nodes_next(self, iter))
67
68 #define be_ifg_foreach_clique(self, iter, buf, count) \
69         for(*(count) = be_ifg_cliques_begin(self, iter, buf); \
70         *(count) != -1 ; \
71         *(count) = be_ifg_cliques_next(self, iter))
72
73 typedef struct {
74         int n_nodes;
75         int n_edges;
76         int n_comps;
77 } be_ifg_stat_t;
78
79 void be_ifg_stat(be_irg_t *birg, be_ifg_t *ifg, be_ifg_stat_t *stat);
80
81 be_ifg_t *be_create_ifg(const be_chordal_env_t *env);
82
83 /*
84      ____                        _
85     |  _ \ _   _ _ __ ___  _ __ (_)_ __   __ _
86     | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` |
87     | |_| | |_| | | | | | | |_) | | | | | (_| |
88     |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, |
89                           |_|            |___/
90 */
91
92 typedef struct _be_ifg_dump_dot_cb_t {
93         int  (*is_dump_node)(void *self, ir_node *irn);
94         void (*graph_attr)(FILE *f, void *self);
95         void (*node_attr)(FILE *f, void *self, ir_node *irn);
96         void (*edge_attr)(FILE *f, void *self, ir_node *from, ir_node *to);
97         void (*at_begin)(FILE *file, void *self);
98         void (*at_end)(FILE *file, void *self);
99 } be_ifg_dump_dot_cb_t;
100
101 void be_ifg_dump_dot(be_ifg_t *ifg, ir_graph *irg, FILE *file, const be_ifg_dump_dot_cb_t *cb, void *self);
102 void be_ifg_check_sorted(const be_ifg_t *ifg);
103 void be_ifg_check_sorted_to_file(const be_ifg_t *ifg, FILE *f);
104 void be_ifg_check_performance(be_chordal_env_t *chordal_env);
105
106
107 #endif /* _BEIFG_H */