2 * Base routines for register allocation.
3 * @author Sebastian Hack
15 #include "besched_t.h"
18 FIRM_IMPL1(is_allocatable_irn, int, const ir_node *)
20 size_t ra_irn_data_offset = 0;
21 size_t ra_irg_data_offset = 0;
25 ra_irn_data_offset = register_additional_node_data(sizeof(ra_info_t));
26 ra_irg_data_offset = register_additional_graph_data(sizeof(void *));
29 static INLINE int values_interfere_dom(const ir_node *a, const ir_node *b)
31 const ir_node *b1 = get_nodes_block(a);
32 const ir_node *b2 = get_nodes_block(b);
35 assert(block_dominates(b1, b2));
38 * if the two blocks are not equal, a and b can only interfere if a is
41 if(b1 != b2 && !is_live_in(b2, a))
44 lo_a = is_live_end(b2, a);
45 lo_b = is_live_end(b2, b);
48 * If the two blocks are the same and one value is live out and the
49 * definition of the other is after the definition ov the live out
50 * value, they interfere.
53 int pos_a = sched_get_time_step(a);
54 int pos_b = sched_get_time_step(b);
56 if((pos_a < pos_b && lo_a) || (pos_b < pos_a && lo_b))
61 * Now it is left to check, if the sequence from the last use of 'b'
62 * (or the end of the block b2, if b is live out)
63 * to the def of 'b' contains a use and NOT the def of 'a'. Then they
69 /* Initialize the liveness. */
73 /* Go from the end of block b2 and try to detect the liveness. */
74 sched_foreach_reverse(b2, irn) {
78 * If the definition of 'a' was found 'a' and 'b' interfere, if
84 /* Same goes for 'b'. */
88 /* If 'a' is not yet live, search for a use. */
90 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
91 if(get_irn_n(irn, i) == a) {
99 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
100 if(get_irn_n(irn, i) == b) {
109 assert(0 && "You may never reach this place");
111 /* This is never reached */
115 int values_interfere(const ir_node *a, const ir_node *b)
117 const ir_node *b1 = get_nodes_block(a);
118 const ir_node *b2 = get_nodes_block(b);
120 if(block_dominates(b1, b2))
121 return values_interfere_dom(a, b);
122 else if(block_dominates(b2, b1))
123 return values_interfere_dom(b, a);