/*
- * 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.
*/
/**
#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;
/** 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. **/
/**********************************************************************/
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;
}
*/
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))
*/
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))
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
close = 0;
}
-#else
-
- ir_loop *l = new_loop();
-
-#endif
-
/* Remove the cfloop from the stack ... */
pop_scc_unmark_visit(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.
}
}
-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);
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);
}