bespill.c 1.68 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
Christian Würdig's avatar
Christian Würdig committed
4
5
 */

6
7
/**
 * @file
8
9
10
 * @brief       Spill module selection; Preparation steps
 * @author      Matthias Braun
 * @date        29.09.2005
Daniel Grund's avatar
Daniel Grund committed
11
 */
12
#include "irtools.h"
Sebastian Hack's avatar
Sebastian Hack committed
13
#include "debug.h"
14
#include "iredges_t.h"
Matthias Braun's avatar
Matthias Braun committed
15
#include "raw_bitset.h"
Matthias Braun's avatar
Matthias Braun committed
16
#include "statev_t.h"
Michael Beck's avatar
Michael Beck committed
17
#include "irgwalk.h"
Daniel Grund's avatar
Daniel Grund committed
18
19

#include "bespill.h"
20
21
#include "bemodule.h"
#include "be.h"
Matthias Braun's avatar
Matthias Braun committed
22
#include "belive_t.h"
23
#include "beirg.h"
24
#include "bearch.h"
25
#include "benode.h"
26
27
#include "besched.h"
#include "bera.h"
28
#include "beintlive_t.h"
Sebastian Hack's avatar
Sebastian Hack committed
29

30
31
#include "lc_opts.h"
#include "lc_opts_enum.h"
Daniel Grund's avatar
Daniel Grund committed
32

33
34
int be_coalesce_spill_slots = 1;
int be_do_remats = 1;
35

36
37
38
39
40
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),
	LC_OPT_LAST
};
41

42
43
static be_module_list_entry_t *spillers;
static be_spill_func           selected_spiller;
44

45
void be_register_spiller(const char *name, be_spill_func spiller)
46
{
47
48
49
	if (selected_spiller == NULL)
		selected_spiller = spiller;
	be_add_module_to_list(&spillers, name, spiller);
50
51
}

52
void be_do_spill(ir_graph *irg, const arch_register_class_t *cls)
Sebastian Hack's avatar
Sebastian Hack committed
53
{
54
	assert(selected_spiller != NULL);
55
	selected_spiller(irg, cls);
Sebastian Hack's avatar
Sebastian Hack committed
56
57
}

Matthias Braun's avatar
Matthias Braun committed
58
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spilloptions)
59
void be_init_spilloptions(void)
60
{
61
62
	lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
	lc_opt_entry_t *spill_grp = lc_opt_get_grp(be_grp, "spill");
63

64
	lc_opt_add_table(spill_grp, be_spill_options);
65
	be_add_module_list_opt(be_grp, "spiller", "spill algorithm",
66
	                       &spillers, (void**) &selected_spiller);
67
}