9315f8dbaa8140bb29a7128e8598464eab2f1e94
[libfirm] / ir / be / bera.h
1 /**
2  * Register allocation functions.
3  * @author Sebastian Hack
4  * @date 13.1.2005
5  */
6
7 #ifndef _BERA_H
8 #define _BERA_H
9
10 #include "firm_config.h"
11
12 #ifdef WITH_LIBCORE
13 #include <libcore/lc_timing.h>
14 #endif
15
16 #include "firm_types.h"
17
18 #include "be.h"
19 #include "belive.h"
20 #include "beirg.h"
21 #include "bemodule.h"
22
23 #ifdef WITH_LIBCORE
24
25 typedef struct {
26         lc_timer_t *t_prolog;      /**< timer for prolog */
27         lc_timer_t *t_epilog;      /**< timer for epilog */
28         lc_timer_t *t_live;        /**< timer for liveness calculation */
29         lc_timer_t *t_spill;       /**< timer for spilling */
30         lc_timer_t *t_spillslots;  /**< spillslot coalescing */
31         lc_timer_t *t_color;       /**< timer for graph coloring */
32         lc_timer_t *t_ifg;         /**< timer for building interference graph */
33         lc_timer_t *t_copymin;     /**< timer for copy minimization */
34         lc_timer_t *t_ssa;         /**< timer for ssa destruction */
35         lc_timer_t *t_verify;      /**< timer for verification runs */
36         lc_timer_t *t_other;       /**< timer for remaining stuff */
37 } be_ra_timer_t;
38
39 extern be_ra_timer_t *global_ra_timer;
40 #else
41 typedef void *be_ra_timer_t;
42 typedef void *lc_opt_entry_t;
43 #endif  /* WITH_LIBCORE */
44
45 typedef struct be_ra_t {
46         void (*allocate)(be_irg_t *bi);   /**< allocate registers on a graph */
47 } be_ra_t;
48
49 void be_register_allocator(const char *name, be_ra_t *allocator);
50
51 /**
52  * Do register allocation with currently selected register allocator
53  */
54 void be_allocate_registers(be_irg_t *birg);
55
56 /**
57  * Check, if two values interfere.
58  * @param lv Liveness information.
59  * @param a The first value.
60  * @param b The second value.
61  * @return 1, if @p a and @p b interfere, 0 if not.
62  */
63 int values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b);
64
65 /**
66  * Check, if a value dominates the other one.
67  * Note, that this function also considers the schedule and does thus
68  * more than block_dominates().
69  *
70  * @param a The first.
71  * @param b The second value.
72  * @return 1 if a dominates b, 0 else.
73  */
74 int value_dominates(const ir_node *a, const ir_node *b);
75
76 #endif /* _BERA_H */