Commit 18814151 authored by Matthias Braun's avatar Matthias Braun
Browse files

change spiller and related interface to use ir_graph* instead of be_irg_t*

[r27691]
parent 69849fc8
......@@ -98,13 +98,13 @@ void be_init_default_asm_constraint_flags(void);
/**
* 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);
/**
......
......@@ -2446,7 +2446,7 @@ void be_abi_fix_stack_nodes(be_abi_irg_t *env)
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,
......
......@@ -259,10 +259,10 @@ static void pre_spill(post_spill_env_t *pse, const arch_register_class_t *cls)
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");
......@@ -277,7 +277,8 @@ static void post_spill(post_spill_env_t *pse, int iteration)
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) {
......@@ -300,10 +301,10 @@ static void post_spill(post_spill_env_t *pse, int iteration)
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);
......@@ -443,7 +444,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
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");
......
......@@ -1233,7 +1233,7 @@ int co_solve_heuristic_new(copy_opt_t *co)
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);
......
......@@ -1428,7 +1428,7 @@ static int co_solve_heuristic_mst(copy_opt_t *co)
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;
......
......@@ -303,6 +303,6 @@ void be_sched_fix_flags(be_irg_t *birg, const arch_register_class_t *flag_cls,
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
if (changed) {
be_remove_dead_nodes_from_schedule(birg);
be_remove_dead_nodes_from_schedule(irg);
}
}
......@@ -129,7 +129,7 @@ ir_node *insert_Perm_after(be_irg_t *birg,
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);
......
......@@ -52,7 +52,7 @@ typedef struct _be_loop_info_t {
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)
......@@ -66,15 +66,16 @@ 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;
......@@ -110,7 +111,8 @@ static unsigned be_compute_block_pressure(const be_irg_t *birg,
* @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;
......@@ -126,7 +128,7 @@ static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop,
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);
......@@ -147,19 +149,18 @@ static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop,
}
/**
* 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));
......@@ -180,17 +181,16 @@ be_loopana_t *be_new_loop_pressure_cls(be_irg_t *birg,
* @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)) {
......
......@@ -36,31 +36,33 @@ typedef struct _be_loopana_t be_loopana_t;
/**
* 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
......@@ -812,7 +812,7 @@ void assure_constraints(be_irg_t *birg)
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);
......
......@@ -770,7 +770,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
/* 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);
......@@ -916,7 +916,8 @@ void be_main(FILE *file_handle, const char *cup_name)
#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);
......@@ -926,7 +927,7 @@ unsigned be_put_ignore_regs(const be_irg_t *birg, const arch_register_class_t *c
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);
}
......@@ -1934,14 +1934,14 @@ static void spill(void)
{
/* 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);
......@@ -1987,10 +1987,10 @@ static void be_pref_alloc(be_irg_t *new_birg)
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);
......
......@@ -156,14 +156,12 @@ static void remove_dead_nodes_walker(ir_node *block, void *data)
}
}
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);
......
......@@ -93,7 +93,7 @@ void sched_remove(ir_node *irn);
* 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)
......
......@@ -50,7 +50,7 @@
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;
......@@ -58,8 +58,8 @@ static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node)
{
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);
......@@ -239,14 +239,13 @@ static void pre_spill_prepare_constr_walker(ir_node *block, void *data)
}
}
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);
......@@ -274,11 +273,11 @@ void be_register_spiller(const char *name, be_spiller_t *spiller)
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);
......
......@@ -40,10 +40,10 @@ typedef struct be_spiller_t {
/**
* 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;
/**
......@@ -58,16 +58,16 @@ void be_register_spiller(const char *name, be_spiller_t *spiller);
/**
* 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
......@@ -927,10 +927,9 @@ static void fix_block_borders(ir_node *block, void *data)
}
}
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));
......@@ -952,11 +951,11 @@ static void be_spill_belady(be_irg_t *birg, const arch_register_class_t *rcls)
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");
......
......@@ -1468,17 +1468,16 @@ static void collect_blocks(ir_node *bl, void *data)
* 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;
......@@ -1493,7 +1492,7 @@ static void be_spill_belady(be_irg_t *birg, const arch_register_class_t *cls)
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);
......
......@@ -377,17 +377,16 @@ static void spill_block(ir_node *block, void *data)
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));
......
......@@ -98,7 +98,6 @@ struct spill_env_t {
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
......@@ -148,15 +147,13 @@ static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value)
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;
......@@ -994,7 +991,7 @@ void be_insert_spills_reloads(spill_env_t *env)
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);
......@@ -1018,7 +1015,7 @@ void be_insert_spills_reloads(spill_env_t *env)
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 */
......@@ -1046,9 +1043,9 @@ void be_insert_spills_reloads(spill_env_t *env)
/* 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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment