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 * Walks over the ir graph, starting at the node given as first argument.
57 * Executes pre before visiting the predecessor of a node, post after.
58 * irg_walk uses the visited flag in irg and the nodes to determine visited
59 * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
60 * flag. Therefore current_ir_graph must be set before calling the walker.
61 * It marks the node as visited before executing pre.
62 * The void* env can be used to pass status information between the
63 * pre and post functions. Does not use the link field.
65 * @param node - the start node
66 * @param pre - walker function, executed before the predecessor of a node are visited
67 * @param post - walker function, executed after the predecessor of a node are visited
68 * @param env - environment, passend to pre and post
71 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
74 * Walks over all reachable nodes in the ir graph.
76 * @param irg - the irg graph
77 * @param pre - walker function, executed before the predecessor of a node are visited
78 * @param post - walker function, executed after the predecessor of a node are visited
79 * @param env - environment, passend to pre and post
81 * Like irg_walk(), but walks over all reachable nodes in the ir
82 * graph, starting at the end operation. During the walk current_ir_graph
83 * is set to irg. Does not use the link field. If interprocedural_view
84 * is set, visits all reachable irgs.
86 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
89 * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
91 * @param pre - walker function, executed before the predecessor of a node are visited
92 * @param post - walker function, executed after the predecessor of a node are visited
93 * @param env - environment, passend to pre and post
95 * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
96 * Sets current_ir_graph properly for each walk. Conserves current
97 * current_ir_graph. In interprocedural view nodes can be visited several
98 * times. Does not use the link field.
100 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
103 * Walks all irgs in interprocedural view.
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, passend to pre and post
109 * This function walks all irgs in interprocedural view.
110 * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
112 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
115 * Walks only over Block nodes in the graph.
117 * @param node - the start node
118 * @param pre - walker function, executed before the predecessor of a node are visited
119 * @param post - walker function, executed after the predecessor of a node are visited
120 * @param env - environment, passend to pre and post
122 * This function Walks only over Block nodes in the graph. Has it's own visited
123 * flag, so that it can be interleaved with the other walker.
124 * If a none block is passed, starts at the block this node belongs to.
125 * If end is passed also visites kept alive blocks. Does not use the link field.
127 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
130 * Walks only over reachable Block nodes in the graph.
132 * @param irg - the irg graph
133 * @param pre - walker function, executed before the predecessor of a node are visited
134 * @param post - walker function, executed after the predecessor of a node are visited
135 * @param env - environment, passend to pre and post
137 * Like irg_block_walk(), but walks over all reachable blocks in the
138 * ir graph, starting at the end block. Does not use the link field.
140 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
143 * Walks over all code in const_code_irg.
145 * @param pre - walker function, executed before the predecessor of a node are visited
146 * @param post - walker function, executed after the predecessor of a node are visited
147 * @param env - environment, passend to pre and post
149 * This function walks over all code in const_code_irg.
150 * Uses visited flag in const_code_irg. Does not use the link field.
152 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
154 # endif /* _IRGWALK_H_ */