2 * Base routines for register allocation.
3 * @author Sebastian Hack
17 #include "besched_t.h"
20 static INLINE int values_interfere_dom(const ir_node *a, const ir_node *b)
22 const ir_node *b1 = get_nodes_block(a);
23 const ir_node *b2 = get_nodes_block(b);
26 assert(block_dominates(b1, b2));
29 * if the two blocks are not equal, a and b can only interfere if a is
32 if(b1 != b2 && !is_live_in(b2, a))
35 lo_a = is_live_end(b2, a);
36 lo_b = is_live_end(b2, b);
39 * If the two blocks are the same and one value is live out and the
40 * definition of the other is after the definition ov the live out
41 * value, they interfere.
44 int pos_a = sched_get_time_step(a);
45 int pos_b = sched_get_time_step(b);
47 if((pos_a < pos_b && lo_a) || (pos_b < pos_a && lo_b))
52 * Now it is left to check, if the sequence from the last use of 'b'
53 * (or the end of the block b2, if b is live out)
54 * to the def of 'b' contains a use and NOT the def of 'a'. Then they
60 /* Initialize the liveness. */
64 /* Go from the end of block b2 and try to detect the liveness. */
65 sched_foreach_reverse(b2, irn) {
69 * If the definition of 'a' was found 'a' and 'b' interfere, if
75 /* Same goes for 'b'. */
79 /* If 'a' is not yet live, search for a use. */
81 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
82 if(get_irn_n(irn, i) == a) {
90 for(i = 0, n = get_irn_arity(irn); i < n; ++i)
91 if(get_irn_n(irn, i) == b) {
100 assert(0 && "You may never reach this place");
102 /* This is never reached */
106 int values_interfere(const ir_node *a, const ir_node *b)
108 const ir_node *b1 = get_nodes_block(a);
109 const ir_node *b2 = get_nodes_block(b);
111 if(block_dominates(b1, b2))
112 return values_interfere_dom(a, b);
113 else if(block_dominates(b2, b1))
114 return values_interfere_dom(b, a);