From 898caa0b0671dfe587c9ff4e2bbca6d40a9ee30f Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Wed, 29 Aug 2001 15:07:44 +0000 Subject: [PATCH] Added routine remove_irp_irg. Changed comment to free_ir_graph. [r247] --- ir/ir/irgraph.c | 2 ++ ir/ir/irgraph.h | 2 ++ ir/ir/irprog.c | 16 +++++++++++++++- ir/ir/irprog.h | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index be11632c5..f29aaf780 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -102,6 +102,8 @@ new_ir_graph (entity *ent, int n_loc) /* Frees the passed irgraph. Deallocates all nodes in this graph and the ir_graph structure. Sets the field irgraph in the corresponding entity to NULL. + Does not remove the irgraph from the list in irprog (requires + inefficient search, call remove_irp_irg by hand). Does not free types, entities or modes that are used only by this graph, nor the entity standing for this graph. */ void free_ir_graph (ir_graph *irg) { diff --git a/ir/ir/irgraph.h b/ir/ir/irgraph.h index 70c3f169e..2968402db 100644 --- a/ir/ir/irgraph.h +++ b/ir/ir/irgraph.h @@ -75,6 +75,8 @@ ir_graph *new_ir_graph (entity *ent, int n_loc); /* Frees the passed irgraph. Deallocates all nodes in this graph and the ir_graph structure. Sets the field irgraph in the corresponding entity to NULL. + Does not remove the irgraph from the list in irprog (requires + inefficient search, call remove_irp_irg by hand). Does not free types, entities or modes that are used only by this graph, nor the entity standing for this graph. */ void free_ir_graph (ir_graph *irg); diff --git a/ir/ir/irprog.c b/ir/ir/irprog.c index 963ae93e0..4de46960e 100644 --- a/ir/ir/irprog.c +++ b/ir/ir/irprog.c @@ -67,12 +67,26 @@ type *get_glob_type(void) { } /* Adds irg to the list of ir graphs in irp. */ -void add_irp_irg(ir_graph *irg) { +void add_irp_irg(ir_graph *irg) { assert (irg != NULL); assert(irp && irp->graphs); ARR_APP1 (ir_graph *, irp->graphs, irg); } +/* Removes irg from the list or irgs, shrinks the list by one. + @@@ does not work properly. */ +void remove_irp_irg(ir_graph *irg){ + int i; + assert(irg); + for (i = 1; i < (ARR_LEN (irp->graphs))-1; i++) + if (irp->graphs[i+1] == irg) { + for(i++; i < (ARR_LEN (irp->graphs)) - 1; i++) + irp->graphs[i] = irp->graphs[i+1]; + ARR_SETLEN(ir_graph*, irp->graphs, (ARR_LEN(irp->graphs)) - 1); + break; + } +} + int get_irp_n_irgs() { assert (irp && irp->graphs); /* Strangely the first element of the array is NULL. Why?? */ diff --git a/ir/ir/irprog.h b/ir/ir/irprog.h index e8b2296f0..84622d39a 100644 --- a/ir/ir/irprog.h +++ b/ir/ir/irprog.h @@ -61,6 +61,9 @@ void set_irp_main_irg(ir_graph *main_irg); /* Adds irg to the list of ir graphs in irp. */ void add_irp_irg(ir_graph *irg); +/* Removes irg from the list or irgs, shrinks the list by one. + @@@ does not work properly. */ +void remove_irp_irg(ir_graph *irg); int get_irp_n_irgs(); ir_graph *get_irp_irg(int pos); void set_irp_irg(int pos, ir_graph *irg); -- 2.20.1