From 72b961b5b05ac239435b379ef340154c64134e25 Mon Sep 17 00:00:00 2001 From: Daniel Grund Date: Fri, 26 Aug 2005 08:33:22 +0000 Subject: [PATCH] Bugfixes --- ir/be/becopyheur.c | 2 +- ir/be/becopyilp.c | 14 ++++++-------- ir/be/becopyopt.c | 2 +- ir/be/becopyopt.h | 2 +- ir/be/becopyoptmain.c | 6 +++--- ir/be/beirgmod.c | 2 +- ir/be/bemain.c | 21 +++++++++++++++++---- ir/be/benode.c | 27 +++++++++++++++++++++++++-- ir/be/bespillilp.c | 8 +++++--- ir/be/bessadestr.c | 7 +++++-- ir/be/beutil.c | 1 + 11 files changed, 66 insertions(+), 26 deletions(-) diff --git a/ir/be/becopyheur.c b/ir/be/becopyheur.c index 4659f8f90..0d152ca1f 100644 --- a/ir/be/becopyheur.c +++ b/ir/be/becopyheur.c @@ -380,7 +380,7 @@ static int qnode_try_color(const qnode_t *qn) { /** * Determines a maximum weighted independent set with respect to * the interference and conflict edges of all nodes in a qnode. - * TODO: This runs in 2^n in worst case. Use a heuristic iff n>??? + * TODO: This runs in n! in worst case. Use a heuristic iff n>??? */ static INLINE void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) { ir_node **safe, **unsafe; diff --git a/ir/be/becopyilp.c b/ir/be/becopyilp.c index 3ff18daf7..8d1dcee1a 100644 --- a/ir/be/becopyilp.c +++ b/ir/be/becopyilp.c @@ -14,22 +14,20 @@ #include #endif +#define PATH_CONSTRAINTS_FOR_CLASSES +#undef PRECOLOR_MAX_CLIQUE #undef NO_NULL_COLORS #undef NO_NULL_COLORS_EXTRA_CSTS #undef NO_NULL_COLORS_WITH_COSTS - #if (defined(NO_NULL_COLORS_EXTRA_CSTS) || defined(NO_NULL_COLORS_WITH_COSTS)) && !defined(NO_NULL_COLORS) #error Chose your weapon! #endif -#undef PRECOLOR_MAX_CLIQUE -#define PATH_CONSTRAINTS_FOR_CLASSES - #include "irprog.h" #include #include -//#include +#include #include #include "xmalloc.h" #include "pset.h" @@ -890,8 +888,8 @@ static void pi_set_start_sol(problem_instance_t *pi) { */ static void pi_solve_ilp(problem_instance_t *pi) { pi_set_start_sol(pi); - lpp_solve_net(pi->curr_lp, LPP_HOST, LPP_SOLVER); -// lpp_solve_cplex(pi->curr_lp); +// lpp_solve_net(pi->curr_lp, LPP_HOST, LPP_SOLVER); + lpp_solve_cplex(pi->curr_lp); DBG((dbg, LEVEL_1, "Solution time: %.2f\n", pi->curr_lp->sol_time)); } @@ -948,7 +946,7 @@ static void pi_apply_solution(problem_instance_t *pi) { sol = xmalloc((pi->last_x_var - pi->first_x_var + 1) * sizeof(*sol)); state = lpp_get_solution(pi->curr_lp, sol, pi->first_x_var, pi->last_x_var); if (state != lpp_optimal) { - printf("Solution state is not 'optimal': %d\n", state); + printf("WARNING: Solution state is not 'optimal': %d\n", state); assert(state >= lpp_feasible && "The solution should at least be feasible!"); } for (i=0; ilast_x_var - pi->first_x_var + 1; ++i) { diff --git a/ir/be/becopyopt.c b/ir/be/becopyopt.c index e71937118..0118ae9b7 100644 --- a/ir/be/becopyopt.c +++ b/ir/be/becopyopt.c @@ -35,7 +35,7 @@ static firm_dbg_module_t *dbg = NULL; /** * Determines a maximum weighted independent set with respect to * the interference and conflict edges of all nodes in a qnode. - * TODO: This runs in 2^n in worst case. Use a heuristic iff n>??? + * TODO: This runs in n! in worst case. Use a heuristic iff n>??? */ static int ou_max_ind_set_costs(unit_t *ou) { be_chordal_env_t *chordal_env = ou->co->chordal_env; diff --git a/ir/be/becopyopt.h b/ir/be/becopyopt.h index c18e3879a..ef0b21f59 100644 --- a/ir/be/becopyopt.h +++ b/ir/be/becopyopt.h @@ -29,7 +29,7 @@ #include "bechordal_t.h" #include "bearch.h" -#define DEBUG_IRG "MergeSort.c__merge__datab" +#define DEBUG_IRG "!!deflate.c__longest_match__datab" #define DEBUG_IRG_LVL_CO SET_LEVEL_1 #define DEBUG_IRG_LVL_HEUR SET_LEVEL_1 #define DEBUG_IRG_LVL_ILP SET_LEVEL_1 diff --git a/ir/be/becopyoptmain.c b/ir/be/becopyoptmain.c index 6a326ee54..d372da655 100644 --- a/ir/be/becopyoptmain.c +++ b/ir/be/becopyoptmain.c @@ -70,9 +70,9 @@ void be_copy_opt(be_chordal_env_t *chordal_env) { copystat_add_heur_costs(costs_heur); DBG((dbg, LEVEL_1, "Heur costs: %3d\n", costs_heur)); #endif + assert(lower_bound == -1 || costs_heur == -1 || lower_bound <= costs_heur); #endif - assert(lower_bound <= costs_heur); #ifdef DO_ILP co_ilp_opt(co); @@ -82,9 +82,9 @@ void be_copy_opt(be_chordal_env_t *chordal_env) { copystat_add_opt_costs(costs_ilp); DBG((dbg, LEVEL_1, "Opt costs: %3d\n", costs_ilp)); #endif + assert(lower_bound == -1 || costs_ilp == -1 || lower_bound <= costs_ilp); + assert(costs_ilp == -1 || costs_heur == -1 || costs_ilp <= costs_heur); #endif - assert(lower_bound <= costs_ilp); - assert(costs_ilp <= costs_heur); free_copy_opt(co); } diff --git a/ir/be/beirgmod.c b/ir/be/beirgmod.c index e3b662df4..e307a4f5c 100644 --- a/ir/be/beirgmod.c +++ b/ir/be/beirgmod.c @@ -30,7 +30,7 @@ #include "beirgmod.h" #define DBG_MODULE firm_dbg_register("firm.be.irgmod") -#define DBG_LEVEL 0 // SET_LEVEL_4 +#define DBG_LEVEL SET_LEVEL_0 struct _dom_front_info_t { pmap *df_map; diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 5f2413b78..c87d5d53b 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -43,6 +43,11 @@ #include "beasm_asm_gnu.h" #undef DUMP_ALLOCATED +#define DUMP_PREPARED +#define DUMP_SPILL +#define DUMP_SCHED +#undef DUMP_POST + #define N_PHASES 256 @@ -115,9 +120,11 @@ static void prepare_graph(be_main_session_env_t *s) if (get_irg_loopinfo_state(s->irg) != (loopinfo_valid & loopinfo_cf_consistent)) construct_cf_backedges(s->irg); +#ifdef DUMP_PREPARED dump_dominator_information(true); dump_ir_block_graph(s->irg, "-prepared"); dump_dominator_information(false); +#endif } static void be_main_loop(void) @@ -135,6 +142,8 @@ static void be_main_loop(void) ir_graph *irg = get_irp_irg(i); be_main_session_env_t session; + dump_ir_block_graph(irg, "-be-begin"); + DBG((env.dbg, LEVEL_1, "====> IRG: %F\n", irg)); /* Init the session. */ @@ -145,7 +154,9 @@ static void be_main_loop(void) /* Schedule the graphs. */ list_sched(irg, trivial_selector); +#ifdef DUMP_SCHED dump_ir_block_graph_sched(irg, "-sched"); +#endif /* Verify the schedule */ sched_verify_irg(irg); @@ -161,8 +172,9 @@ static void be_main_loop(void) DBG((env.dbg, LEVEL_1, "----> Reg class: %s\n", cls->name)); be_spill_ilp(&session, cls); +#ifdef DUMP_SPILL dump_ir_block_graph_sched(session.irg, "-spill"); - +#endif be_liveness(irg); be_numbering(irg); be_check_pressure(&session, cls); @@ -186,9 +198,9 @@ static void be_main_loop(void) #endif copystat_collect_cls(chordal_env); -// dump_allocated_irg(env.arch_env, irg, "pre"); + dump_allocated_irg(env.arch_env, irg, "pre"); be_copy_opt(chordal_env); -// dump_allocated_irg(env.arch_env, irg, "post"); + dump_allocated_irg(env.arch_env, irg, "post"); be_ssa_destruction(chordal_env); be_ssa_destruction_check(chordal_env); @@ -197,8 +209,9 @@ static void be_main_loop(void) be_ra_chordal_done(chordal_env); be_numbering_done(irg); } +#ifdef DUMP_POST dump_ir_block_graph_sched(session.irg, "-post"); - +#endif copystat_dump(irg); } } diff --git a/ir/be/benode.c b/ir/be/benode.c index b7a53f047..714bb1746 100644 --- a/ir/be/benode.c +++ b/ir/be/benode.c @@ -251,8 +251,16 @@ be_node_set_irn_reg(const arch_irn_ops_t *_self, ir_node *irn, int idx, const arch_register_t *reg) { const arch_register_t **regs; + be_op_t *bo; + const be_node_factory_t *factory = + container_of(_self, const be_node_factory_t, irn_ops); idx = redir_proj((const ir_node **) &irn, idx); + bo = pmap_get(factory->irn_op_map, get_irn_op(irn)); + + if(!bo) + return; + regs = (const arch_register_t **) &irn->attr; regs[idx] = reg; } @@ -261,10 +269,25 @@ const arch_register_t * be_node_get_irn_reg(const arch_irn_ops_t *_self, const ir_node *irn, int idx) { const arch_register_t **regs; + be_op_t *bo; + int i, pos = arch_pos_make_out(idx); + const be_node_factory_t *factory = + container_of(_self, const be_node_factory_t, irn_ops); idx = redir_proj(&irn, idx); - regs = (const arch_register_t **) &irn->attr; - return regs[idx]; + bo = pmap_get(factory->irn_op_map, get_irn_op(irn)); + + if(!bo) + return NULL; + + for(i = 0; i < bo->n_pos; ++i) { + if(bo->pos[i] == pos) { + regs = (const arch_register_t **) &irn->attr; + return regs[idx]; + } + } + + return NULL; } arch_irn_class_t be_node_classify(const arch_irn_ops_t *_self, const ir_node *irn) diff --git a/ir/be/bespillilp.c b/ir/be/bespillilp.c index fa9731e4d..6898c2ce0 100644 --- a/ir/be/bespillilp.c +++ b/ir/be/bespillilp.c @@ -24,6 +24,7 @@ #include #include +#include #include "be_t.h" #include "belive_t.h" @@ -39,8 +40,8 @@ #define DBG_LEVEL SET_LEVEL_3 -#define DUMP_SOLUTION -#define DUMP_ILP +#undef DUMP_SOLUTION +#undef DUMP_ILP #define LPP_SERVER "i44pc52" #define LPP_SOLVER "cplex" @@ -645,7 +646,8 @@ void be_spill_ilp(const be_main_session_env_t *session_env, #endif DBG((si.dbg, LEVEL_1, "%F\n", session_env->irg)); - lpp_solve_net(si.lpp, LPP_SERVER, LPP_SOLVER); +// lpp_solve_net(si.lpp, LPP_SERVER, LPP_SOLVER); + lpp_solve_cplex(si.lpp); assert(lpp_is_sol_valid(si.lpp) && "ILP not feasible"); assert(lpp_is_sol_valid(si.lpp) && "solution of ILP must be valid"); diff --git a/ir/be/bessadestr.c b/ir/be/bessadestr.c index c302a5441..de7cbcf07 100644 --- a/ir/be/bessadestr.c +++ b/ir/be/bessadestr.c @@ -30,7 +30,7 @@ static firm_dbg_module_t *dbg = NULL; #define DEBUG_LVL SET_LEVEL_0 - +#undef DUMP_GRAPHS #define get_chordal_arch(ce) ((ce)->session_env->main_env->arch_env) #define get_reg(irn) arch_get_irn_register(get_chordal_arch(chordal_env), irn, 0) @@ -278,10 +278,13 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) { build_phi_rings(chordal_env); insert_all_perms(chordal_env); +#ifdef DUMP_GRAPHS dump_ir_block_graph_sched(irg, "-ssa_destr_perms_placed"); - +#endif set_regs_or_place_dupls(chordal_env); +#ifdef DUMP_GRAPHS dump_ir_block_graph_sched(irg, "-ssa_destr_regs_set"); +#endif pmap_destroy(perm_map); } diff --git a/ir/be/beutil.c b/ir/be/beutil.c index 04e7e1b9f..aa950cd1e 100644 --- a/ir/be/beutil.c +++ b/ir/be/beutil.c @@ -32,6 +32,7 @@ static void dump_allocated_block(ir_node *block, void *data) ir_fprintf(f, "node:{title:\"b%N\"\nlabel:\"%n\n", block, block); sched_foreach(block, irn) { const char *prefix = ""; + const arch_register_t *reg = arch_get_irn_register(env, irn, 0); ir_fprintf(f, "\n"); -- 2.20.1