2 * Internal register allocation facility.
3 * @author Sebastian Hack
10 #include "firm_config.h"
15 #define DBG_BERA "firm.be.ra"
17 typedef struct _ra_node_info_t {
18 int pressure; /**< Register pressure at this node. */
19 int color; /**< The color assigned to this node. */
22 typedef struct _ra_block_info_t {
23 bitset_t *used_colors; /**< A bitmask containing all colors used in the block. */
27 * Register allocation data for a node.
29 typedef struct _ra_info_t {
32 ra_block_info_t block;
36 #define get_ra_irn_info(irn) get_irn_data(irn, ra_info_t, ra_irn_data_offset)
37 #define get_ra_info_irn(inf) get_irn_data_base(inf, ra_irn_data_offset)
39 #define get_ra_node_info(the_node) (&get_ra_irn_info(the_node)->v.node)
40 #define get_ra_block_info(the_block) (&get_ra_irn_info(the_block)->v.block)
42 extern size_t ra_irn_data_offset;
44 extern size_t ra_irg_data_offset;
46 #define get_irg_ra_link(irg) (*(get_irg_data(irg, void *, ra_irg_data_offset)))
47 #define set_irg_ra_link(irg,ptr) (*(get_irg_data(irg, void *, ra_irg_data_offset)) = ptr)
50 * Initialize the register allocation framework.
52 void be_ra_init(void);
55 * The 'no color' color. The register allocator should use this value,
56 * if a color cannot be assigned at some point.
61 * Check, if a color is valid.
62 * @param col The color.
63 * @return 1, if the color is ok, 0 if the color is illegal.
65 #define is_color(col) ((col) != NO_COLOR)
67 static INLINE int __get_irn_color(const ir_node *irn)
69 assert(!is_Block(irn) && "No block allowed here");
70 return get_ra_node_info(irn)->color;
73 static INLINE void __set_irn_color(const ir_node *irn, int color)
75 assert(!is_Block(irn) && "No block allowed here");
76 get_ra_node_info(irn)->color = color;
79 static INLINE int __is_allocatable_irn(const ir_node *irn)
81 assert(!is_Block(irn) && "No block allowed here");
82 return mode_is_datab(get_irn_mode(irn));
85 #define get_irn_color(irn) __get_irn_color(irn)
86 #define set_irn_color(irn,col) __set_irn_color(irn, col)
87 #define is_allocatable_irn(irn) __is_allocatable_irn(irn)
90 * Check, if two phi operands interfere.
91 * @param a A node which is operand to a phi function.
92 * @param b Another node which is operand to a phi function.
93 * @return 1, if @p a and @p b interfere, 0 if not.
95 int phi_ops_interfere(const ir_node *a, const ir_node *b);