Converted documentation to doxygen.
[libfirm] / ir / ir / irgraph.c
index 8464cdd..c4d6c20 100644 (file)
@@ -23,7 +23,7 @@
 # include "mangle.h"
 
 ir_graph *current_ir_graph;
-INLINE ir_graph *get_current_ir_graph() {
+INLINE ir_graph *get_current_ir_graph(void) {
   return current_ir_graph;
 }
 INLINE void set_current_ir_graph(ir_graph *graph) {
@@ -32,13 +32,18 @@ INLINE void set_current_ir_graph(ir_graph *graph) {
 
 
 bool interprocedural_view = false;
-INLINE bool get_interprocedural_view() {
+INLINE bool get_interprocedural_view(void) {
   return interprocedural_view;
 }
 INLINE void set_interprocedural_view(bool state) {
   interprocedural_view = state;
 }
 
+static ident* frame_type_suffix = NULL;
+void init_irgraph(void) {
+  frame_type_suffix = id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX));
+}
+
 #if USE_EXPLICIT_PHI_IN_STACK
 /* really defined in ircons.c */
 typedef struct Phi_in_stack Phi_in_stack;
@@ -106,8 +111,7 @@ new_ir_graph (entity *ent, int n_loc)
 
 /**
       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))));
+  res->frame_type = new_type_class(mangle(get_entity_ident(ent), frame_type_suffix));
   /* Remove type from type list.  Must be treated differently than other types. */
   remove_irp_type_from_list(res->frame_type);
 
@@ -126,6 +130,10 @@ new_ir_graph (entity *ent, int n_loc)
   res->frame   = new_Proj (res->start, mode_P, pns_frame_base);
   res->globals = new_Proj (res->start, mode_P, pns_globals);
   res->args    = new_Proj (res->start, mode_T, pns_args);
+#ifdef DEBUG_libfirm
+  res->graph_nr = get_irp_new_node_nr();
+#endif
+
 
   add_in_edge(res->start_block, projX);
   /*
@@ -208,6 +216,18 @@ void free_ir_graph (ir_graph *irg) {
    {attr type} get_irg_{attribute name} (ir_graph *irg);
    void set_irg_{attr name} (ir_graph *irg, {attr type} {attr}); */
 
+/* Outputs a unique number for this node */
+
+INLINE long
+get_irg_graph_nr(ir_graph *irg) {
+  assert(irg);
+#ifdef DEBUG_libfirm
+  return irg->graph_nr;
+#else
+  return 0;
+#endif
+}
+
 ir_node *
 get_irg_start_block (ir_graph *irg)
 {
@@ -395,6 +415,34 @@ set_irg_n_loc (ir_graph *irg, int n_loc)
 #endif
 }
 
+
+
+/* Returns the obstack associated with the graph. */
+struct obstack *get_irg_obstack(ir_graph *irg) {
+  return irg->obst;
+}
+
+/*
+ * Returns true if the node n is allocated on the storage of graph irg.
+ *
+ * Implementation is GLIBC specific as is uses the internal _obstack_chunk implementation.
+ */
+int node_is_in_irgs_storage(ir_graph *irg, ir_node *n)
+{
+  struct _obstack_chunk        *p;
+
+  /*
+   * checks wheater the ir_node pointer i on the obstack.
+   * A more sophisticated chaeck would test the "whole" ir_node
+   */
+  for (p = irg->obst->chunk; p; p = p->prev) {
+    if (((char *)p->contents <= (char *)n) && ((char *)n < (char *)p->limit))
+      return 1;
+  }
+
+  return 0;
+}
+
 irg_phase_state
 get_irg_phase_state (ir_graph *irg) {
   return irg->phase_state;