1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
8 * Traverse an ir graph.
10 * @author Boris Boesler
12 * Traverse an ir graph:
13 * - execute the pre function before recursion
14 * - execute the post function after recursion
16 * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
17 * graph before starting the walker.
27 /* type of callback function for ir_graph walk */
28 #ifndef _IRG_WALK_FUNC_TYPEDEF_
29 #define _IRG_WALK_FUNC_TYPEDEF_
31 * The type of a walk function. Does not use the link field.
33 * @param node - the node that is just visited
34 * @param env - an environment pointer passed by the walk functions
36 typedef void irg_walk_func(ir_node *node, void *env);
39 /** Allocates some necessary datastructures. */
40 void init_ip_walk(void);
42 /** Frees some necessary datastructures. */
43 void finish_ip_walk(void);
46 * Walks over the ir graph.
48 * @param node - the start node
49 * @param pre - walker function, executed before the predecessor of a node are visited
50 * @param post - walker function, executed after the predecessor of a node are visited
51 * @param env - environment, passend to pre and post
53 * Walks over the ir graph, starting at the node given as first argument.
54 * Executes pre before visiting the predecessor of a node, post after.
55 * irg_walk uses the visited flag in irg and the nodes to determine visited
56 * nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
57 * flag. It marks the node as visited before executing pre.
58 * The void* env can be used to pass status information between the
59 * pre and post functions. Does not use the link field.
61 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
64 * Walks over all reachable nodes in the ir graph.
66 * @param irg - the irg graph
67 * @param pre - walker function, executed before the predecessor of a node are visited
68 * @param post - walker function, executed after the predecessor of a node are visited
69 * @param env - environment, passend to pre and post
71 * Like irg_walk(), but walks over all reachable nodes in the ir
72 * graph, starting at the end operation. During the walk current_ir_graph
73 * is set to irg. Does not use the link field.
75 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
78 * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
80 * @param pre - walker function, executed before the predecessor of a node are visited
81 * @param post - walker function, executed after the predecessor of a node are visited
82 * @param env - environment, passend to pre and post
84 * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
85 * Sets current_ir_graph properly for each walk. Conserves current
86 * current_ir_graph. In interprocedural view nodes can be visited several
87 * times. Does not use the link field.
89 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
92 * Walks all irgs in interprocedural view.
94 * @param pre - walker function, executed before the predecessor of a node are visited
95 * @param post - walker function, executed after the predecessor of a node are visited
96 * @param env - environment, passend to pre and post
98 * This function walks all irgs in interprocedural view.
99 * Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
101 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
104 * Walks only over Block nodes in the graph.
106 * @param node - the start node
107 * @param pre - walker function, executed before the predecessor of a node are visited
108 * @param post - walker function, executed after the predecessor of a node are visited
109 * @param env - environment, passend to pre and post
111 * This function Walks only over Block nodes in the graph. Has it's own visited
112 * flag, so that it can be interleaved with the other walker.
113 * If a none block is passed, starts at the block this node belongs to.
114 * If end is passed also visites kept alive blocks. Does not use the link field.
116 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
119 * Walks only over reachable Block nodes in the graph.
121 * @param irg - the irg graph
122 * @param pre - walker function, executed before the predecessor of a node are visited
123 * @param post - walker function, executed after the predecessor of a node are visited
124 * @param env - environment, passend to pre and post
126 * Like irg_block_walk(), but walks over all reachable blocks in the
127 * ir graph, starting at the end block. Does not use the link field.
129 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
132 * Walks over all code in const_code_irg.
134 * @param pre - walker function, executed before the predecessor of a node are visited
135 * @param post - walker function, executed after the predecessor of a node are visited
136 * @param env - environment, passend to pre and post
138 * This function walks over all code in const_code_irg.
139 * Uses visited flag in const_code_irg. Does not use the link field.
141 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
143 # endif /* _IRGWALK_H_ */