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);
47 /** Allocates some necessary datastructures. */
48 void init_ip_walk(void);
50 /** Frees some necessary datastructures. */
51 void finish_ip_walk(void);
54 * Walks over the ir graph.
56 * @param node - the start node
57 * @param pre - walker function, executed before the predecessor of a node are visited
58 * @param post - walker function, executed after the predecessor of a node are visited
59 * @param env - environment, passend to pre and post
61 * Walks over the ir graph, starting at the node given as first argument.
62 * Executes pre before visiting the predecessor of a node, post after.
63 * irg_walk uses the visited flag in irg and the nodes to determine visited
64 * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
65 * flag. It marks the node as visited before executing pre.
66 * The void* env can be used to pass status information between the
67 * pre and post functions. Does not use the link field.
69 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
72 * Walks over all reachable nodes in the ir graph.
74 * @param irg - the irg graph
75 * @param pre - walker function, executed before the predecessor of a node are visited
76 * @param post - walker function, executed after the predecessor of a node are visited
77 * @param env - environment, passend to pre and post
79 * Like irg_walk(), but walks over all reachable nodes in the ir
80 * graph, starting at the end operation. During the walk current_ir_graph
81 * is set to irg. Does not use the link field.
83 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
86 * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
88 * @param pre - walker function, executed before the predecessor of a node are visited
89 * @param post - walker function, executed after the predecessor of a node are visited
90 * @param env - environment, passend to pre and post
92 * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
93 * Sets current_ir_graph properly for each walk. Conserves current
94 * current_ir_graph. In interprocedural view nodes can be visited several
95 * times. Does not use the link field.
97 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
100 * Walks all irgs in interprocedural view.
102 * @param pre - walker function, executed before the predecessor of a node are visited
103 * @param post - walker function, executed after the predecessor of a node are visited
104 * @param env - environment, passend to pre and post
106 * This function walks all irgs in interprocedural view.
107 * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
109 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
112 * Walks only over Block nodes in the graph.
114 * @param node - the start node
115 * @param pre - walker function, executed before the predecessor of a node are visited
116 * @param post - walker function, executed after the predecessor of a node are visited
117 * @param env - environment, passend to pre and post
119 * This function Walks only over Block nodes in the graph. Has it's own visited
120 * flag, so that it can be interleaved with the other walker.
121 * If a none block is passed, starts at the block this node belongs to.
122 * If end is passed also visites kept alive blocks. Does not use the link field.
124 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
127 * Walks only over reachable Block nodes in the graph.
129 * @param irg - the irg graph
130 * @param pre - walker function, executed before the predecessor of a node are visited
131 * @param post - walker function, executed after the predecessor of a node are visited
132 * @param env - environment, passend to pre and post
134 * Like irg_block_walk(), but walks over all reachable blocks in the
135 * ir graph, starting at the end block. Does not use the link field.
137 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
140 * Walks over all code in const_code_irg.
142 * @param pre - walker function, executed before the predecessor of a node are visited
143 * @param post - walker function, executed after the predecessor of a node are visited
144 * @param env - environment, passend to pre and post
146 * This function walks over all code in const_code_irg.
147 * Uses visited flag in const_code_irg. Does not use the link field.
149 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
151 # endif /* _IRGWALK_H_ */