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