put bespill options into separate file
authorMatthias Braun <matze@braunis.de>
Thu, 12 Oct 2006 14:28:08 +0000 (14:28 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 12 Oct 2006 14:28:08 +0000 (14:28 +0000)
ir/be/Makefile.in
ir/be/bechordal_main.c
ir/be/bespill.c
ir/be/bespilloptions.c [new file with mode: 0644]
ir/be/bespilloptions.h [new file with mode: 0644]
ir/be/bespillslots.c
ir/be/bespillslots.h

index b3c5833..c9d1ad7 100644 (file)
@@ -37,7 +37,7 @@ SOURCES +=    Makefile.in besched.h belistsched.h belistsched.c \
        bejavacoal.c becopyheur3.c bespillcost.c bespillremat.c \
        bespillslots.h bespillslots.c beprofile.c \
        bestatevent.h bestatevent.c be_dbgout.h bestabs.c beschedrss.c \
-       beblocksched.h beblocksched.c
+       beblocksched.h beblocksched.c bespilloptions.c bespilloptions.h
 
 
 include $(topdir)/MakeRules
index b4160d0..62dbe32 100644 (file)
@@ -61,6 +61,7 @@
 #include "bespillbelady.h"
 #include "bespillmorgan.h"
 #include "bespillslots.h"
+#include "bespilloptions.h"
 #include "belower.h"
 
 #ifdef WITH_ILP
@@ -133,9 +134,6 @@ static be_ra_chordal_opts_t options = {
        BE_CH_VRFY_WARN,
 };
 
-/* coalesce spill slots */
-static int coalesce_spill_slots = 1;
-
 /** The name of the file where the statistics are put to. */
 static char stat_file_name[2048];
 
@@ -233,7 +231,6 @@ static lc_opt_enum_int_var_t be_ch_vrfy_var = {
 
 static const lc_opt_table_entry_t be_chordal_options[] = {
        LC_OPT_ENT_STR      ("statfile",      "the name of the statisctics file", stat_file_name, sizeof(stat_file_name)),
-       LC_OPT_ENT_BOOL     ("spill.coal",    "coalesce the spill slots", &coalesce_spill_slots),
        LC_OPT_ENT_ENUM_INT ("spill",         "spill method", &spill_var),
        LC_OPT_ENT_ENUM_PTR ("ifg",           "interference graph flavour", &ifg_flavor_var),
        LC_OPT_ENT_ENUM_PTR ("perm",          "perm lowering options", &lower_perm_var),
@@ -263,6 +260,7 @@ static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
 #ifdef WITH_ILP
                be_spill_remat_register_options(chordal_grp);
 #endif
+               be_spill_register_options(chordal_grp);
        }
 }
 #endif /* WITH_LIBCORE */
@@ -790,7 +788,7 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
 
        BE_TIMER_PUSH(ra_timer.t_spillslots);
 
-       be_coalesce_spillslots(&chordal_env, coalesce_spill_slots);
+       be_coalesce_spillslots(&chordal_env);
        dump(BE_CH_DUMP_SPILLSLOTS, irg, NULL, "-spillslots", dump_ir_block_graph_sched);
 
        BE_TIMER_POP(ra_timer.t_spillslots);
index 7784817..321bf2f 100644 (file)
@@ -34,6 +34,8 @@
 #include "bechordal_t.h"
 #include "bejavacoal.h"
 #include "benodesets.h"
+#include "bespilloptions.h"
+#include "bestatevent.h"
 
 // only rematerialise when costs are less than REMAT_COST_LIMIT
 // TODO determine a good value here...
@@ -539,10 +541,12 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
 int be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before) {
        spill_info_t *spill_info;
 
-       // is the node rematerializable?
-       int costs = check_remat_conditions_costs(env, to_spill, before, 0);
-       if(costs < REMAT_COST_LIMIT)
-               return costs;
+       if(be_do_remats) {
+               // is the node rematerializable?
+               int costs = check_remat_conditions_costs(env, to_spill, before, 0);
+               if(costs < REMAT_COST_LIMIT)
+                       return costs;
+       }
 
        // do we already have a spill?
        spill_info = find_spillinfo(env, to_spill);
@@ -569,6 +573,9 @@ int be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *bl
 void be_insert_spills_reloads(spill_env_t *env) {
        const arch_env_t *arch_env = env->arch_env;
        spill_info_t *si;
+       int remats = 0;
+       int reloads = 0;
+       int spills = 0;
 
        /* process each spilled node */
        for(si = set_first(env->spills); si; si = set_next(env->spills)) {
@@ -580,14 +587,19 @@ void be_insert_spills_reloads(spill_env_t *env) {
                for(rld = si->reloaders; rld; rld = rld->next) {
                        ir_node *new_val;
 
-                       if (check_remat_conditions(env, si->spilled_node, rld->reloader)) {
+                       if (be_do_remats && check_remat_conditions(env, si->spilled_node, rld->reloader)) {
                                new_val = do_remat(env, si->spilled_node, rld->reloader);
+                               remats++;
                        } else {
                                /* make sure we have a spill */
-                               spill_node(env, si);
+                               if(si->spill == NULL) {
+                                       spill_node(env, si);
+                                       spills++;
+                               }
 
-                               /* do a reload */
+                               /* create a reload */
                                new_val = be_reload(arch_env, env->cls, rld->reloader, mode, si->spill);
+                               reloads++;
                        }
 
                        DBG((env->dbg, LEVEL_1, " %+F of %+F before %+F\n", new_val, si->spilled_node, rld->reloader));
@@ -605,6 +617,12 @@ void be_insert_spills_reloads(spill_env_t *env) {
                si->reloaders = NULL;
        }
 
+       if(be_stat_ev_is_active()) {
+               be_stat_ev("spill_spills", spills);
+               be_stat_ev("spill_reloads", reloads);
+               be_stat_ev("spill_remats", remats);
+       }
+
        be_remove_dead_nodes_from_schedule(env->chordal_env->irg);
        be_liveness_recompute(env->chordal_env->lv);
 }
diff --git a/ir/be/bespilloptions.c b/ir/be/bespilloptions.c
new file mode 100644 (file)
index 0000000..488323c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Author:      Daniel Grund, Sebastian Hack, Matthias Braun
+ * Date:               29.09.2005
+ * Copyright:   (c) Universitaet Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "bespilloptions.h"
+
+#ifdef WITH_LIBCORE
+#include <libcore/lc_opts.h>
+#include <libcore/lc_opts_enum.h>
+#include <libcore/lc_timing.h>
+#endif /* WITH_LIBCORE */
+
+int be_coalesce_spill_slots = 1;
+int be_do_remats = 1;
+
+#ifdef WITH_LIBCORE
+static const lc_opt_table_entry_t be_spill_options[] = {
+       LC_OPT_ENT_BOOL ("coalesce_slots", "coalesce the spill slots", &be_coalesce_spill_slots),
+       LC_OPT_ENT_BOOL ("remat", "try to rematerialize values instead of reloading", &be_do_remats),
+       { NULL }
+};
+
+void be_spill_register_options(lc_opt_entry_t *grp)
+{
+       static int     run_once = 0;
+       lc_opt_entry_t *spill_grp;
+
+       if (run_once)
+               return;
+
+       run_once       = 1;
+       spill_grp = lc_opt_get_grp(grp, "spill");
+
+       lc_opt_add_table(spill_grp, be_spill_options);
+}
+#endif /* WITH_LIBCORE */
diff --git a/ir/be/bespilloptions.h b/ir/be/bespilloptions.h
new file mode 100644 (file)
index 0000000..1f1e383
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Author:      Matthias Braun
+ * Date:               12.10.2006
+ * Copyright:   (c) Universitaet Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ */
+#ifndef BESPILL_OPTIONS_H_
+#define BESPILL_OPTIONS_H_
+
+extern int be_coalesce_spill_slots;
+extern int be_do_remats;
+
+#ifdef WITH_LIBCORE
+#include <libcore/lc_opts.h>
+void be_spill_register_options(lc_opt_entry_t *grp);
+#endif
+
+#endif
index b854d61..a7a13ed 100644 (file)
@@ -27,7 +27,7 @@
 #include "bejavacoal.h"
 #include "benodesets.h"
 #include "bestatevent.h"
-
+#include "bespilloptions.h"
 
 #define DBG_COALESCING         1
 #define DBG_INTERFERENCES      2
@@ -761,7 +761,7 @@ static int count_spillslots(const ss_env_t *env) {
        return slotcount;
 }
 
-void be_coalesce_spillslots(const be_chordal_env_t *chordal_env, int coalesce_spillslots) {
+void be_coalesce_spillslots(const be_chordal_env_t *chordal_env) {
        ss_env_t env;
 
        obstack_init(&env.obst);
@@ -779,7 +779,7 @@ void be_coalesce_spillslots(const be_chordal_env_t *chordal_env, int coalesce_sp
 
        be_stat_ev("spillslots", set_count(env.spills));
 
-       if(coalesce_spillslots) {
+       if(be_coalesce_spill_slots) {
                do_greedy_coalescing(&env);
                if(be_stat_ev_is_active()) {
                        be_stat_ev("spillslots_after_coalescing", count_spillslots(&env));
index 65e8419..21dce05 100644 (file)
@@ -12,6 +12,6 @@
 /**
  * Computes the spill offsets for all spill nodes in the irg
  */
-void be_coalesce_spillslots(const be_chordal_env_t *chordal_env, int coalesce_spillslots);
+void be_coalesce_spillslots(const be_chordal_env_t *chordal_env);
 
 #endif