Added code to support the value based type (compound parameter calls)
[libfirm] / ir / be / bechordal_main.c
index a747d0d..2ee908c 100644 (file)
 #include "list.h"
 #include "bitset.h"
 #include "iterator.h"
+#include "firm_config.h"
 
 #ifdef WITH_LIBCORE
 #include <libcore/lc_opts.h>
 #include <libcore/lc_opts_enum.h>
+#include <libcore/lc_timing.h>
 #endif /* WITH_LIBCORE */
 
 #include "irmode_t.h"
@@ -50,6 +52,8 @@
 
 #ifdef WITH_ILP
 #include "bespillilp.h"
+#include "bespillremat.h"
+#include "bespillappel.h"
 #endif /* WITH_ILP */
 
 #include "becopystat.h"
@@ -122,8 +126,10 @@ static const lc_opt_enum_int_items_t spill_items[] = {
        { "morgan", BE_CH_SPILL_MORGAN },
        { "belady", BE_CH_SPILL_BELADY },
 #ifdef WITH_ILP
-       { "ilp",        BE_CH_SPILL_ILP },
-#endif
+       { "ilp",    BE_CH_SPILL_ILP    },
+       { "remat",  BE_CH_SPILL_REMAT  },
+       { "appel",  BE_CH_SPILL_APPEL  },
+#endif /* WITH_ILP */
        { NULL, 0 }
 };
 
@@ -136,14 +142,18 @@ static const lc_opt_enum_int_items_t copymin_items[] = {
 #ifdef WITH_ILP
        { "ilp1",  BE_CH_COPYMIN_ILP1 },
        { "ilp2",  BE_CH_COPYMIN_ILP2 },
-#endif
+#endif /* WITH_ILP */
        { NULL, 0 }
 };
 
 static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
