treatment of pseudo irgs
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 11 Nov 2004 09:36:29 +0000 (09:36 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 11 Nov 2004 09:36:29 +0000 (09:36 +0000)
[r4371]

ir/ir/irdump.c
ir/ir/irgraph.c
ir/ir/irgraph.h
ir/ir/irgraph_t.h
ir/ir/irprog.c
ir/ir/irprog.h
ir/ir/irprog_t.h

index 25ac336..2d85c79 100644 (file)
@@ -701,6 +701,7 @@ static INLINE int dump_node_info(FILE *F, ir_node *n)
   } break;
   case iro_CallBegin: {
     ir_node *call = get_CallBegin_call(n);
+    fprintf(F, "Call: %ld\n", get_irn_node_nr(call));
     if (Call_has_callees(call)) {
       fprintf(F, "possible callees: \n");
       for (i = 0; i < get_Call_n_callees(call); i++) {
index ce8923a..3f00b28 100644 (file)
@@ -79,7 +79,7 @@ void free_Phi_in_stack(Phi_in_stack *s);
    and optimization.
 */
 ir_graph *
-new_ir_graph (entity *ent, int n_loc)
+new_r_ir_graph (entity *ent, int n_loc)
 {
   ir_graph *res;
   ir_node *first_block;
@@ -93,7 +93,6 @@ new_ir_graph (entity *ent, int n_loc)
   stat_new_graph(res, ent);
 
   current_ir_graph = res;
-  add_irp_irg(res);          /* remember this graph global. */
 
   /*-- initialized for each graph. --*/
   if (get_opt_precise_exc_context()) {
@@ -181,6 +180,14 @@ new_ir_graph (entity *ent, int n_loc)
 }
 
 
+ir_graph *
+new_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;
+}
+
 /* Make a rudimentary ir graph for the constant code.
    Must look like a correct irg, spare everything else. */
 ir_graph *new_const_code_irg(void) {
@@ -677,20 +684,3 @@ void
 (inc_irg_block_visited)(ir_graph *irg) {
   __inc_irg_block_visited(irg);
 }
-
-/* is irg a pseudo graph for analysis? */
-int is_pseudo_ir_graph(ir_graph *irg)
-{
-  int res = false;
-  entity *ent;
-
-  assert(irg && "nothing here");
-  assert(is_ir_graph(irg) && "no ir_graph given");
-
-  ent = get_irg_entity(irg);
-  if(visibility_external_allocated == get_entity_visibility(ent)
-     && peculiarity_existent == get_entity_peculiarity(ent)) {
-    res = true;
-  }
-  return(res);
-}
index 64667f9..78d74b1 100644 (file)
@@ -91,7 +91,7 @@ void      set_current_ir_graph(ir_graph *graph);
 int get_interprocedural_view(void);
 void set_interprocedural_view(int state);
 
-/** Create a new ir graph to built ir for a procedure.
+/** Create a new ir graph to build ir for a procedure.
  *
  *  ent is the entity representing this procedure, i.e., the type of the
  *  entity must be of a method type.  The constructor automatically sets the
@@ -99,7 +99,9 @@ void set_interprocedural_view(int state);
  *  n_loc is the number of local variables in this procedure including
  *  the procedure parameters.
  *  The constructor adds the new irgraph to the list in ir_prog.
- *  The state of the ir graph is:  phase_building, op_pin_state_pinned, outs_none. */
+ *  The state of the ir graph is:  phase_building, op_pin_state_pinned, outs_none.
+ *
+ *  @see new_pseudo_ir_graph() */
 ir_graph *new_ir_graph (entity *ent, int n_loc);
 
 /** Frees the passed irgraph.
@@ -361,7 +363,4 @@ void          inc_irg_block_visited (ir_graph *irg);
 unsigned long get_irg_block_visited (const ir_graph *irg);
 void          set_irg_block_visited (ir_graph *irg, unsigned long i);
 
-/* is irg a pseudo graph for analysis? */
-int      is_pseudo_ir_graph(ir_graph *irg);
-
 # endif /* _IRGRAPH_H_ */
index 355f998..e5b3617 100644 (file)
@@ -27,6 +27,7 @@
 #include "firm_common_t.h"
 #include "irtypeinfo.h"
 #include "irprog.h"
+#include "pseudo_irg.h"
 
 #include "irloop.h"
 
@@ -121,6 +122,9 @@ struct ir_graph {
  */
 void init_irgraph(void);
 
+/* Internal constructor that does not add to irp_irgs or the like. */
+ir_graph *new_r_ir_graph (entity *ent, int n_loc);
+
 /** Make a rudimentary ir graph for the constant code.
    Must look like a correct irg, spare everything else. */
 ir_graph *new_const_code_irg(void);
index d8a2e59..b0a44eb 100644 (file)
@@ -18,6 +18,7 @@
 
 # include "irprog_t.h"
 # include "irgraph_t.h"
+# include "pseudo_irg.h"
 # include "array.h"
 # include "obst.h"
 # include "typegmod.h"
@@ -61,7 +62,8 @@ ir_prog *new_ir_prog (void) {
   memset(res, 0, sizeof(res));
   irp = res;
   /* res->obst      = (struct obstack *) xmalloc (sizeof (struct obstack)); */
-  res->graphs = NEW_ARR_F (ir_graph *, 0);
+  res->graphs        = NEW_ARR_F (ir_graph *, 0);
+  res->pseudo_graphs = NEW_ARR_F (ir_graph *, 0);
   res->types  = NEW_ARR_F (type *, 0);
   res->name   = new_id_from_str(INITAL_PROG_NAME);
 
@@ -149,6 +151,23 @@ void set_irp_irg(int pos, ir_graph *irg) {
   irp->graphs[pos] = irg;
 }
 
+/* Gets the number of graphs _and_ pseudo graphs. */
+int       get_irp_n_allirgs(void) {
+  /* We can not call get_irp_n_irgs, as we end up in a recursion ... */
+  return ARR_LEN((irp)->graphs) + get_irp_n_pseudo_irgs();
+}
+
+/* Returns the ir graph at position pos of all graphs (including
+ pseudo graphs).  Visits first graphs, then pseudo graphs. */
+ir_graph *get_irp_allirg(int pos) {
+  int n_irgs = get_irp_n_irgs();
+  if (pos < n_irgs)
+    return (irp)->graphs[pos];
+  else
+    return get_irp_pseudo_irg(pos-n_irgs);
+}
+
+
 /* Adds type to the list of types in irp. */
 void add_irp_type(type *typ) {
   assert (typ != NULL);
index 8d2eab3..9df3282 100644 (file)
@@ -120,6 +120,13 @@ ir_graph *get_irp_irg(int pos);
 /** Sets the ir graph at position pos. */
 void      set_irp_irg(int pos, ir_graph *irg);
 
+/** Gets the number of graphs _and_ pseudo graphs. */
+int       get_irp_n_allirgs(void);
+
+/** Returns the ir graph at position pos of all graphs (including
+ pseudo graphs).  Visits first graphs, then pseudo graphs. */
+ir_graph *get_irp_allirg(int pos);
+
 
 /** Returns the "global" type of the irp. */
 type *get_glob_type(void);
index 46f2d43..ecaa8f1 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "irprog.h"
 #include "irgraph.h"
+#include "pseudo_irg.h"
 #include "ircgcons.h"
 #include "firm_common_t.h"
 #include "typegmod.h"
@@ -38,6 +39,7 @@ struct ir_prog {
   ir_graph  *main_irg;            /**< entry point to the compiled program
                                       @@@ or a list, in case we compile a library or the like? */
   ir_graph **graphs;              /**< all graphs in the ir */
+  ir_graph **pseudo_graphs;       /**< all pseudo graphs in the ir. See pseudo_irg.c */
   ir_graph  *const_code_irg;      /**< This ir graph gives the proper environment
                                       to allocate nodes the represent values
                                       of constant entities. It is not meant as
@@ -80,12 +82,14 @@ __get_glob_type(void) {
 static INLINE int
 __get_irp_n_irgs(void) {
   assert (irp && irp->graphs);
+  if (get_visit_pseudo_irgs()) return get_irp_n_allirgs();
   return (ARR_LEN((irp)->graphs));
 }
 
 static INLINE ir_graph *
 __get_irp_irg(int pos){
   assert (irp && irp->graphs);
+  if (get_visit_pseudo_irgs()) return get_irp_allirg(pos);
   return irp->graphs[pos];
 }