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