bera.c 1.85 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
Christian Würdig's avatar
Christian Würdig committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

Sebastian Hack's avatar
Sebastian Hack committed
20
/**
Christian Würdig's avatar
Christian Würdig committed
21
22
23
24
25
 * @file
 * @brief       Base routines for register allocation.
 * @author      Sebastian Hack
 * @date        22.11.2004
 * @version     $Id$
Sebastian Hack's avatar
Sebastian Hack committed
26
 */
Michael Beck's avatar
Michael Beck committed
27
#include "config.h"
Sebastian Hack's avatar
Sebastian Hack committed
28

29
30
#include <stdlib.h>

Sebastian Hack's avatar
Sebastian Hack committed
31
32
33
34
35
#include "pset.h"
#include "impl.h"

#include "irnode.h"
#include "irmode.h"
36
#include "irdom.h"
Christian Würdig's avatar
Christian Würdig committed
37
#include "iredges.h"
Sebastian Hack's avatar
Sebastian Hack committed
38

39
#include "bera.h"
40
#include "beutil.h"
41
#include "besched.h"
42
#include "belive_t.h"
43
#include "bemodule.h"
Sebastian Hack's avatar
Sebastian Hack committed
44

45
46
47
48
49
50
51
52
53
54
55
/** The list of register allocators */
static be_module_list_entry_t *register_allocators = NULL;
static be_ra_t *selected_allocator = NULL;

void be_register_allocator(const char *name, be_ra_t *allocator)
{
	if(selected_allocator == NULL)
		selected_allocator = allocator;
	be_add_module_to_list(&register_allocators, name, allocator);
}

56
57
58
59
60
61
62
63
void be_allocate_registers(be_irg_t *birg)
{
	assert(selected_allocator != NULL);
	if(selected_allocator != NULL) {
		selected_allocator->allocate(birg);
	}
}

64
65
void be_init_ra(void)
{
66
67
68
69
	lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");

	be_add_module_list_opt(be_grp, "regalloc", "register allocator",
	                       &register_allocators, (void**) &selected_allocator);
70
}
71
BE_REGISTER_MODULE_CONSTRUCTOR(init_be_ra);