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"
26 #ifndef _IR_EXTBB_TYPEDEF_
27 #define _IR_EXTBB_TYPEDEF_
28 typedef struct _ir_extblk ir_extblk;
31 /** Flags for extended basic block state. */
33 ir_extblk_info_none = 0, /**< No extended basic block information is constructed. Default. */
34 ir_extblk_info_valid = 1, /**< Extended basic block information is valid. */
35 ir_extblk_info_invalid = 2 /**< Extended basic block information is constructed but invalid. */
36 } irg_extblk_info_state;
38 /* type of callback function for ir_graph walk */
39 #ifndef _EXTBB_WALK_FUNC_TYPEDEF_
40 #define _EXTBB_WALK_FUNC_TYPEDEF_
42 * The type of a walk function. Does not use the link field.
44 * @param blk - the extended basic block that is just visited
45 * @param env - an environment pointer passed by the walk functions
47 typedef void extbb_walk_func(ir_extblk *blk, void *env);
51 * Checks whether a pointer points to a extended basic block.
52 * Intern version for libFirm.
54 int is_ir_extbb(const void *thing);
57 * Compute the extended basic blocks for a graph.
59 void compute_extbb(ir_graph *irg);
62 * Compute the extended basic blocks for a graph based on execution frequencies.
64 void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
67 * free all extended block info.
69 void free_extbb(ir_graph *irg);
72 * Return the extended block of a node.
74 * @param node the node
76 ir_extblk *get_nodes_extbb(ir_node *node);
79 * Gets the visited counter of an extended block.
81 * @param blk the extended basic block
83 unsigned long get_extbb_visited(const ir_extblk *blk);
86 * Sets the visited counter of an extended block.
88 * @param blk the extended basic block
90 void set_extbb_visited(ir_extblk *blk, unsigned long visited);
93 * Mark an extended block as visited in a graph.
94 * Uses the block visit flag.
96 * @param blk the extended basic block
98 void mark_extbb_visited(ir_extblk *blk);
101 * Returns non-zero if an extended was visited.
102 * Uses the block visit flag.
104 * @param blk the extended basic block
106 int extbb_visited(const ir_extblk *blk);
109 * Returns non-zero if an extended block was NOT visited.
110 * Uses the block visit flag.
112 * @param blk the extended basic block
114 int extbb_not_visited(const ir_extblk *blk);
117 * Returns the link field of an extended block.
119 * @param blk the extended basic block
121 void *get_extbb_link(const ir_extblk *blk);
124 * Sets the link field of an extended block.
126 * @param blk the extended basic block
127 * @param link the new link value
129 void set_extbb_link(ir_extblk *blk, void *link);
132 * Return the number of basic blocks of an extended block.
134 * @param blk the extended basic block
136 int get_extbb_n_blocks(const ir_extblk *blk);
139 * Return the i'th basic block of an extended block.
141 * @param blk the extended basic block
142 * @param pos the position
144 ir_node *get_extbb_block(ir_extblk *blk, int pos);
147 * Return the leader basic block of an extended block.
149 * @param blk the extended basic block
151 ir_node *get_extbb_leader(ir_extblk *blk);
154 * Return the node number of an extended block.
155 * Its the block number of the leader block
157 * @param blk the extended basic block
159 long get_extbb_node_nr(ir_extblk *blk);
162 * Walks only over Extended Basic Block nodes in the graph.
164 * @param blk - the start extended block node
165 * @param pre - walker function, executed before the predecessor of a node are visited
166 * @param post - walker function, executed after the predecessor of a node are visited
167 * @param env - environment, passed to pre and post
169 * This function Walks only over Block nodes in the graph. Has it's own visited
170 * flag, so that it can be interleaved with the other walker.
171 * If a none block is passed, starts at the block this node belongs to.
172 * If end is passed also visits kept alive blocks. Does not use the link field.
174 void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env);
177 * Walks only over reachable Extended Basic Block nodes in the graph.
178 * Ensures, that the extended block containing the End node is visited last
179 * and the block containing Start visited first (in post order).
181 * @param irg - the irg graph
182 * @param pre - walker function, executed before the predecessor of a block are visited
183 * @param post - walker function, executed after the predecessor of a block are visited
184 * @param env - environment, passed to pre and post
186 void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env);
188 #endif /* _IREXTBB_H_ */