X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fheights.c;h=e860a03a71206601b32d03b88c9a879ad988f959;hb=555593b0aebec433b871920acc2b0a869b072055;hp=4586fc8b4ef3eb5886484b5e01a81dac7a48ac91;hpb=f6b78c1b4c5885ac0c3e20ae0afca754cb3edbf9;p=libfirm diff --git a/ir/ana/heights.c b/ir/ana/heights.c index 4586fc8b4..e860a03a7 100644 --- a/ir/ana/heights.c +++ b/ir/ana/heights.c @@ -22,7 +22,6 @@ * @brief Compute heights of nodes inside basic blocks * @author Sebastian Hack * @date 19.04.2006 - * @version $Id$ */ #include "config.h" @@ -32,12 +31,12 @@ #include #include -#include "list.h" #include "irdump.h" #include "irgwalk.h" -#include "irtools.h" #include "irnodemap.h" #include "iredges_t.h" +#include "list.h" +#include "util.h" struct ir_heights_t { ir_nodemap data; @@ -54,16 +53,15 @@ typedef struct { static irn_height_t *maybe_get_height_data(const ir_heights_t *heights, const ir_node *node) { - irn_height_t *height = (irn_height_t*)ir_nodemap_get(&heights->data, node); + irn_height_t *height = ir_nodemap_get(irn_height_t, &heights->data, node); return height; } static irn_height_t *get_height_data(ir_heights_t *heights, const ir_node *node) { - irn_height_t *height = (irn_height_t*)ir_nodemap_get(&heights->data, node); + irn_height_t *height = ir_nodemap_get(irn_height_t, &heights->data, node); if (height == NULL) { - height = obstack_alloc(&heights->obst, sizeof(*height)); - memset(height, 0, sizeof(*height)); + height = OALLOCZ(&heights->obst, irn_height_t); ir_nodemap_insert(&heights->data, node, height); } return height; @@ -101,12 +99,12 @@ static bool search(ir_heights_t *h, const ir_node *curr, const ir_node *tgt) return false; /* Check, if we have already been here. Coming more often won't help :-) */ - h_curr = get_height_data(h, curr); + h_curr = maybe_get_height_data(h, curr); if (h_curr->visited >= h->visited) return false; /* If we are too deep into the DAG we won't find the target either. */ - h_tgt = get_height_data(h, tgt); + h_tgt = maybe_get_height_data(h, tgt); if (h_curr->height > h_tgt->height) return false; @@ -123,16 +121,12 @@ static bool search(ir_heights_t *h, const ir_node *curr, const ir_node *tgt) return false; } -/** - * Check, if one node can be reached from another one, according to data - * dependence. - */ int heights_reachable_in_block(ir_heights_t *h, const ir_node *n, const ir_node *m) { int res = 0; - irn_height_t *hn = get_height_data(h, n); - irn_height_t *hm = get_height_data(h, m); + irn_height_t *hn = maybe_get_height_data(h, n); + irn_height_t *hm = maybe_get_height_data(h, m); assert(get_nodes_block(n) == get_nodes_block(m)); assert(hn != NULL && hm != NULL); @@ -155,8 +149,6 @@ static unsigned compute_height(ir_heights_t *h, ir_node *irn, const ir_node *bl) { irn_height_t *ih = get_height_data(h, irn); - const ir_edge_t *edge; - /* bail out if we already visited that node. */ if (ih->visited >= h->visited) return ih->height; @@ -192,8 +184,7 @@ static unsigned compute_height(ir_heights_t *h, ir_node *irn, const ir_node *bl) static unsigned compute_heights_in_block(ir_node *bl, ir_heights_t *h) { - int max_height = -1; - const ir_edge_t *edge; + int max_height = -1; h->visited++; @@ -230,11 +221,10 @@ unsigned get_irn_height(const ir_heights_t *heights, const ir_node *irn) unsigned heights_recompute_block(ir_heights_t *h, ir_node *block) { ir_graph *irg = get_irn_irg(block); - const ir_edge_t *edge; - edges_assure(irg); + assure_edges(irg); - /* reset phase data for all nodes in the block */ + /* reset data for all nodes in the block */ foreach_out_edge(block, edge) { ir_node *irn = get_edge_src_irn(edge); irn_height_t *ih = get_height_data(h, irn); @@ -247,12 +237,12 @@ unsigned heights_recompute_block(ir_heights_t *h, ir_node *block) ir_heights_t *heights_new(ir_graph *irg) { - ir_heights_t *res = XMALLOC(ir_heights_t); + ir_heights_t *res = XMALLOCZ(ir_heights_t); ir_nodemap_init(&res->data, irg); obstack_init(&res->obst); res->dump_handle = dump_add_node_info_callback(height_dump_cb, res); - edges_assure(irg); + assure_edges(irg); irg_block_walk_graph(irg, compute_heights_in_block_walker, NULL, res); return res;