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 * Compute the extended basic blocks for a graph
52 void compute_extbb(ir_graph *irg);
55 * free all extended block info.
57 void free_extbb(ir_graph *irg);
60 * Return the extended block of a node.
62 * @param blk the extended basic block
64 ir_extblk *get_nodes_extbb(ir_node *node);
67 * Gets the visited counter of an extended block.
69 * @param blk the extended basic block
71 unsigned long get_extbb_visited(const ir_extblk *blk);
74 * Sets the visited counter of an extended block.
76 * @param blk the extended basic block
78 void set_extbb_visited(ir_extblk *blk, unsigned long visited);
81 * Mark an extended block as visited in a graph.
82 * Uses the block visit flag.
84 * @param blk the extended basic block
86 void mark_extbb_visited(ir_extblk *blk);
89 * Returns non-zero if an extended was visited.
90 * Uses the block visit flag.
92 * @param blk the extended basic block
94 int extbb_visited(const ir_extblk *blk);
97 * Returns non-zero if an extended block was NOT visited.
98 * Uses the block visit flag.
100 * @param blk the extended basic block
102 int extbb_not_visited(const ir_extblk *blk);
105 * Returns the link field of an extended block.
107 * @param blk the extended basic block
109 void *get_extbb_link(const ir_extblk *blk);
112 * Sets the link field of an extended block.
114 * @param blk the extended basic block
115 * @param link the new link value
117 void set_extbb_link(ir_extblk *blk, void *link);
120 * Return the number of basic blocks of an extended block.
122 * @param blk the extended basic block
124 int get_extbb_n_blocks(const ir_extblk *blk);
127 * Return the i'th basic block of an extended block.
129 * @param blk the extended basic block
130 * @param pos the position
132 ir_node *get_extbb_block(ir_extblk *blk, int pos);
135 * Return the leader basic block of an extended block.
137 * @param blk the extended basic block
139 ir_node *get_extbb_leader(ir_extblk *blk);
142 * Return the node number of an extended block.
143 * Its the block number of the leader block
145 * @param blk the extended basic block
147 long get_extbb_node_nr(ir_extblk *blk);
150 * Walks only over Extended Basic Block nodes in the graph.
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
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.
162 void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
165 * Walks only over reachable Extended Basic Block nodes in the graph.
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
172 void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
174 #endif /* _IREXTBB_H_ */