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)
*/
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
/**
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;
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 */
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 */
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);
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 */
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;
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;
}
#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;
}
}
#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;
}
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();
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)
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;) {
/* 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)
/* 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)));
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
/* 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)) {
}
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;
}
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) {
}
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. */
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) {
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);
}
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)
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);
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,
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);
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);
}
/*****************************************************************************/
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);
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);
}
/*****************************************************************************/
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);
class_walk_s2s_2(tp, pre, post, env);
}
}
- irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+ irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
}