Convert to doxygen comments
[libfirm] / ir / ir / irgwalk.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 * All rights reserved.
3 *
4 * Author: Boris Boesler
5 *
6 * traverse an ir graph
7 * - execute the pre function before recursion
8 * - execute the post function after recursion
9 *
10 * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
11 * graph before starting the walker.
12 */
13
14 /* $Id$ */
15
16 # ifndef _IRGWALK_H_
17 # define _IRGWALK_H_
18
19 # include "irnode.h"
20
21 /* type of callback function for ir_graph walk */
22 #ifndef _IRG_WALK_FUNC_TYPEDEF_
23 #define _IRG_WALK_FUNC_TYPEDEF_
24 /**
25  * The type of a walk function.
26  *
27  * @param node - the node that is just visited
28  * @param env  - an environment pointer passed by the walk functions
29  */
30 typedef void irg_walk_func(ir_node *node, void *env);
31 #endif
32
33 /** Allocates some necessary datastructures. */
34 void init_ip_walk(void);
35
36 /** Frees some necessary datastructures. */
37 void finish_ip_walk(void);
38
39 /**
40  * Walks over the ir graph.
41  *
42  * @param node - the start node
43  * @param pre  - walker function, executed before the predecessor of a node are visited
44  * @param post - walker function, executed after the predecessor of a node are visited
45  * @param env  - environment, passend to pre and post
46  *
47  * Walks over the ir graph, starting at the node given as first argument.
48  * Executes pre before visiting the predecessor of a node, post after.
49  * irg_walk uses the visited flag in irg and the nodes to determine visited
50  * nodes.  It executes inc_irg_visited(current_ir_graph) to generate a new
51  * flag.  It marks the node as visited before executing pre.
52  * The void* env can be used to pass status information between the
53  * pre and post functions.
54  */
55 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
56
57 /**
58  * Walks over all reachable nodes in the ir graph.
59  *
60  * @param irg  - the irg graph
61  * @param pre  - walker function, executed before the predecessor of a node are visited
62  * @param post - walker function, executed after the predecessor of a node are visited
63  * @param env  - environment, passend to pre and post
64  *
65  * Like irg_walk(), but walks over all reachable nodes in the ir
66  * graph, starting at the end operation. During the walk current_ir_graph
67  * is set to irg.
68  */
69 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
70
71 /**
72  * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
73  *
74  * @param pre  - walker function, executed before the predecessor of a node are visited
75  * @param post - walker function, executed after the predecessor of a node are visited
76  * @param env  - environment, passend to pre and post
77  *
78  * This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
79  * Sets current_ir_graph properly for each walk.  Conserves current
80  * current_ir_graph.  In interprocedural view nodes can be visited several
81  * times.
82  */
83 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
84
85 /**
86  * Walks all irgs in interprocedural view.
87  *
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
91  *
92  * This function walks all irgs in interprocedural view.
93  * Visits each node only once.Sets current_ir_graph properly.
94  */
95 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
96
97 /**
98  * Walks only over Block nodes in the graph.
99  *
100  * @param node - the start node
101  * @param pre  - walker function, executed before the predecessor of a node are visited
102  * @param post - walker function, executed after the predecessor of a node are visited
103  * @param env  - environment, passend to pre and post
104  *
105  * This function Walks only over Block nodes in the graph. Has it's own visited
106  * flag, so that it can be interleaved with the other walker.
107  * If a none block is passed, starts at the block this node belongs to.
108  * If end is passed also visites kept alive blocks.
109  */
110 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
111
112 /**
113  * Walks only over reachable Block nodes in the graph.
114  *
115  * @param irg  - the irg graph
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
119  *
120  * Like irg_block_walk(), but walks over all reachable blocks in the
121  * ir graph, starting at the end block.
122  */
123 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
124
125 /**
126  * Walks over all code in const_code_irg.
127  *
128  * @param pre  - walker function, executed before the predecessor of a node are visited
129  * @param post - walker function, executed after the predecessor of a node are visited
130  * @param env  - environment, passend to pre and post
131  *
132  * This function walks over all code in const_code_irg.
133  * Uses visited flag in const_code_irg.
134  */
135 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
136
137 # endif /* _IRGWALK_H_ */