2 * Internal register allocation facility.
3 * @author Sebastian Hack
10 #include "firm_config.h"
13 #define DBG_BERA "firm.be.ra"
15 typedef struct _ra_node_info_t {
16 int pressure; /**< Register pressure at this node. */
17 int color; /**< The color assigned to this node. */
20 typedef struct _ra_block_info_t {
21 bitset_t *used_colors; /**< A bitmask containing all colors used in the block. */
25 * Register allocation data for a node.
27 typedef struct _ra_info_t {
30 ra_block_info_t block;
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)
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)
40 extern size_t ra_irn_data_offset;
42 extern size_t ra_irg_data_offset;
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)
48 * Initialize the register allocation framework.
50 void be_ra_init(void);
53 * The 'no color' color. The register allocator should use this value,
54 * if a color cannot be assigned at some point.
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.
63 #define is_color(col) ((col) != NO_COLOR)
65 static INLINE int __get_irn_color(const ir_node *irn)
67 assert(!is_Block(irn) && "No block allowed here");
68 return get_ra_node_info(irn)->color;
71 static INLINE void __set_irn_color(const ir_node *irn, int color)
73 assert(!is_Block(irn) && "No block allowed here");
74 get_ra_node_info(irn)->color = color;
77 static INLINE int __is_allocatable_irn(const ir_node *irn)
79 assert(!is_Block(irn) && "No block allowed here");
80 return mode_is_datab(get_irn_mode(irn));
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)