#include "benodesets.h"
#include "bestatevent.h"
#include "bespilloptions.h"
+#include "bemodule.h"
#define DBG_COALESCING 1
#define DBG_INTERFERENCES 2
* |_|
*/
-static ir_node *get_memory_edge(const ir_node *node)
+static INLINE ir_node *get_memory_edge(const ir_node *node)
{
int i, arity;
return res;
}
-#if 0
-static void dump_interference_graph(be_fec_env_t *env, bitset_t **interferences, const char* suffix) {
- char name[256];
- int i;
- int spillcount;
- spill_t *spill;
- FILE *f;
- static int cnt = 0;
-
- snprintf(name, sizeof(name), "%d-%s-spillslots-%s.vcg", cnt++, get_irg_dump_name(env->chordal_env->birg->irg), suffix);
-
- f = fopen(name, "w");
- assert(f != NULL);
-
- fprintf(f, "graph: {\n");
-
- spillcount = set_count(env->spills);
- for(spill = set_first(env->spills), i = 0; spill != NULL; spill = set_next(env->spills), ++i) {
- int slotid = spill->spillslot;
- fprintf(f, "\tnode: { title: \"n%d\" label: \"%d\" }\n", i, slotid);
- }
-
- for(i = 0; i < ARR_LEN(env->affinity_edges); ++i) {
- affinity_edge_t *edge = env->affinity_edges[i];
- fprintf(f, "\tedge: { sourcename: \"n%d\" targetname: \"n%d\" color: green }\n", edge->slot1, edge->slot2);
- }
-
- for(i = 0; i < spillcount; ++i) {
- int i2;
- for(i2 = 0; i2 < spillcount; ++i2) {
- if(bitset_is_set(interferences[i], i2)) {
- fprintf(f, "\tedge: { sourcename: \"n%d\" targetname: \"n%d\" color: red }\n", i, i2);
- }
- }
- }
-
- fprintf(f, "}\n");
- fclose(f);
-}
-#endif
-
/**
* A greedy coalescing algorithm for spillslots:
* 1. Sort the list of affinity edges
// construct interferences
for(i = 0; i < spillcount; ++i) {
+ ir_node *spill1 = spilllist[i]->spill;
+ if(is_NoMem(spill1))
+ continue;
+
for(i2 = i+1; i2 < spillcount; ++i2) {
- if(values_interfere(lv, spilllist[i]->spill, spilllist[i2]->spill)) {
- DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n", i, i2));
+ ir_node *spill2 = spilllist[i2]->spill;
+ if(is_NoMem(spill2))
+ continue;
+
+ if(values_interfere(lv, spill1, spill2)) {
+ DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n",
+ i, i2));
bitset_set(interferences[i], i2);
bitset_set(interferences[i2], i);
}
}
}
} else {
- arch_set_frame_entity(arch_env, node, slot->entity);
+ if(!is_NoMem(node))
+ arch_set_frame_entity(arch_env, node, slot->entity);
}
}
env->reloads = NEW_ARR_F(ir_node*, 0);
env->affinity_edges = NEW_ARR_F(affinity_edge_t*, 0);
env->memperms = new_set(cmp_memperm, 10);
- FIRM_DBG_REGISTER(dbg, "firm.be.spillslots");
return env;
}
be_node_needs_frame_entity(env, node, mode, align);
}
-void be_coalesce_spillslots(const be_chordal_env_t *chordal_env)
+void be_coalesce_spillslots(be_irg_t *birg)
{
- be_fec_env_t *env = be_new_frame_entity_coalescer(chordal_env->birg);
+ be_fec_env_t *env = be_new_frame_entity_coalescer(birg);
/* collect reloads */
- irg_walk_graph(chordal_env->irg, NULL, collect_spills_walker, env);
+ irg_walk_graph(birg->irg, NULL, collect_spills_walker, env);
be_assign_entities(env);
be_free_frame_entity_coalescer(env);
}
+
+void be_init_spillslots(void)
+{
+ FIRM_DBG_REGISTER(dbg, "firm.be.spillslots");
+}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillslots);