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
* same register as the out operand. */
int const n_regs = env->cls->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) {
/* Try to find an in operand which has ... */
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
be_operand_t *const out_op = &insn->ops[j];
for (int i = insn->use_start; i < insn->n_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;
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)
/* Put all nodes which live through the constrained instruction also to the
* allocation bipartite graph. They are considered unconstrained. */
if (perm != NULL) {
be_lv_t *const lv = be_get_irg_liveness(env->irg);
foreach_out_edge(perm, edge) {
ir_node *const proj = get_edge_src_irn(edge);
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;
/* 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
conflict_t c;
/* search for live range interference */
if (n1 != n2) {
be_lv_t *const lv = be_get_irg_liveness(get_irn_irg(n1));
if (be_values_interfere(lv, n1, n2))
if (be_values_interfere(n1, n2))
return 1;
}
/* search for recoloring conflicts */
......
......@@ -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));
/* determine the nodes costs */
be_lv_t *const lv = be_get_irg_liveness(env->co->irg);
co_gs_foreach_neighb(a, n) {
costs += 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;
}
......
......@@ -81,7 +81,6 @@ static inline bool sr_is_simplicial(ilp_env_t *const ienv, ir_node const *const
{
bool res = true;
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;
be_ifg_foreach_neighbour(ienv->co->cenv->ifg, &iter, ifn, curr) {
/* Only consider non-removed neighbours. */
......@@ -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. */
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;
goto end;
}
......
......@@ -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)
{
/* 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) {
struct obstack ob;
const ir_node *center = aff->irn;
......@@ -359,7 +358,7 @@ static void build_clique_star_cstr(ilp_env_t *ienv)
n_edges = 0;
for (i=0; i<n_nodes; ++i) {
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);
}
}
......@@ -461,14 +460,13 @@ static void extend_path(ilp_env_t *ienv, pdeq *path, const ir_node *irn)
curr_path = ALLOCAN(ir_node*, len);
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) {
if (be_values_interfere(lv, irn, curr_path[i]))
if (be_values_interfere(irn, curr_path[i]))
goto end;
}
/* 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. */
/* And a path of length 2 is covered by a clique star constraint. */
if (len > 2) {
......
......@@ -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
* 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.
* 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)
ir_node *o_node = ou->nodes[o];
if (i_node == o_node)
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[unsafe_count] = i_node;
++unsafe_count;
......@@ -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);
/* 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))
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 */
break;
}
......@@ -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 */
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) */
if (be_values_interfere(lv, unsafe[i], unsafe[o]))
if (be_values_interfere(unsafe[i], unsafe[o]))
goto no_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)
unit->node_count = 1;
INIT_LIST_HEAD(&unit->queue);
be_lv_t *const lv = be_get_irg_liveness(co->irg);
/* Phi with some/all of its arguments */
if (is_Phi(irn)) {
/* init */
......@@ -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.");
if (arg == irn)
continue;
if (be_values_interfere(lv, irn, arg)) {
if (be_values_interfere(irn, arg)) {
unit->inevitable_costs += co->get_costs(irn, i);
continue;
}
......@@ -412,7 +411,7 @@ static void co_collect_units(ir_node *irn, void *env)
unit->costs = XREALLOC(unit->costs, int, unit->node_count);
} else if (is_Perm_Proj(irn)) {
/* 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->costs = XMALLOCN(int, 2);
unit->node_count = 2;
......@@ -429,7 +428,7 @@ static void co_collect_units(ir_node *irn, void *env)
ir_node *o = get_irn_n(skip_Proj(irn), i);
if (arch_irn_is_ignore(o))
continue;
if (be_values_interfere(lv, irn, o))
if (be_values_interfere(irn, o))
continue;
++count;
}
......@@ -447,7 +446,7 @@ static void co_collect_units(ir_node *irn, void *env)
if (other & (1U << i)) {
ir_node *o = get_irn_n(skip_Proj(irn), i);
if (!arch_irn_is_ignore(o) &&
!be_values_interfere(lv, irn, o)) {
!be_values_interfere(irn, o)) {
unit->nodes[k] = o;
unit->costs[k] = co->get_costs(irn, -1);
++k;
......@@ -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 */
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 */
struct list_head *tmp = &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)
memset(stat, 0, sizeof(stat[0]));
/* count affinity edges. */
be_lv_t *const lv = be_get_irg_liveness(co->irg);
co_gs_foreach_aff_node(co, an) {
stat->aff_nodes += 1;
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)
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->inevit_costs += neigh->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)
{
be_lv_t *const lv = be_get_irg_liveness(co->irg);
if (n1 != n2 && !be_values_interfere(lv, n1, n2)) {
if (n1 != n2 && !be_values_interfere(n1, n2)) {
add_edge(co, n1, n2, costs);
add_edge(co, n2, n1, costs);
}
......
......@@ -26,6 +26,7 @@
#include "belive_t.h"
#include "besched.h"
#include "bemodule.h"
#include "beirg.h"
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_
}
}
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);
if (value_strictly_dominates(b, a)) {
......@@ -460,7 +461,9 @@ 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
* 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))
return true;
......
......@@ -128,7 +128,7 @@ void be_liveness_end_of_block(const be_lv_t *lv,
* @param b The second value.
* @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.
......
......@@ -705,13 +705,13 @@ static int push_through_perm(ir_node *perm)
int new_size;
ir_node *frontier = bl;
int i, n;
be_lv_t *lv = be_get_irg_liveness(irg);
/* 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));
const arch_register_class_t *cls = arch_get_irn_reg_class(one_proj);
assert(is_Proj(one_proj));
(void)irg;
DB((dbg_permmove, LEVEL_1, "perm move %+F irg %+F\n", perm, irg));
/* Find the point in the schedule after which the
......@@ -728,7 +728,7 @@ static int push_through_perm(ir_node *perm)
goto found_front;
}
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;
goto found_front;
}
......
......@@ -161,7 +161,7 @@ static void prepare_constr_insn(ir_node *const node)
* results. Additional copies here would destroy this. */
if (be_is_Copy(in))
continue;
if (!be_values_interfere(lv, node, in))
if (!be_values_interfere(node, in))
continue;
bool common_limits = false;
......
Markdown is supported
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