fix invalid double definition of irg_extblk_info_state
[libfirm] / include / libfirm / irextbb.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   Extended basis block support.
23  * @author  Michael Beck
24  * @date    5.2005
25  * @version $Id$
26  */
27 #ifndef FIRM_ANA_IREXTBB_H
28 #define FIRM_ANA_IREXTBB_H
29
30 #include "firm_types.h"
31 #include "execfreq.h"
32 #include "begin.h"
33
34 /* type of callback function for ir_graph walk */
35 #ifndef _EXTBB_WALK_FUNC_TYPEDEF_
36 #define _EXTBB_WALK_FUNC_TYPEDEF_
37 /**
38  * The type of a walk function.  Does not use the link field.
39  *
40  * @param blk  - the extended basic block that is just visited
41  * @param env  - an environment pointer passed by the walk functions
42  */
43 typedef void extbb_walk_func(ir_extblk *blk, void *env);
44 #endif
45
46 /**
47  * Checks whether a pointer points to a extended basic block.
48  * Intern version for libFirm.
49  */
50 FIRM_API int is_ir_extbb(const void *thing);
51
52 /**
53  * Compute the extended basic blocks for a graph.
54  */
55 FIRM_API void compute_extbb(ir_graph *irg);
56
57 /**
58  * Compute the extended basic blocks for a graph based on execution frequencies.
59  */
60 FIRM_API void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
61
62 /**
63  * free all extended block info.
64  */
65 FIRM_API void free_extbb(ir_graph *irg);
66
67 /**
68  * Return the extended block of a node.
69  *
70  * @param node  the node
71  */
72 FIRM_API ir_extblk *get_nodes_extbb(const ir_node *node);
73
74 /**
75  * Gets the visited counter of an extended block.
76  *
77  * @param blk  the extended basic block
78  */
79 FIRM_API ir_visited_t get_extbb_visited(const ir_extblk *blk);
80
81 /**
82  * Sets the visited counter of an extended block.
83  *
84  * @param blk      the extended basic block
85  * @param visited  new value for the visited counter
86  */
87 FIRM_API void set_extbb_visited(ir_extblk *blk, ir_visited_t visited);
88
89 /**
90  * Mark an extended block as visited in a graph.
91  * Uses the block visit flag.
92  *
93  * @param blk  the extended basic block
94  */
95 FIRM_API void mark_extbb_visited(ir_extblk *blk);
96
97 /**
98  * Returns non-zero if an extended was visited.
99  * Uses the block visit flag.
100  *
101  * @param blk  the extended basic block
102  */
103 FIRM_API int extbb_visited(const ir_extblk *blk);
104
105 /**
106  * Returns non-zero if an extended block was NOT visited.
107  * Uses the block visit flag.
108  *
109  * @param blk  the extended basic block
110  */
111 FIRM_API int extbb_not_visited(const ir_extblk *blk);
112
113 /**
114  * Returns the link field of an extended block.
115  *
116  * @param blk  the extended basic block
117  */
118 FIRM_API void *get_extbb_link(const ir_extblk *blk);
119
120 /**
121  * Sets the link field of an extended block.
122  *
123  * @param blk  the extended basic block
124  * @param link the new link value
125  */
126 FIRM_API void set_extbb_link(ir_extblk *blk, void *link);
127
128 /**
129  * Return the number of basic blocks of an extended block.
130  *
131  * @param blk  the extended basic block
132  */
133 FIRM_API int get_extbb_n_blocks(const ir_extblk *blk);
134
135 /**
136  * Return the i'th basic block of an extended block.
137  *
138  * @param blk  the extended basic block
139  * @param pos  the position
140  */
141 FIRM_API ir_node *get_extbb_block(const ir_extblk *blk, int pos);
142
143 /**
144  * Return the leader basic block of an extended block.
145  *
146  * @param blk  the extended basic block
147  */
148 FIRM_API ir_node *get_extbb_leader(const ir_extblk *blk);
149
150 /**
151  * Return the node number of an extended block.
152  * Its the block number of the leader block
153  *
154  * @param blk  the extended basic block
155  */
156 FIRM_API long get_extbb_node_nr(const ir_extblk *blk);
157
158 /**
159  * Walks only over Extended Basic Block nodes in the graph.
160  *
161  * @param blk  - the start extended block node
162  * @param pre  - walker function, executed before the predecessor of a node are
163  *               visited
164  * @param post - walker function, executed after the predecessor of a node are
165  *               visited
166  * @param env  - environment, passed to pre and post
167  *
168  * This function Walks only over Block nodes in the graph. Has it's own visited
169  * flag, so that it can be interleaved with the other walker.
170  * If a none block is passed, starts at the block this node belongs to.
171  * If end is passed also visits kept alive blocks. Does not use the link field.
172  */
173 FIRM_API void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre,
174                                 extbb_walk_func *post, void *env);
175
176 /**
177  * Walks only over reachable Extended Basic Block nodes in the graph.
178  * Ensures, that the extended block containing the End node is visited last
179  * and the block containing Start visited first (in post order).
180  *
181  * @param irg  - the irg graph
182  * @param pre  - walker function, executed before the predecessor of a block
183  *               are visited
184  * @param post - walker function, executed after the predecessor of a block
185  *               are visited
186  * @param env  - environment, passed to pre and post
187  */
188 FIRM_API void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre,
189                                       extbb_walk_func *post, void *env);
190
191 #include "end.h"
192
193 #endif