Added access routines to external variables.
[libfirm] / ir / ir / irgraph.c
index 7d67269..7ffd10a 100644 (file)
 
 # include "ircons.h"
 # include "irgraph_t.h"
-# include "irprog.h"
+# include "irprog_t.h"
 # include "iropt_t.h"
 # include "array.h"
 # include "irgmod.h"
 # include "mangle.h"
 
 ir_graph *current_ir_graph;
+INLINE ir_graph *get_current_ir_graph() {
+  return current_ir_graph;
+}
+INLINE void set_current_ir_graph(ir_graph *graph) {
+  current_ir_graph = graph;
+}
+
 
 bool interprocedural_view = false;
+INLINE bool get_interprocedural_view() {
+  return interprocedural_view;
+}
+INLINE void set_interprocedural_view(bool state) {
+  interprocedural_view = state;
+}
 
 #if USE_EXPLICIT_PHI_IN_STACK
 /* really defined in ircons.c */
@@ -45,6 +58,7 @@ void free_Phi_in_stack(Phi_in_stack *s);
 ir_graph *
 new_ir_graph (entity *ent, int n_loc)
 {
+  int i;
   ir_graph *res;
   ir_node *first_block;
   ir_node *projX;
@@ -87,14 +101,16 @@ new_ir_graph (entity *ent, int n_loc)
   res->outs_state = no_outs;
   res->dom_state = no_dom;
 
-  /** Type inforamtion for the procedure of the graph **/
+  /** Type information for the procedure of the graph **/
   res->ent = ent;
   set_entity_irg(ent, res);
 
   /** A type that represents the stack frame.  A class type so that it can
       contain "inner" methods as in Pascal. **/
   res->frame_type = new_type_class(mangle(get_entity_ident(ent),
-       id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX))));
+         id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX))));
+  /* Remove type from type list.  Must be treated differently than other types. */
+  remove_irp_type_from_list(res->frame_type);
 
   /** Nodes needed in every graph **/
   res->end_block = new_immBlock ();
@@ -360,7 +376,7 @@ is_frame_type(type *ftp) {
 }
 
 int
-get_irg_n_loc (ir_graph *irg)
+get_irg_n_locs (ir_graph *irg)
 {
 #if PRECISE_EXC_CONTEXT
   return irg->n_loc - 1 - 1;
@@ -408,15 +424,23 @@ void set_irg_dom_inconsistent(ir_graph *irg) {
   irg->dom_state = dom_inconsistent;
 }
 
-inline void
-set_irg_pinned (ir_graph *irg, op_pinned p)
-{
+INLINE void
+set_irg_pinned (ir_graph *irg, op_pinned p) {
   irg->pinned = p;
 }
 
-/* maximum of all ir_graphs */
-static int max_irg_visited = 0;
+INLINE void
+set_irg_link (ir_graph *irg, void *thing) {
+  irg->link = thing;
+}
+
+INLINE void *
+get_irg_link (ir_graph *irg) {
+  return irg->link;
+}
 
+/* maximum visited flag content of all ir_graph visited fields. */
+static int max_irg_visited = 0;
 
 unsigned long
 get_irg_visited (ir_graph *irg)
@@ -428,6 +452,9 @@ void
 set_irg_visited (ir_graph *irg, unsigned long visited)
 {
   irg->visited = visited;
+  if (irg->visited > max_irg_visited) {
+    max_irg_visited = irg->visited;
+  }
 }
 
 void
@@ -441,6 +468,23 @@ inc_irg_visited (ir_graph *irg)
 unsigned long
 get_max_irg_visited(void)
 {
+  int i;
+  //for(i = 0; i < get_irp_n_irgs(); i++)
+  //  assert(max_irg_visited >= get_irg_visited(get_irp_irg(i)));
+  return max_irg_visited;
+}
+
+void set_max_irg_visited(int val) {
+  max_irg_visited = val;
+}
+
+unsigned long
+inc_max_irg_visited(void)
+{
+  int i;
+  //  for(i = 0; i < get_irp_n_irgs(); i++)
+  //assert(max_irg_visited >= get_irg_visited(get_irp_irg(i)));
+  max_irg_visited++;
   return max_irg_visited;
 }