Fixed extbb construction (why it was damaged ?)
[libfirm] / ir / ana / irextbb.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/irextbb.h
4  * Purpose:     Extended basis block support.
5  * Author:      Michael Beck
6  * Modified by:
7  * Created:     5.2005
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2002-2005 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file irextbb.h
15  *
16  *  Computes extended basic blocks.
17  *
18  *  @author Michael Beck
19  */
20 #ifndef _IREXTBB_H_
21 #define _IREXTBB_H_
22
23 #include "firm_types.h"
24
25 #ifndef _IR_EXTBB_TYPEDEF_
26 #define _IR_EXTBB_TYPEDEF_
27 typedef struct _ir_extblk ir_extblk;
28 #endif
29
30 /** Flags for extended basic block state. */
31 typedef enum {
32   ir_extblk_info_none    = 0,  /**< No extended basic block information is constructed. Default. */
33   ir_extblk_info_valid   = 1,  /**< Extended basic block information is valid. */
34   ir_extblk_info_invalid = 2   /**< Extended basic block information is constructed but invalid. */
35 } irg_extblk_info_state;
36
37 /* type of callback function for ir_graph walk */
38 #ifndef _EXTBB_WALK_FUNC_TYPEDEF_
39 #define _EXTBB_WALK_FUNC_TYPEDEF_
40 /**
41  * The type of a walk function.  Does not use the link field.
42  *
43  * @param blk  - the extended basic block that is just visited
44  * @param env  - an environment pointer passed by the walk functions
45  */
46 typedef void extbb_walk_func(ir_extblk *blk, void *env);
47 #endif
48
49 /**
50  * Compute the extended basic blocks for a graph
51  */
52 void compute_extbb(ir_graph *irg);
53
54 /**
55  * free all extended block info.
56  */
57 void free_extbb(ir_graph *irg);
58
59 /**
60  * Return the extended block of a node.
61  *
62  * @param blk  the extended basic block
63  */
64 ir_extblk *get_nodes_extbb(ir_node *node);
65
66 /**
67  * Gets the visited counter of an extended block.
68  *
69  * @param blk  the extended basic block
70  */
71 unsigned long get_extbb_visited(const ir_extblk *blk);
72
73 /**
74  * Sets the visited counter of an extended block.
75  *
76  * @param blk  the extended basic block
77  */
78 void set_extbb_visited(ir_extblk *blk, unsigned long visited);
79
80 /**
81  * Mark an extended block as visited in a graph.
82  * Uses the block visit flag.
83  *
84  * @param blk  the extended basic block
85  */
86 void mark_extbb_visited(ir_extblk *blk);
87
88 /**
89  * Returns non-zero if an extended was visited.
90  * Uses the block visit flag.
91  *
92  * @param blk  the extended basic block
93  */
94 int extbb_visited(const ir_extblk *blk);
95
96 /**
97  * Returns non-zero if an extended block was NOT visited.
98  * Uses the block visit flag.
99  *
100  * @param blk  the extended basic block
101  */
102 int extbb_not_visited(const ir_extblk *blk);
103
104 /**
105  * Returns the link field of an extended block.
106  *
107  * @param blk  the extended basic block
108  */
109 void *get_extbb_link(const ir_extblk *blk);
110
111 /**
112  * Sets the link field of an extended block.
113  *
114  * @param blk  the extended basic block
115  * @param link the new link value
116  */
117 void set_extbb_link(ir_extblk *blk, void *link);
118
119 /**
120  * Return the number of basic blocks of an extended block.
121  *
122  * @param blk  the extended basic block
123  */
124 int get_extbb_n_blocks(const ir_extblk *blk);
125
126 /**
127  * Return the i'th basic block of an extended block.
128  *
129  * @param blk  the extended basic block
130  * @param pos  the position
131  */
132 ir_node *get_extbb_block(ir_extblk *blk, int pos);
133
134 /**
135  * Return the leader basic block of an extended block.
136  *
137  * @param blk  the extended basic block
138  */
139 ir_node *get_extbb_leader(ir_extblk *blk);
140
141 /**
142  * Return the node number of an extended block.
143  * Its the block number of the leader block
144  *
145  * @param blk  the extended basic block
146  */
147 long get_extbb_node_nr(ir_extblk *blk);
148
149 /**
150  * Walks only over Extended Basic Block nodes in the graph.
151  *
152  * @param blk  - the start extended block node
153  * @param pre  - walker function, executed before the predecessor of a node are visited
154  * @param post - walker function, executed after the predecessor of a node are visited
155  * @param env  - environment, passed to pre and post
156  *
157  * This function Walks only over Block nodes in the graph. Has it's own visited
158  * flag, so that it can be interleaved with the other walker.
159  * If a none block is passed, starts at the block this node belongs to.
160  * If end is passed also visits kept alive blocks. Does not use the link field.
161  */
162 void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
163
164 /**
165  * Walks only over reachable Extended Basic Block nodes in the graph.
166  *
167  * @param irg  - the irg graph
168  * @param pre  - walker function, executed before the predecessor of a block are visited
169  * @param post - walker function, executed after the predecessor of a block are visited
170  * @param env  - environment, passed to pre and post
171  */
172 void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
173
174 #endif /* _IREXTBB_H_ */