Added FuncCall op
[libfirm] / ir / ir / irgwalk.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irgwalk.h
4  * Purpose:
5  * Author:      Boris Boesler
6  * Modified by: Goetz Lindenmaier
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1999-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 /**
15  * @file irgwalk.h
16  *
17  * Traverse an ir graph.
18  *
19  * @author Boris Boesler
20  *
21  * Traverse an ir graph:
22  * - execute the pre function before recursion
23  * - execute the post function after recursion
24  *
25  * Uses current_ir_graph (from irgraph.h)!!! Set it to the proper
26  * graph before starting the walker.
27  */
28
29
30 # ifndef _IRGWALK_H_
31 # define _IRGWALK_H_
32
33 # include "irnode.h"
34
35 /* type of callback function for ir_graph walk */
36 #ifndef _IRG_WALK_FUNC_TYPEDEF_
37 #define _IRG_WALK_FUNC_TYPEDEF_
38 /**
39  * The type of a walk function.  Does not use the link field.
40  *
41  * @param node - the node that is just visited
42  * @param env  - an environment pointer passed by the walk functions
43  */
44 typedef void irg_walk_func(ir_node *node, void *env);
45 #endif
46
47 /** Allocates some necessary datastructures. */
48 void init_ip_walk(void);
49
50 /** Frees some necessary datastructures. */
51 void finish_ip_walk(void);
52
53 /**
54  * Walks over the ir graph.
55  *
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
60  *
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.
68  */
69 void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
70
71 /**
72  * Walks over all reachable nodes in the ir graph.
73  *
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
78  *
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.
83  */
84 void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
85
86 /**
87  * Executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
88  *
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
92  *
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.
97  */
98 void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
99
100 /**
101  * Walks all irgs in interprocedural view.
102  *
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
106  *
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.
109  */
110 void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
111
112 /**
113  * Walks only over Block nodes in the graph.
114  *
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
119  *
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.
124  */
125 void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env);
126
127 /**
128  * Walks only over reachable Block nodes in the graph.
129  *
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
134  *
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.
137  */
138 void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env);
139
140 /**
141  * Walks over all code in const_code_irg.
142  *
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
146  *
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.
149  */
150 void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env);
151
152 # endif /* _IRGWALK_H_ */