2 * Base routines for register allocation.
3 * @author Sebastian Hack
18 #include "besched_t.h"
21 FIRM_IMPL1(is_allocatable_irn, int, const ir_node *)
23 size_t ra_irn_data_offset = 0;
24 size_t ra_irg_data_offset = 0;
28 ra_irn_data_offset = register_additional_node_data(sizeof(ra_info_t));
29 ra_irg_data_offset = register_additional_graph_data(sizeof(void *));
32 static INLINE int values_interfere_dom(const ir_node *a, const ir_node *b)
34 const ir_node *b1 = get_nodes_block(a);
35 const ir_node *b2 = get_nodes_block(b);
38 assert(block_dominates(b1, b2));
41 * if the two blocks are not equal, a and b can only interfere if a is
44 if(b1 != b2 && !is_live_in(b2, a))
47 lo_a = is_live_end(b2, a);
48 lo_b = is_live_end(b2, b);
51 * If the two blocks are the same and one value is live out and the
52 * definition of the other is after the definition ov the live out
53 * value, they interfere.
56 int pos_a = sched_get_time_step(a);
57 int pos_b = sched_get_time_step(b);
59 if((pos_a < pos_b && lo_a) || (pos_b < pos_a && lo_b))
64 * Now it is left to check, if the sequence from the last use of 'b'
65 * (or the end of the block b2, if b is live out)
66 * to the def of 'b' contains a use and NOT the def of 'a'. Then they
72 /* Initialize the liveness. */
76 /* Go from the end of block b2 and try to detect the liveness. */
77 sched_foreach_reverse(b2, irn) {
81 * If the definition of 'a' was found 'a' and 'b' interfere, if
87 /* Same goes for 'b'. */
91 /* If 'a' is not yet live, search for a use. */
93 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
94 if(get_irn_n(irn, i) == a) {
102 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
103 if(get_irn_n(irn, i) == b) {
112 assert(0 && "You may never reach this place");
114 /* This is never reached */
118 int values_interfere(const ir_node *a, const ir_node *b)
120 const ir_node *b1 = get_nodes_block(a);
121 const ir_node *b2 = get_nodes_block(b);
123 if(block_dominates(b1, b2))
124 return values_interfere_dom(a, b);
125 else if(block_dominates(b2, b1))
126 return values_interfere_dom(b, a);