Implement access functions for machine nodes with machine operands
[libfirm] / ir / be / bechordal_main.c
index b423b2c..3548395 100644 (file)
 
 
 void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
-       firm_dbg_module_t *dbg = chordal_env->dbg;
        const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
        struct obstack ob;
        pmap_entry *pme;
        ir_node **nodes, *n1, *n2;
        int i, o;
+       DEBUG_ONLY(firm_dbg_module_t *dbg = chordal_env->dbg;)
 
        /* Collect all irns */
        obstack_init(&ob);
@@ -98,13 +98,13 @@ void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
 static void check_pressure_walker(ir_node *bl, void *data)
 {
        be_chordal_env_t *env = data;
-       firm_dbg_module_t *dbg = env->dbg;
        int n_regs = arch_register_class_n_regs(env->cls);
 
        pset *live = pset_new_ptr_default();
        int step = 0;
        ir_node *irn;
        irn_live_t *li;
+       DEBUG_ONLY(firm_dbg_module_t *dbg = env->dbg;)
 
        live_foreach(bl, li) {
                if(live_is_end(li) && chordal_has_class(env, li->irn)) {
@@ -161,7 +161,7 @@ static be_ra_chordal_opts_t options = {
        BE_CH_SPILL_BELADY,
        BE_CH_COPYMIN_HEUR,
        BE_CH_IFG_STD,
-       BE_CH_LOWER_PERM_SWAP
+       BE_CH_LOWER_PERM_SWAP,
 };
 
 #ifdef WITH_LIBCORE
@@ -188,8 +188,13 @@ static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
 };
 
 static const lc_opt_enum_int_items_t lower_perm_items[] = {
-       { "swap", BE_CH_LOWER_PERM_SWAP },
        { "copy", BE_CH_LOWER_PERM_COPY },
+       { "swap", BE_CH_LOWER_PERM_SWAP },
+       { "stat", BE_CH_LOWER_PERM_STAT },
+       { NULL, 0 }
+};
+
+static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
        { NULL, 0 }
 };
 
@@ -218,16 +223,33 @@ static lc_opt_enum_int_var_t ifg_flavor_var = {
 };
 
 static lc_opt_enum_int_var_t lower_perm_var = {
-       &options.lower_perm_method, lower_perm_items
+       &options.lower_perm_opt, lower_perm_items
 };
 
 static lc_opt_enum_int_var_t dump_var = {
        &options.dump_flags, dump_items
 };
 
+static const lc_opt_table_entry_t be_chordal_options[] = {
+       LC_OPT_ENT_ENUM_MASK("spill", "spill method (belady or ilp)", &spill_var),
+       LC_OPT_ENT_ENUM_PTR("copymin", "copymin method (heur or ilp)", &copymin_var),
+       LC_OPT_ENT_ENUM_PTR("ifg", "interference graph flavour (std or fast)", &ifg_flavor_var),
+       LC_OPT_ENT_ENUM_MASK("perm", "perm lowering options (copy, swap, stat)", &lower_perm_var),
+       LC_OPT_ENT_ENUM_MASK("dump", "select dump phases", &dump_var),
+       { NULL }
+};
+
 static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
 {
-       grp = lc_opt_get_grp(grp, "chordal");
+       static int run_once = 0;
+       lc_opt_entry_t *chordal_grp;
+
+       if (! run_once) {
+               run_once    = 1;
+               chordal_grp = lc_opt_get_grp(grp, "chordal");
+
+               lc_opt_add_table(chordal_grp, be_chordal_options);
+       }
 }
 #endif
 
@@ -240,11 +262,11 @@ static void dump(unsigned mask, ir_graph *irg,
                if(cls) {
                        char buf[256];
                        snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
-                       dump_func(irg, buf);
+                       be_dump(irg, buf, dump_func);
                }
 
                else
-                       dump_func(irg, suffix);
+                       be_dump(irg, suffix, dump_func);
        }
 }
 
@@ -260,9 +282,9 @@ static void be_ra_chordal_main(const be_irg_t *bi)
 
        chordal_env.opts         = &options;
        chordal_env.irg          = irg;
-       chordal_env.dbg          = firm_dbg_register("firm.be.chordal");
-       chordal_env.birg                 = bi;
+       chordal_env.birg         = bi;
        chordal_env.dom_front    = be_compute_dominance_frontiers(irg);
+       FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
 
        obstack_init(&chordal_env.obst);
 
@@ -292,9 +314,6 @@ static void be_ra_chordal_main(const be_irg_t *bi)
                be_liveness(irg);
                be_check_pressure(&chordal_env);
 
-               be_liveness(irg);
-               be_check_pressure(&chordal_env);
-
                /* Color the graph. */
                be_ra_chordal_color(&chordal_env);
                dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
@@ -304,7 +323,6 @@ static void be_ra_chordal_main(const be_irg_t *bi)
                be_ifg_check(chordal_env.ifg);
 
                /* copy minimization */
-               copystat_collect_cls(&chordal_env);
 #ifdef COPYOPT_STAT
                co_compare_solvers(&chordal_env);
 #else
@@ -323,7 +341,7 @@ static void be_ra_chordal_main(const be_irg_t *bi)
                be_ssa_destruction(&chordal_env);
                dump(BE_CH_DUMP_SSADESTR, irg, chordal_env.cls, "-ssadestr", dump_ir_block_graph_sched);
                be_ssa_destruction_check(&chordal_env);
-//             be_ra_chordal_check(&chordal_env);
+               be_ra_chordal_check(&chordal_env);
 
                copystat_dump(irg);
 
@@ -336,7 +354,9 @@ static void be_ra_chordal_main(const be_irg_t *bi)
 
        dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
 
-       lower_nodes_after_ra(&chordal_env, options.lower_perm_method == BE_CH_LOWER_PERM_COPY ? 1 : 0);
+       lower_nodes_after_ra(&chordal_env,
+               options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0,
+               options.lower_perm_opt & BE_CH_LOWER_PERM_STAT ? 1 : 0);
        dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
 
        obstack_free(&chordal_env.obst, NULL);