/**
* Put the registers to be ignored in this IRG into a bitset.
- * @param birg The backend IRG data structure.
+ * @param irg The graph
* @param cls The register class.
* @param bs The bitset (may be NULL).
* @return The number of registers to be ignored.
*/
-unsigned be_put_ignore_regs(const be_irg_t *birg,
- const arch_register_class_t *cls, bitset_t *bs);
+unsigned be_put_ignore_regs(const ir_graph *irg,
+ const arch_register_class_t *cls, bitset_t *bs);
/**
return;
}
- be_ssa_construction_init(&senv, birg);
+ be_ssa_construction_init(&senv, irg);
be_ssa_construction_add_copies(&senv, walker_env.sp_nodes,
ARR_LEN(walker_env.sp_nodes));
be_ssa_construction_fix_users_array(&senv, walker_env.sp_nodes,
stat_ev_do(pse->pre_spill_cost = be_estimate_irg_costs(irg, birg->exec_freq));
/* put all ignore registers into the ignore register set. */
- be_put_ignore_regs(birg, pse->cls, chordal_env->ignore_colors);
+ be_put_ignore_regs(irg, pse->cls, chordal_env->ignore_colors);
be_timer_push(T_RA_CONSTR);
- be_pre_spill_prepare_constr(chordal_env->birg, chordal_env->cls);
+ be_pre_spill_prepare_constr(irg, chordal_env->cls);
be_timer_pop(T_RA_CONSTR);
dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "constr-pre");
be_irg_t *birg = pse->birg;
ir_graph *irg = birg->irg;
int colors_n = arch_register_class_n_regs(chordal_env->cls);
- int allocatable_regs = colors_n - be_put_ignore_regs(birg, chordal_env->cls, NULL);
+ int allocatable_regs
+ = colors_n - be_put_ignore_regs(irg, chordal_env->cls, NULL);
/* some special classes contain only ignore regs, no work to be done */
if (allocatable_regs > 0) {
be_timer_push(T_VERIFY);
if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
be_verify_schedule(birg);
- be_verify_register_pressure(birg, pse->cls, irg);
+ be_verify_register_pressure(irg, pse->cls);
} else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
assert(be_verify_schedule(birg) && "Schedule verification failed");
- assert(be_verify_register_pressure(birg, pse->cls, irg)
+ assert(be_verify_register_pressure(irg, pse->cls)
&& "Register pressure verification failed");
}
be_timer_pop(T_VERIFY);
pre_spill(&pse, cls);
be_timer_push(T_RA_SPILL);
- be_do_spill(birg, cls);
+ be_do_spill(irg, cls);
be_timer_pop(T_RA_SPILL);
dump(BE_CH_DUMP_SPILL, irg, pse.cls, "spill");
env.co = co;
env.n_regs = co->cls->n_regs;
env.ignore_regs = bitset_alloca(co->cls->n_regs);
- be_put_ignore_regs(co->cenv->birg, co->cls, env.ignore_regs);
+ be_put_ignore_regs(co->cenv->irg, co->cls, env.ignore_regs);
FIRM_DBG_REGISTER(env.dbg, "firm.be.co2");
INIT_LIST_HEAD(&env.cloud_head);
phase_init(&mst_env.ph, co->irg, co_mst_irn_init);
phase_set_private(&mst_env.ph, &mst_env);
- k = be_put_ignore_regs(co->cenv->birg, co->cls, ignore_regs);
+ k = be_put_ignore_regs(co->cenv->irg, co->cls, ignore_regs);
k = n_regs - k;
mst_env.n_regs = n_regs;
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
if (changed) {
- be_remove_dead_nodes_from_schedule(birg);
+ be_remove_dead_nodes_from_schedule(irg);
}
}
curr = proj;
- be_ssa_construction_init(&senv, birg);
+ be_ssa_construction_init(&senv, birg->irg);
be_ssa_construction_add_copy(&senv, perm_op);
be_ssa_construction_add_copy(&senv, proj);
be_ssa_construction_fix_users(&senv, perm_op);
struct _be_loopana_t {
set *data;
- be_irg_t *birg;
+ ir_graph *irg;
};
static int cmp_loop_info(const void *a, const void *b, size_t size)
/**
* Compute the highest register pressure in a block.
- * @param birg The graph.
+ * @param irg The graph.
* @param block The block to compute pressure for.
* @param cls The register class to compute pressure for.
* @return The highest register pressure in the given block.
*/
-static unsigned be_compute_block_pressure(const be_irg_t *birg,
- ir_node *block, const arch_register_class_t *cls)
+static unsigned be_compute_block_pressure(const ir_graph *irg,
+ ir_node *block,
+ const arch_register_class_t *cls)
{
- be_lv_t *lv = be_get_irg_liveness(birg->irg);
+ be_lv_t *lv = be_get_irg_liveness(irg);
ir_nodeset_t live_nodes;
ir_node *irn;
int max_live;
* @param cls The register class to compute pressure for.
* @return The highest register pressure in the given loop.
*/
-static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop, const arch_register_class_t *cls)
+static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop,
+ const arch_register_class_t *cls)
{
int i, max;
unsigned pressure;
loop_element elem = get_loop_element(loop, i);
if (*elem.kind == k_ir_node)
- son_pressure = be_compute_block_pressure(loop_ana->birg, elem.node, cls);
+ son_pressure = be_compute_block_pressure(loop_ana->irg, elem.node, cls);
else {
assert(*elem.kind == k_ir_loop);
son_pressure = be_compute_loop_pressure(loop_ana, elem.son, cls);
}
/**
- * Compute the register pressure for a class of all loops in the birg.
- * @param birg The backend irg object
+ * Compute the register pressure for a class of all loops in a graph
+ * @param irg The graph
* @param cls The register class to compute the pressure for
* @return The loop analysis object.
*/
-be_loopana_t *be_new_loop_pressure_cls(be_irg_t *birg,
+be_loopana_t *be_new_loop_pressure_cls(ir_graph *irg,
const arch_register_class_t *cls)
{
- ir_graph *irg = be_get_birg_irg(birg);
be_loopana_t *loop_ana = XMALLOC(be_loopana_t);
loop_ana->data = new_set(cmp_loop_info, 16);
- loop_ana->birg = birg;
+ loop_ana->irg = irg;
DBG((dbg, LEVEL_1, "\n=====================================================\n", cls->name));
DBG((dbg, LEVEL_1, " Computing register pressure for class %s:\n", cls->name));
* @param birg The backend irg object
* @return The loop analysis object.
*/
-be_loopana_t *be_new_loop_pressure(be_irg_t *birg,
+be_loopana_t *be_new_loop_pressure(ir_graph *irg,
const arch_register_class_t *cls)
{
- ir_graph *irg = be_get_birg_irg(birg);
be_loopana_t *loop_ana = XMALLOC(be_loopana_t);
ir_loop *irg_loop = get_irg_loop(irg);
const arch_env_t *arch_env = be_get_irg_arch_env(irg);
int i;
loop_ana->data = new_set(cmp_loop_info, 16);
- loop_ana->birg = birg;
+ loop_ana->irg = irg;
/* construct control flow loop tree */
if (! (get_irg_loopinfo_state(irg) & loopinfo_cf_consistent)) {
/**
* Compute the register pressure for a class of all loops in the birg.
- * @param birg The backend irg object
+ * @param irg The graph
* @param cls The register class to compute the pressure for
* @return The loop analysis object.
*/
-be_loopana_t *be_new_loop_pressure_cls(be_irg_t *birg, const arch_register_class_t *cls);
+be_loopana_t *be_new_loop_pressure_cls(ir_graph *irg,
+ const arch_register_class_t *cls);
/**
* Compute the register pressure of all loops in the birg.
- * @param birg The backend irg object
+ * @param irg The graph
* @param cls register class to compute loop pressure for,
* if NULL computes for all classes
* @return The loop analysis object.
*/
-be_loopana_t *be_new_loop_pressure(be_irg_t *birg,
+be_loopana_t *be_new_loop_pressure(ir_graph *irg,
const arch_register_class_t *cls);
/**
* Returns the computed register pressure for the given class and loop.
* @return The pressure or INT_MAX if not found
*/
-unsigned be_get_loop_pressure(be_loopana_t *loop_ana, const arch_register_class_t *cls, ir_loop *loop);
+unsigned be_get_loop_pressure(be_loopana_t *loop_ana,
+ const arch_register_class_t *cls, ir_loop *loop);
/**
* Frees loop analysis object.
*/
void be_free_loop_pressure(be_loopana_t *loop_ana);
-#endif /* FIRM_BE_BELOOPANA_H */
+#endif
DB((dbg_constr, LEVEL_1, "\n"));
/* introduce the copies for the operand and it's copies */
- be_ssa_construction_init(&senv, birg);
+ be_ssa_construction_init(&senv, irg);
be_ssa_construction_add_copy(&senv, map_entry.node);
be_ssa_construction_add_copies(&senv, nodes, n);
be_ssa_construction_fix_users(&senv, map_entry.node);
/* fix stack offsets */
be_timer_push(T_ABI);
be_abi_fix_stack_nodes(birg->abi);
- be_remove_dead_nodes_from_schedule(birg);
+ be_remove_dead_nodes_from_schedule(irg);
be_abi_fix_stack_bias(birg->abi);
be_timer_pop(T_ABI);
#endif
}
-unsigned be_put_ignore_regs(const be_irg_t *birg, const arch_register_class_t *cls, bitset_t *bs)
+unsigned be_put_ignore_regs(const ir_graph *irg,
+ const arch_register_class_t *cls, bitset_t *bs)
{
if (bs == NULL)
bs = bitset_alloca(cls->n_regs);
assert(bitset_size(bs) == cls->n_regs);
arch_put_non_ignore_regs(cls, bs);
bitset_flip_all(bs);
- be_abi_put_ignore_regs(birg->abi, cls, bs);
+ be_abi_put_ignore_regs(be_birg_from_irg(irg)->abi, cls, bs);
return bitset_popcount(bs);
}
{
/* make sure all nodes show their real register pressure */
be_timer_push(T_RA_CONSTR);
- be_pre_spill_prepare_constr(birg, cls);
+ be_pre_spill_prepare_constr(irg, cls);
be_timer_pop(T_RA_CONSTR);
dump(DUMP_RA, irg, "-spillprepare");
/* spill */
be_timer_push(T_RA_SPILL);
- be_do_spill(birg, cls);
+ be_do_spill(irg, cls);
be_timer_pop(T_RA_SPILL);
be_timer_push(T_RA_SPILL_APPLY);
be_timer_push(T_VERIFY);
if (birg->main_env->options->vrfy_option == BE_VRFY_WARN) {
be_verify_schedule(birg);
- be_verify_register_pressure(birg, cls, irg);
+ be_verify_register_pressure(irg, cls);
} else if (birg->main_env->options->vrfy_option == BE_VRFY_ASSERT) {
assert(be_verify_schedule(birg) && "Schedule verification failed");
- assert(be_verify_register_pressure(birg, cls, irg)
+ assert(be_verify_register_pressure(irg, cls)
&& "Register pressure verification failed");
}
be_timer_pop(T_VERIFY);
}
}
-void be_remove_dead_nodes_from_schedule(be_irg_t *birg)
+void be_remove_dead_nodes_from_schedule(ir_graph *irg)
{
- ir_graph *irg = be_get_birg_irg(birg);
-
remove_dead_nodes_env_t env;
env.reachable = bitset_alloca(get_irg_last_idx(irg));
- env.lv = be_get_irg_liveness(irg);
- env.irg = irg;
+ env.lv = be_get_irg_liveness(irg);
+ env.irg = irg;
// mark all reachable nodes
irg_walk_graph(irg, mark_dead_nodes_walker, NULL, &env);
* Removes dead nodes from schedule
* @param irg the graph
*/
-void be_remove_dead_nodes_from_schedule(be_irg_t *birg);
+void be_remove_dead_nodes_from_schedule(ir_graph *irg);
#define SCHED_INITIAL_GRANULARITY (1 << 14)
#define get_irn_sched_info(irn) (&be_get_info(skip_Proj_const(irn))->sched_info)
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
typedef struct be_pre_spill_env_t {
- be_irg_t *birg;
+ ir_graph *irg;
const arch_register_class_t *cls;
} be_pre_spill_env_t;
{
const arch_register_class_t *cls = env->cls;
ir_node *block = get_nodes_block(node);
- const be_irg_t *birg = env->birg;
- be_lv_t *lv = birg->lv;
+ const ir_graph *irg = env->irg;
+ be_lv_t *lv = be_get_irg_liveness(irg);
unsigned *tmp = NULL;
unsigned *def_constr = NULL;
int arity = get_irn_arity(node);
}
}
-void be_pre_spill_prepare_constr(be_irg_t *birg,
+void be_pre_spill_prepare_constr(ir_graph *irg,
const arch_register_class_t *cls)
{
- ir_graph *irg = birg->irg;
be_pre_spill_env_t env;
memset(&env, 0, sizeof(env));
- env.birg = birg;
- env.cls = cls;
+ env.irg = irg;
+ env.cls = cls;
be_assure_liveness(irg);
be_add_module_to_list(&spillers, name, spiller);
}
-void be_do_spill(be_irg_t *birg, const arch_register_class_t *cls)
+void be_do_spill(ir_graph *irg, const arch_register_class_t *cls)
{
assert(selected_spiller != NULL);
- selected_spiller->spill(birg, cls);
+ selected_spiller->spill(irg, cls);
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spilloptions);
/**
* The spill function.
*
- * @param birg the graph to spill on
+ * @param irg the graph to spill on
* @param cls the register class to spill
*/
- void (*spill)(be_irg_t *birg, const arch_register_class_t *cls);
+ void (*spill)(ir_graph *irg, const arch_register_class_t *cls);
} be_spiller_t;
/**
/**
* Execute the selected spill algorithm
*
- * @param birg the graph to spill on
+ * @param irg the graph to spill on
* @param cls the register class to spill
*/
-void be_do_spill(be_irg_t *birg, const arch_register_class_t *cls);
+void be_do_spill(ir_graph *irg, const arch_register_class_t *cls);
/**
* Adds additional copies, so constraints needing additional registers to be
* solved correctly induce the additional register pressure.
*/
-void be_pre_spill_prepare_constr(be_irg_t *birg,
+void be_pre_spill_prepare_constr(ir_graph *irg,
const arch_register_class_t *cls);
#endif
}
}
-static void be_spill_belady(be_irg_t *birg, const arch_register_class_t *rcls)
+static void be_spill_belady(ir_graph *irg, const arch_register_class_t *rcls)
{
int i;
- ir_graph *irg = be_get_birg_irg(birg);
be_liveness_assure_sets(be_assure_liveness(irg));
obstack_init(&obst);
cls = rcls;
lv = be_get_irg_liveness(irg);
- n_regs = cls->n_regs - be_put_ignore_regs(birg, cls, NULL);
+ n_regs = cls->n_regs - be_put_ignore_regs(irg, cls, NULL);
ws = new_workset();
uses = be_begin_uses(irg, lv);
- loop_ana = be_new_loop_pressure(birg, cls);
- senv = be_new_spill_env(birg);
+ loop_ana = be_new_loop_pressure(irg, cls);
+ senv = be_new_spill_env(irg);
blocklist = be_get_cfgpostorder(irg);
stat_ev_tim_pop("belady_time_init");
* In the transformed graph, the register pressure never exceeds the number
* of available registers.
*
- * @param birg The backend graph
+ * @param irg The graph
* @param cls The register class to spill
*/
-static void be_spill_belady(be_irg_t *birg, const arch_register_class_t *cls)
+static void be_spill_belady(ir_graph *irg, const arch_register_class_t *cls)
{
- ir_graph *irg = be_get_birg_irg(birg);
belady_env_t env;
int i, n_regs;
/* some special classes contain only ignore regs, nothing to do then */
- n_regs = cls->n_regs - be_put_ignore_regs(birg, cls, NULL);
+ n_regs = cls->n_regs - be_put_ignore_regs(irg, cls, NULL);
if (n_regs == 0)
return;
env.dfs = env.lv->dfs;
env.n_regs = n_regs;
env.ws = new_workset(&env, &env.ob);
- env.senv = be_new_spill_env(birg);
+ env.senv = be_new_spill_env(irg);
env.ef = be_get_irg_exec_freq(irg);
env.spilled = bitset_irg_obstack_alloc(&env.ob, irg);
env.extra_spilled = ir_nodeset_new(64);
ir_nodeset_destroy(&live_nodes);
}
-static void be_spill_daemel(be_irg_t *birg, const arch_register_class_t *new_cls)
+static void be_spill_daemel(ir_graph *irg, const arch_register_class_t *new_cls)
{
- ir_graph *irg = be_get_birg_irg(birg);
- n_regs = new_cls->n_regs - be_put_ignore_regs(birg, new_cls, NULL);
+ n_regs = new_cls->n_regs - be_put_ignore_regs(irg, new_cls, NULL);
if (n_regs == 0)
return;
be_liveness_assure_sets(be_assure_liveness(irg));
- spill_env = be_new_spill_env(birg);
+ spill_env = be_new_spill_env(irg);
cls = new_cls;
lv = be_get_irg_liveness(irg);
spilled_nodes = bitset_malloc(get_irg_last_idx(irg));
const arch_env_t *arch_env;
ir_graph *irg;
struct obstack obst;
- be_irg_t *birg;
int spill_cost; /**< the cost of a single spill node */
int reload_cost; /**< the cost of a reload node */
set *spills; /**< all spill_info_t's, which must be
return res;
}
-spill_env_t *be_new_spill_env(be_irg_t *birg)
+spill_env_t *be_new_spill_env(ir_graph *irg)
{
- const arch_env_t *arch_env = birg->main_env->arch_env;
- ir_graph *irg = be_get_birg_irg(birg);
+ const arch_env_t *arch_env = be_get_irg_arch_env(irg);
spill_env_t *env = XMALLOC(spill_env_t);
env->spills = new_set(cmp_spillinfo, 1024);
env->irg = irg;
- env->birg = birg;
env->arch_env = arch_env;
ir_nodeset_init(&env->mem_phis);
env->spill_cost = arch_env->spill_cost;
be_ssa_construction_env_t senv;
/* be_lv_t *lv = be_get_irg_liveness(env->irg); */
- be_ssa_construction_init(&senv, env->birg);
+ be_ssa_construction_init(&senv, env->irg);
be_ssa_construction_add_copy(&senv, to_spill);
be_ssa_construction_add_copies(&senv, copies, ARR_LEN(copies));
be_ssa_construction_fix_users(&senv, to_spill);
be_ssa_construction_env_t senv;
- be_ssa_construction_init(&senv, env->birg);
+ be_ssa_construction_init(&senv, env->irg);
spill = si->spills;
for ( ; spill != NULL; spill = spill->next) {
/* maybe we rematerialized the value and need no spill */
/* Matze: In theory be_ssa_construction should take care of the liveness...
* try to disable this again in the future */
- be_liveness_invalidate(env->birg->lv);
+ be_liveness_invalidate(be_get_irg_liveness(env->irg));
- be_remove_dead_nodes_from_schedule(env->birg);
+ be_remove_dead_nodes_from_schedule(env->irg);
be_timer_pop(T_RA_SPILL_APPLY);
}
/**
* Creates a new spill environment.
*/
-spill_env_t *be_new_spill_env(be_irg_t *birg);
+spill_env_t *be_new_spill_env(ir_graph *irg);
/**
* Deletes a spill environment.
/**
* Collect spill/reload cost statistics for a graph.
- * @param birg The backend graph.
+ * @param irg The graph.
* @param costs A struct which will be filled with the costs.
*/
-void be_get_total_spill_costs(be_irg_t *birg, be_total_spill_costs_t *costs);
+void be_get_total_spill_costs(ir_graph *irg, be_total_spill_costs_t *costs);
/**
* Check, if a node is rematerializable.
}
}
-void be_ssa_construction_init(be_ssa_construction_env_t *env, be_irg_t *birg)
+void be_ssa_construction_init(be_ssa_construction_env_t *env, ir_graph *irg)
{
- ir_graph *irg = be_get_birg_irg(birg);
ir_node *sb = get_irg_start_block(irg);
int n_blocks = get_Block_dom_max_subtree_pre_num(sb);
* @param env an SSA empty construction environment
* @param birg
*/
-void be_ssa_construction_init(be_ssa_construction_env_t *env, be_irg_t *birg);
+void be_ssa_construction_init(be_ssa_construction_env_t *env, ir_graph *irg);
void be_ssa_construction_add_copy(be_ssa_construction_env_t *env,
ir_node *value);
int i, len;
ir_node **phis;
- be_ssa_construction_init(&senv, birg);
+ be_ssa_construction_init(&senv, irg);
if (sched_is_scheduled(info->value))
be_ssa_construction_add_copy(&senv, info->value);
be_ssa_construction_add_copies(&senv,
}
/* some nodes might be dead now. */
- be_remove_dead_nodes_from_schedule(birg);
+ be_remove_dead_nodes_from_schedule(irg);
ir_nodemap_destroy(&env.spill_infos);
be_end_uses(env.uses);
/**
* Start a walk over the irg and check the register pressure.
*/
-int be_verify_register_pressure(const be_irg_t *birg,
- const arch_register_class_t *cls, ir_graph *irg)
+int be_verify_register_pressure(ir_graph *irg, const arch_register_class_t *cls)
{
be_verify_register_pressure_env_t env;
env.lv = be_liveness(irg);
env.irg = irg;
env.cls = cls;
- env.registers_available = env.cls->n_regs - be_put_ignore_regs(birg, env.cls, NULL);
+ env.registers_available
+ = env.cls->n_regs - be_put_ignore_regs(irg, env.cls, NULL);
env.problem_found = 0;
be_liveness_assure_sets(env.lv);
* Verifies, that the register pressure for a given register class doesn't exceed the limit
* of available registers.
*
- * @param birg The backend IRG.
- * @param cls The register class to check.
* @param irg The irg to check.
+ * @param cls The register class to check.
* @return 1 if the pressure is valid, 0 otherwise.
*/
-int be_verify_register_pressure(const be_irg_t *birg, const arch_register_class_t* cls, ir_graph *irg);
+int be_verify_register_pressure(ir_graph *irg,
+ const arch_register_class_t* cls);
/**
* Does some sanity checks on the schedule.
return;
}
- be_ssa_construction_init(&senv, birg);
+ be_ssa_construction_init(&senv, irg);
be_ssa_construction_add_copies(&senv, env.state_nodes,
ARR_LEN(env.state_nodes));
be_ssa_construction_fix_users(&senv, initial_value);