X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firgwalk.c;h=10484be99d1450f771d07ec131b1e2bc68e44c71;hb=a826556627270364ae3683c31e4b8cec4b5479c4;hp=a7ca5ff577b780dc2db0fae2d97c18d153b85daa;hpb=2bc2dd4bd4f64982e9c5d2f1ea70d63d0eb10044;p=libfirm diff --git a/ir/ir/irgwalk.c b/ir/ir/irgwalk.c index a7ca5ff57..10484be99 100644 --- a/ir/ir/irgwalk.c +++ b/ir/ir/irgwalk.c @@ -123,7 +123,8 @@ static void irg_walk_cg(ir_node * node, ir_visited_t visited, /** * Insert all ir_graphs in irg_set, that are (transitive) reachable. */ -static void collect_irgs(ir_node * node, pset_new_t *irg_set) { +static void collect_irgs(ir_node * node, pset_new_t *irg_set) +{ if (is_Call(node)) { int i; for (i = get_Call_n_callees(node) - 1; i >= 0; --i) { @@ -143,8 +144,8 @@ static void collect_irgs(ir_node * node, pset_new_t *irg_set) { * * @return number of visited nodes */ -static unsigned -irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void * env) { +static unsigned irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void * env) +{ int i; unsigned cnt = 1; ir_graph *irg = current_ir_graph; @@ -171,8 +172,8 @@ irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void * env) { * * @return number of visited nodes */ -static unsigned -irg_walk_2_post(ir_node *node, irg_walk_func *post, void * env) { +static unsigned irg_walk_2_post(ir_node *node, irg_walk_func *post, void * env) +{ int i; unsigned cnt = 1; ir_graph *irg = current_ir_graph; @@ -200,8 +201,8 @@ irg_walk_2_post(ir_node *node, irg_walk_func *post, void * env) { * * @return number of visited nodes */ -static unsigned -irg_walk_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) { +static unsigned irg_walk_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) +{ int i; unsigned cnt = 1; ir_graph *irg = current_ir_graph; @@ -231,8 +232,8 @@ irg_walk_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * e * * @return number of visited nodes */ -static unsigned -irg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) +unsigned irg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, + void *env) { if (node->visited < current_ir_graph->visited) { if (!post) return irg_walk_2_pre (node, pre, env); @@ -286,7 +287,8 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) /* * walk over a graph */ -void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) { +void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) +{ ir_graph * rem = current_ir_graph; hook_irg_walk(irg, (generic_func *)pre, (generic_func *)post); @@ -299,7 +301,8 @@ void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void /* Executes irg_walk(end, pre, post, env) for all irgraphs in irprog. Sets current_ir_graph properly for each walk. Conserves current current_ir_graph. */ -void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) { +void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) +{ int i, n; ir_graph *irg; @@ -316,8 +319,8 @@ void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) { * * @return number of visited nodes */ -static unsigned -irg_walk_in_or_dep_2_pre(ir_node *node, irg_walk_func *pre, void *env) { +static unsigned irg_walk_in_or_dep_2_pre(ir_node *node, irg_walk_func *pre, void *env) +{ int i; unsigned cnt = 1; ir_graph *irg = current_ir_graph; @@ -344,8 +347,8 @@ irg_walk_in_or_dep_2_pre(ir_node *node, irg_walk_func *pre, void *env) { * * @return number of visited nodes */ -static unsigned -irg_walk_in_or_dep_2_post(ir_node *node, irg_walk_func *post, void *env) { +static unsigned irg_walk_in_or_dep_2_post(ir_node *node, irg_walk_func *post, void *env) +{ int i; unsigned cnt = 1; ir_graph *irg = current_ir_graph; @@ -373,8 +376,8 @@ irg_walk_in_or_dep_2_post(ir_node *node, irg_walk_func *post, void *env) { * * @return number of visited nodes */ -static unsigned -irg_walk_in_or_dep_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) { +static unsigned irg_walk_in_or_dep_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) +{ int i; unsigned cnt = 1; ir_graph *irg = current_ir_graph; @@ -404,8 +407,7 @@ irg_walk_in_or_dep_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post * * @return number of visited nodes */ -static unsigned -irg_walk_in_or_dep_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) +static unsigned irg_walk_in_or_dep_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) { if (node->visited < current_ir_graph->visited) { if (! post) return irg_walk_in_or_dep_2_pre (node, pre, env); @@ -435,7 +437,8 @@ void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post, /* * Walk over a graph. Follow all edges (including dependencies) */ -void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) { +void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) +{ ir_graph * rem = current_ir_graph; hook_irg_walk(irg, (generic_func *)pre, (generic_func *)post); @@ -451,8 +454,8 @@ void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func * * Returns current_ir_graph and sets it to the irg of predecessor index * of node n. */ -static inline ir_graph * -switch_irg(ir_node *n, int index) { +static inline ir_graph * switch_irg(ir_node *n, int index) +{ ir_graph *old_current = current_ir_graph; if (get_interprocedural_view()) { @@ -471,8 +474,7 @@ switch_irg(ir_node *n, int index) { } #ifdef INTERPROCEDURAL_VIEW -static void -cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) +static void cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) { int i; ir_graph *rem = NULL; @@ -497,7 +499,8 @@ cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) } /* Walks all irgs in interprocedural view. Visits each node only once. */ -void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) { +void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) +{ int i; ir_graph *rem = current_ir_graph; int rem_view = get_interprocedural_view(); @@ -560,7 +563,8 @@ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) { /***************************************************************************/ /* Walks back from n until it finds a real cf op. */ -static ir_node *get_cf_op(ir_node *n) { +static ir_node *get_cf_op(ir_node *n) +{ while (!is_cfop(n) && !is_fragile_op(n) && !is_Bad(n)) { n = skip_Id(n); n = skip_Tuple(n); @@ -578,7 +582,7 @@ static void irg_block_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *p if (pre) pre(node, env); - for(i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) { + for (i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) { /* find the corresponding predecessor block. */ ir_node *pred = get_cf_op(get_Block_cfgpred(node, i)); pred = get_nodes_block(pred); @@ -640,7 +644,8 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * walk over a graph block wise */ void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, - irg_walk_func *post, void *env) { + irg_walk_func *post, void *env) +{ ir_graph * rem = current_ir_graph; current_ir_graph = irg; irg_block_walk(get_irg_end(irg), pre, post, env); @@ -650,7 +655,8 @@ void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre, /* * Additionally walk over all anchors. Do NOT increase the visit flag. */ -void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) { +void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env) +{ ir_graph * rem = current_ir_graph; current_ir_graph = irg; @@ -670,7 +676,7 @@ typedef struct walk_env { static void walk_initializer(ir_initializer_t *initializer, walk_env *env) { - switch(initializer->kind) { + switch (initializer->kind) { case IR_INITIALIZER_CONST: irg_walk(initializer->consti.value, env->pre, env->post, env->env); return; @@ -680,7 +686,7 @@ static void walk_initializer(ir_initializer_t *initializer, walk_env *env) case IR_INITIALIZER_COMPOUND: { size_t i; - for(i = 0; i < initializer->compound.n_initializers; ++i) { + for (i = 0; i < initializer->compound.n_initializers; ++i) { ir_initializer_t *subinitializer = initializer->compound.initializers[i]; walk_initializer(subinitializer, env); @@ -709,7 +715,8 @@ static void walk_entity(ir_entity *ent, void *env) } /* Walks over all code in const_code_irg. */ -void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env) { +void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env) +{ int i, j, n_types; walk_env my_env; ir_segment_t s;