bearch: Disallow passing Projs to get_irn_ops().
[libfirm] / ir / be / bera.c
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       Base routines for register allocation.
9  * @author      Sebastian Hack
10  * @date        22.11.2004
11  */
12 #include "config.h"
13
14 #include <stdlib.h>
15
16 #include "pset.h"
17
18 #include "irnode.h"
19 #include "irmode.h"
20 #include "irdom.h"
21 #include "iredges.h"
22 #include "irtools.h"
23
24 #include "bera.h"
25 #include "beutil.h"
26 #include "besched.h"
27 #include "belive_t.h"
28 #include "bemodule.h"
29
30 /** The list of register allocators */
31 static be_module_list_entry_t *register_allocators = NULL;
32 static be_ra_t *selected_allocator = NULL;
33
34 void be_register_allocator(const char *name, be_ra_t *allocator)
35 {
36         if (selected_allocator == NULL)
37                 selected_allocator = allocator;
38         be_add_module_to_list(&register_allocators, name, allocator);
39 }
40
41 void be_allocate_registers(ir_graph *irg)
42 {
43         assert(selected_allocator != NULL);
44         if (selected_allocator != NULL) {
45                 selected_allocator->allocate(irg);
46         }
47 }
48
49 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_ra)
50 void be_init_ra(void)
51 {
52         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
53
54         be_add_module_list_opt(be_grp, "regalloc", "register allocator",
55                                &register_allocators, (void**) &selected_allocator);
56 }