Commit 8c580eca authored by Michael Beck's avatar Michael Beck
Browse files

- indentation fixed

[r22538]
parent ca8494f9
...@@ -44,31 +44,31 @@ ...@@ -44,31 +44,31 @@
* Metadata for block walker * Metadata for block walker
*/ */
typedef struct _blk_collect_data_t { typedef struct _blk_collect_data_t {
struct obstack obst; /**< obstack to allocate objects on */ struct obstack obst; /**< obstack to allocate objects on */
pset *blk_map; /**< Hash map: Block -> List */ pset *blk_map; /**< Hash map: Block -> List */
ir_node **blk_list; /**< the Block list */ ir_node **blk_list; /**< the Block list */
unsigned follow_deps : 1; /**< follow dependency edges */ unsigned follow_deps : 1; /**< follow dependency edges */
} blk_collect_data_t; } blk_collect_data_t;
/** /**
* An entry for a block in the blk_map * An entry for a block in the blk_map
*/ */
typedef struct _block_entry_t { typedef struct _block_entry_t {
ir_node *block; /**< the block */ ir_node *block; /**< the block */
ir_node **phi_list; /**< the list of Phi instruction */ ir_node **phi_list; /**< the list of Phi instruction */
ir_node **df_list; /**< the list of data flow instruction */ ir_node **df_list; /**< the list of data flow instruction */
ir_node **cf_list; /**< the list of control flow instructions */ ir_node **cf_list; /**< the list of control flow instructions */
ir_node **entry_list; /**< list of all block entries */ ir_node **entry_list; /**< list of all block entries */
} block_entry_t; } block_entry_t;
/** /**
* compare two block_entries * compare two block_entries
*/ */
static int addr_cmp(const void *elt, const void *key) { static int addr_cmp(const void *elt, const void *key) {
const block_entry_t *e1 = elt; const block_entry_t *e1 = elt;
const block_entry_t *e2 = key; const block_entry_t *e2 = key;
return e1->block != e2->block; return e1->block != e2->block;
} }
/** /**
...@@ -76,23 +76,23 @@ static int addr_cmp(const void *elt, const void *key) { ...@@ -76,23 +76,23 @@ static int addr_cmp(const void *elt, const void *key) {
*/ */
static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx) static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx)
{ {
block_entry_t key; block_entry_t key;
block_entry_t *elem; block_entry_t *elem;
key.block = block; key.block = block;
elem = pset_find(ctx->blk_map, &key, HASH_PTR(block)); elem = pset_find(ctx->blk_map, &key, HASH_PTR(block));
if (elem) if (elem)
return elem; return elem;
elem = obstack_alloc(&ctx->obst, sizeof(*elem)); elem = obstack_alloc(&ctx->obst, sizeof(*elem));
elem->block = block; elem->block = block;
elem->phi_list = NEW_ARR_F(ir_node *, 0); elem->phi_list = NEW_ARR_F(ir_node *, 0);
elem->df_list = NEW_ARR_F(ir_node *, 0); elem->df_list = NEW_ARR_F(ir_node *, 0);
elem->cf_list = NEW_ARR_F(ir_node *, 0); elem->cf_list = NEW_ARR_F(ir_node *, 0);
elem->entry_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 pset_insert(ctx->blk_map, elem, HASH_PTR(block));
} }
/** /**
...@@ -100,34 +100,34 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx) ...@@ -100,34 +100,34 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx)
*/ */
static void traverse_pre(blk_collect_data_t* blks, irg_walk_func *pre, void *env) static void traverse_pre(blk_collect_data_t* blks, irg_walk_func *pre, void *env)
{ {
int i, j; int i, j;
for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) { for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) {
ir_node *block = blks->blk_list[i]; ir_node *block = blks->blk_list[i];
block_entry_t *entry = block_find_entry(block, blks); block_entry_t *entry = block_find_entry(block, blks);
for (j = ARR_LEN(entry->cf_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->cf_list) - 1; j >= 0; --j) {
ir_node *node = entry->cf_list[j]; ir_node *node = entry->cf_list[j];
pre(node, env); pre(node, env);
} }
for (j = ARR_LEN(entry->df_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->df_list) - 1; j >= 0; --j) {
ir_node *node = entry->df_list[j]; ir_node *node = entry->df_list[j];
pre(node, env); pre(node, env);
} }
for (j = ARR_LEN(entry->phi_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->phi_list) - 1; j >= 0; --j) {
ir_node *node = entry->phi_list[j]; ir_node *node = entry->phi_list[j];
pre(node, env); pre(node, env);
} }
pre(block, env); pre(block, env);
DEL_ARR_F(entry->entry_list); DEL_ARR_F(entry->entry_list);
DEL_ARR_F(entry->phi_list); DEL_ARR_F(entry->phi_list);
DEL_ARR_F(entry->df_list); DEL_ARR_F(entry->df_list);
DEL_ARR_F(entry->cf_list); DEL_ARR_F(entry->cf_list);
} }
} }
/** /**
...@@ -135,34 +135,34 @@ static void traverse_pre(blk_collect_data_t* blks, irg_walk_func *pre, void *env ...@@ -135,34 +135,34 @@ 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) static void traverse_post(blk_collect_data_t* blks, irg_walk_func *post, void *env)
{ {
int i, j; int i, j;
for (i = 0; i < ARR_LEN(blks->blk_list); ++i) { for (i = 0; i < ARR_LEN(blks->blk_list); ++i) {
ir_node *block = blks->blk_list[i]; ir_node *block = blks->blk_list[i];
block_entry_t *entry = block_find_entry(block, blks); block_entry_t *entry = block_find_entry(block, blks);
post(block, env); post(block, env);
for (j = 0; j < ARR_LEN(entry->phi_list); ++j) { for (j = 0; j < ARR_LEN(entry->phi_list); ++j) {
ir_node *node = entry->phi_list[j]; ir_node *node = entry->phi_list[j];
post(node, env); post(node, env);
} }
for (j = 0; j < ARR_LEN(entry->df_list); ++j) { for (j = 0; j < ARR_LEN(entry->df_list); ++j) {
ir_node *node = entry->df_list[j]; ir_node *node = entry->df_list[j];
post(node, env); post(node, env);
} }
for (j = 0; j < ARR_LEN(entry->cf_list); ++j) { for (j = 0; j < ARR_LEN(entry->cf_list); ++j) {
ir_node *node = entry->cf_list[j]; ir_node *node = entry->cf_list[j];
post(node, env); post(node, env);
} }
DEL_ARR_F(entry->entry_list); DEL_ARR_F(entry->entry_list);
DEL_ARR_F(entry->phi_list); DEL_ARR_F(entry->phi_list);
DEL_ARR_F(entry->df_list); DEL_ARR_F(entry->df_list);
DEL_ARR_F(entry->cf_list); DEL_ARR_F(entry->cf_list);
} }
} }
/** /**
...@@ -170,112 +170,109 @@ static void traverse_post(blk_collect_data_t* blks, irg_walk_func *post, void *e ...@@ -170,112 +170,109 @@ 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) static void traverse_both(blk_collect_data_t* blks, irg_walk_func *pre, irg_walk_func *post, void *env)
{ {
int i, j; int i, j;
for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) { for (i = ARR_LEN(blks->blk_list) - 1; i >= 0; --i) {
ir_node *block = blks->blk_list[i]; ir_node *block = blks->blk_list[i];
block_entry_t *entry = block_find_entry(block, blks); block_entry_t *entry = block_find_entry(block, blks);
for (j = ARR_LEN(entry->cf_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->cf_list) - 1; j >= 0; --j) {
ir_node *node = entry->cf_list[j]; ir_node *node = entry->cf_list[j];
pre(node, env); pre(node, env);
} }
for (j = ARR_LEN(entry->df_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->df_list) - 1; j >= 0; --j) {
ir_node *node = entry->df_list[j]; ir_node *node = entry->df_list[j];
pre(node, env); pre(node, env);
} }
for (j = ARR_LEN(entry->phi_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->phi_list) - 1; j >= 0; --j) {
ir_node *node = entry->phi_list[j]; ir_node *node = entry->phi_list[j];
pre(node, env); pre(node, env);
} }
pre(block, env); pre(block, env);
} }
/* second step */ /* second step */
traverse_post(blks, post, env); traverse_post(blks, post, env);
} }
/** /**
* Do the traversal * Do the traversal
*/ */
static void traverse(blk_collect_data_t* blks, irg_walk_func *pre, irg_walk_func *post, void *env) static void traverse(blk_collect_data_t* blks, irg_walk_func *pre, irg_walk_func *post, void *env)
{ {
if (!post) traverse_pre (blks, pre, env); if (!post) traverse_pre (blks, pre, env);
else if (!pre) traverse_post(blks, post, env); else if (!pre) traverse_post(blks, post, env);
else traverse_both(blks, pre, post, env); else traverse_both(blks, pre, post, env);
} }
/** /**
* walks over the graph and collects all blocks and all block entries * walks over the graph and collects all blocks and all block entries
*/ */
static void collect_walk(ir_node *node, blk_collect_data_t *env) static void collect_walk(ir_node *node, blk_collect_data_t *env)
{ {
int i, is_phi; int i, is_phi;
block_entry_t *entry; block_entry_t *entry;
ir_node *block; ir_node *block;
mark_irn_visited(node); mark_irn_visited(node);
if (node->op == op_Block) { if (node->op == op_Block) {
/* predecessors of a block are control flow nodes */ /* predecessors of a block are control flow nodes */
for (i = _get_walk_arity(env, node) - 1; i >= 0; --i) { for (i = _get_walk_arity(env, node) - 1; i >= 0; --i) {
ir_node *pred = _get_walk_irn_n(env, node, i); ir_node *pred = _get_walk_irn_n(env, node, i);
ir_node *blk = get_nodes_block(pred); ir_node *blk = get_nodes_block(pred);
if (!irn_visited(pred)) { if (!irn_visited(pred)) {
collect_walk(pred, env); collect_walk(pred, env);
/* control flow predecessors are always block inputs */ /* control flow predecessors are always block inputs */
entry = block_find_entry(blk, env); entry = block_find_entry(blk, env);
ARR_APP1(ir_node *, entry->entry_list, pred); ARR_APP1(ir_node *, entry->entry_list, pred);
} }
} }
/* it's a block, put it into the block list */ /* it's a block, put it into the block list */
if (node == get_irg_end_block(current_ir_graph)) { if (node == get_irg_end_block(current_ir_graph)) {
/* Put the end block always last. If we don't do it here, /* Put the end block always last. If we don't do it here,
* it might be placed elsewhere if the graph contains * it might be placed elsewhere if the graph contains
* endless loops. * endless loops.
*/ */
} } else {
else { ARR_APP1(ir_node *, env->blk_list, node);
ARR_APP1(ir_node *, env->blk_list, node); }
} }
} else {
else { block = get_nodes_block(node);
block = get_nodes_block(node);
if (!irn_visited(block))
if (!irn_visited(block)) collect_walk(block, env);
collect_walk(block, env);
is_phi = is_Phi(node);
is_phi = is_Phi(node); for (i = _get_walk_arity(env, node) - 1; i >= 0; --i) {
for (i = _get_walk_arity(env, node) - 1; i >= 0; --i) { ir_node *pred = _get_walk_irn_n(env, node, i);
ir_node *pred = _get_walk_irn_n(env, node, i);
if (!irn_visited(pred)) {
if (!irn_visited(pred)) { collect_walk(pred, env);
collect_walk(pred, env);
/* BEWARE: predecessors of End nodes might be blocks */
/* BEWARE: predecessors of End nodes might be blocks */ if (is_no_Block(pred)) {
if (is_no_Block(pred)) { ir_node *blk = get_nodes_block(pred);
ir_node *blk = get_nodes_block(pred);
/*
/* * Note that Phi predecessors are always block entries
* Note that Phi predecessors are always block entries * because Phi edges are always "outside" a block
* because Phi edges are always "outside" a block */
*/ if (block != blk || is_phi) {
if (block != blk || is_phi) { entry = block_find_entry(blk, env);
entry = block_find_entry(blk, env); ARR_APP1(ir_node *, entry->entry_list, pred);
ARR_APP1(ir_node *, entry->entry_list, pred); }
} }
} }
} }
} }
}
} }
/** /**
...@@ -285,42 +282,40 @@ static void collect_walk(ir_node *node, blk_collect_data_t *env) ...@@ -285,42 +282,40 @@ static void collect_walk(ir_node *node, blk_collect_data_t *env)
static void collect_blks_lists(ir_node *node, ir_node *block, static void collect_blks_lists(ir_node *node, ir_node *block,
block_entry_t *entry, blk_collect_data_t *env) block_entry_t *entry, blk_collect_data_t *env)
{ {
int i; int i;
mark_irn_visited(node); mark_irn_visited(node);
/* /*
* Do not descent into Phi predecessors, these are always * Do not descent into Phi predecessors, these are always
* outside the current block because Phi edges are always * outside the current block because Phi edges are always
* "outside". * "outside".
*/ */
if (! is_Phi(node)) { if (! is_Phi(node)) {
for (i = _get_walk_arity(env, node) - 1; i >= 0; --i) { for (i = _get_walk_arity(env, node) - 1; i >= 0; --i) {
ir_node *pred = _get_walk_irn_n(env, node, i); ir_node *pred = _get_walk_irn_n(env, node, i);
/* BEWARE: predecessors of End nodes might be blocks */ /* BEWARE: predecessors of End nodes might be blocks */
if (is_no_Block(pred)) { if (is_no_Block(pred)) {
ir_node *blk = get_nodes_block(pred); ir_node *blk = get_nodes_block(pred);
if (!irn_visited(pred)) { if (!irn_visited(pred)) {
if (block != blk) if (block != blk)
continue; continue;
collect_blks_lists(pred, block, entry, env); collect_blks_lists(pred, block, entry, env);
} }
} }
} }
} } else {
else { ARR_APP1(ir_node *, entry->phi_list, node);
ARR_APP1(ir_node *, entry->phi_list, node); return;
return; }
}
if (get_irn_mode(node) == mode_X) {
if (get_irn_mode(node) == mode_X) { ARR_APP1(ir_node *, entry->cf_list, node);
ARR_APP1(ir_node *, entry->cf_list, node); } else {
} ARR_APP1(ir_node *, entry->df_list, node);
else { }
ARR_APP1(ir_node *, entry->df_list, node);
}
} }
/** /**
...@@ -328,24 +323,24 @@ static void collect_blks_lists(ir_node *node, ir_node *block, ...@@ -328,24 +323,24 @@ static void collect_blks_lists(ir_node *node, ir_node *block,
*/ */
static void collect_lists(blk_collect_data_t *env) static void collect_lists(blk_collect_data_t *env)
{ {
int i, j; int i, j;
ir_node *block, *node; ir_node *block, *node;
block_entry_t *entry; block_entry_t *entry;
inc_irg_visited(current_ir_graph); inc_irg_visited(current_ir_graph);
for (i = ARR_LEN(env->blk_list) - 1; i >= 0; --i) { for (i = ARR_LEN(env->blk_list) - 1; i >= 0; --i) {
block = env->blk_list[i]; block = env->blk_list[i];
entry = block_find_entry(block, env); entry = block_find_entry(block, env);
for (j = ARR_LEN(entry->entry_list) - 1; j >= 0; --j) { for (j = ARR_LEN(entry->entry_list) - 1; j >= 0; --j) {
node = entry->entry_list[j]; node = entry->entry_list[j];
/* a entry might already be visited due to Phi loops */ /* a entry might already be visited due to Phi loops */
if (node->visited < current_ir_graph->visited) if (node->visited < current_ir_graph->visited)
collect_blks_lists(node, block, entry, env); collect_blks_lists(node, block, entry, env);
} }
} }
} }
/** /**
...@@ -354,66 +349,64 @@ static void collect_lists(blk_collect_data_t *env) ...@@ -354,66 +349,64 @@ static void collect_lists(blk_collect_data_t *env)
static void static void
do_irg_walk_blk(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env, unsigned follow_deps) do_irg_walk_blk(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env, unsigned follow_deps)
{ {
ir_node *end_node = get_irg_end(irg); ir_node *end_node = get_irg_end(irg);
ir_node *end_blk = get_irg_end_block(irg); ir_node *end_blk = get_irg_end_block(irg);
blk_collect_data_t blks; blk_collect_data_t blks;
block_entry_t *entry; block_entry_t *entry;
#ifdef INTERPROCEDURAL_VIEW #ifdef INTERPROCEDURAL_VIEW
/* switch off interprocedural view */ /* switch off interprocedural view */
int old_view = get_interprocedural_view(); int old_view = get_interprocedural_view();
set_interprocedural_view(0); set_interprocedural_view(0);
#endif #endif
obstack_init(&blks.obst); obstack_init(&blks.obst);
blks.blk_map = new_pset(addr_cmp, 1); blks.blk_map = new_pset(addr_cmp, 1);
blks.blk_list = NEW_ARR_F(ir_node *, 0); blks.blk_list = NEW_ARR_F(ir_node *, 0);
blks.follow_deps = follow_deps != 0; blks.follow_deps = follow_deps != 0;
/* first step: traverse the graph and fill the lists */ /* first step: traverse the graph and fill the lists */
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED); ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
inc_irg_visited(irg); inc_irg_visited(irg);
collect_walk(end_node, &blks); collect_walk(end_node, &blks);
/* add the end block */ /* add the end block */
ARR_APP1(ir_node *, blks.blk_list, end_blk); ARR_APP1(ir_node *, blks.blk_list, end_blk);
/* and the end node */ /* and the end node */
entry = block_find_entry(end_blk, &blks); entry = block_find_entry(end_blk, &blks);
ARR_APP1(ir_node *, entry->entry_list, end_node); ARR_APP1(ir_node *, entry->entry_list, end_node);
collect_lists(&blks); collect_lists(&blks);
/* second step: traverse the list */ /* second step: traverse the list */
traverse(&blks, pre, post, env); traverse(&blks, pre, post, env);
DEL_ARR_F(blks.blk_list); DEL_ARR_F(blks.blk_list);