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. If interprocedural_view
82 * is set, visits all reachable irgs.
84 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
87 * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
89 * @param pre - walker function, executed before the predecessor of a node are visited
90 * @param post - walker function, executed after the predecessor of a node are visited
91 * @param env - environment, passend to pre and post
93 * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
94 * Sets current_ir_graph properly for each walk. Conserves current
95 * current_ir_graph. In interprocedural view nodes can be visited several
96 * times. Does not use the link field.
98 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
101 * Walks all irgs in interprocedural view.
103 * @param pre - walker function, executed before the predecessor of a node are visited
104 * @param post - walker function, executed after the predecessor of a node are visited
105 * @param env - environment, passend to pre and post
107 * This function walks all irgs in interprocedural view.
108 * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
110 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
113 * Walks only over Block nodes in the graph.
115 * @param node - the start node
116 * @param pre - walker function, executed before the predecessor of a node are visited
117 * @param post - walker function, executed after the predecessor of a node are visited
118 * @param env - environment, passend to pre and post
120 * This function Walks only over Block nodes in the graph. Has it's own visited
121 * flag, so that it can be interleaved with the other walker.
122 * If a none block is passed, starts at the block this node belongs to.
123 * If end is passed also visites kept alive blocks. Does not use the link field.
125 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
128 * Walks only over reachable Block nodes in the graph.
130 * @param irg - the irg graph
131 * @param pre - walker function, executed before the predecessor of a node are visited
132 * @param post - walker function, executed after the predecessor of a node are visited
133 * @param env - environment, passend to pre and post
135 * Like irg_block_walk(), but walks over all reachable blocks in the
136 * ir graph, starting at the end block. Does not use the link field.
138 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
141 * Walks over all code in const_code_irg.
143 * @param pre - walker function, executed before the predecessor of a node are visited
144 * @param post - walker function, executed after the predecessor of a node are visited
145 * @param env - environment, passend to pre and post
147 * This function walks over all code in const_code_irg.
148 * Uses visited flag in const_code_irg. Does not use the link field.
150 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
152 # endif /* _IRGWALK_H_ */