Commit c18d23ad authored by Matthias Braun's avatar Matthias Braun
Browse files

remove lv argument from be_values_interfere

We query liveness from the irg on demand now.
parent d1b570dc
...@@ -53,7 +53,6 @@ static void pair_up_operands(be_chordal_env_t const *const env, be_insn_t *const ...@@ -53,7 +53,6 @@ static void pair_up_operands(be_chordal_env_t const *const env, be_insn_t *const
* same register as the out operand. */ * same register as the out operand. */
int const n_regs = env->cls->n_regs; int const n_regs = env->cls->n_regs;
unsigned *const bs = rbitset_alloca(n_regs); unsigned *const bs = rbitset_alloca(n_regs);
be_lv_t *const lv = be_get_irg_liveness(env->irg);
for (int j = 0; j < insn->use_start; ++j) { for (int j = 0; j < insn->use_start; ++j) {
/* Try to find an in operand which has ... */ /* Try to find an in operand which has ... */
be_operand_t *smallest = NULL; be_operand_t *smallest = NULL;
...@@ -61,7 +60,7 @@ static void pair_up_operands(be_chordal_env_t const *const env, be_insn_t *const ...@@ -61,7 +60,7 @@ static void pair_up_operands(be_chordal_env_t const *const env, be_insn_t *const
be_operand_t *const out_op = &insn->ops[j]; be_operand_t *const out_op = &insn->ops[j];
for (int i = insn->use_start; i < insn->n_ops; ++i) { for (int i = insn->use_start; i < insn->n_ops; ++i) {
be_operand_t *const op = &insn->ops[i]; be_operand_t *const op = &insn->ops[i];
if (op->partner || be_values_interfere(lv, insn->irn, op->carrier)) if (op->partner || be_values_interfere(insn->irn, op->carrier))
continue; continue;
rbitset_copy(bs, op->regs, n_regs); rbitset_copy(bs, op->regs, n_regs);
...@@ -166,12 +165,11 @@ static void handle_constraints(be_chordal_env_t *const env, ir_node *const irn) ...@@ -166,12 +165,11 @@ static void handle_constraints(be_chordal_env_t *const env, ir_node *const irn)
/* Put all nodes which live through the constrained instruction also to the /* Put all nodes which live through the constrained instruction also to the
* allocation bipartite graph. They are considered unconstrained. */ * allocation bipartite graph. They are considered unconstrained. */
if (perm != NULL) { if (perm != NULL) {
be_lv_t *const lv = be_get_irg_liveness(env->irg);
foreach_out_edge(perm, edge) { foreach_out_edge(perm, edge) {
ir_node *const proj = get_edge_src_irn(edge); ir_node *const proj = get_edge_src_irn(edge);
assert(is_Proj(proj)); assert(is_Proj(proj));
if (!be_values_interfere(lv, proj, irn) || pmap_contains(partners, proj)) if (!be_values_interfere(proj, irn) || pmap_contains(partners, proj))
continue; continue;
/* Don't insert a node twice. */ /* Don't insert a node twice. */
......
...@@ -110,8 +110,7 @@ static inline int qnode_are_conflicting(const qnode_t *qn, const ir_node *n1, co ...@@ -110,8 +110,7 @@ static inline int qnode_are_conflicting(const qnode_t *qn, const ir_node *n1, co
conflict_t c; conflict_t c;
/* search for live range interference */ /* search for live range interference */
if (n1 != n2) { if (n1 != n2) {
be_lv_t *const lv = be_get_irg_liveness(get_irn_irg(n1)); if (be_values_interfere(n1, n2))
if (be_values_interfere(lv, n1, n2))
return 1; return 1;
} }
/* search for recoloring conflicts */ /* search for recoloring conflicts */
......
...@@ -710,11 +710,10 @@ static void populate_cloud(co2_t *env, co2_cloud_t *cloud, affinity_node_t *a, i ...@@ -710,11 +710,10 @@ static void populate_cloud(co2_t *env, co2_cloud_t *cloud, affinity_node_t *a, i
DB((env->dbg, LEVEL_2, "\t%+F\n", ci->inh.irn)); DB((env->dbg, LEVEL_2, "\t%+F\n", ci->inh.irn));
/* determine the nodes costs */ /* determine the nodes costs */
be_lv_t *const lv = be_get_irg_liveness(env->co->irg);
co_gs_foreach_neighb(a, n) { co_gs_foreach_neighb(a, n) {
costs += n->costs; costs += n->costs;
DB((env->dbg, LEVEL_3, "\t\tneigh %+F cost %d\n", n->irn, n->costs)); DB((env->dbg, LEVEL_3, "\t\tneigh %+F cost %d\n", n->irn, n->costs));
if (be_values_interfere(lv, a->irn, n->irn)) if (be_values_interfere(a->irn, n->irn))
cloud->inevit += n->costs; cloud->inevit += n->costs;
} }
......
...@@ -81,7 +81,6 @@ static inline bool sr_is_simplicial(ilp_env_t *const ienv, ir_node const *const ...@@ -81,7 +81,6 @@ static inline bool sr_is_simplicial(ilp_env_t *const ienv, ir_node const *const
{ {
bool res = true; bool res = true;
ir_node **all = NEW_ARR_F(ir_node*, 0); ir_node **all = NEW_ARR_F(ir_node*, 0);
be_lv_t *const lv = be_get_irg_liveness(ienv->co->irg);
neighbours_iter_t iter; neighbours_iter_t iter;
be_ifg_foreach_neighbour(ienv->co->cenv->ifg, &iter, ifn, curr) { be_ifg_foreach_neighbour(ienv->co->cenv->ifg, &iter, ifn, curr) {
/* Only consider non-removed neighbours. */ /* Only consider non-removed neighbours. */
...@@ -90,7 +89,7 @@ static inline bool sr_is_simplicial(ilp_env_t *const ienv, ir_node const *const ...@@ -90,7 +89,7 @@ static inline bool sr_is_simplicial(ilp_env_t *const ienv, ir_node const *const
/* Check whether the current node forms a clique with all previous nodes. */ /* Check whether the current node forms a clique with all previous nodes. */
for (size_t i = ARR_LEN(all); i-- != 0;) { for (size_t i = ARR_LEN(all); i-- != 0;) {
if (!be_values_interfere(lv, curr, all[i])) { if (!be_values_interfere(curr, all[i])) {
res = false; res = false;
goto end; goto end;
} }
......
...@@ -330,7 +330,6 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou ...@@ -330,7 +330,6 @@ static inline void remove_edge(set *edges, ir_node *n1, ir_node *n2, size_t *cou
static void build_clique_star_cstr(ilp_env_t *ienv) static void build_clique_star_cstr(ilp_env_t *ienv)
{ {
/* for each node with affinity edges */ /* for each node with affinity edges */
be_lv_t *const lv = be_get_irg_liveness(ienv->co->irg);
co_gs_foreach_aff_node(ienv->co, aff) { co_gs_foreach_aff_node(ienv->co, aff) {
struct obstack ob; struct obstack ob;
const ir_node *center = aff->irn; const ir_node *center = aff->irn;
...@@ -359,7 +358,7 @@ static void build_clique_star_cstr(ilp_env_t *ienv) ...@@ -359,7 +358,7 @@ static void build_clique_star_cstr(ilp_env_t *ienv)
n_edges = 0; n_edges = 0;
for (i=0; i<n_nodes; ++i) { for (i=0; i<n_nodes; ++i) {
for (o=0; o<i; ++o) { for (o=0; o<i; ++o) {
if (be_values_interfere(lv, nodes[i], nodes[o])) if (be_values_interfere(nodes[i], nodes[o]))
add_edge(edges, nodes[i], nodes[o], &n_edges); add_edge(edges, nodes[i], nodes[o], &n_edges);
} }
} }
...@@ -461,14 +460,13 @@ static void extend_path(ilp_env_t *ienv, pdeq *path, const ir_node *irn) ...@@ -461,14 +460,13 @@ static void extend_path(ilp_env_t *ienv, pdeq *path, const ir_node *irn)
curr_path = ALLOCAN(ir_node*, len); curr_path = ALLOCAN(ir_node*, len);
pdeq_copyl(path, (const void **)curr_path); pdeq_copyl(path, (const void **)curr_path);
be_lv_t *const lv = be_get_irg_liveness(ienv->co->irg);
for (i=1; i<len; ++i) { for (i=1; i<len; ++i) {
if (be_values_interfere(lv, irn, curr_path[i])) if (be_values_interfere(irn, curr_path[i]))
goto end; goto end;
} }
/* check for terminating interference */ /* check for terminating interference */
if (be_values_interfere(lv, irn, curr_path[0])) { if (be_values_interfere(irn, curr_path[0])) {
/* One node is not a path. */ /* One node is not a path. */
/* And a path of length 2 is covered by a clique star constraint. */ /* And a path of length 2 is covered by a clique star constraint. */
if (len > 2) { if (len > 2) {
......
...@@ -269,7 +269,7 @@ static int co_get_costs_all_one(const ir_node *root, int pos) ...@@ -269,7 +269,7 @@ static int co_get_costs_all_one(const ir_node *root, int pos)
* Determines a maximum weighted independent set with respect to * Determines a maximum weighted independent set with respect to
* the interference and conflict edges of all nodes in a qnode. * the interference and conflict edges of all nodes in a qnode.
*/ */
static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv) static int ou_max_ind_set_costs(unit_t *const ou)
{ {
/* assign the nodes into two groups. /* assign the nodes into two groups.
* safe: node has no interference, hence it is in every max stable set. * safe: node has no interference, hence it is in every max stable set.
...@@ -287,7 +287,7 @@ static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv) ...@@ -287,7 +287,7 @@ static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv)
ir_node *o_node = ou->nodes[o]; ir_node *o_node = ou->nodes[o];
if (i_node == o_node) if (i_node == o_node)
continue; continue;
if (be_values_interfere(lv, i_node, o_node)) { if (be_values_interfere(i_node, o_node)) {
unsafe_costs[unsafe_count] = ou->costs[i]; unsafe_costs[unsafe_count] = ou->costs[i];
unsafe[unsafe_count] = i_node; unsafe[unsafe_count] = i_node;
++unsafe_count; ++unsafe_count;
...@@ -310,7 +310,7 @@ static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv) ...@@ -310,7 +310,7 @@ static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv)
bitset_set(best, i); bitset_set(best, i);
/* check if it is a stable set */ /* check if it is a stable set */
for (int o=bitset_next_set(best, 0); o!=-1 && o<i; o=bitset_next_set(best, o+1)) for (int o=bitset_next_set(best, 0); o!=-1 && o<i; o=bitset_next_set(best, o+1))
if (be_values_interfere(lv, unsafe[i], unsafe[o])) { if (be_values_interfere(unsafe[i], unsafe[o])) {
bitset_clear(best, i); /* clear the bit and try next one */ bitset_clear(best, i); /* clear the bit and try next one */
break; break;
} }
...@@ -326,7 +326,7 @@ static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv) ...@@ -326,7 +326,7 @@ static int ou_max_ind_set_costs(unit_t *const ou, be_lv_t const *const lv)
/* check if curr is a stable set */ /* check if curr is a stable set */
for (int i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1)) for (int i=bitset_next_set(curr, 0); i!=-1; i=bitset_next_set(curr, i+1))
for (int o=bitset_next_set(curr, i+1); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to qnode_max_ind_set(): NOT (curr, i) */ for (int o=bitset_next_set(curr, i+1); o!=-1; o=bitset_next_set(curr, o+1)) /* !!!!! difference to qnode_max_ind_set(): NOT (curr, i) */
if (be_values_interfere(lv, unsafe[i], unsafe[o])) if (be_values_interfere(unsafe[i], unsafe[o]))
goto no_stable_set; goto no_stable_set;
/* if we arrive here, we have a stable set */ /* if we arrive here, we have a stable set */
...@@ -364,7 +364,6 @@ static void co_collect_units(ir_node *irn, void *env) ...@@ -364,7 +364,6 @@ static void co_collect_units(ir_node *irn, void *env)
unit->node_count = 1; unit->node_count = 1;
INIT_LIST_HEAD(&unit->queue); INIT_LIST_HEAD(&unit->queue);
be_lv_t *const lv = be_get_irg_liveness(co->irg);
/* Phi with some/all of its arguments */ /* Phi with some/all of its arguments */
if (is_Phi(irn)) { if (is_Phi(irn)) {
/* init */ /* init */
...@@ -378,7 +377,7 @@ static void co_collect_units(ir_node *irn, void *env) ...@@ -378,7 +377,7 @@ static void co_collect_units(ir_node *irn, void *env)
assert(arch_get_irn_reg_class(arg) == co->cls && "Argument not in same register class."); assert(arch_get_irn_reg_class(arg) == co->cls && "Argument not in same register class.");
if (arg == irn) if (arg == irn)
continue; continue;
if (be_values_interfere(lv, irn, arg)) { if (be_values_interfere(irn, arg)) {
unit->inevitable_costs += co->get_costs(irn, i); unit->inevitable_costs += co->get_costs(irn, i);
continue; continue;
} }
...@@ -412,7 +411,7 @@ static void co_collect_units(ir_node *irn, void *env) ...@@ -412,7 +411,7 @@ static void co_collect_units(ir_node *irn, void *env)
unit->costs = XREALLOC(unit->costs, int, unit->node_count); unit->costs = XREALLOC(unit->costs, int, unit->node_count);
} else if (is_Perm_Proj(irn)) { } else if (is_Perm_Proj(irn)) {
/* Proj of a perm with corresponding arg */ /* Proj of a perm with corresponding arg */
assert(!be_values_interfere(lv, irn, get_Perm_src(irn))); assert(!be_values_interfere(irn, get_Perm_src(irn)));
unit->nodes = XMALLOCN(ir_node*, 2); unit->nodes = XMALLOCN(ir_node*, 2);
unit->costs = XMALLOCN(int, 2); unit->costs = XMALLOCN(int, 2);
unit->node_count = 2; unit->node_count = 2;
...@@ -429,7 +428,7 @@ static void co_collect_units(ir_node *irn, void *env) ...@@ -429,7 +428,7 @@ static void co_collect_units(ir_node *irn, void *env)
ir_node *o = get_irn_n(skip_Proj(irn), i); ir_node *o = get_irn_n(skip_Proj(irn), i);
if (arch_irn_is_ignore(o)) if (arch_irn_is_ignore(o))
continue; continue;
if (be_values_interfere(lv, irn, o)) if (be_values_interfere(irn, o))
continue; continue;
++count; ++count;
} }
...@@ -447,7 +446,7 @@ static void co_collect_units(ir_node *irn, void *env) ...@@ -447,7 +446,7 @@ static void co_collect_units(ir_node *irn, void *env)
if (other & (1U << i)) { if (other & (1U << i)) {
ir_node *o = get_irn_n(skip_Proj(irn), i); ir_node *o = get_irn_n(skip_Proj(irn), i);
if (!arch_irn_is_ignore(o) && if (!arch_irn_is_ignore(o) &&
!be_values_interfere(lv, irn, o)) { !be_values_interfere(irn, o)) {
unit->nodes[k] = o; unit->nodes[k] = o;
unit->costs[k] = co->get_costs(irn, -1); unit->costs[k] = co->get_costs(irn, -1);
++k; ++k;
...@@ -468,7 +467,7 @@ static void co_collect_units(ir_node *irn, void *env) ...@@ -468,7 +467,7 @@ static void co_collect_units(ir_node *irn, void *env)
} }
/* Determine the minimal costs this unit will cause: min_nodes_costs */ /* Determine the minimal costs this unit will cause: min_nodes_costs */
unit->min_nodes_costs += unit->all_nodes_costs - ou_max_ind_set_costs(unit, lv); unit->min_nodes_costs += unit->all_nodes_costs - ou_max_ind_set_costs(unit);
/* Insert the new ou according to its sort_key */ /* Insert the new ou according to its sort_key */
struct list_head *tmp = &co->units; struct list_head *tmp = &co->units;
while (tmp->next != &co->units while (tmp->next != &co->units
...@@ -561,7 +560,6 @@ void co_complete_stats(const copy_opt_t *co, co_complete_stats_t *stat) ...@@ -561,7 +560,6 @@ void co_complete_stats(const copy_opt_t *co, co_complete_stats_t *stat)
memset(stat, 0, sizeof(stat[0])); memset(stat, 0, sizeof(stat[0]));
/* count affinity edges. */ /* count affinity edges. */
be_lv_t *const lv = be_get_irg_liveness(co->irg);
co_gs_foreach_aff_node(co, an) { co_gs_foreach_aff_node(co, an) {
stat->aff_nodes += 1; stat->aff_nodes += 1;
bitset_set(seen, get_irn_idx(an->irn)); bitset_set(seen, get_irn_idx(an->irn));
...@@ -575,7 +573,7 @@ void co_complete_stats(const copy_opt_t *co, co_complete_stats_t *stat) ...@@ -575,7 +573,7 @@ void co_complete_stats(const copy_opt_t *co, co_complete_stats_t *stat)
stat->unsatisfied_edges += 1; stat->unsatisfied_edges += 1;
} }
if (be_values_interfere(lv, an->irn, neigh->irn)) { if (be_values_interfere(an->irn, neigh->irn)) {
stat->aff_int += 1; stat->aff_int += 1;
stat->inevit_costs += neigh->costs; stat->inevit_costs += neigh->costs;
} }
...@@ -628,8 +626,7 @@ static void add_edge(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs) ...@@ -628,8 +626,7 @@ static void add_edge(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs)
static inline void add_edges(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs) static inline void add_edges(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs)
{ {
be_lv_t *const lv = be_get_irg_liveness(co->irg); if (n1 != n2 && !be_values_interfere(n1, n2)) {
if (n1 != n2 && !be_values_interfere(lv, n1, n2)) {
add_edge(co, n1, n2, costs); add_edge(co, n1, n2, costs);
add_edge(co, n2, n1, costs); add_edge(co, n2, n1, costs);
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "belive_t.h" #include "belive_t.h"
#include "besched.h" #include "besched.h"
#include "bemodule.h" #include "bemodule.h"
#include "beirg.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
...@@ -444,7 +445,7 @@ void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_ ...@@ -444,7 +445,7 @@ void be_liveness_nodes_live_before(be_lv_t const *const lv, arch_register_class_
} }
} }
bool be_values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b) bool be_values_interfere(const ir_node *a, const ir_node *b)
{ {
assert(a != b); assert(a != b);
if (value_strictly_dominates(b, a)) { if (value_strictly_dominates(b, a)) {
...@@ -461,6 +462,8 @@ bool be_values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b) ...@@ -461,6 +462,8 @@ bool be_values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b)
/* If a is live end in b's block it is /* If a is live end in b's block it is
* live at b's definition (a dominates b) */ * live at b's definition (a dominates b) */
const ir_node *const bb = get_nodes_block(b); const ir_node *const bb = get_nodes_block(b);
const ir_graph *const irg = get_Block_irg(bb);
const be_lv_t *const lv = be_get_irg_liveness(irg);
if (be_is_live_end(lv, bb, a)) if (be_is_live_end(lv, bb, a))
return true; return true;
......
...@@ -128,7 +128,7 @@ void be_liveness_end_of_block(const be_lv_t *lv, ...@@ -128,7 +128,7 @@ void be_liveness_end_of_block(const be_lv_t *lv,
* @param b The second value. * @param b The second value.
* @return true, if a and b interfere, false if not. * @return true, if a and b interfere, false if not.
*/ */
bool be_values_interfere(const be_lv_t *lv, const ir_node *a, const ir_node *b); bool be_values_interfere(const ir_node *a, const ir_node *b);
/** /**
* Compute a set of nodes which are live just before the given node. * Compute a set of nodes which are live just before the given node.
......
...@@ -705,13 +705,13 @@ static int push_through_perm(ir_node *perm) ...@@ -705,13 +705,13 @@ static int push_through_perm(ir_node *perm)
int new_size; int new_size;
ir_node *frontier = bl; ir_node *frontier = bl;
int i, n; int i, n;
be_lv_t *lv = be_get_irg_liveness(irg);
/* get some Proj and find out the register class of that Proj. */ /* get some Proj and find out the register class of that Proj. */
ir_node *one_proj = get_edge_src_irn(get_irn_out_edge_first_kind(perm, EDGE_KIND_NORMAL)); ir_node *one_proj = get_edge_src_irn(get_irn_out_edge_first_kind(perm, EDGE_KIND_NORMAL));
const arch_register_class_t *cls = arch_get_irn_reg_class(one_proj); const arch_register_class_t *cls = arch_get_irn_reg_class(one_proj);
assert(is_Proj(one_proj)); assert(is_Proj(one_proj));
(void)irg;
DB((dbg_permmove, LEVEL_1, "perm move %+F irg %+F\n", perm, irg)); DB((dbg_permmove, LEVEL_1, "perm move %+F irg %+F\n", perm, irg));
/* Find the point in the schedule after which the /* Find the point in the schedule after which the
...@@ -728,7 +728,7 @@ static int push_through_perm(ir_node *perm) ...@@ -728,7 +728,7 @@ static int push_through_perm(ir_node *perm)
goto found_front; goto found_front;
} }
be_foreach_use(irn, cls, in_req_, op, op_req_, be_foreach_use(irn, cls, in_req_, op, op_req_,
if (!be_values_interfere(lv, op, one_proj)) { if (!be_values_interfere(op, one_proj)) {
frontier = irn; frontier = irn;
goto found_front; goto found_front;
} }
......
...@@ -161,7 +161,7 @@ static void prepare_constr_insn(ir_node *const node) ...@@ -161,7 +161,7 @@ static void prepare_constr_insn(ir_node *const node)
* results. Additional copies here would destroy this. */ * results. Additional copies here would destroy this. */
if (be_is_Copy(in)) if (be_is_Copy(in))
continue; continue;
if (!be_values_interfere(lv, node, in)) if (!be_values_interfere(node, in))
continue; continue;
bool common_limits = false; bool common_limits = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment