X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fircfscc.c;h=415323c4d5878839f91bd10a4a025671e6fd9022;hb=bd81af027a8771684ad2928fa5589cdc70562170;hp=b6e4dcf546b75c79e0b08bedb1df421c096a9397;hpb=ceb8c85dcec7d95e97093c5577f1e3d5a1a362d3;p=libfirm diff --git a/ir/ana/ircfscc.c b/ir/ana/ircfscc.c index b6e4dcf54..415323c4d 100644 --- a/ir/ana/ircfscc.c +++ b/ir/ana/ircfscc.c @@ -24,7 +24,6 @@ * [Trapp:99], Chapter 5.2.1.2. * @author Goetz Lindenmaier * @date 7.2002 - * @version $Id$ */ #include "config.h" @@ -38,8 +37,7 @@ #include "irgwalk.h" #include "irprog_t.h" #include "irdump.h" - -#define NO_CFLOOPS_WITHOUT_HEAD 1 +#include "ircons_t.h" /** The outermost graph the scc is computed for */ static ir_graph *outermost_ir_graph; @@ -53,14 +51,6 @@ static int loop_node_cnt = 0; /** Counter to generate depth first numbering of visited nodes. */ static int current_dfn = 1; -static unsigned max_loop_depth = 0; - -void link_to_reg_end(ir_node *n, void *env); - -/**********************************************************************/ -/* Node attributes **/ -/**********************************************************************/ - /**********************************************************************/ /* Node attributes needed for the construction. **/ /**********************************************************************/ @@ -268,9 +258,8 @@ static inline void pop_scc_unmark_visit(ir_node *n) static ir_loop *new_loop(void) { ir_loop *father = current_loop; - ir_loop *son = alloc_loop(father, outermost_ir_graph->obst); + ir_loop *son = alloc_loop(father, get_irg_obstack(outermost_ir_graph)); - if (son->depth > max_loop_depth) max_loop_depth = son->depth; current_loop = son; return father; } @@ -327,14 +316,11 @@ static inline void finish_scc(void) */ static int is_head(ir_node *n, ir_node *root) { - int i, arity; int some_outof_loop = 0, some_in_loop = 0; (void) root; - assert(is_Block(n)); - - arity = get_Block_n_cfgpreds(n); - for (i = 0; i < arity; i++) { + int const arity = get_Block_n_cfgpreds(n); + for (int i = 0; i < arity; i++) { ir_node *pred = get_Block_cfgpred_block(n, i); /* ignore Bad control flow: it cannot happen */ if (is_Bad(pred)) @@ -362,14 +348,12 @@ static int is_head(ir_node *n, ir_node *root) */ static int is_endless_head(ir_node *n, ir_node *root) { - int i, arity; int none_outof_loop = 1, some_in_loop = 0; (void) root; - assert(is_Block(n)); /* Test for legal loop header: Block, Phi, ... */ - arity = get_Block_n_cfgpreds(n); - for (i = 0; i < arity; i++) { + int const arity = get_Block_n_cfgpreds(n); + for (int i = 0; i < arity; i++) { ir_node *pred = get_Block_cfgpred_block(n, i); /* ignore Bad control flow: it cannot happen */ if (is_Bad(pred)) @@ -568,8 +552,6 @@ static void cfscc(ir_node *n) Next actions: Open a new cfloop on the cfloop tree and try to find inner cfloops */ -#if NO_CFLOOPS_WITHOUT_HEAD - /* This is an adaption of the algorithm from fiasco / optscc to * avoid cfloops without Block or Phi as first node. This should * severely reduce the number of evaluations of nodes to detect @@ -587,12 +569,6 @@ static void cfscc(ir_node *n) close = 0; } -#else - - ir_loop *l = new_loop(); - -#endif - /* Remove the cfloop from the stack ... */ pop_scc_unmark_visit(n); @@ -604,9 +580,7 @@ static void cfscc(ir_node *n) cfscc(tail); assert(irn_visited(n)); -#if NO_CFLOOPS_WITHOUT_HEAD if (close) -#endif close_loop(l); } else { /* AS: No cfloop head was found, that is we have straight line code. @@ -616,18 +590,13 @@ static void cfscc(ir_node *n) } } -/* Constructs control flow backedge information for irg. */ -int construct_cf_backedges(ir_graph *irg) +void construct_cf_backedges(ir_graph *irg) { - ir_graph *rem = current_ir_graph; ir_loop *head_rem; ir_node *end = get_irg_end(irg); struct obstack temp; int i; - max_loop_depth = 0; - - current_ir_graph = irg; outermost_ir_graph = irg; obstack_init(&temp); @@ -650,19 +619,14 @@ int construct_cf_backedges(ir_graph *irg) obstack_free(&temp, NULL); assert(head_rem == current_loop); - mature_loops(current_loop, irg->obst); + mature_loops(current_loop, get_irg_obstack(irg)); set_irg_loop(irg, current_loop); - set_irg_loopinfo_state(irg, loopinfo_cf_consistent); - assert(get_irg_loop(irg)->kind == k_ir_loop); - - current_ir_graph = rem; - return max_loop_depth; + add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO); } -void assure_cf_loop(ir_graph *irg) +void assure_loopinfo(ir_graph *irg) { - irg_loopinfo_state state = get_irg_loopinfo_state(irg); - - if (state != loopinfo_cf_consistent) - construct_cf_backedges(irg); + if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO)) + return; + construct_cf_backedges(irg); }