split irg and irp resources, add IRP_RESOURCE_TYPE_LINK
authorMatthias Braun <matze@braunis.de>
Thu, 4 Aug 2011 07:57:52 +0000 (09:57 +0200)
committerMatthias Braun <matze@braunis.de>
Thu, 4 Aug 2011 10:35:28 +0000 (12:35 +0200)
14 files changed:
include/libfirm/irgraph.h
include/libfirm/irprog.h
ir/ana/rta.c
ir/be/beabi.c
ir/be/bestabs.c
ir/ir/irgraph.c
ir/ir/irprog.c
ir/opt/garbage_collect.c
ir/opt/opt_frame.c
ir/opt/opt_inline.c
ir/opt/scalar_replace.c
ir/tr/tr_inheritance.c
ir/tr/type.c
ir/tr/typewalk.c

index 71fbc55..2a72e6a 100644 (file)
@@ -483,16 +483,7 @@ typedef enum ir_resources_t {
        IR_RESOURCE_IRN_VISITED   = 1 << 2,  /**< IR-node visited flags are used. */
        IR_RESOURCE_IRN_LINK      = 1 << 3,  /**< IR-node link fields are used. */
        IR_RESOURCE_LOOP_LINK     = 1 << 4,  /**< IR-loop link fields are used. */
-       IR_RESOURCE_PHI_LIST      = 1 << 5,  /**< Block Phi lists are used. */
-       IR_RESOURCE_IRG_LINK      = 1 << 6,  /**< IR-graph link fields used. */
-
-       /* global (irp) resources */
-       IR_RESOURCE_ENTITY_LINK   = 1 << 8,  /**< IR-entity link fields are used. */
-       IR_RESOURCE_TYPE_VISITED  = 1 << 9,  /**< type visited flags */
-
-       /* masks */
-       IR_RESOURCE_LOCAL_MASK    = 0x00FF,  /**< Mask for all local resources. */
-       IR_RESOURCE_GLOBAL_MASK   = 0xFF00   /**< Mask for all global resources. */
+       IR_RESOURCE_PHI_LIST      = 1 << 5   /**< Block Phi lists are used. */
 } ir_resources_t;
 ENUM_BITSET(ir_resources_t)
 
index 66c695c..c133e0f 100644 (file)
@@ -74,14 +74,23 @@ ENUM_COUNTABLE(ir_segment_t)
  */
 FIRM_API ir_prog *irp;
 
+typedef enum irp_resources_t {
+       IRP_RESOURCE_NONE         = 0,
+       IRP_RESOURCE_IRG_LINK     = 1 << 0,
+       IRP_RESOURCE_ENTITY_LINK  = 1 << 1,
+       IRP_RESOURCE_TYPE_VISITED = 1 << 2,
+       IRP_RESOURCE_TYPE_LINK    = 1 << 3,
+} irp_resources_t;
+ENUM_BITSET(irp_resources_t)
+
 #ifndef NDEBUG
-FIRM_API void irp_reserve_resources(ir_prog *irp, ir_resources_t resources);
-FIRM_API void irp_free_resources(ir_prog *irp, ir_resources_t resources);
-FIRM_API ir_resources_t irp_resources_reserved(const ir_prog *irp);
+FIRM_API void irp_reserve_resources(ir_prog *irp, irp_resources_t resources);
+FIRM_API void irp_free_resources(ir_prog *irp, irp_resources_t resources);
+FIRM_API irp_resources_t irp_resources_reserved(const ir_prog *irp);
 #else
-#define irp_reserve_resources(irp, resources)
-#define irp_free_resources(irp, resources)
-#define irp_resources_reserved(irp)   0
+#define irp_reserve_resources(irp, resources) (void)0
+#define irp_free_resources(irp, resources)    (void)0
+#define irp_resources_reserved(irp)           0
 #endif
 
 /**
index ea0ae3f..8a829b5 100644 (file)
@@ -361,7 +361,7 @@ void rta_delete_dead_graphs(void)
        size_t   i, n_dead_irgs, n_graphs = get_irp_n_irgs();
        ir_graph *irg, *next_irg, *dead_irgs;
 
-       irp_reserve_resources(irp, IR_RESOURCE_IRG_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_IRG_LINK);
 
        n_dead_irgs = 0;
        dead_irgs = NULL;
@@ -384,7 +384,7 @@ void rta_delete_dead_graphs(void)
 
        DB((dbg, LEVEL_1, "RTA: dead methods = %zu\n", n_dead_irgs));
 
-       irp_free_resources(irp, IR_RESOURCE_IRG_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_IRG_LINK);
 }
 
 /* Clean up the RTA data structures.  Call this after calling rta_init */
