2 * Internal register allocation facility.
3 * @author Sebastian Hack
10 #include "firm_config.h"
16 #define DBG_BERA "firm.be.ra"
18 typedef struct _ra_node_info_t {
19 int pressure; /**< Register pressure at this node. */
20 int color; /**< The color assigned to this node. */
23 typedef struct _ra_block_info_t {
24 bitset_t *used_colors; /**< A bitmask containing all colors used in the block. */
25 struct list_head border_head; /**< A list head to enqueue the borders. */
29 * Register allocation data for a node.
31 typedef struct _ra_info_t {
34 ra_block_info_t block;
38 #define get_ra_irn_info(irn) get_irn_data(irn, ra_info_t, ra_irn_data_offset)
39 #define get_ra_info_irn(inf) get_irn_data_base(inf, ra_irn_data_offset)
41 #define get_ra_node_info(the_node) (&get_ra_irn_info(the_node)->v.node)
42 #define get_ra_block_info(the_block) (&get_ra_irn_info(the_block)->v.block)
44 extern size_t ra_irn_data_offset;
46 extern size_t ra_irg_data_offset;
48 #define get_irg_ra_link(irg) (*(get_irg_data(irg, void *, ra_irg_data_offset)))
49 #define set_irg_ra_link(irg,ptr) (*(get_irg_data(irg, void *, ra_irg_data_offset)) = ptr)
52 * Initialize the register allocation framework.
54 void be_ra_init(void);
57 * The 'no color' color. The register allocator should use this value,
58 * if a color cannot be assigned at some point.
63 * Check, if a color is valid.
64 * @param col The color.
65 * @return 1, if the color is ok, 0 if the color is illegal.
67 #define is_color(col) ((col) != NO_COLOR)
69 static INLINE int _get_irn_color(const ir_node *irn)
71 assert(!is_Block(irn) && "No block allowed here");
72 return get_ra_node_info(irn)->color;
75 static INLINE void _set_irn_color(const ir_node *irn, int color)
77 assert(!is_Block(irn) && "No block allowed here");
78 get_ra_node_info(irn)->color = color;
81 static INLINE int _is_allocatable_irn(const ir_node *irn)
83 assert(!is_Block(irn) && "No block allowed here");
84 return mode_is_datab(get_irn_mode(irn));
87 #define get_irn_color(irn) _get_irn_color(irn)
88 #define set_irn_color(irn,col) _set_irn_color(irn, col)
89 #define is_allocatable_irn(irn) _is_allocatable_irn(irn)
91 static INLINE struct list_head *_get_block_border_head(ir_node *block)
93 return &get_ra_block_info(block)->border_head;
97 * Check, if two phi operands interfere.
98 * @param a A node which is operand to a phi function.
99 * @param b Another node which is operand to a phi function.
100 * @return 1, if @p a and @p b interfere, 0 if not.
102 int phi_ops_interfere(const ir_node *a, const ir_node *b);
104 #endif /* BERA_T_H */