From e6c2ee205ade54c9979359a0be3fb7cf8d11c601 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Thu, 11 Nov 2004 09:28:32 +0000 Subject: [PATCH] treat pseudo irgs special parse 'local' from xml files [r4367] --- ir/external/Makefile.in | 4 +-- ir/external/pseudo_irg.c | 58 ++++++++++++++++++++++++++++++++++++++++ ir/external/pseudo_irg.h | 27 +++++++++++++++++++ ir/external/read.c | 21 ++++++++++++++- ir/external/read.h | 6 +++++ 5 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 ir/external/pseudo_irg.c create mode 100644 ir/external/pseudo_irg.h diff --git a/ir/external/Makefile.in b/ir/external/Makefile.in index f6670146c..863af3e02 100644 --- a/ir/external/Makefile.in +++ b/ir/external/Makefile.in @@ -19,12 +19,12 @@ srcdir = @srcdir@ topdir = ../.. subdir := ir/external -INSTALL_HEADERS = read.h +INSTALL_HEADERS = read.h pseudo_irg.h SOURCES = $(INSTALL_HEADERS) SOURCES += Makefile.in \ - read.c + read.c pseudo_irg.c include $(topdir)/MakeRules diff --git a/ir/external/pseudo_irg.c b/ir/external/pseudo_irg.c new file mode 100644 index 000000000..7914d962f --- /dev/null +++ b/ir/external/pseudo_irg.c @@ -0,0 +1,58 @@ + + +#include "pseudo_irg.h" + +#include "irgraph_t.h" +#include "irprog_t.h" +#include "array.h" + + +/** Returns the number of pseudo graphs in the program. */ +int get_irp_n_pseudo_irgs(void) { + return ARR_LEN(irp->pseudo_graphs); +} + +/** Returns the number of pseudo graphs in the program. */ +ir_graph *get_irp_pseudo_irg(int pos) { + return irp->pseudo_graphs[pos]; +} + +void add_irp_pseudo_irg(ir_graph *irg) { + ARR_APP1(ir_graph *, irp->pseudo_graphs, irg); +} + + +/* Create a new ir graph to build a pseudo representation of a procedure. + * + * The pseudo representation can only be used for analyses. It may not be + * optimized. Pseudo graphs are kept in a separate graph list in irprog. + */ +ir_graph * +new_pseudo_ir_graph(entity *ent, int n_loc) { + ir_graph *res = new_r_ir_graph (ent, n_loc); + add_irp_irg(res); /* remember this graph global. */ + return res; +} + +/** Returns true ir ir_graph is pseudo graph. */ +int is_pseudo_ir_graph(ir_graph *irg) +{ + assert(irg && "nothing here"); + assert(is_ir_graph(irg) && "no ir_graph given"); + + int i, n_pseudo_irgs = get_irp_n_pseudo_irgs(); + for (i = 0; i < n_pseudo_irgs; ++i) { + if (irg == get_irp_pseudo_irg(i)) return true; + } + return false; +} + +static int visit_pseudo_irgs = 0; + +void set_visit_pseudo_irgs(int x) { + visit_pseudo_irgs = x; +} + +int get_visit_pseudo_irgs(void) { + return visit_pseudo_irgs; +} diff --git a/ir/external/pseudo_irg.h b/ir/external/pseudo_irg.h new file mode 100644 index 000000000..2861a31f2 --- /dev/null +++ b/ir/external/pseudo_irg.h @@ -0,0 +1,27 @@ + +#include "entity.h" +#include "irgraph.h" + + +/** Create a new ir graph to build a pseudo representation of a procedure. + * + * The pseudo representation can only be used for analyses. It may not be + * optimized. Pseudo graphs are kept in a separate graph list in irprog. + */ +ir_graph *new_pseudo_ir_graph(entity *ent, int n_loc); + +/** Returns true ir ir_graph is pseudo graph. + * Is irg a pseudo graph for analysis? */ +int is_pseudo_ir_graph(ir_graph *irg); + +/** Returns the number of pseudo graphs in the program. */ +int get_irp_n_pseudo_irgs(void); + +/** Returns the number of pseudo graphs in the program. */ +ir_graph *get_irp_pseudo_irg(int pos); + + +/** If set, get_irp_n_irgs and get_irp_irg behave as if all + pseudo graphs are in the irg list. */ +void set_visit_pseudo_irgs(int x); +int get_visit_pseudo_irgs(void); diff --git a/ir/external/read.c b/ir/external/read.c index bce0191a1..652bebca9 100644 --- a/ir/external/read.c +++ b/ir/external/read.c @@ -30,6 +30,7 @@ #include "read.h" #include "irprog.h" #include "irgraph.h" +#include "pseudo_irg.h" #include "ircons.h" #include "irmode.h" #include "irdump.h" @@ -1379,9 +1380,12 @@ static void create_abstract_firm(module_t *module, proc_t *proc, entity *fent) && peculiarity_existent == get_entity_peculiarity(fent) && "not an abstract entity"); /* create irg in entity */ - irg = new_ir_graph(fent, 0); + irg = new_pseudo_ir_graph(fent, 0); set_irg_inline_property(irg, irg_inline_forbidden); + /* If the spec says so: */ + set_entity_visibility(fent, visibility_local); + VERBOSE_PRINT((stdout, "create effects for %s\n", get_id_str(proc -> proc_ident))); @@ -1629,11 +1633,26 @@ void create_abstraction(const char *filename) modules = NULL; } + +void free_abstraction(void) { + int i, n_pseudo_irgs = get_irp_n_pseudo_irgs(); + for (i = 0; i < n_pseudo_irgs; ++i) { + ir_graph *p_irg = get_irp_pseudo_irg(i); + set_entity_visibility(get_irg_entity(p_irg), visibility_external_allocated); + // @@@ free_pseudo_ir_graph(p_irg); + } +} + + /********************************************************************/ /* * $Log$ + * Revision 1.15 2004/11/11 09:28:32 goetz + * treat pseudo irgs special + * parse 'local' from xml files + * * Revision 1.14 2004/11/10 14:42:00 boesler * be more helpful if a method does not exist * diff --git a/ir/external/read.h b/ir/external/read.h index c7079094c..fe1492b35 100644 --- a/ir/external/read.h +++ b/ir/external/read.h @@ -20,11 +20,17 @@ /** read the file and build the graphs */ void create_abstraction(const char *filename); +void free_abstraction(void); + #endif /* defined _READ_H_ */ /* $Log$ + Revision 1.8 2004/11/11 09:28:32 goetz + treat pseudo irgs special + parse 'local' from xml files + Revision 1.7 2004/10/25 13:52:24 boesler seperated read.h (public interface) and read_t.h (types) -- 2.20.1