adapted to new callback
[libfirm] / ir / be / bespillslots.c
index 481c23f..9cbe76e 100644 (file)
@@ -25,6 +25,7 @@
 #include "bespillslots.h"
 #include "bechordal_t.h"
 #include "bejavacoal.h"
+#include "benodesets.h"
 
 
 #define DBG_COALESCING         1
@@ -59,10 +60,11 @@ typedef struct _ss_env_t {
 
 /** Compare 2 affinity edges (used in quicksort) */
 static int cmp_affinity(const void *d1, const void *d2) {
-       const affinity_edge_t *e1 = d1;
-       const affinity_edge_t *e2 = d2;
+       const affinity_edge_t * const *e1 = d1;
+       const affinity_edge_t * const *e2 = d2;
 
-       return e1->affinity < e2->affinity ? -1 : 1;
+       // sort in descending order
+       return (*e1)->affinity < (*e2)->affinity ? 1 : -1;
 }
 
 static int cmp_spill(const void* d1, const void* d2, size_t size) {
@@ -73,7 +75,7 @@ static int cmp_spill(const void* d1, const void* d2, size_t size) {
 
 static spill_t *get_spill(ss_env_t *env, ir_node *node) {
        spill_t spill, *res;
-       int hash = HASH_PTR(node);
+       int hash = nodeset_hash(node);
 
        spill.spill = node;
        res = set_find(env->spills, &spill, sizeof(spill), hash);
@@ -107,7 +109,7 @@ static spill_t *collect_spill(ss_env_t *env, ir_node *node) {
        const arch_env_t *arch_env = env->arch_env;
        const arch_register_class_t *cls;
        spill_t spill, *res;
-       int hash = HASH_PTR(node);
+       int hash = nodeset_hash(node);
 
        assert(arch_irn_class_is(arch_env, node, spill));
 
@@ -133,7 +135,7 @@ static spill_t *collect_spill(ss_env_t *env, ir_node *node) {
 static spill_t *collect_memphi(ss_env_t *env, ir_node *node) {
        int i, arity;
        spill_t spill, *res;
-       int hash = HASH_PTR(node);
+       int hash = nodeset_hash(node);
 
        assert(is_Phi(node));
 
@@ -164,7 +166,7 @@ static spill_t *collect_memphi(ss_env_t *env, ir_node *node) {
                if(res->cls == NULL) {
                        res->cls = arg_spill->cls;
                } else {
-                       assert(res->cls == arg_spill->cls);
+                       assert(arg_spill->cls == NULL || res->cls == arg_spill->cls);
                }
 
                // add an affinity edge
@@ -525,7 +527,7 @@ static memperm_t *get_memperm(ss_env_t *env, ir_node *block) {
        int hash;
 
        entry.block = block;
-       hash = HASH_PTR(block);
+       hash = nodeset_hash(block);
 
        res = set_find(env->memperms, &entry, sizeof(entry), hash);