index 97b7cec..ca2d907 100644 (file)
@@ -1685,7 +1685,7 @@ static void modify_irg(ir_graph *irg)
 
        old_mem = get_irg_initial_mem(irg);
 
-       irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        /* set the links of all frame entities to NULL, we use it
           to detect if an entity is already linked in the value_param_list */
@@ -1751,7 +1751,7 @@ static void modify_irg(ir_graph *irg)
        fix_address_of_parameter_access(env, irg, ctx.value_param_list);
 
        DEL_ARR_F(ctx.value_param_list);
-       irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        /* Fill the argument vector */
        arg_tuple = get_irg_args(irg);
index eca305a..759079b 100644 (file)
@@ -617,9 +617,14 @@ static void gen_types(stabs_handle *h)
 
        env.h  = h;
        env.wq = new_waitq();
+
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_LINK);
        type_walk(NULL, walk_type, &env);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_LINK);
+
        finish_types(&env);
        del_waitq(env.wq);
+
 }  /* gen_types */
 
 
index f6f381a..63a4092 100644 (file)
@@ -396,7 +396,7 @@ ir_graph *create_irg_copy(ir_graph *irg)
        new_identities(res);
 
        /* clone the frame type here for safety */
-       irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK);
        res->frame_type  = clone_frame_type(irg->frame_type);
 
        res->phase_state = irg->phase_state;
@@ -426,7 +426,7 @@ ir_graph *create_irg_copy(ir_graph *irg)
        res->estimated_node_count = irg->estimated_node_count;
 
        ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
-       irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        return res;
 }
@@ -883,7 +883,6 @@ void irg_invalidate_phases(ir_graph *irg)
 #ifndef NDEBUG
 void ir_reserve_resources(ir_graph *irg, ir_resources_t resources)
 {
-       assert((resources & ~IR_RESOURCE_LOCAL_MASK) == 0);
        assert((irg->reserved_resources & resources) == 0);
        irg->reserved_resources |= resources;
 }
index daeb232..f4ce08b 100644 (file)
@@ -507,20 +507,19 @@ ident *get_irp_asm(size_t pos)
 }
 
 #ifndef NDEBUG
-void irp_reserve_resources(ir_prog *irp, ir_resources_t resources)
+void irp_reserve_resources(ir_prog *irp, irp_resources_t resources)
 {
-       assert((resources & ~IR_RESOURCE_GLOBAL_MASK) == 0);
        assert((irp->reserved_resources & resources) == 0);
        irp->reserved_resources |= resources;
 }
 
-void irp_free_resources(ir_prog *irp, ir_resources_t resources)
+void irp_free_resources(ir_prog *irp, irp_resources_t resources)
 {
        assert((irp->reserved_resources & resources) == resources);
        irp->reserved_resources &= ~resources;
 }
 
-ir_resources_t irp_resources_reserved(const ir_prog *irp)
+irp_resources_t irp_resources_reserved(const ir_prog *irp)
 {
        return irp->reserved_resources;
 }
index 64c0a67..9ea12b8 100644 (file)
@@ -155,7 +155,7 @@ void garbage_collect_entities(void)
        FIRM_DBG_REGISTER(dbg, "firm.opt.garbagecollect");
 
        /* start a type walk for all externally visible entities */
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        inc_max_irg_visited();
 
@@ -185,7 +185,7 @@ void garbage_collect_entities(void)
                ir_type *type = get_segment_type(s);
                garbage_collect_in_segment(type);
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 ir_prog_pass_t *garbage_collect_entities_pass(const char *name)
index 1e6420c..7699322 100644 (file)
@@ -49,7 +49,7 @@ void opt_frame_irg(ir_graph *irg)
        if (n <= 0)
                return;
 
-       irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        /* clear all entity links */
        for (i = n; i > 0;) {
@@ -109,7 +109,7 @@ void opt_frame_irg(ir_graph *irg)
                /* we changed the frame type, its layout should be redefined */
                set_type_state(frame_tp, layout_undefined);
        }
-       irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 }
 
 ir_graph_pass_t *opt_frame_irg_pass(const char *name)
index df5fbb0..6c5e336 100644 (file)
@@ -429,7 +429,7 @@ int inline_method(ir_node *call, ir_graph *called_graph)
 
        /* entitiy link is used to link entities on old stackframe to the
         * new stackframe */
-       irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        /* copy entities and nodes */
        assert(!irn_visited(get_irg_end(called_graph)));
