/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* An affinity chunk.
*/
typedef struct _aff_chunk_t {
- ir_node **n; /**< An ARR_F containing all nodes of the chunk. */
- bitset_t *nodes; /**< A bitset containing all nodes inside this chunk. */
- bitset_t *interfere; /**< A bitset containing all interfering neighbours of the nodes in this chunk. */
- int weight; /**< Weight of this chunk */
- unsigned weight_consistent : 1; /**< Set if the weight is consistent. */
- unsigned deleted : 1; /**< Set if the was deleted. */
- int id; /**< For debugging: An id of this chunk. */
- int visited;
- col_cost_t *color_affinity;
+ const ir_node **n; /**< An ARR_F containing all nodes of the chunk. */
+ bitset_t *nodes; /**< A bitset containing all nodes inside this chunk. */
+ bitset_t *interfere; /**< A bitset containing all interfering neighbours of the nodes in this chunk. */
+ int weight; /**< Weight of this chunk */
+ unsigned weight_consistent : 1; /**< Set if the weight is consistent. */
+ unsigned deleted : 1; /**< Set if the was deleted. */
+ int id; /**< For debugging: An id of this chunk. */
+ int visited;
+ col_cost_t *color_affinity;
} aff_chunk_t;
/**
* An affinity edge.
*/
typedef struct _aff_edge_t {
- ir_node *src; /**< Source node. */
- ir_node *tgt; /**< Target node. */
+ const ir_node *src; /**< Source node. */
+ const ir_node *tgt; /**< Target node. */
double weight; /**< The weight of this edge. */
} aff_edge_t;
/* stores coalescing related information for a node */
typedef struct _co_mst_irn_t {
- ir_node *irn; /**< the irn this information belongs to */
+ const ir_node *irn; /**< the irn this information belongs to */
aff_chunk_t *chunk; /**< the chunk this irn belongs to */
bitset_t *adm_colors; /**< set of admissible colors for this irn */
ir_node **int_neighs; /**< array of all interfering neighbours (cached for speed reasons) */
aff_chunk_t *c = xmalloc(sizeof(*c));
c->weight = -1;
c->weight_consistent = 0;
- c->n = NEW_ARR_F(ir_node *, 0);
+ c->n = NEW_ARR_F(const ir_node *, 0);
c->nodes = bitset_irg_malloc(env->co->irg);
c->interfere = bitset_irg_malloc(env->co->irg);
c->color_affinity = xmalloc(env->n_regs * sizeof(c->color_affinity[0]));
/**
* In case there is no phase information for irn, initialize it.
*/
-static void *co_mst_irn_init(ir_phase *ph, ir_node *irn, void *old) {
+static void *co_mst_irn_init(ir_phase *ph, const ir_node *irn, void *old) {
co_mst_irn_t *res = old ? old : phase_alloc(ph, sizeof(res[0]));
co_mst_env_t *env = ph->priv;
/**
* Check if affinity chunk @p chunk interferes with node @p irn.
*/
-static INLINE int aff_chunk_interferes(co_mst_env_t *env, const aff_chunk_t *chunk, ir_node *irn) {
+static INLINE int aff_chunk_interferes(co_mst_env_t *env, const aff_chunk_t *chunk, const ir_node *irn) {
(void) env;
return bitset_is_set(chunk->interfere, get_irn_idx(irn));
}
* Returns the affinity chunk of @p irn or creates a new
* one with @p irn as element if there is none assigned.
*/
-static INLINE aff_chunk_t *get_aff_chunk(co_mst_env_t *env, ir_node *irn) {
+static INLINE aff_chunk_t *get_aff_chunk(co_mst_env_t *env, const ir_node *irn) {
co_mst_irn_t *node = get_co_mst_irn(env, irn);
return node->chunk;
}
* are no interference edges from chunk(src) to chunk(tgt)).
* @return 1 if successful, 0 if not possible
*/
-static int aff_chunk_absorb(co_mst_env_t *env, ir_node *src, ir_node *tgt) {
+static int aff_chunk_absorb(co_mst_env_t *env, const ir_node *src, const ir_node *tgt) {
aff_chunk_t *c1 = get_aff_chunk(env, src);
aff_chunk_t *c2 = get_aff_chunk(env, tgt);
}
for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
- ir_node *n = c->n[idx];
+ const ir_node *n = c->n[idx];
const affinity_node_t *an = get_affinity_info(env->co, n);
co_mst_irn_t *node = get_co_mst_irn(env, n);
*/
static int count_interfering_aff_neighs(co_mst_env_t *env, const affinity_node_t *an) {
const neighb_t *neigh;
- ir_node *irn = an->irn;
+ const ir_node *irn = an->irn;
const co_mst_irn_t *node = get_co_mst_irn(env, irn);
int res = 0;
/* build the affinity edges */
co_gs_foreach_neighb(an, neigh) {
- ir_node *m = neigh->irn;
- int m_idx = get_irn_idx(m);
+ const ir_node *m = neigh->irn;
+ int m_idx = get_irn_idx(m);
/* record the edge in only one direction */
if (n_idx < m_idx) {
static __attribute__((unused)) void chunk_order_nodes(co_mst_env_t *env, aff_chunk_t *chunk)
{
pqueue *grow = new_pqueue();
- int i;
+ const ir_node *max_node = NULL;
int max_weight = 0;
- ir_node *max_node = NULL;
+ int i;
for (i = ARR_LEN(chunk->n) - 1; i >= 0; i--) {
- ir_node *irn = chunk->n[i];
- affinity_node_t *an = get_affinity_info(env->co, irn);
+ const ir_node *irn = chunk->n[i];
+ affinity_node_t *an = get_affinity_info(env->co, irn);
int w = 0;
neighb_t *neigh;
for (i = ARR_LEN(chunk->n) - 1; i >= 0; --i)
bitset_add_irn(visited, chunk->n[i]);
- pqueue_put(grow, max_node, max_weight);
+ pqueue_put(grow, (void *) max_node, max_weight);
bitset_remv_irn(visited, max_node);
i = 0;
while (!pqueue_empty(grow)) {
co_mst_irn_t *node = get_co_mst_irn(env, neigh->irn);
if (bitset_contains_irn(visited, node->irn)) {
- pqueue_put(grow, neigh->irn, neigh->costs);
+ pqueue_put(grow, (void *) neigh->irn, neigh->costs);
bitset_remv_irn(visited, node->irn);
}
}
if (an != NULL) {
neighb_t *neigh;
co_gs_foreach_neighb(an, neigh) {
- ir_node *m = neigh->irn;
- int m_idx = get_irn_idx(m);
+ const ir_node *m = neigh->irn;
+ int m_idx = get_irn_idx(m);
co_mst_irn_t *n2;
/* skip ignore nodes */
aff_chunk_t *best = NULL;
for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
- ir_node *irn;
+ const ir_node *irn;
co_mst_irn_t *node;
aff_chunk_t *tmp_chunk;
decide_func_t *decider;
/* try to bring all nodes of given chunk to the current color. */
for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
- ir_node *irn = c->n[idx];
+ const ir_node *irn = c->n[idx];
co_mst_irn_t *node = get_co_mst_irn(env, irn);
int good;
DB((dbg, LEVEL_2, "using color %d\n", best_color));
for (idx = 0, len = ARR_LEN(best_chunk->n); idx < len; ++idx) {
- ir_node *irn = best_chunk->n[idx];
- co_mst_irn_t *node = get_co_mst_irn(env, irn);
+ const ir_node *irn = best_chunk->n[idx];
+ co_mst_irn_t *node = get_co_mst_irn(env, irn);
int res;
/* bring the node to the color. */
/* remove the nodes in best chunk from original chunk */
bitset_andnot(c->nodes, best_chunk->nodes);
for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
- ir_node *irn = c->n[idx];
+ const ir_node *irn = c->n[idx];
if (bitset_is_set(best_chunk->nodes, get_irn_idx(irn))) {
int last = ARR_LEN(c->n) - 1;
/* we have to get the nodes back into the original chunk because they are scattered over temporary chunks */
for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
- ir_node *n = c->n[idx];
- co_mst_irn_t *nn = get_co_mst_irn(env, n);
+ const ir_node *n = c->n[idx];
+ co_mst_irn_t *nn = get_co_mst_irn(env, n);
nn->chunk = c;
}
visited = bitset_irg_malloc(env->co->irg);
bitset_or(visited, best_chunk->nodes);
for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
- ir_node *irn = c->n[idx];
+ const ir_node *irn = c->n[idx];
if (! bitset_is_set(visited, get_irn_idx(irn))) {
aff_chunk_t *new_chunk = new_aff_chunk(env);
co_mst_irn_t *node = get_co_mst_irn(env, irn);
}
for (idx = 0, len = ARR_LEN(best_chunk->n); idx < len; ++idx) {
- ir_node *n = best_chunk->n[idx];
- co_mst_irn_t *nn = get_co_mst_irn(env, n);
+ const ir_node *n = best_chunk->n[idx];
+ co_mst_irn_t *nn = get_co_mst_irn(env, n);
nn->chunk = NULL;
}
FIRM_DBG_REGISTER(dbg, "firm.be.co.heur4");
}
+
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyheur4);