add sopport for compile without WITH_LIBCORE
[libfirm] / ir / be / bespilloptions.c
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Option handling for spiller.
23  * @author      Daniel Grund, Sebastian Hack, Matthias Braun
24  * @date        29.09.2005
25  * @version     $Id$
26  */
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include "irtools.h"
32
33 #include "bespilloptions.h"
34 #include "bemodule.h"
35 #include "be.h"
36
37
38 int be_coalesce_spill_slots = 1;
39 int be_do_remats = 1;
40
41 #ifdef WITH_LIBCORE
42 #include <libcore/lc_opts.h>
43 #include <libcore/lc_opts_enum.h>
44 #include <libcore/lc_timing.h>
45
46 static const lc_opt_table_entry_t be_spill_options[] = {
47         LC_OPT_ENT_BOOL ("coalesce_slots", "coalesce the spill slots", &be_coalesce_spill_slots),
48         LC_OPT_ENT_BOOL ("remat", "try to rematerialize values instead of reloading", &be_do_remats),
49         LC_OPT_LAST
50 };
51 #endif /* WITH_LIBCORE */
52
53 static be_module_list_entry_t *spillers = NULL;
54 static be_spiller_t *selected_spiller = NULL;
55
56 void be_register_spiller(const char *name, be_spiller_t *spiller)
57 {
58         if(selected_spiller == NULL)
59                 selected_spiller = spiller;
60         be_add_module_to_list(&spillers, name, spiller);
61 }
62
63 void be_do_spill(be_irg_t *birg, const arch_register_class_t* cls)
64 {
65         assert(selected_spiller != NULL);
66         if(selected_spiller != NULL) {
67                 selected_spiller->spill(birg, cls);
68         }
69 }
70
71 void be_init_spilloptions(void)
72 {
73 #ifdef WITH_LIBCORE
74         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
75         lc_opt_entry_t *spill_grp = lc_opt_get_grp(be_grp, "spill");
76
77         lc_opt_add_table(spill_grp, be_spill_options);
78         be_add_module_list_opt(spill_grp, "spiller", "spill algorithm",
79                                &spillers, (void**) &selected_spiller);
80 #endif /* WITH_LIBCORE */
81 }
82
83 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spilloptions);