treat pseudo irgs special
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 11 Nov 2004 09:28:32 +0000 (09:28 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 11 Nov 2004 09:28:32 +0000 (09:28 +0000)
parse 'local' from xml files

[r4367]

ir/external/Makefile.in
ir/external/pseudo_irg.c [new file with mode: 0644]
ir/external/pseudo_irg.h [new file with mode: 0644]
ir/external/read.c
ir/external/read.h

index f667014..863af3e 100644 (file)
@@ -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 (file)
index 0000000..7914d96
--- /dev/null
@@ -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 (file)
index 0000000..2861a31
--- /dev/null
@@ -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);
index bce0191..652bebc 100644 (file)
@@ -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);
+  }
+}
+
+
 /********************************************************************/
 
 \f
 /*
  * $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
  *
index c707909..fe1492b 100644 (file)
 /** 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)