Commit 294764ce authored by Matthias Braun's avatar Matthias Braun
Browse files

get rid of benodesets (in favour of ir_nodeset), report nextuse place in beuses

[r16417]
parent 6dbf1a93
......@@ -43,7 +43,6 @@
#include "becopyopt_t.h"
#include "becopystat.h"
#include "benodesets.h"
#include "beintlive_t.h"
#include "beirg_t.h"
......@@ -56,7 +55,7 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
#define SLOTS_CHANGED_NODES 32
#define list_entry_queue(lh) list_entry(lh, qnode_t, queue)
#define HASH_CONFLICT(c) (nodeset_hash(c.n1) ^ nodeset_hash(c.n2))
#define HASH_CONFLICT(c) (hash_irn(c.n1) ^ hash_irn(c.n2))
/**
* Modeling additional conflicts between nodes. NOT live range interference
......@@ -155,7 +154,7 @@ static int set_cmp_node_stat_t(const void *x, const void *y, size_t size) {
static INLINE const node_stat_t *qnode_find_node(const qnode_t *qn, ir_node *irn) {
node_stat_t find;
find.irn = irn;
return set_find(qn->changed_nodes, &find, sizeof(find), nodeset_hash(irn));
return set_find(qn->changed_nodes, &find, sizeof(find), hash_irn(irn));
}
/**
......@@ -167,7 +166,7 @@ static INLINE node_stat_t *qnode_find_or_insert_node(const qnode_t *qn, ir_node
find.irn = irn;
find.new_color = NO_COLOR;
find.pinned_local = 0;
return set_insert(qn->changed_nodes, &find, sizeof(find), nodeset_hash(irn));
return set_insert(qn->changed_nodes, &find, sizeof(find), hash_irn(irn));
}
/**
......
......@@ -61,7 +61,6 @@
#include "becopyilp_t.h"
#include "beifg_t.h"
#include "besched_t.h"
#include "benodesets.h"
#define DEBUG_LVL 1
......@@ -232,7 +231,7 @@ static int compare_edge_t(const void *k1, const void *k2, size_t size) {
return ! (e1->n1 == e2->n1 && e1->n2 == e2->n2);
}
#define HASH_EDGE(e) (nodeset_hash((e)->n1) ^ nodeset_hash((e)->n2))
#define HASH_EDGE(e) (hash_irn((e)->n1) ^ hash_irn((e)->n2))
static INLINE edge_t *add_edge(set *edges, ir_node *n1, ir_node *n2, int *counter) {
edge_t new_edge;
......
......@@ -60,7 +60,6 @@
#include "belive_t.h"
#include "beinsn_t.h"
#include "besched_t.h"
#include "benodesets.h"
#include "bejavacoal.h"
#include "bestatevent.h"
#include "beirg_t.h"
......@@ -741,7 +740,7 @@ static void add_edge(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs) {
new_node.irn = n1;
new_node.degree = 0;
new_node.neighbours = NULL;
node = set_insert(co->nodes, &new_node, sizeof(new_node), nodeset_hash(new_node.irn));
node = set_insert(co->nodes, &new_node, sizeof(new_node), hash_irn(new_node.irn));
for (nbr = node->neighbours; nbr; nbr = nbr->next)
if (nbr->irn == n2) {
......@@ -833,7 +832,7 @@ int co_gs_is_optimizable(copy_opt_t *co, ir_node *irn) {
ASSERT_GS_AVAIL(co);
new_node.irn = irn;
n = set_find(co->nodes, &new_node, sizeof(new_node), nodeset_hash(new_node.irn));
n = set_find(co->nodes, &new_node, sizeof(new_node), hash_irn(new_node.irn));
if (n) {
return (n->degree > 0);
} else
......
......@@ -30,11 +30,11 @@
#include "obst.h"
#include "list.h"
#include "set.h"
#include "irnode_t.h"
#include "bearch_t.h"
#include "bechordal_t.h"
#include "becopyopt.h"
#include "benodesets.h"
/**
* Data representing the problem of copy minimization.
......@@ -140,7 +140,7 @@ static INLINE affinity_node_t *get_affinity_info(const copy_opt_t *co, ir_node *
ASSERT_GS_AVAIL(co);
find.irn = irn;
return set_find(co->nodes, &find, sizeof(find), nodeset_hash(irn));
return set_find(co->nodes, &find, sizeof(find), hash_irn(irn));
}
#define co_gs_nodes_begin(co) set_first((co)->nodes)
......
......@@ -43,7 +43,6 @@
#include "beintlive_t.h"
#include "beifg_t.h"
#include "bechordal_t.h"
#include "benodesets.h"
typedef struct _cli_head_t {
struct list_head list;
......@@ -116,7 +115,7 @@ static cli_element_t *get_new_cli_element(ifg_clique_t *ifg)
return cli_element;
}
static void write_clique(nodeset *live_set, ifg_clique_t *ifg)
static void write_clique(ir_nodeset_t *live_set, ifg_clique_t *ifg)
{
ir_node *live_irn;
ir_node *test_node;
......@@ -127,8 +126,9 @@ static void write_clique(nodeset *live_set, ifg_clique_t *ifg)
cli_element_t *element = NULL;
cli_head_t *cli_head = get_new_cli_head(ifg);
int is_element = 0;
ir_nodeset_iterator_t iter;
foreach_nodeset(live_set, live_irn)
foreach_ir_nodeset(live_set, live_irn, iter)
{
/* test if node is max or min dominator*/
test_node = live_irn;
......@@ -327,10 +327,12 @@ static void find_neighbour_walker(ir_node *bl, void *data)
{
ifg_clique_t *ifg = data;
struct list_head *head = get_block_border_head(ifg->env, bl);
int was_def = 0;
nodeset *live = new_nodeset(ifg->env->cls->n_regs);
int was_def = 0;
ir_nodeset_t live;
border_t *b;
ir_nodeset_init(&live);
assert(is_Block(bl) && "There is no block to work on.");
foreach_border_head(head, b) /* follow the borders of the block */
......@@ -339,7 +341,7 @@ static void find_neighbour_walker(ir_node *bl, void *data)
if (b->is_def) /* b is a new node */
{
nodeset_insert(live, irn);
ir_nodeset_insert(&live, irn);
if(b->is_real)
{
was_def = 1;
......@@ -349,13 +351,13 @@ static void find_neighbour_walker(ir_node *bl, void *data)
{
if (was_def == 1) /* if there is a USE after a DEF... */
{
write_clique(live, ifg); /* ...add the clique. */
write_clique(&live, ifg); /* ...add the clique. */
was_def = 0;
}
nodeset_remove(live, irn);
ir_nodeset_remove(&live, irn);
}
}
del_nodeset(live);
ir_nodeset_destroy(&live);
}
static void find_first_neighbour(const ifg_clique_t *ifg, cli_iter_t *it, const ir_node *irn)
......
......@@ -30,7 +30,6 @@
#include <stdlib.h>
#include "benodesets.h"
#include "list.h"
#include "irnode_t.h"
......@@ -171,10 +170,12 @@ static void find_neighbour_walker(ir_node *bl, void *data)
{
ifg_list_t *ifg = data;
struct list_head *head = get_block_border_head(ifg->env, bl);
nodeset *live = new_nodeset(ifg->env->cls->n_regs);
ir_nodeset_t live;
ir_node *live_irn = NULL;
border_t *b = NULL;
ir_nodeset_init(&live);
assert(is_Block(bl) && "There is no block to work on");
foreach_border_head(head, b) /* follow the borders of each block */
......@@ -182,10 +183,12 @@ static void find_neighbour_walker(ir_node *bl, void *data)
if (b->is_def)
{
create_node(ifg, b->irn); /* add the node to the array of all nodes of this ifg implementation */
nodeset_insert(live, b->irn);
ir_nodeset_insert(&live, b->irn);
if (b->is_real) /* this is a new node */
{
foreach_nodeset(live, live_irn)
ir_nodeset_iterator_t iter;
foreach_ir_nodeset(&live, live_irn, iter)
{
if (b->irn != live_irn) /* add a as a neighbour to b and vice versa */
add_edge(ifg, b->irn, live_irn);
......@@ -194,13 +197,11 @@ static void find_neighbour_walker(ir_node *bl, void *data)
}
else /* b->irn is now dead */
{
if (nodeset_find(live, b->irn))
nodeset_remove(live, b->irn);
ir_nodeset_remove(&live, b->irn);
}
}
if (live)
del_nodeset(live);
ir_nodeset_destroy(&live);
}
static ir_node *get_first_node(const ifg_list_t *ifg, nodes_iter_t *it)
......
......@@ -71,7 +71,6 @@
#include "beutil.h"
#include "bestat.h"
#include "beirg_t.h"
#include "benodesets.h"
typedef struct _ilpsched_options_t {
unsigned regpress;
......@@ -1127,7 +1126,7 @@ static void create_variables(be_ilpsched_env_t *env, lpp_t *lpp, be_ilpsched_irn
* Collect all operands and nodes @p irn depends on.
* If there is a Proj within the dependencies, all other Projs of the parent node are added as well.
*/
static nodeset *sta_collect_in_deps(ir_node *irn, nodeset *deps) {
static void sta_collect_in_deps(ir_node *irn, ir_nodeset_t *deps) {
int i;
for (i = get_irn_ins_or_deps(irn) - 1; i >= 0; --i) {
......@@ -1139,15 +1138,13 @@ static nodeset *sta_collect_in_deps(ir_node *irn, nodeset *deps) {
p = get_Proj_pred(p);
foreach_out_edge(p, edge) {
ir_node *src = get_edge_src_irn(edge);
nodeset_insert(deps, src);
ir_nodeset_insert(deps, src);
}
}
else {
nodeset_insert(deps, p);
ir_nodeset_insert(deps, p);
}
}
return deps;
}
/**
......@@ -1175,7 +1172,10 @@ static void create_assignment_and_precedence_constraints(be_ilpsched_env_t *env,
be_ilpsched_irn_t *node;
ilpsched_node_attr_t *na;
ir_node *pred;
nodeset *deps = new_nodeset(16);
ir_nodeset_t deps;
ir_nodeset_iterator_t iter;
ir_nodeset_init(&deps);
node = get_ilpsched_irn(env, irn);
na = get_ilpsched_node_attr(node);
......@@ -1200,8 +1200,8 @@ static void create_assignment_and_precedence_constraints(be_ilpsched_env_t *env,
ilp_timer_push(t_cst_prec);
bs_block_irns = bitset_clear_all(bs_block_irns);
deps = sta_collect_in_deps(irn, deps);
foreach_nodeset(deps, pred) {
sta_collect_in_deps(irn, &deps);
foreach_ir_nodeset(&deps, pred, iter) {
unsigned t_low, t_high, t;
be_ilpsched_irn_t *pred_node;
ilpsched_node_attr_t *pna;
......@@ -1274,7 +1274,7 @@ static void create_assignment_and_precedence_constraints(be_ilpsched_env_t *env,
DEL_ARR_F(tmp_var_idx);
}
}
del_nodeset(deps);
ir_nodeset_destroy(&deps);
ilp_timer_pop();
}
DBG((env->dbg, LEVEL_1, "\t%u assignement constraints (%g sec)\n",
......
......@@ -45,7 +45,6 @@
#include "besched_t.h"
#include "bestat.h"
#include "bessaconstr.h"
#include "benodesets.h"
#include "beintlive_t.h"
#undef KEEP_ALIVE_COPYKEEP_HACK
......@@ -599,8 +598,8 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different,
sched_add_after(irn, keep);
/* insert the other different and it's copies into the set */
key.op = other_different;
entry = pset_find(op_set, &key, nodeset_hash(other_different));
key.op = other_different;
entry = pset_find(op_set, &key, hash_irn(other_different));
if (! entry) {
entry = obstack_alloc(&env->obst, sizeof(*entry));
......@@ -617,7 +616,7 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different,
ir_nodeset_insert(&entry->copies, keep);
}
pset_insert(op_set, entry, nodeset_hash(other_different));
pset_insert(op_set, entry, hash_irn(other_different));
}
/**
......
/*
* Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @brief A lightweight wrapper around pset to store IR nodes.
* @author Michael Beck
* @version $Id$
*
* In some algorithms we want a more deterministic behavior
* which the pset_ptr did not guarantee due to it's hash function
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "benodesets.h"
#include "irnode_t.h"
/*
* Calculates a hash value for a node.
*
* Use its node number
*/
unsigned nodeset_hash(const ir_node *n) {
return (unsigned)get_irn_idx(n);
}
/*
* Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @brief A lightweight wrapper around pset to store IR nodes.
* @author Michael Beck
* @version $Id$
*
* In some algorithms we want a more deterministic behavior
* which the pset_ptr did not guarantee due to it's hash function
*/
#ifndef FIRM_BE_BENODESETS_H
#define FIRM_BE_BENODESETS_H
#include "irnode.h"
#include "pset.h"
typedef struct pset nodeset;
/**
* Calculates a hash value for a node.
*/
unsigned nodeset_hash(const ir_node *n);
/**
* Creates a new nodeset.
*
* @param slots Initial number of collision chains. I.e., #slots
* different keys can be hashed without collisions.
*
* @returns
* created nodeset
*/
static INLINE nodeset *new_nodeset(int slots)
{
return new_pset(pset_default_ptr_cmp, slots);
}
/*
* Define some convenience macros.
*/
#define new_nodeset_default() new_nodeset(64)
/**
* Deletes a nodeset.
*
* @param nset the nodeset
*
* @note
* This does NOT delete the elements of this node set, just it's pointers!
*/
static INLINE void del_nodeset(nodeset *nset)
{
del_pset(nset);
}
/**
* Returns the number of nodes in a nodeset.
*
* @param nset the nodeset
*/
static INLINE int nodeset_count(nodeset *nset)
{
return pset_count(nset);
}
/**
* Searches a node in a node set.
*
* @param nset the pset to search in
* @param key the node to search
*
* @return
* the pointer of the found node in the nodeset or NULL if it was not found
*/
static INLINE ir_node *nodeset_find(nodeset *nset, ir_node *key)
{
return (ir_node *) pset_find(nset, key, nodeset_hash(key));
}
/**
* Inserts a node into a pset.
*
* @param nset the nodeset to insert in
* @param key a pointer to the element to be inserted
*
* @return a pointer to the inserted element
*
* @note
* It is not possible to insert an element more than once. If an element
* that should be inserted is already in the set, this functions does
* nothing but returning its already existing set_entry.
*/
static INLINE ir_node *nodeset_insert(nodeset *nset, ir_node *key)
{
return (ir_node *) pset_insert(nset, key, nodeset_hash(key));
}
/**
* Removes a node from a nodeset.
*
* @param nset the nodeset to delete in
* @param key a pointer to the element to be deleted
*
* @return
* the pointer to the removed element
*
* @remark
* The current implementation did not allow to remove non-existing elements.
* @@@ so, does it do now?
* Further, it is allowed to remove elements during an iteration
* including the current one.
*/
static INLINE ir_node *nodeset_remove(nodeset *nset, ir_node *key)
{
return (ir_node *) pset_remove(nset, key, nodeset_hash(key));
}
/**
* Returns the first node of a nodeset.
*
* @param nset the nodeset to iterate
*
* @return a node or NULL if the set is empty
*/
static INLINE ir_node *nodeset_first(nodeset *nset)
{
return (ir_node *) pset_first(nset);
}
/**
* Returns the next node of a nodeset.
*
* @param nset the nodeset to iterate
*
* @return a node or NULL if the iteration is finished
*/
static INLINE ir_node *nodeset_next(nodeset *nset)
{
return (ir_node *) pset_next(nset);
}
/**
* Breaks the iteration of a set. Must be called before
* the next nodeset_first() call if the iteration was NOT
* finished.
*
* @param nset the nodeset
*/
static INLINE void nodeset_break(nodeset *nset)
{
pset_break(nset);
}
/**
* Iterate over a node set.
*
* @param nset the nodeset
* @param irn the iterator node
*/
#define foreach_nodeset(nset, irn) for (irn = nodeset_first(nset); irn; irn = nodeset_next(nset))
#endif /* FIRM_BE_BENODESETS_H */
......@@ -52,7 +52,6 @@
#include "benode_t.h"
#include "besched_t.h"
#include "beschedmris.h"
#include "benodesets.h"
#include "beirg.h"
struct _mris_env_t {
......@@ -278,30 +277,32 @@ static void replace_tuple_by_repr_proj(mris_env_t *env, ir_node **in)
static void lineage_formation(mris_env_t *env)
{
DEBUG_ONLY(firm_dbg_module_t *dbg = env->dbg);
nodeset *nodes = new_nodeset(128);
ir_nodeset_t nodes;
const ir_edge_t *edge;
const ir_edge_t *edge;
ir_nodeset_init(&nodes);
foreach_out_edge(env->bl, edge) {
ir_node *irn = get_edge_src_irn(edge);
if(to_appear(env, irn))
nodeset_insert(nodes, irn);
ir_nodeset_insert(&nodes, irn);
}
while(nodeset_count(nodes) > 0) {
while(ir_nodeset_size(&nodes) > 0) {
mris_irn_t *mi;
ir_node *irn;
ir_node *highest_node = NULL;
ir_node *lowest_desc = NULL;
ir_node *start;
ir_node *irn;
ir_node *highest_node = NULL;
ir_node *lowest_desc = NULL;
ir_node *start;
mris_irn_t *start_mi;
ir_nodeset_iterator_t iter;
ir_node **in;
int recompute_height = 0;
unsigned curr_height = 0;
/* search the highest node which is not yet in a lineage. */
for(irn = nodeset_first(nodes); irn; irn = nodeset_next(nodes)) {
foreach_ir_nodeset(&nodes, irn, iter) {
unsigned height = get_irn_height(env->heights, irn);
if(height > curr_height) {
highest_node = irn;
......@@ -320,7 +321,7 @@ static void lineage_formation(mris_env_t *env)
mi->lineage_next = NULL;
mi->lineage_end = NULL;
list_add(&mi->lineage_list, &env->lineage_head);
nodeset_remove(nodes, highest_node);
ir_nodeset_remove(&nodes, highest_node);
/*
put all descendants in an array.
......@@ -377,7 +378,7 @@ static void lineage_formation(mris_env_t *env)
start_mi->lineage_end = lowest_desc;
lowest_mi->lineage_start = start;
nodeset_remove(nodes, lowest_desc);
ir_nodeset_remove(&nodes, lowest_desc);
}
/* else we cannot extend this lineage, so break. */
......@@ -396,6 +397,8 @@ static void lineage_formation(mris_env_t *env)
if(recompute_height)
heights_recompute(env->heights);
}
ir_nodeset_destroy(&nodes);
}
static int fuse_two_lineages(mris_env_t *env, mris_irn_t *u, mris_irn_t *v)
......
......@@ -44,7 +44,6 @@
#include "bespillslots.h"
#include "bechordal_t.h"
#include "bejavacoal.h"
#include "benodesets.h"
#include "bestatevent.h"
#include "bespilloptions.h"
#include "bemodule.h"
......@@ -106,7 +105,7 @@ static int cmp_spill(const void* d1, const void* d2, size_t size)
static spill_t *get_spill(be_fec_env_t *env, ir_node *node)
{
spill_t spill, *res;
int hash = nodeset_hash(node);
int hash = hash_irn(node);
spill.spill = node;
res = set_find(env->spills, &spill, sizeof(spill), hash);
......@@ -141,7 +140,7 @@ static spill_t *collect_spill(be_fec_env_t *env, ir_node *node,
const ir_mode *mode, int align)
{
spill_t spill, *res;
int hash = nodeset_hash(node);