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 ir_node *spill_location; /**< Spill location node of the node.
20 If NULL, the node is not spilled. */
21 int pressure; /**< Register pressure at this node. */
22 int color; /**< The color assigned to this node. */
25 typedef struct _ra_block_info_t {
26 bitset_t *used_colors; /**< A bitmask containing all colors used in the block. */
27 struct list_head border_head; /**< A list head to enqueue the borders. */
31 * Register allocation data for a node.
33 typedef struct _ra_info_t {
36 ra_block_info_t block;
40 #define get_ra_irn_info(irn) get_irn_data(irn, ra_info_t, ra_irn_data_offset)
41 #define get_ra_info_irn(inf) get_irn_data_base(inf, ra_irn_data_offset)
43 #define get_ra_node_info(the_node) (&get_ra_irn_info(the_node)->v.node)
44 #define get_ra_block_info(the_block) (&get_ra_irn_info(the_block)->v.block)
46 #define get_block_border_head(bl) (&get_ra_block_info(bl)->border_head)
48 extern size_t ra_irn_data_offset;
50 extern size_t ra_irg_data_offset;
52 #define get_irg_ra_link(irg) (*(get_irg_data(irg, void *, ra_irg_data_offset)))
53 #define set_irg_ra_link(irg,ptr) (*(get_irg_data(irg, void *, ra_irg_data_offset)) = ptr)
56 * Initialize the register allocation framework.
58 void be_ra_init(void);
61 * The 'no color' color. The register allocator should use this value,
62 * if a color cannot be assigned at some point.
67 * Check, if a color is valid.
68 * @param col The color.
69 * @return 1, if the color is ok, 0 if the color is illegal.
71 #define is_color(col) ((col) != NO_COLOR)
73 static INLINE int _get_irn_color(const ir_node *irn)
75 assert(!is_Block(irn) && "No block allowed here");
76 return get_ra_node_info(irn)->color;
79 static INLINE void _set_irn_color(const ir_node *irn, int color)
81 assert(!is_Block(irn) && "No block allowed here");
82 get_ra_node_info(irn)->color = color;
85 static INLINE int _is_allocatable_irn(const ir_node *irn)
87 assert(!is_Block(irn) && "No block allowed here");
88 return mode_is_datab(get_irn_mode(irn));
91 #define get_irn_color(irn) _get_irn_color(irn)
92 #define set_irn_color(irn,col) _set_irn_color(irn, col)
93 #define is_allocatable_irn(irn) _is_allocatable_irn(irn)
95 static INLINE struct list_head *_get_block_border_head(ir_node *block)
97 return &get_ra_block_info(block)->border_head;
101 * Check, if two phi operands interfere.
102 * @param a A node which is operand to a phi function.
103 * @param b Another node which is operand to a phi function.
104 * @return 1, if @p a and @p b interfere, 0 if not.
106 int phi_ops_interfere(const ir_node *a, const ir_node *b);
108 #endif /* BERA_T_H */