BugFix: when a node in schedule got exchanged, it is turned into Bad: do not set...
[libfirm] / ir / be / bespilloptions.c
1 /*
2  * Author:      Daniel Grund, Sebastian Hack, Matthias Braun
3  * Date:                29.09.2005
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  */
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #include "irtools.h"
12
13 #include "bespilloptions.h"
14 #include "bemodule.h"
15 #include "be.h"
16
17 #include <libcore/lc_opts.h>
18 #include <libcore/lc_opts_enum.h>
19 #include <libcore/lc_timing.h>
20
21 int be_coalesce_spill_slots = 1;
22 int be_do_remats = 1;
23
24 static const lc_opt_table_entry_t be_spill_options[] = {
25         LC_OPT_ENT_BOOL ("coalesce_slots", "coalesce the spill slots", &be_coalesce_spill_slots),
26         LC_OPT_ENT_BOOL ("remat", "try to rematerialize values instead of reloading", &be_do_remats),
27         { NULL }
28 };
29
30 static be_module_list_entry_t *spillers = NULL;
31 static be_spiller_t *selected_spiller = NULL;
32
33 void be_register_spiller(const char *name, be_spiller_t *spiller)
34 {
35         if(selected_spiller == NULL)
36                 selected_spiller = spiller;
37         be_add_module_to_list(&spillers, name, spiller);
38 }
39
40 void be_do_spill(const be_chordal_env_t *env)
41 {
42         assert(selected_spiller != NULL);
43         if(selected_spiller != NULL) {
44                 selected_spiller->spill(env);
45         }
46 }
47
48 void be_init_spill(void)
49 {
50         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
51         lc_opt_entry_t *spill_grp = lc_opt_get_grp(be_grp, "spill");
52
53         lc_opt_add_table(spill_grp, be_spill_options);
54         be_add_module_list_opt(spill_grp, "spiller", "spill algorithm",
55                                &spillers, (void**) &selected_spiller);
56 }
57
58 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);