From 56a871bc4bfe49ae51c8d16fea662a3b1ab1836e Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Wed, 17 Dec 2003 09:16:55 +0000 Subject: [PATCH] freeing of loop information added [r2230] --- ir/ana/irloop.h | 13 +++++++++++-- ir/ana/irscc.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/ir/ana/irloop.h b/ir/ana/irloop.h index 2691d54fc..1dfe236f2 100644 --- a/ir/ana/irloop.h +++ b/ir/ana/irloop.h @@ -80,7 +80,10 @@ void set_irg_loop(ir_graph *irg, ir_loop *l); ir_loop *get_irg_loop(ir_graph *irg); /** Returns the loop n is contained in. - assumes current_ir_graph set properly. */ + assumes current_ir_graph set properly. */ +/* @@@ @@@ @@@ @@@@ @@@ + current impl is very expensive: O(#nodes in irg). + Is used by heapanal (O(#phi)) --> better impl required. */ ir_loop *get_irn_loop(ir_node *n); /** Returns outer loop, itself if outermost. */ @@ -107,13 +110,19 @@ loop_element get_loop_element (ir_loop *loop, int pos); */ /** Constructs backedge information for irg in intraprocedural view. */ +/* @@@ Well, maybe construct_loop_information or analyze_loops ? */ void construct_backedges(ir_graph *irg); /** Constructs backedges for all irgs in interprocedural view. All loops in the graph will be marked as such, not only realizeable loops and recursions in the program. E.g., if the same funcion is - called twice, there is a loop between the first funcion return and + called twice, there is a loop between the first function return and the second call. */ void construct_ip_backedges(void); +/** Removes all loop information. + Resets all backedges */ +void free_loop_information(ir_graph *irg); +void free_all_loop_information (void); + #endif /* _IRLOOP_H_ */ diff --git a/ir/ana/irscc.c b/ir/ana/irscc.c index 08fb9bac9..ed19bac6d 100644 --- a/ir/ana/irscc.c +++ b/ir/ana/irscc.c @@ -596,6 +596,13 @@ static void test(ir_node *pred, ir_node *root, ir_node *this) { } #endif +/* Test for legal loop header: Block, Phi, ... */ +INLINE static bool is_possible_loop_head(ir_node *n) { + return ((get_irn_op(n) == op_Block) || + (get_irn_op(n) == op_Phi) || + ((get_irn_op(n) == op_Filter) && interprocedural_view)); +} + /* Returns true if n is a loop header, i.e., it is a Block, Phi or Filter node and has predecessors within the loop and out of the loop. */ @@ -605,10 +612,8 @@ is_head (ir_node *n, ir_node *root) int i; int some_outof_loop = 0, some_in_loop = 0; - /* Test for legal loop header */ - if (!((get_irn_op(n) == op_Block) || - (get_irn_op(n) == op_Phi) || - ((get_irn_op(n) == op_Filter) && interprocedural_view))) + /* Test for legal loop header: Block, Phi, ... */ + if (!is_possible_loop_head(n)) return false; if (!is_outermost_Start(n)) { @@ -864,3 +869,28 @@ void construct_ip_backedges (void) { current_ir_graph = rem; interprocedural_view = rem_ipv; } + + +static void reset_backedges(ir_node *n, void *env) { + if (is_possible_loop_head(n)) + clear_backedges(n); +} + +/** Removes all loop information. + Resets all backedges */ +void free_loop_information(ir_graph *irg) { + set_irg_loop(irg, NULL); + /* We cannot free the loop nodes, they are on the obstack. */ + irg_walk_graph(irg, NULL, reset_backedges, NULL); +} + + +void free_all_loop_information (void) { + int i; + int rem = interprocedural_view; + interprocedural_view = 1; /* To visit all filter nodes */ + for (i = 0; i < get_irp_n_irgs(); i++) { + free_loop_information(get_irp_irg(i)); + } + interprocedural_view = rem; +} -- 2.20.1