X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Firextbb.c;h=34fd81cf227d38c6d03eb28a8a1d7251e314cde5;hb=c8e1cf6a41fa2077058cce740783ab78990ac0ab;hp=fe99ffcde40a83b17608712b0a65231aa8306287;hpb=d935aa267d00966c360931d2f0f43008030c0592;p=libfirm diff --git a/ir/ana/irextbb.c b/ir/ana/irextbb.c index fe99ffcde..34fd81cf2 100644 --- a/ir/ana/irextbb.c +++ b/ir/ana/irextbb.c @@ -24,9 +24,7 @@ * @date 5.2005 * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include "irextbb_t.h" #include "irgwalk.h" @@ -37,21 +35,26 @@ #include "xmalloc.h" #include "irprintf.h" -typedef struct _env { +/** + * Environment for extbb construction. + */ +typedef struct env { struct obstack *obst; /**< the obstack where allocations took place */ ir_extblk *head; /**< head of the list of all extended blocks */ ir_node *start_block; /**< the start block of the current graph */ } env_t; -int (is_ir_extbb)(const void *thing) { +int (is_ir_extbb)(const void *thing) +{ return _is_ir_extbb(thing); } /** * allocate a new extended block header. */ -static void allocate_extblk(ir_node *block, env_t *env) { - ir_extblk *extblk = obstack_alloc(env->obst, sizeof(*extblk)); +static void allocate_extblk(ir_node *block, env_t *env) +{ + ir_extblk *extblk = OALLOC(env->obst, ir_extblk); extblk->kind = k_ir_extblk; extblk->visited = 1; @@ -67,7 +70,8 @@ static void allocate_extblk(ir_node *block, env_t *env) { * Returns the number of block successors. * we are interested only in 1, 2 and >2. */ -static int get_block_n_succs(ir_node *block) { +static int get_block_n_succs(ir_node *block) +{ if (edges_activated(current_ir_graph)) { const ir_edge_t *edge; @@ -86,7 +90,8 @@ static int get_block_n_succs(ir_node *block) { /** * Pre block-walker. Calculates the extended block info. */ -static void pre_walk_calc_extbb(ir_node *block, void *ctx) { +static void pre_walk_calc_extbb(ir_node *block, void *ctx) +{ int n = get_Block_n_cfgpreds(block); env_t *env = ctx; @@ -175,7 +180,7 @@ static void post_walk_calc_extbb(ir_node *block, void *ctx) /* replace all sentinels by the extbb info */ prev = block; list = NULL; - while (1) { + for (;;) { if (get_Block_extbb(prev) != sentinel) break; set_irn_link(prev, list); @@ -196,7 +201,8 @@ static void post_walk_calc_extbb(ir_node *block, void *ctx) /* * Compute the extended basic blocks for a graph */ -void compute_extbb(ir_graph *irg) { +void compute_extbb(ir_graph *irg) +{ env_t env; ir_extblk *extbb, *next; @@ -264,7 +270,8 @@ void compute_extbb(ir_graph *irg) { } /* free all extended block info. */ -void free_extbb(ir_graph *irg) { +void free_extbb(ir_graph *irg) +{ if (irg->extbb_obst) { obstack_free(irg->extbb_obst, NULL); xfree(irg->extbb_obst); @@ -274,67 +281,80 @@ void free_extbb(ir_graph *irg) { } /* Return the extended block of a node. */ -ir_extblk *get_nodes_extbb(ir_node *node) { - ir_node *block = is_Block(node) ? node : get_irn_n(node, -1); +ir_extblk *get_nodes_extbb(const ir_node *node) +{ + const ir_node *block = is_Block(node) ? node : get_nodes_block(node); return get_Block_extbb(block); } /* Gets the visited counter of an extended block. */ -ir_visited_t (get_extbb_visited)(const ir_extblk *blk) { +ir_visited_t (get_extbb_visited)(const ir_extblk *blk) +{ return _get_extbb_visited(blk); } /* Sets the visited counter of an extended block. */ -void (set_extbb_visited)(ir_extblk *blk, ir_visited_t visited) { +void (set_extbb_visited)(ir_extblk *blk, ir_visited_t visited) +{ _set_extbb_visited(blk, visited); } /* Mark an extended block as visited in a graph. */ -void (mark_extbb_visited)(ir_extblk *blk) { +void (mark_extbb_visited)(ir_extblk *blk) +{ _mark_extbb_visited(blk); } /* Returns non-zero if an extended was visited. */ -int (extbb_visited)(const ir_extblk *blk) { +int (extbb_visited)(const ir_extblk *blk) +{ return _extbb_visited(blk); } /* Returns non-zero if an extended block was NOT visited. */ -int (extbb_not_visited)(const ir_extblk *blk) { +int (extbb_not_visited)(const ir_extblk *blk) +{ return _extbb_not_visited(blk); } /* Returns the link field of an extended block. */ -void *(get_extbb_link)(const ir_extblk *blk) { +void *(get_extbb_link)(const ir_extblk *blk) +{ return _get_extbb_link(blk); } /* Sets the link field of an extended block. */ -void (set_extbb_link)(ir_extblk *blk, void *link) { +void (set_extbb_link)(ir_extblk *blk, void *link) +{ _set_extbb_link(blk, link); } /* Return the number of basic blocks of an extended block */ -int (get_extbb_n_blocks)(const ir_extblk *blk) { +int (get_extbb_n_blocks)(const ir_extblk *blk) +{ return _get_extbb_n_blocks(blk); } /* Return the i'th basic block of an extended block */ -ir_node *(get_extbb_block)(ir_extblk *blk, int pos) { +ir_node *(get_extbb_block)(const ir_extblk *blk, int pos) +{ return _get_extbb_block(blk, pos); } /* Return the leader basis block of an extended block. */ -ir_node *(get_extbb_leader)(ir_extblk *blk) { +ir_node *(get_extbb_leader)(const ir_extblk *blk) +{ return _get_extbb_leader(blk); } /* Return the node number of an extended block. */ -long get_extbb_node_nr(ir_extblk *blk) { +long get_extbb_node_nr(const ir_extblk *blk) +{ return get_irn_node_nr(get_extbb_leader(blk)); } -static void irg_extblock_walk_2(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env) { +static void irg_extblock_walk_2(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env) +{ int i; ir_node *node; @@ -362,7 +382,8 @@ static void irg_extblock_walk_2(ir_extblk *blk, extbb_walk_func *pre, extbb_walk /* walks only over extended Block nodes in the graph. Has it's own visited flag, so that it can be interleaved with the other walker. */ -void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env) { +void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env) +{ ir_node *pred, *start_bl = get_irg_start_block(current_ir_graph); ir_extblk *start_blk = get_Block_extbb(start_bl); int i; @@ -400,7 +421,8 @@ void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *po } /* Walks only over reachable Extended Basic Block nodes in the graph. */ -void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env) { +void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env) +{ ir_node *endbl = get_irg_end_block(irg); ir_extblk *blk = get_Block_extbb(endbl); ir_graph *rem = current_ir_graph;