X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firgwalk_blk.c;h=e42c681f820619c936330feecf9978cf0ebb42bf;hb=ac1d48fe48c45e62769a1a4824fe5099e7a22aa6;hp=b5d25f9090b032346d1ddd91c0b39f4dd164d246;hpb=8cb8730614f09dc3a9966839b0d936f15e9a3412;p=libfirm diff --git a/ir/ir/irgwalk_blk.c b/ir/ir/irgwalk_blk.c index b5d25f909..e42c681f8 100644 --- a/ir/ir/irgwalk_blk.c +++ b/ir/ir/irgwalk_blk.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -21,7 +21,6 @@ * @file * @brief Blockwise walker implementation * @author Michael Beck - * @version $Id$ */ #include "config.h" @@ -32,6 +31,7 @@ #include "irhooks.h" #include "array.h" #include "hashptr.h" +#include "ircons.h" #define _get_walk_arity(env, node) \ ((env)->follow_deps ? get_irn_ins_or_deps((node)) : get_irn_arity((node))) @@ -64,8 +64,8 @@ typedef struct block_entry_t { */ static int addr_cmp(const void *elt, const void *key) { - const block_entry_t *e1 = elt; - const block_entry_t *e2 = key; + const block_entry_t *e1 = (const block_entry_t*)elt; + const block_entry_t *e2 = (const block_entry_t*)key; return e1->block != e2->block; } @@ -79,7 +79,7 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx) block_entry_t *elem; key.block = block; - elem = pset_find(ctx->blk_map, &key, HASH_PTR(block)); + elem = (block_entry_t*)pset_find(ctx->blk_map, &key, hash_ptr(block)); if (elem) return elem; @@ -91,7 +91,7 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx) elem->cf_list = NEW_ARR_F(ir_node *, 0); elem->entry_list = NEW_ARR_F(ir_node *, 0); - return pset_insert(ctx->blk_map, elem, HASH_PTR(block)); + return (block_entry_t*)pset_insert(ctx->blk_map, elem, hash_ptr(block)); } /** @@ -99,20 +99,20 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx) */ static void traverse_block_pre(ir_node *block, block_entry_t *entry, irg_walk_func *pre, void *env) { - int j; + size_t j; - for (j = ARR_LEN(entry->cf_list) - 1; j >= 0; --j) { - ir_node *node = entry->cf_list[j]; + for (j = ARR_LEN(entry->cf_list); j > 0;) { + ir_node *node = entry->cf_list[--j]; pre(node, env); } - for (j = ARR_LEN(entry->df_list) - 1; j >= 0; --j) { - ir_node *node = entry->df_list[j]; + for (j = ARR_LEN(entry->df_list); j > 0;) { + ir_node *node = entry->df_list[--j]; pre(node, env); } - for (j = ARR_LEN(entry->phi_list) - 1; j >= 0; --j) { - ir_node *node = entry->phi_list[j]; + for (j = ARR_LEN(entry->phi_list); j > 0;) { + ir_node *node = entry->phi_list[--j]; pre(node, env); } @@ -125,7 +125,7 @@ static void traverse_block_pre(ir_node *block, block_entry_t *entry, irg_walk_fu static void traverse_block_post(ir_node *block, block_entry_t *entry, irg_walk_func *post, void *env) { - int j, n; + size_t j, n; post(block, env); @@ -150,10 +150,10 @@ static void traverse_block_post(ir_node *block, block_entry_t *entry, */ static void traverse_pre(blk_collect_data_t *blks, irg_walk_func *pre, void *env) { - int i; + size_t i; - for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) { - ir_node *block = blks->blk_list[i]; + for (i = ARR_LEN(blks->blk_list); i > 0;) { + ir_node *block = blks->blk_list[--i]; block_entry_t *entry = block_find_entry(block, blks); traverse_block_pre(block, entry, pre, env); @@ -170,7 +170,7 @@ static void traverse_pre(blk_collect_data_t *blks, irg_walk_func *pre, void *env */ static void traverse_post(blk_collect_data_t *blks, irg_walk_func *post, void *env) { - int i, k; + size_t i, k; for (i = 0, k = ARR_LEN(blks->blk_list); i < k; ++i) { ir_node *block = blks->blk_list[i]; @@ -190,10 +190,10 @@ static void traverse_post(blk_collect_data_t *blks, irg_walk_func *post, void *e */ static void traverse_both(blk_collect_data_t *blks, irg_walk_func *pre, irg_walk_func *post, void *env) { - int i; + size_t i; - for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) { - ir_node *block = blks->blk_list[i]; + for (i = ARR_LEN(blks->blk_list); i > 0;) { + ir_node *block = blks->blk_list[--i]; block_entry_t *entry = block_find_entry(block, blks); traverse_block_pre(block, entry, pre, env); @@ -225,7 +225,7 @@ typedef struct dom_traversal_t { */ static void dom_block_visit_pre(ir_node *block, void *env) { - dom_traversal_t *ctx = env; + dom_traversal_t *ctx = (dom_traversal_t*)env; block_entry_t *entry = block_find_entry(block, ctx->blks); traverse_block_pre(block, entry, ctx->pre, ctx->env); @@ -236,7 +236,7 @@ static void dom_block_visit_pre(ir_node *block, void *env) */ static void dom_block_visit_post(ir_node *block, void *env) { - dom_traversal_t *ctx = env; + dom_traversal_t *ctx = (dom_traversal_t*)env; block_entry_t *entry = block_find_entry(block, ctx->blks); traverse_block_post(block, entry, ctx->post, ctx->env); @@ -247,7 +247,7 @@ static void dom_block_visit_post(ir_node *block, void *env) */ static void dom_block_visit_both(ir_node *block, void *env) { - dom_traversal_t *ctx = env; + dom_traversal_t *ctx = (dom_traversal_t*)env; block_entry_t *entry = block_find_entry(block, ctx->blks); traverse_block_pre(block, entry, ctx->pre, ctx->env); @@ -267,11 +267,11 @@ static void traverse_dom_blocks_top_down(blk_collect_data_t* blks, irg_walk_func ctx.env = env; if (pre != NULL && post != NULL) - dom_tree_walk_irg(current_ir_graph, dom_block_visit_both, NULL, &ctx); + dom_tree_walk_irg(current_ir_graph, dom_block_visit_both, NULL, &ctx); else if (pre != NULL) - dom_tree_walk_irg(current_ir_graph, dom_block_visit_pre, NULL, &ctx); + dom_tree_walk_irg(current_ir_graph, dom_block_visit_pre, NULL, &ctx); else if (post != NULL) - dom_tree_walk_irg(current_ir_graph, dom_block_visit_post, NULL, &ctx); + dom_tree_walk_irg(current_ir_graph, dom_block_visit_post, NULL, &ctx); } /** @@ -389,18 +389,18 @@ static void collect_blks_lists(ir_node *node, ir_node *block, */ static void collect_lists(blk_collect_data_t *env) { - int i, j; + size_t i, j; ir_node *block, *node; block_entry_t *entry; inc_irg_visited(current_ir_graph); - for (i = ARR_LEN(env->blk_list) - 1; i >= 0; --i) { - block = env->blk_list[i]; + for (i = ARR_LEN(env->blk_list); i > 0;) { + block = env->blk_list[--i]; entry = block_find_entry(block, env); - for (j = ARR_LEN(entry->entry_list) - 1; j >= 0; --j) { - node = entry->entry_list[j]; + for (j = ARR_LEN(entry->entry_list); j > 0;) { + node = entry->entry_list[--j]; /* a entry might already be visited due to Phi loops */ if (node->visited < current_ir_graph->visited) @@ -410,7 +410,7 @@ static void collect_lists(blk_collect_data_t *env) } /** - * Intraprozedural graph walker over blocks. + * Intra procedural graph walker over blocks. */ static void do_irg_walk_blk(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env, unsigned follow_deps,