#include "config.h"
#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
#include "irloop_t.h"
#include "irnode_t.h"
static ir_loop *current_loop; /* Current cfloop construction is working
on. */
static int loop_node_cnt = 0; /* Counts the number of allocated cfloop nodes.
- Each cfloop node gets a unique number.
- What for? ev. remove. @@@ */
+ Each cfloop node gets a unique number.
+ What for? ev. remove. @@@ */
static int current_dfn = 1; /* Counter to generate depth first numbering
- of visited nodes. */
+ of visited nodes. */
+
+static int max_loop_depth = 0;
void link_to_reg_end (ir_node *n, void *env);
son->outer_loop = father;
add_loop_son(father, son);
son->depth = father->depth+1;
+ if (son->depth > max_loop_depth) max_loop_depth = son->depth;
} else { /* The root loop */
son->outer_loop = son;
son->depth = 0;
}
/* Constructs backedge information for irg. */
-void construct_cf_backedges(ir_graph *irg) {
+int construct_cf_backedges(ir_graph *irg) {
ir_graph *rem = current_ir_graph;
ir_loop *head_rem;
ir_node *end = get_irg_end(irg);
int i;
- assert(!interprocedural_view &&
+ assert(!get_interprocedural_view() &&
"use construct_ip_backedges");
+ max_loop_depth = 0;
current_ir_graph = irg;
outermost_ir_graph = irg;
assert(get_irg_loop(current_ir_graph)->kind == k_ir_loop);
current_ir_graph = rem;
+ return max_loop_depth;
}
-void construct_ip_cf_backedges (void) {
+int construct_ip_cf_backedges (void) {
ir_graph *rem = current_ir_graph;
- int rem_ipv = interprocedural_view;
+ int rem_ipv = get_interprocedural_view();
int i;
assert(get_irp_ip_view_state() == ip_view_valid);
-
+ max_loop_depth = 0;
outermost_ir_graph = get_irp_main_irg();
init_ip_scc();
current_loop = NULL;
new_loop(); /* sets current_loop */
- interprocedural_view = 1;
+ set_interprocedural_view(true);
inc_max_irg_visited();
for (i = 0; i < get_irp_n_irgs(); i++)
assert(get_irg_loop(outermost_ir_graph)->kind == k_ir_loop);
current_ir_graph = rem;
- interprocedural_view = rem_ipv;
+ set_interprocedural_view(rem_ipv);
+ return max_loop_depth;
}
static void reset_backedges(ir_node *n) {
+ int rem = get_interprocedural_view();
+
assert(is_Block(n));
- int rem = interprocedural_view;
- interprocedural_view = 1;
+ set_interprocedural_view(true);
clear_backedges(n);
- interprocedural_view = 0;
+ set_interprocedural_view(false);
clear_backedges(n);
- interprocedural_view = rem;
+ set_interprocedural_view(rem);
}
static void loop_reset_backedges(ir_loop *l) {
void free_all_cfloop_information (void) {
int i;
- int rem = interprocedural_view;
- interprocedural_view = 1; /* To visit all filter nodes */
+ int rem = get_interprocedural_view();
+ set_interprocedural_view(true); /* To visit all filter nodes */
for (i = 0; i < get_irp_n_irgs(); i++) {
free_cfloop_information(get_irp_irg(i));
}
- interprocedural_view = rem;
+ set_interprocedural_view(rem);
}