-       { "std",  BE_CH_IFG_STD },
-       { "fast", BE_CH_IFG_FAST },
-       { NULL, 0 }
+       { "std",     BE_CH_IFG_STD     },
+       { "fast",    BE_CH_IFG_FAST    },
+       { "clique",  BE_CH_IFG_CLIQUE  },
+       { "pointer", BE_CH_IFG_POINTER },
+       { "list",    BE_CH_IFG_LIST    },
+       { "check",   BE_CH_IFG_CHECK   },
+       { NULL,      0                 }
 };
 
 static const lc_opt_enum_int_items_t lower_perm_items[] = {
@@ -185,7 +195,7 @@ static lc_opt_enum_int_var_t copymin_var = {
 };
 
 static lc_opt_enum_int_var_t ifg_flavor_var = {
-       &options.spill_method, ifg_flavor_items
+       &options.ifg_flavor, ifg_flavor_items
 };
 
 static lc_opt_enum_int_var_t lower_perm_var = {
@@ -201,9 +211,9 @@ static lc_opt_enum_int_var_t be_ch_vrfy_var = {
 };
 
 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_MASK("spill",   "spill method (belady, ilp, remat or appel)", &spill_var),
        LC_OPT_ENT_ENUM_PTR ("copymin", "copymin method (none, heur1, heur2, ilp1, ilp2 or stat)", &copymin_var),
-       LC_OPT_ENT_ENUM_PTR ("ifg",     "interference graph flavour (std or fast)", &ifg_flavor_var),
+       LC_OPT_ENT_ENUM_PTR ("ifg",     "interference graph flavour (std, fast, clique, pointer, list, check)", &ifg_flavor_var),
        LC_OPT_ENT_ENUM_PTR ("perm",    "perm lowering options (copy or swap)", &lower_perm_var),
        LC_OPT_ENT_ENUM_MASK("dump",    "select dump phases", &dump_var),
        LC_OPT_ENT_ENUM_PTR ("vrfy",    "verify options (off, warn, assert)", &be_ch_vrfy_var),
@@ -262,6 +272,33 @@ FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const cha
        return fopen(buf, "wt");
 }
 
+void check_ifg_implementations(be_chordal_env_t *chordal_env)
+{
+       FILE *f;
+
+       f = be_chordal_open(chordal_env, "std", "log");
+       chordal_env->ifg = be_ifg_std_new(chordal_env);
+       be_ifg_check_sorted(chordal_env->ifg, f);
+       fclose(f);
+
+       f = be_chordal_open(chordal_env, "list", "log");
+       chordal_env->ifg = be_ifg_list_new(chordal_env);
+       be_ifg_check_sorted(chordal_env->ifg, f);
+       fclose(f);
+
+       f = be_chordal_open(chordal_env, "clique", "log");
+       chordal_env->ifg = be_ifg_clique_new(chordal_env);
+       be_ifg_check_sorted(chordal_env->ifg, f);
+       fclose(f);
+
+       f = be_chordal_open(chordal_env, "pointer", "log");
+       chordal_env->ifg = be_ifg_pointer_new(chordal_env);
+       be_ifg_check_sorted(chordal_env->ifg, f);
+       fclose(f);
+
+       chordal_env->ifg = NULL;
+};
+
 static void be_ra_chordal_main(const be_irg_t *bi)
 {
        const be_main_env_t *main_env = bi->main_env;
@@ -272,6 +309,9 @@ static void be_ra_chordal_main(const be_irg_t *bi)
        int j, m;
        be_chordal_env_t chordal_env;
 
+       //lc_timer_t *timer = lc_timer_register("getTime","get Time of copy minimization using the ifg");
+       //unsigned long elapsed_milisec = 0;
+
        compute_doms(irg);
 
        chordal_env.opts          = &options;
@@ -306,6 +346,12 @@ static void be_ra_chordal_main(const be_irg_t *bi)
                case BE_CH_SPILL_ILP:
                        be_spill_ilp(&chordal_env);
                        break;
+               case BE_CH_SPILL_REMAT:
+                       be_spill_remat(&chordal_env);
+                       break;
+               case BE_CH_SPILL_APPEL:
+                       be_spill_appel(&chordal_env);
+                       break;
 #endif /* WITH_ILP */
                default:
                        fprintf(stderr, "no valid spiller selected. falling back to belady\n");
@@ -330,9 +376,35 @@ static void be_ra_chordal_main(const be_irg_t *bi)
                be_ra_chordal_color(&chordal_env);
                dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
 
-               /* Build the interference graph. */
-               chordal_env.ifg = be_ifg_std_new(&chordal_env);
-               be_ifg_check(chordal_env.ifg);
+               /* Check the implementations of the ifg */
+
+               switch (options.ifg_flavor) {
+                       default:
+                               fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
+                       case BE_CH_IFG_STD:
+                       case BE_CH_IFG_FAST:
+                               chordal_env.ifg = be_ifg_std_new(&chordal_env);
+                               break;
+                       case BE_CH_IFG_CLIQUE:
+                               chordal_env.ifg = be_ifg_clique_new(&chordal_env);
+                               break;
+                       case BE_CH_IFG_POINTER:
+                               chordal_env.ifg = be_ifg_pointer_new(&chordal_env);
+                               break;
+                       case BE_CH_IFG_LIST:
+                               chordal_env.ifg = be_ifg_list_new(&chordal_env);
+                               break;
+                       case BE_CH_IFG_CHECK:
+                               check_ifg_implementations(&chordal_env);
+                               /* Build the interference graph. */
+                               chordal_env.ifg = be_ifg_std_new(&chordal_env);
+                               //be_ifg_check(chordal_env.ifg);
+                               //be_ifg_check_sorted(chordal_env.ifg);
+                               break;
+               }
+
+               /* start timer */
+               //lc_timer_reset_and_start(timer);
 
                /* copy minimization */
                co = NULL;
@@ -342,6 +414,12 @@ static void be_ra_chordal_main(const be_irg_t *bi)
                        co_build_graph_structure(co);
                }
 
+               /* stop timer */
+               //lc_timer_stop(timer);
+               //elapsed_milisec = lc_timer_elapsed_msec(timer);
+
+               //ir_printf("%u\n", elapsed_milisec);
+
                switch(options.copymin_method) {
                        case BE_CH_COPYMIN_HEUR1:
                                co_solve_heuristic(co);