automatically generate most getter/setter functions of firm nodes
[libfirm] / ir / ir / irgraph.c
index 67ab88d..a4b8ae5 100644 (file)
@@ -48,6 +48,7 @@
 #include "iredges_t.h"
 #include "type_t.h"
 #include "irmemory.h"
+#include "irphase.h"
 
 #define INITIAL_IDX_IRN_MAP_SIZE 1024
 
@@ -119,8 +120,7 @@ static ir_graph *alloc_graph(void)
 {
        ir_graph *res;
        size_t   size = sizeof(ir_graph) + additional_graph_data_size;
-       char     *ptr = xmalloc(size);
-       memset(ptr, 0, size);
+       char     *ptr = XMALLOCNZ(char, size);
 
        res = (ir_graph *)(ptr + additional_graph_data_size);
        res->kind = k_ir_graph;
@@ -738,16 +738,6 @@ int get_irg_n_locs(ir_graph *irg)
                return irg->n_loc - 1;
 }
 
-void set_irg_n_loc(ir_graph *irg, int n_loc)
-{
-       if (get_opt_precise_exc_context())
-               irg->n_loc = n_loc + 1 + 1;
-       else
-               irg->n_loc = n_loc + 1;
-}
-
-
-
 /* Returns the obstack associated with the graph. */
 struct obstack *
 (get_irg_obstack)(const ir_graph *irg) {
@@ -1014,6 +1004,26 @@ void *get_irg_loc_description(ir_graph *irg, int n)
        return irg->loc_descriptions ? irg->loc_descriptions[n] : NULL;
 }
 
+void irg_register_phase(ir_graph *irg, ir_phase_id id, ir_phase *phase)
+{
+       assert(id <= PHASE_LAST);
+       assert(irg->phases[id] == NULL);
+       irg->phases[id] = phase;
+}
+
+void irg_invalidate_phases(ir_graph *irg)
+{
+       int p;
+       for (p = 0; p <= PHASE_LAST; ++p) {
+               ir_phase *phase = irg->phases[p];
+               if (phase == NULL)
+                       continue;
+
+               phase_free(phase);
+               irg->phases[p] = NULL;
+       }
+}
+
 #ifndef NDEBUG
 void ir_reserve_resources(ir_graph *irg, ir_resources_t resources)
 {