Removed ANNOUNCE macro
[libfirm] / ir / ir / irgwalk.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irgwalk.h
4  * Purpose:
5  * Author:      Boris Boesler
6  * Modified by: Goetz Lindenmaier
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1999-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 /**
15  * @file irgwalk.h
16  *
17  * Traverse an ir graph.
18  *
19  * @author Boris Boesler
20  *
21  * Traverse an ir graph:
22  * - execute the pre function before recursion
23  * - execute the post function after recursion
24  *
25  * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
26  * graph before starting the walker.
27  */
28 #ifndef _FIRM_IR_IRGWALK_H_
29 #define _FIRM_IR_IRGWALK_H_
30
31 #include "firm_types.h"
32
33 /* type of callback function for ir_graph walk */
34 #ifndef _IRG_WALK_FUNC_TYPEDEF_
35 #define _IRG_WALK_FUNC_TYPEDEF_
36 /**
37  * The type of a walk function.  Does not use the link field.
38  *
39  * @param node - the node that is just visited
40  * @param env  - an environment pointer passed by the walk functions
41  */
42 typedef void irg_walk_func(ir_node *node, void *env);
43 #endif
44
45 /**
46  * Walks over the ir graph.
47  *
48  * Walks over the ir graph, starting at the node given as first argument.
49  * Executes pre before visiting the predecessor of a node, post after.
50  * irg_walk uses the visited flag in irg and the nodes to determine visited
51  * nodes.  It executes inc_irg_visited(current_ir_graph) to generate a new
52  * flag.  Therefore current_ir_graph must be set before calling the walker.
53  * It marks the node as visited before executing pre.
54  * The void* env can be used to pass status information between the
55  * pre and post functions.  Does not use the link fields.
56  *
57  * @param node - the start node
58  * @param pre  - walker function, executed before the predecessor of a node are visited
59  * @param post - walker function, executed after the predecessor of a node are visited
60  * @param env  - environment, passed to pre and post
61  *
62  */
63 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
64
65 /**
66  * Walks over all reachable nodes in the ir graph.
67  *
68  * @param irg  - the irg graph
69  * @param pre  - walker function, executed before the predecessor of a node are visited
70  * @param post - walker function, executed after the predecessor of a node are visited
71  * @param env  - environment, passed to pre and post
72  *
73  * Like irg_walk(), but walks over all reachable nodes in the ir
74  * graph, starting at the end operation. During the walk current_ir_graph
75  * is set to irg.  Does not use the link field.  If interprocedural_view
76  * is set, visits all reachable irgs.
77  */
78 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
79
80 /**
81  * Walks over the ir graph.
82  *
83  * Walks over the ir graph, starting at the node given as first argument.
84  * Executes pre before visiting the predecessor of a node, post after.
85  * irg_walk uses the visited flag in irg and the nodes to determine visited
86  * nodes.  It executes inc_irg_visited(current_ir_graph) to generate a new
87  * flag.  Therefore current_ir_graph must be set before calling the walker.
88  * It marks the node as visited before executing pre.
89  * The void* env can be used to pass status information between the
90  * pre and post functions.  Does not use the link fields.
91  * This walker also follows additional dependency egdes.
92  *
93  * @param node - the start node
94  * @param pre  - walker function, executed before the predecessor of a node are visited
95  * @param post - walker function, executed after the predecessor of a node are visited
96  * @param env  - environment, passed to pre and post
97  *
98  */
99 void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
100
101 /**
102  * Walks over all reachable nodes in the ir graph.
103  *
104  * @param irg  - the irg graph
105  * @param pre  - walker function, executed before the predecessor of a node are visited
106  * @param post - walker function, executed after the predecessor of a node are visited
107  * @param env  - environment, passed to pre and post
108  *
109  * Like irg_walk(), but walks over all reachable nodes in the ir
110  * graph, starting at the end operation. During the walk current_ir_graph
111  * is set to irg.  Does not use the link field.
112  * This walker also follows additional dependency egdes.
113  * interprocedural_view is not yet supported.
114  */
115 void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
116
117 /**
118  * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
119  *
120  * @param pre  - walker function, executed before the predecessor of a node are visited
121  * @param post - walker function, executed after the predecessor of a node are visited
122  * @param env  - environment, passed to pre and post
123  *
124  * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
125  * Sets current_ir_graph properly for each walk.  Conserves current
126  * current_ir_graph.  In interprocedural view nodes can be visited several
127  * times.  Does not use the link field.
128  */
129 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
130
131 /**
132  * Walks all irgs in interprocedural view.
133  *
134  * @param pre  - walker function, executed before the predecessor of a node are visited
135  * @param post - walker function, executed after the predecessor of a node are visited
136  * @param env  - environment, passed to pre and post
137  *
138  * This function walks all irgs in interprocedural view.
139  * Visits each node only once.  Sets current_ir_graph properly. Does not use the link field.
140  */
141 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
142
143 /** Walks only over Block nodes in the graph.
144  *
145  * @param node - the start node
146  * @param pre  - walker function, executed before the predecessor of a node are visited
147  * @param post - walker function, executed after the predecessor of a node are visited
148  * @param env  - environment, passed to pre and post
149  *
150  * This function Walks only over Block nodes in the graph. Has it's own visited
151  * flag, so that it can be interleaved with the other walker.
152  * If a none block is passed, starts at the block this node belongs to.
153  * If end is passed also visits kept alive blocks. Does not use the link field.
154  */
155 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
156
157 /**
158  * Walks only over reachable Block nodes in the graph.
159  *
160  * @param irg  - the irg graph
161  * @param pre  - walker function, executed before the predecessor of a node are visited
162  * @param post - walker function, executed after the predecessor of a node are visited
163  * @param env  - environment, passed to pre and post
164  *
165  * Like irg_block_walk(), but walks over all reachable blocks in the
166  * ir graph, starting at the end block. Does not use the link field.
167  */
168 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
169
170 /**
171  * Walks over all code in const_code_irg.
172  *
173  * @param pre  - walker function, executed before the predecessor of a node are visited
174  * @param post - walker function, executed after the predecessor of a node are visited
175  * @param env  - environment, passed to pre and post
176  *
177  * This function walks over all code in const_code_irg.
178  * Uses visited flag in const_code_irg.  Does not use the link field.
179  */
180 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
181
182 /**
183  * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
184  * before going to another block, starting at the end operation.
185  * Executes pre before visiting the predecessor of a node, post after.
186  * irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
187  * determine visited nodes.
188  * It executes inc_irg_visited(current_ir_graph) to generate a new
189  * flag. It marks the node as visited before executing pre.
190  * The void *env can be used to pass status information between the
191  * pre and post functions.  Does not use the link fields.
192  * Walks only intraprocedural, even in interprocedural view.
193  *
194  * @param irg  - the irg graph
195  * @param pre  - walker function, executed before the predecessor of a node are visited
196  * @param post - walker function, executed after the predecessor of a node are visited
197  * @param env  - environment, passed to pre and post
198  */
199 void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
200
201 /**
202  * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
203  * before going to another block, starting at the end operation.
204  * Executes pre before visiting the predecessor of a node, post after.
205  * irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
206  * determine visited nodes.
207  * It executes inc_irg_visited(current_ir_graph) to generate a new
208  * flag. It marks the node as visited before executing pre.
209  * The void *env can be used to pass status information between the
210  * pre and post functions.  Does not use the link fields.
211  * Walks only intraprocedural, even in interprocedural view.
212  * This walker also follows dependency edges.
213  *
214  * @param irg  - the irg graph
215  * @param pre  - walker function, executed before the predecessor of a node are visited
216  * @param post - walker function, executed after the predecessor of a node are visited
217  * @param env  - environment, passed to pre and post
218  */
219 void irg_walk_in_or_dep_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
220
221 /**
222  * Additionally walk over all anchors. Do NOT increase the visit flag.
223  * This function visits all anchor nodes that otherwise might not been visited in a
224  * walk, for instance the Bad() node.
225  *
226  * @param irg  - the irg graph
227  * @param pre  - walker function, executed before the predecessor of a node are visited
228  * @param post - walker function, executed after the predecessor of a node are visited
229  * @param env  - environment, passed to pre and post
230  */
231 void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
232
233 #endif /* _FIRM_IR_IRGWALK_H_ */