3 * Internal datastructures for the chordal register allocator.
4 * @author Sebastian Hack
22 #include "bechordal.h"
24 /** Defines an invalid register index. */
29 #define DBG_CHORDAL "firm.be.ra.chordal"
32 * A liveness interval border.
34 typedef struct _border_t {
36 unsigned magic; /**< A magic number for checking. */
38 struct list_head list; /**< list head for queuing. */
39 struct _border_t *other_end; /**< The other end of the border. */
40 ir_node *irn; /**< The node. */
41 unsigned step; /**< The number equal to the interval border. */
42 unsigned pressure; /**< The pressure at this interval border.
43 (The border itself is counting). */
44 unsigned is_def : 1; /**< Does this border denote a use or a def. */
45 unsigned is_real : 1; /**< Is the def/use real? Or is it just inserted
46 at block beginnings or ends to ensure that inside
47 a block, each value has one begin and one end. */
51 * Environment for each of the chordal register allocator phases
53 struct _be_chordal_env_t {
54 struct obstack obst; /**< An obstack for temporary storage. */
55 pmap *border_heads; /**< Maps blocks to border heads. */
56 ir_graph *irg; /**< The graph the reg alloc is running on. */
59 set *nodes; /**< The interference graph nodes. */
60 set *edges; /**< The interference graph edges. */
63 bitset_t *live; /**< A liveness bitset. */
64 bitset_t *colors; /**< The color mask. */
65 bitset_t *in_colors; /**< Colors used by live in values. */
66 int colors_n; /**< The number of colors. */
67 const arch_env_t *arch_env; /**< The arch interface environment. */
68 const arch_register_class_t *cls; /**< The current register class. */
69 void *data; /**< Some pointer, to which different
70 phases can attach data to. */
73 static INLINE struct list_head *
74 _get_block_border_head(const be_chordal_env_t *inf, ir_node *bl)
76 return pmap_get(inf->border_heads, bl);
79 #define get_block_border_head(info, bl) _get_block_border_head(info, bl)
81 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b);
84 typedef struct _if_node_t {
89 typedef struct _if_edge_t {
93 set *be_ra_get_ifg_edges(const be_chordal_env_t *env);
94 set *be_ra_get_ifg_nodes(const be_chordal_env_t *env);
95 int ifg_has_edge(const be_chordal_env_t *env, const if_node_t *n1, const if_node_t* n2);
97 #define ifn_get_degree(ifnode) pset_count(ifnode->neighb)
98 #define foreach_neighb(ifnode, curr) \
99 for(curr=pset_first(ifnode->neighb); curr; curr=pset_next(ifnode->neighb))
102 extern void be_ra_chordal_spill(be_chordal_env_t *env);
104 #endif /* _BECHORDAL_T_H */