3 * File name: ir/ir/irgwalk.h
5 * Author: Boris Boesler
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1999-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 * Traverse an ir graph.
19 * @author Boris Boesler
21 * Traverse an ir graph:
22 * - execute the pre function before recursion
23 * - execute the post function after recursion
25 * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
26 * graph before starting the walker.
35 /* type of callback function for ir_graph walk */
36 #ifndef _IRG_WALK_FUNC_TYPEDEF_
37 #define _IRG_WALK_FUNC_TYPEDEF_
39 * The type of a walk function. Does not use the link field.
41 * @param node - the node that is just visited
42 * @param env - an environment pointer passed by the walk functions
44 typedef void irg_walk_func(ir_node *node, void *env);
48 * Walks over the ir graph.
50 * Walks over the ir graph, starting at the node given as first argument.
51 * Executes pre before visiting the predecessor of a node, post after.
52 * irg_walk uses the visited flag in irg and the nodes to determine visited
53 * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
54 * flag. Therefore current_ir_graph must be set before calling the walker.
55 * It marks the node as visited before executing pre.
56 * The void* env can be used to pass status information between the
57 * pre and post functions. Does not use the link fields.
59 * @param node - the start node
60 * @param pre - walker function, executed before the predecessor of a node are visited
61 * @param post - walker function, executed after the predecessor of a node are visited
62 * @param env - environment, passend to pre and post
65 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
68 * Walks over all reachable nodes in the ir graph.
70 * @param irg - the irg graph
71 * @param pre - walker function, executed before the predecessor of a node are visited
72 * @param post - walker function, executed after the predecessor of a node are visited
73 * @param env - environment, passend to pre and post
75 * Like irg_walk(), but walks over all reachable nodes in the ir
76 * graph, starting at the end operation. During the walk current_ir_graph
77 * is set to irg. Does not use the link field. If interprocedural_view
78 * is set, visits all reachable irgs.
80 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
83 * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
85 * @param pre - walker function, executed before the predecessor of a node are visited
86 * @param post - walker function, executed after the predecessor of a node are visited
87 * @param env - environment, passend to pre and post
89 * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
90 * Sets current_ir_graph properly for each walk. Conserves current
91 * current_ir_graph. In interprocedural view nodes can be visited several
92 * times. Does not use the link field.
94 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
97 * Walks all irgs in interprocedural view.
99 * @param pre - walker function, executed before the predecessor of a node are visited
100 * @param post - walker function, executed after the predecessor of a node are visited
101 * @param env - environment, passend to pre and post
103 * This function walks all irgs in interprocedural view.
104 * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
106 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
109 * Walks only over Block nodes in the graph.
111 * @param node - the start node
112 * @param pre - walker function, executed before the predecessor of a node are visited
113 * @param post - walker function, executed after the predecessor of a node are visited
114 * @param env - environment, passend to pre and post
116 * This function Walks only over Block nodes in the graph. Has it's own visited
117 * flag, so that it can be interleaved with the other walker.
118 * If a none block is passed, starts at the block this node belongs to.
119 * If end is passed also visites kept alive blocks. Does not use the link field.
121 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
124 * Walks only over reachable Block nodes in the graph.
126 * @param irg - the irg graph
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, passend to pre and post
131 * Like irg_block_walk(), but walks over all reachable blocks in the
132 * ir graph, starting at the end block. Does not use the link field.
134 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
137 * Walks over all code in const_code_irg.
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, passend to pre and post
143 * This function walks over all code in const_code_irg.
144 * Uses visited flag in const_code_irg. Does not use the link field.
146 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
149 * Walks over reachable nodes in block-wise order, i.e. visit all nodes in a block
150 * before going to another block, starting at the node given as first argument.
151 * Executes pre before visiting the predecessor of a node, post after.
152 * irg_walk_blkwise() uses the visited flag in irg and the nodes to determine visited
153 * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
154 * flag. Therefore current_ir_graph must be set before calling the walker.
155 * It marks the node as visited before executing pre.
156 * The void *env can be used to pass status information between the
157 * pre and post functions. Does not use the link fields.
158 * Do NOT leave the graph in interprocedural view.
160 * @param pre - walker function, executed before the predecessor of a node are visited
161 * @param post - walker function, executed after the predecessor of a node are visited
162 * @param env - environment, passend to pre and post
164 * This function works like irg_walk, except that it enters and leaves blocks only once.
165 * So, the post walker see a 'valid schedule' of the code, the pre-walker a 'reversed schedule'
167 void irg_walk_blkwise(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
170 * Walks over all reachable nodes in the ir graph in block-wise order.
172 * @param irg - the irg graph
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, passend to pre and post
177 * Like irg_walk_blkwise(), but walks over all reachable nodes in the ir
178 * graph, starting at the end operation. During the walk current_ir_graph
179 * is set to irg. Does not use the link fields.
180 * Do NOT leave the graph in interprocedural view.
182 void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
184 # endif /* _IRGWALK_H_ */