X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fircfscc.c;h=5b89447e9f3ad2c78349eed7abffb91bba19225c;hb=e97a86a5e90141c2cb4ccdc34195cab035627c3f;hp=a7e0c97ab9e56e99bf16a0b0045a66c24fc5a1fa;hpb=3bb47464dc990c9def630a208a12da1bdd035bbb;p=libfirm diff --git a/ir/ana/ircfscc.c b/ir/ana/ircfscc.c index a7e0c97ab..5b89447e9 100644 --- a/ir/ana/ircfscc.c +++ b/ir/ana/ircfscc.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -24,7 +10,6 @@ * [Trapp:99], Chapter 5.2.1.2. * @author Goetz Lindenmaier * @date 7.2002 - * @version $Id$ */ #include "config.h" @@ -38,8 +23,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 +37,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 +244,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 +302,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 +334,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 +538,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 +555,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 +566,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 +576,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,17 +605,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_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO); - - current_ir_graph = rem; - return max_loop_depth; + add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO); } void assure_loopinfo(ir_graph *irg) { - if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)) + if (irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO)) return; construct_cf_backedges(irg); }