2 * Base routines for register allocation.
3 * @author Sebastian Hack
18 #include "besched_t.h"
21 int value_dominates(const ir_node *a, const ir_node *b)
24 const ir_node *ba = get_block(a);
25 const ir_node *bb = get_block(b);
28 * a and b are not in the same block,
29 * so dominance is determined by the dominance of the blocks.
32 res = block_dominates(ba, bb);
35 * Dominance is determined by the time steps of the schedule.
38 sched_timestep_t as = sched_get_time_step(a);
39 sched_timestep_t bs = sched_get_time_step(b);
47 * Check, if two values interfere.
48 * @param a The first value.
49 * @param b The second value.
50 * @return 1, if a and b interfere, 0 if not.
52 int values_interfere(const ir_node *a, const ir_node *b)
54 int a2b = value_dominates(a, b);
55 int b2a = value_dominates(b, a);
57 /* If there is no dominance relation, they do not interfere. */
59 const ir_edge_t *edge;
60 ir_node *ba = get_nodes_block(a);
61 ir_node *bb = get_nodes_block(b);
64 * Adjust a and b so, that a dominates b if
65 * a dominates b or vice versa.
74 * If a is live end in b's block it is
75 * live at b's definition (a dominates b)
77 if(is_live_end(bb, a))
81 * Look at all usages of a.
82 * If there's one usage of a in the block of b, then
83 * we check, if this use is dominated by b, if that's true
85 * Uses of a not in b's block can be disobeyed, because the
86 * check for a being live at the end of b's block is already
89 foreach_out_edge(a, edge) {
90 const ir_node *user = edge->src;
91 if(get_nodes_block(user) == bb
93 && value_dominates(b, user))