is_ir_extbb() added
[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  * Checks whether a pointer points to a extended basic block.
51  * Intern version for libFirm.
52  */
53 int is_ir_extbb(const void *thing);
54
55 /**
56  * Compute the extended basic blocks for a graph
57  */
58 void compute_extbb(ir_graph *irg);
59
60 /**
61  * free all extended block info.
62  */
63 void free_extbb(ir_graph *irg);
64
65 /**
66  * Return the extended block of a node.
67  *
68  * @param blk  the extended basic block
69  */
70 ir_extblk *get_nodes_extbb(ir_node *node);
71
72 /**
73  * Gets the visited counter of an extended block.
74  *
75  * @param blk  the extended basic block
76  */
77 unsigned long get_extbb_visited(const ir_extblk *blk);
78
79 /**
80  * Sets the visited counter of an extended block.
81  *
82  * @param blk  the extended basic block
83  */
84 void set_extbb_visited(ir_extblk *blk, unsigned long visited);
85
86 /**
87  * Mark an extended block as visited in a graph.
88  * Uses the block visit flag.
89  *
90  * @param blk  the extended basic block
91  */
92 void mark_extbb_visited(ir_extblk *blk);
93
94 /**
95  * Returns non-zero if an extended was visited.
96  * Uses the block visit flag.
97  *
98  * @param blk  the extended basic block
99  */
100 int extbb_visited(const ir_extblk *blk);
101
102 /**
103  * Returns non-zero if an extended block was NOT visited.
104  * Uses the block visit flag.
105  *
106  * @param blk  the extended basic block
107  */
108 int extbb_not_visited(const ir_extblk *blk);
109
110 /**
111  * Returns the link field of an extended block.
112  *
113  * @param blk  the extended basic block
114  */
115 void *get_extbb_link(const ir_extblk *blk);
116
117 /**
118  * Sets the link field of an extended block.
119  *
120  * @param blk  the extended basic block
121  * @param link the new link value
122  */
123 void set_extbb_link(ir_extblk *blk, void *link);
124
125 /**
126  * Return the number of basic blocks of an extended block.
127  *
128  * @param blk  the extended basic block
129  */
130 int get_extbb_n_blocks(const ir_extblk *blk);
131
132 /**
133  * Return the i'th basic block of an extended block.
134  *
135  * @param blk  the extended basic block
136  * @param pos  the position
137  */
138 ir_node *get_extbb_block(ir_extblk *blk, int pos);
139
140 /**
141  * Return the leader basic block of an extended block.
142  *
143  * @param blk  the extended basic block
144  */
145 ir_node *get_extbb_leader(ir_extblk *blk);
146
147 /**
148  * Return the node number of an extended block.
149  * Its the block number of the leader block
150  *
151  * @param blk  the extended basic block
152  */
153 long get_extbb_node_nr(ir_extblk *blk);
154
155 /**
156  * Walks only over Extended Basic Block nodes in the graph.
157  *
158  * @param blk  - the start extended block node
159  * @param pre  - walker function, executed before the predecessor of a node are visited
160  * @param post - walker function, executed after the predecessor of a node are visited
161  * @param env  - environment, passed to pre and post
162  *
163  * This function Walks only over Block nodes in the graph. Has it's own visited
164  * flag, so that it can be interleaved with the other walker.
165  * If a none block is passed, starts at the block this node belongs to.
166  * If end is passed also visits kept alive blocks. Does not use the link field.
167  */
168 void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
169
170 /**
171  * Walks only over reachable Extended Basic Block nodes in the graph.
172  *
173  * @param irg  - the irg graph
174  * @param pre  - walker function, executed before the predecessor of a block are visited
175  * @param post - walker function, executed after the predecessor of a block are visited
176  * @param env  - environment, passed to pre and post
177  */
178 void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
179
180 #endif /* _IREXTBB_H_ */