properly mark symbols in the public API to be exported. This allows us to use -fvisib...
[libfirm] / include / libfirm / irextbb.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Extended basis block support.
23  * @author  Michael Beck
24  * @date    5.2005
25  * @version $Id$
26  */
27 #ifndef FIRM_ANA_IREXTBB_H
28 #define FIRM_ANA_IREXTBB_H
29
30 #include "firm_types.h"
31 #include "execfreq.h"
32 #include "begin.h"
33
34 /** Flags for extended basic block state. */
35 typedef enum {
36   ir_extblk_info_none    = 0,  /**< No extended basic block information is constructed. Default. */
37   ir_extblk_info_valid   = 1,  /**< Extended basic block information is valid. */
38   ir_extblk_info_invalid = 2   /**< Extended basic block information is constructed but invalid. */
39 } irg_extblk_info_state;
40
41 /* type of callback function for ir_graph walk */
42 #ifndef _EXTBB_WALK_FUNC_TYPEDEF_
43 #define _EXTBB_WALK_FUNC_TYPEDEF_
44 /**
45  * The type of a walk function.  Does not use the link field.
46  *
47  * @param blk  - the extended basic block that is just visited
48  * @param env  - an environment pointer passed by the walk functions
49  */
50 typedef void extbb_walk_func(ir_extblk *blk, void *env);
51 #endif
52
53 /**
54  * Checks whether a pointer points to a extended basic block.
55  * Intern version for libFirm.
56  */
57 FIRM_DLL int is_ir_extbb(const void *thing);
58
59 /**
60  * Compute the extended basic blocks for a graph.
61  */
62 FIRM_DLL void compute_extbb(ir_graph *irg);
63
64 /**
65  * Compute the extended basic blocks for a graph based on execution frequencies.
66  */
67 FIRM_DLL void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
68
69 /**
70  * free all extended block info.
71  */
72 FIRM_DLL void free_extbb(ir_graph *irg);
73
74 /**
75  * Return the extended block of a node.
76  *
77  * @param node  the node
78  */
79 FIRM_DLL ir_extblk *get_nodes_extbb(const ir_node *node);
80
81 /**
82  * Gets the visited counter of an extended block.
83  *
84  * @param blk  the extended basic block
85  */
86 FIRM_DLL ir_visited_t get_extbb_visited(const ir_extblk *blk);
87
88 /**
89  * Sets the visited counter of an extended block.
90  *
91  * @param blk      the extended basic block
92  * @param visited  new value for the visited counter
93  */
94 FIRM_DLL void set_extbb_visited(ir_extblk *blk, ir_visited_t visited);
95
96 /**
97  * Mark an extended block as visited in a graph.
98  * Uses the block visit flag.
99  *
100  * @param blk  the extended basic block
101  */
102 FIRM_DLL void mark_extbb_visited(ir_extblk *blk);
103
104 /**
105  * Returns non-zero if an extended was visited.
106  * Uses the block visit flag.
107  *
108  * @param blk  the extended basic block
109  */
110 FIRM_DLL int extbb_visited(const ir_extblk *blk);
111
112 /**
113  * Returns non-zero if an extended block was NOT visited.
114  * Uses the block visit flag.
115  *
116  * @param blk  the extended basic block
117  */
118 FIRM_DLL int extbb_not_visited(const ir_extblk *blk);
119
120 /**
121  * Returns the link field of an extended block.
122  *
123  * @param blk  the extended basic block
124  */
125 FIRM_DLL void *get_extbb_link(const ir_extblk *blk);
126
127 /**
128  * Sets the link field of an extended block.
129  *
130  * @param blk  the extended basic block
131  * @param link the new link value
132  */
133 FIRM_DLL void set_extbb_link(ir_extblk *blk, void *link);
134
135 /**
136  * Return the number of basic blocks of an extended block.
137  *
138  * @param blk  the extended basic block
139  */
140 FIRM_DLL int get_extbb_n_blocks(const ir_extblk *blk);
141
142 /**
143  * Return the i'th basic block of an extended block.
144  *
145  * @param blk  the extended basic block
146  * @param pos  the position
147  */
148 FIRM_DLL ir_node *get_extbb_block(const ir_extblk *blk, int pos);
149
150 /**
151  * Return the leader basic block of an extended block.
152  *
153  * @param blk  the extended basic block
154  */
155 FIRM_DLL ir_node *get_extbb_leader(const ir_extblk *blk);
156
157 /**
158  * Return the node number of an extended block.
159  * Its the block number of the leader block
160  *
161  * @param blk  the extended basic block
162  */
163 FIRM_DLL long get_extbb_node_nr(const ir_extblk *blk);
164
165 /**
166  * Walks only over Extended Basic Block nodes in the graph.
167  *
168  * @param blk  - the start extended block node
169  * @param pre  - walker function, executed before the predecessor of a node are
170  *               visited
171  * @param post - walker function, executed after the predecessor of a node are
172  *               visited
173  * @param env  - environment, passed to pre and post
174  *
175  * This function Walks only over Block nodes in the graph. Has it's own visited
176  * flag, so that it can be interleaved with the other walker.
177  * If a none block is passed, starts at the block this node belongs to.
178  * If end is passed also visits kept alive blocks. Does not use the link field.
179  */
180 FIRM_DLL void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre,
181                                 extbb_walk_func *post, void *env);
182
183 /**
184  * Walks only over reachable Extended Basic Block nodes in the graph.
185  * Ensures, that the extended block containing the End node is visited last
186  * and the block containing Start visited first (in post order).
187  *
188  * @param irg  - the irg graph
189  * @param pre  - walker function, executed before the predecessor of a block
190  *               are visited
191  * @param post - walker function, executed after the predecessor of a block
192  *               are visited
193  * @param env  - environment, passed to pre and post
194  */
195 FIRM_DLL void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre,
196                                       extbb_walk_func *post, void *env);
197
198 #include "end.h"
199
200 #endif