changed localize_consts
[libfirm] / ir / be / bera_t.h
1 /**
2  * Internal register allocation facility.
3  * @author Sebastian Hack
4  * @date 8.12.2004
5  */
6
7 #ifndef _BERA_H
8 #define _BERA_H
9
10 #include "firm_config.h"
11 #include "bitset.h"
12
13 #define DBG_BERA "firm.be.ra"
14
15 typedef struct _ra_node_info_t {
16         int pressure;                                                   /**< Register pressure at this node. */
17         int color;                                                              /**< The color assigned to this node. */
18 } ra_node_info_t;
19
20 typedef struct _ra_block_info_t {
21         bitset_t *used_colors;          /**< A bitmask containing all colors used in the block. */
22 } ra_block_info_t;
23
24 /**
25  * Register allocation data for a node.
26  */
27 typedef struct _ra_info_t {
28         union {
29                 ra_node_info_t node;
30                 ra_block_info_t block;
31         } v;
32 } ra_info_t;
33
34 #define get_ra_irn_info(irn) get_irn_data(irn, ra_info_t, ra_irn_data_offset)
35 #define get_ra_info_irn(inf) get_irn_data_base(inf, ra_irn_data_offset)
36
37 #define get_ra_node_info(the_node)              (&get_ra_irn_info(the_node)->v.node)
38 #define get_ra_block_info(the_block)    (&get_ra_irn_info(the_block)->v.block)
39
40 extern size_t ra_irn_data_offset;
41
42 extern size_t ra_irg_data_offset;
43
44 #define get_irg_ra_link(irg) (*(get_irg_data(irg, void *, ra_irg_data_offset)))
45 #define set_irg_ra_link(irg,ptr) (*(get_irg_data(irg, void *, ra_irg_data_offset)) = ptr)
46
47 /**
48  * Initialize the register allocation framework.
49  */
50 void be_ra_init(void);
51
52 /**
53  * The 'no color' color. The register allocator should use this value,
54  * if a color cannot be assigned at some point.
55  */
56 #define NO_COLOR (-1)
57
58 /**
59  * Check, if a color is valid.
60  * @param col The color.
61  * @return 1, if the color is ok, 0 if the color is illegal.
62  */
63 #define is_color(col) ((col) != NO_COLOR)
64
65 static INLINE int __get_irn_color(const ir_node *irn)
66 {
67         assert(!is_Block(irn) && "No block allowed here");
68         return get_ra_node_info(irn)->color;
69 }
70
71 static INLINE void __set_irn_color(const ir_node *irn, int color)
72 {
73         assert(!is_Block(irn) && "No block allowed here");
74         get_ra_node_info(irn)->color = color;
75 }
76
77 static INLINE int __is_allocatable_irn(const ir_node *irn)
78 {
79         assert(!is_Block(irn) && "No block allowed here");
80         return mode_is_datab(get_irn_mode(irn));
81 }
82
83 #define get_irn_color(irn)                                                              __get_irn_color(irn)
84 #define set_irn_color(irn,col)                                          __set_irn_color(irn, col)
85 #define is_allocatable_irn(irn)                                         __is_allocatable_irn(irn)
86
87 #endif