C99 features removed
[libfirm] / ir / be / bespillmorgan.c
index 0f10523..fffc61d 100644 (file)
@@ -33,6 +33,7 @@
 #include "irgraph_t.h"
 #include "irprintf.h"
 #include "obst.h"
+#include "error.h"
 
 #include "bespillmorgan.h"
 #include "bechordal_t.h"
@@ -91,23 +92,26 @@ typedef struct morgan_block_attr {
 
 //---------------------------------------------------------------------------
 
-static int loop_edge_cmp(const void* p1, const void* p2, size_t s) {
+static int loop_edge_cmp(const void* p1, const void* p2, size_t size) {
        loop_edge_t *e1 = (loop_edge_t*) p1;
        loop_edge_t *e2 = (loop_edge_t*) p2;
+       (void) size;
 
        return e1->block != e2->block || e1->pos != e2->pos;
 }
 
-static int loop_attr_cmp(const void *e1, const void *e2, size_t s) {
+static int loop_attr_cmp(const void *e1, const void *e2, size_t size) {
        loop_attr_t *la1 = (loop_attr_t*) e1;
        loop_attr_t *la2 = (loop_attr_t*) e2;
+       (void) size;
 
        return la1->loop != la2->loop;
 }
 
-static int block_attr_cmp(const void *e1, const void *e2, size_t s) {
+static int block_attr_cmp(const void *e1, const void *e2, size_t size) {
        block_attr_t *b1 = (block_attr_t*) e1;
        block_attr_t *b2 = (block_attr_t*) e2;
+       (void) size;
 
        return b1->block != b2->block;
 }
@@ -311,7 +315,10 @@ static void construct_block_livethrough_unused(ir_node *block, void *data) {
        /*
         * All values that are used within the block are not unused (and therefore not
         * livethrough_unused)
+        *
+        * TODO FIXME use block out edges and not schedule to find uses
         */
+       panic("needs fixing");
        sched_foreach(block, node) {
                int i, arity;
 
@@ -406,20 +413,21 @@ static bitset_t *construct_loop_livethrough_unused(morgan_env_t *env, const ir_l
 
 typedef struct _spillcandidate_t {
        ir_node *node;
-       int cost;
+       double cost;
 } spillcandidate_t;
 
 static int compare_spillcandidates(const void *d1, const void *d2) {
        const spillcandidate_t *cand1 = d1;
        const spillcandidate_t *cand2 = d2;
 
-       return cand1->cost - cand2->cost;
+       return (int)(cand1->cost - cand2->cost);
 }
 
 static void spill_values(morgan_env_t *env, const loop_attr_t *loop_attr, int spills) {
        const bitset_t *cand_bitset = loop_attr->livethrough_unused;
        int candidatecount = bitset_popcnt(cand_bitset);
        spillcandidate_t *candidates;
+       bitset_pos_t idx;
        int i, c;
        loop_edge_t *edge;
 
@@ -428,17 +436,17 @@ static void spill_values(morgan_env_t *env, const loop_attr_t *loop_attr, int sp
        candidates = alloca(sizeof(candidates[0]) * candidatecount);
 
        DBG((dbg, DBG_CHOOSE, "Candidates for loop %d\n", get_loop_loop_nr(loop_attr->loop)));
-       // build candidiatelist
+       // build candidiate list
        c = 0;
-       bitset_foreach(cand_bitset, i) {
-               ir_node *node = get_idx_irn(env->irg, i);
+       bitset_foreach(cand_bitset, idx) {
+               ir_node *node = get_idx_irn(env->irg, idx);
                candidates[c].node = node;
-               candidates[c].cost = 0;
+               candidates[c].cost = 0.0;
 
                for(edge = set_first(loop_attr->out_edges); edge != NULL; edge = set_next(loop_attr->out_edges)) {
                        candidates[c].cost += be_get_reload_costs_on_edge(env->senv, node, edge->block, edge->pos);
                }
-               DBG((dbg, DBG_CHOOSE, "%+F has costs %d\n", node, candidates[c].cost));
+               DBG((dbg, DBG_CHOOSE, "%+F has costs %f\n", node, candidates[c].cost));
 
                c++;
        }
@@ -462,11 +470,13 @@ static int reduce_register_pressure_in_block(morgan_env_t *env, const ir_node* b
        ir_node *node;
        int max_pressure;
        int loop_unused_spills_needed;
-       pset *live_nodes = pset_new_ptr_default();
+       ir_nodeset_t live_nodes;
        const be_lv_t *lv = env->lv;
 
-       be_liveness_end_of_block(lv, env->arch, env->cls, block, live_nodes);
-       max_pressure = pset_count(live_nodes);
+       ir_nodeset_init(&live_nodes);
+
+       be_liveness_end_of_block(lv, env->arch, env->cls, block, &live_nodes);
+       max_pressure = ir_nodeset_size(&live_nodes);
 
        DBG((dbg, DBG_LIVE, "Reduce pressure to %d In Block %+F:\n", env->registers_available, block));
 
@@ -479,12 +489,12 @@ static int reduce_register_pressure_in_block(morgan_env_t *env, const ir_node* b
                if(is_Phi(node))
                        break;
 
-               be_liveness_transfer(env->arch, env->cls, node, live_nodes);
-               pressure = pset_count(live_nodes);
+               be_liveness_transfer(env->arch, env->cls, node, &live_nodes);
+               pressure = ir_nodeset_size(&live_nodes);
                if(pressure > max_pressure)
                        max_pressure = pressure;
        }
-       del_pset(live_nodes);
+       ir_nodeset_destroy(&live_nodes);
 
        loop_unused_spills_needed = max_pressure - env->registers_available;