@@ -437,7 +437,7 @@ int inline_method(ir_node *call, ir_graph *called_graph)
        irg_walk_core(get_irg_end(called_graph), copy_node_inline, set_preds_inline,
                      irg);
 
-       irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        /* -- Merge the end of the inlined procedure with the call site -- */
        /* We will turn the old Call node into a Tuple with the following
index 33d7857..d87b402 100644 (file)
@@ -703,7 +703,7 @@ int scalar_replacement_opt(ir_graph *irg)
 
        /* we use the link field to store the VNUM */
        ir_reserve_resources(irg, IR_RESOURCE_IRN_LINK);
-       irp_reserve_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_reserve_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        /* Find possible scalar replacements */
        if (find_possible_replacements(irg)) {
@@ -775,7 +775,7 @@ int scalar_replacement_opt(ir_graph *irg)
        }
 
        ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
-       irp_free_resources(irp, IR_RESOURCE_ENTITY_LINK);
+       irp_free_resources(irp, IRP_RESOURCE_ENTITY_LINK);
 
        return res;
 }
index 191656d..9f5f1b4 100644 (file)
@@ -353,7 +353,7 @@ void compute_inh_transitive_closure(void)
        free_inh_transitive_closure();
 
        /* The 'down' relation */
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();  /* Inc twice: one if on stack, second if values computed. */
        inc_master_type_visited();
        for (i = 0; i < n_types; ++i) {
@@ -402,7 +402,7 @@ void compute_inh_transitive_closure(void)
        }
 
        irp->inh_trans_closure_state = inh_transitive_closure_valid;
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 /** Free memory occupied by the transitive closure information. */
index 2a11023..5627f25 100644 (file)
@@ -2079,7 +2079,7 @@ ir_type *clone_frame_type(ir_type *type)
 
        assert(is_frame_type(type));
        /* the entity link resource should be allocated if this function is called */
-       assert(irp_resources_reserved(irp) & IR_RESOURCE_ENTITY_LINK);
+       assert(irp_resources_reserved(irp) & IRP_RESOURCE_ENTITY_LINK);
 
        res = new_type_frame();
        for (i = 0, n = get_class_n_members(type); i < n; ++i) {
index b0725f3..bd0466e 100644 (file)
@@ -263,7 +263,7 @@ void type_walk(type_walk_func *pre, type_walk_func *post, void *env)
        size_t      i, n_types = get_irp_n_types();
        type_or_ent cont;
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        for (i = 0; i < n_types; ++i) {
                cont.typ = get_irp_type(i);
@@ -271,7 +271,7 @@ void type_walk(type_walk_func *pre, type_walk_func *post, void *env)
        }
        cont.typ = get_glob_type();
        do_type_walk(cont, pre, post, env);
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 void type_walk_prog(type_walk_func *pre, type_walk_func *post, void *env)
@@ -324,7 +324,7 @@ void type_walk_irg(ir_graph *irg,
           Here we initially increase the flag.  We only call do_type_walk that does
           not increase the flag.
        */
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        irg_walk(get_irg_end(irg), start_type_walk, NULL, &type_env);
 
@@ -335,7 +335,7 @@ void type_walk_irg(ir_graph *irg,
        do_type_walk(cont, pre, post, env);
 
        current_ir_graph = rem;
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 static void type_walk_s2s_2(type_or_ent tore,
@@ -418,7 +418,7 @@ void type_walk_super2sub(type_walk_func *pre,
        type_or_ent cont;
        size_t      i, n_types = get_irp_n_types();
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        cont.typ = get_glob_type();
        type_walk_s2s_2(cont, pre, post, env);
@@ -426,7 +426,7 @@ void type_walk_super2sub(type_walk_func *pre,
                cont.typ = get_irp_type(i);
                type_walk_s2s_2(cont, pre, post, env);
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 /*****************************************************************************/
@@ -504,7 +504,7 @@ void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env)
        size_t      i, n_types = get_irp_n_types();
        type_or_ent cont;
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        cont.typ = get_glob_type();
        type_walk_super_2(cont, pre, post, env);
@@ -512,7 +512,7 @@ void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env)
                cont.typ = get_irp_type(i);
                type_walk_super_2(cont, pre, post, env);
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 /*****************************************************************************/
@@ -556,7 +556,7 @@ void class_walk_super2sub(class_walk_func *pre,
        size_t i, n_types = get_irp_n_types();
        ir_type *tp;
 
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();
        for (i = 0; i < n_types; i++) {
                tp = get_irp_type(i);
@@ -568,7 +568,7 @@ void class_walk_super2sub(class_walk_func *pre,
                        class_walk_s2s_2(tp, pre, post, env);
                }
        }
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }