3 * File name: ir/ana/irextbb.h
4 * Purpose: Extended basis block support.
9 * Copyright: (c) 2002-2005 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 * Computes extended basic blocks.
18 * @author Michael Beck
23 #include "firm_types.h"
25 #ifndef _IR_EXTBB_TYPEDEF_
26 #define _IR_EXTBB_TYPEDEF_
27 typedef struct _ir_extblk ir_extblk;
30 /** Flags for extended basic block state. */
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;
37 /* type of callback function for ir_graph walk */
38 #ifndef _EXTBB_WALK_FUNC_TYPEDEF_
39 #define _EXTBB_WALK_FUNC_TYPEDEF_
41 * The type of a walk function. Does not use the link field.
43 * @param blk - the extended basic block that is just visited
44 * @param env - an environment pointer passed by the walk functions
46 typedef void extbb_walk_func(ir_extblk *blk, void *env);
50 * Checks whether a pointer points to a extended basic block.
51 * Intern version for libFirm.
53 int is_ir_extbb(const void *thing);
56 * Compute the extended basic blocks for a graph.
58 void compute_extbb(ir_graph *irg);
61 * free all extended block info.
63 void free_extbb(ir_graph *irg);
66 * Return the extended block of a node.
68 * @param blk the extended basic block
70 ir_extblk *get_nodes_extbb(ir_node *node);
73 * Gets the visited counter of an extended block.
75 * @param blk the extended basic block
77 unsigned long get_extbb_visited(const ir_extblk *blk);
80 * Sets the visited counter of an extended block.
82 * @param blk the extended basic block
84 void set_extbb_visited(ir_extblk *blk, unsigned long visited);
87 * Mark an extended block as visited in a graph.
88 * Uses the block visit flag.
90 * @param blk the extended basic block
92 void mark_extbb_visited(ir_extblk *blk);
95 * Returns non-zero if an extended was visited.
96 * Uses the block visit flag.
98 * @param blk the extended basic block
100 int extbb_visited(const ir_extblk *blk);
103 * Returns non-zero if an extended block was NOT visited.
104 * Uses the block visit flag.
106 * @param blk the extended basic block
108 int extbb_not_visited(const ir_extblk *blk);
111 * Returns the link field of an extended block.
113 * @param blk the extended basic block
115 void *get_extbb_link(const ir_extblk *blk);
118 * Sets the link field of an extended block.
120 * @param blk the extended basic block
121 * @param link the new link value
123 void set_extbb_link(ir_extblk *blk, void *link);
126 * Return the number of basic blocks of an extended block.
128 * @param blk the extended basic block
130 int get_extbb_n_blocks(const ir_extblk *blk);
133 * Return the i'th basic block of an extended block.
135 * @param blk the extended basic block
136 * @param pos the position
138 ir_node *get_extbb_block(ir_extblk *blk, int pos);
141 * Return the leader basic block of an extended block.
143 * @param blk the extended basic block
145 ir_node *get_extbb_leader(ir_extblk *blk);
148 * Return the node number of an extended block.
149 * Its the block number of the leader block
151 * @param blk the extended basic block
153 long get_extbb_node_nr(ir_extblk *blk);
156 * Walks only over Extended Basic Block nodes in the graph.
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
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.
168 void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
171 * Walks only over reachable Extended Basic Block nodes in the graph.
172 * Ensures, that the extended block containing the End node is visited last
173 * and the block containing Start visited first (in post order).
175 * @param irg - the irg graph
176 * @param pre - walker function, executed before the predecessor of a block are visited
177 * @param post - walker function, executed after the predecessor of a block are visited
178 * @param env - environment, passed to pre and post
180 void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
182 #endif /* _IREXTBB_H_ */