be_lower_for_target is now a simple function in the public API
[libfirm] / ir / be / bespillbelady2.c
index ecfa4b1..6abbbd5 100644 (file)
@@ -111,8 +111,8 @@ typedef struct loc_t {
 } loc_t;
 
 typedef struct workset_t {
-       int len;                        /**< current length */
-       loc_t vals[0];          /**< inlined array of the values/distances in this working set */
+       int len;            /**< current length */
+       loc_t vals[0];      /**< inlined array of the values/distances in this working set */
 } workset_t;
 
 typedef struct belady_env_t {
@@ -126,12 +126,12 @@ typedef struct belady_env_t {
 
        ir_node **blocks;            /**< Array of all blocks. */
        int n_blocks;                /**< Number of blocks in the graph. */
-       int n_regs;                              /**< number of regs in this reg-class */
-       workset_t *ws;                   /**< the main workset used while processing a block. ob-allocated */
-       ir_node *instr;                  /**< current instruction */
+       int n_regs;                  /**< number of regs in this reg-class */
+       workset_t *ws;               /**< the main workset used while processing a block. ob-allocated */
+       ir_node *instr;              /**< current instruction */
        int instr_nr;                /**< current instruction number (relative to block start) */
 
-       spill_env_t *senv;               /**< see bespill.h */
+       spill_env_t *senv;           /**< see bespill.h */
        bitset_t *spilled;           /**< bitset to keep all the irns which have already been spilled. */
        ir_nodeset_t *extra_spilled; /** All nodes for which a special spill location has been computed. */
 } belady_env_t;
@@ -139,8 +139,8 @@ typedef struct belady_env_t {
 
 static int loc_compare(const void *a, const void *b)
 {
-       const loc_t *p = a;
-       const loc_t *q = b;
+       const loc_t *p = (const loc_t*)a;
+       const loc_t *q = (const loc_t*)b;
        return (p->time > q->time) - (p->time < q->time);
 }
 
@@ -255,7 +255,7 @@ static inline int workset_get_index(const workset_t *ws, const ir_node *val)
  * @p v  A variable to put the current value in
  * @p i  An integer for internal use
  */
-#define workset_foreach(ws, v, i)      for (i=0; \
+#define workset_foreach(ws, v, i)  for (i=0; \
                                                                                v=(i < ws->len) ? ws->vals[i].irn : NULL, i < ws->len; \
                                                                                ++i)
 
@@ -295,7 +295,7 @@ typedef struct block_info_t {
 
 } block_info_t;
 
-static inline void *new_block_info(belady_env_t *bel, int id)
+static inline block_info_t *new_block_info(belady_env_t *bel, int id)
 {
        ir_node      *bl  = bel->blocks[id];
        block_info_t *res = OALLOCZ(&bel->ob, block_info_t);
@@ -349,8 +349,8 @@ static void build_next_uses(block_info_t *bi)
 
                for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
                        ir_node *op = get_irn_n(irn, i);
-                       next_use_t *curr = phase_get_irn_data(&bi->next_uses, op);
-                       next_use_t *use  = phase_alloc(&bi->next_uses, sizeof(use[0]));
+                       next_use_t *curr = (next_use_t*)phase_get_irn_data(&bi->next_uses, op);
+                       next_use_t *use  = (next_use_t*)phase_alloc(&bi->next_uses, sizeof(use[0]));
 
                        use->is_first_use = 1;
                        use->step         = sched_get_time_step(irn);
@@ -367,7 +367,10 @@ static void build_next_uses(block_info_t *bi)
        }
 }
 
-#define get_current_use(bi, irn)        phase_get_irn_data(&(bi)->next_uses, (irn))
+static inline next_use_t *get_current_use(block_info_t *bi, const ir_node *node)
+{
+       return (next_use_t*)phase_get_irn_data(&bi->next_uses, node);
+}
 
 static inline void advance_current_use(block_info_t *bi, const ir_node *irn)
 {
@@ -379,8 +382,8 @@ static inline void advance_current_use(block_info_t *bi, const ir_node *irn)
 
 static __attribute__((unused)) int block_freq_gt(const void *a, const void *b)
 {
-       const ir_node * const *p = a;
-       const ir_node * const *q = b;
+       const ir_node * const *p = (const ir_node**)a;
+       const ir_node * const *q = (const ir_node**)b;
        block_info_t *pi = get_block_info(*p);
        block_info_t *qi = get_block_info(*q);
        double diff = qi->exec_freq - pi->exec_freq;
@@ -389,8 +392,8 @@ static __attribute__((unused)) int block_freq_gt(const void *a, const void *b)
 
 static int block_freq_dfs_gt(const void *a, const void *b)
 {
-       const ir_node * const *p = a;
-       const ir_node * const *q = b;
+       const ir_node * const *p = (const ir_node**)a;
+       const ir_node * const *q = (const ir_node**)b;
        block_info_t *pi = get_block_info(*p);
        block_info_t *qi = get_block_info(*q);
        double diff;
@@ -651,8 +654,8 @@ static void displace(block_info_t *bi, workset_t *new_vals, int is_usage)
  */
 static void belady(belady_env_t *env, int id)
 {
-       block_info_t *block_info = new_block_info(env, id);
-       const ir_node *block     = block_info->bl;
+       block_info_t  *block_info = new_block_info(env, id);
+       const ir_node *block      = block_info->bl;
 
        workset_t *new_vals;
        ir_node *irn;
@@ -1380,7 +1383,7 @@ static bring_in_t **determine_global_order(belady_env_t *env)
        }
 
        obstack_ptr_grow(&env->ob, NULL);
-       res = obstack_finish(&env->ob);
+       res = (bring_in_t**)obstack_finish(&env->ob);
        qsort(res, n, sizeof(res[0]), bring_in_cmp);
        return res;
 }
@@ -1450,7 +1453,7 @@ static void global_assign(belady_env_t *env)
 
 static void collect_blocks(ir_node *bl, void *data)
 {
-       belady_env_t *env = data;
+       belady_env_t *env = (belady_env_t*)data;
        ++env->n_blocks;
        obstack_ptr_grow(&env->ob, bl);
 }
@@ -1469,7 +1472,7 @@ static void be_spill_belady(ir_graph *irg, const arch_register_class_t *cls)
        int i, n_regs;
 
        /* some special classes contain only ignore regs, nothing to do then */
-       n_regs = cls->n_regs - be_put_ignore_regs(irg, cls, NULL);
+       n_regs = be_get_n_allocatable_regs(irg, cls);
        if (n_regs == 0)
                return;
 
@@ -1492,7 +1495,7 @@ static void be_spill_belady(ir_graph *irg, const arch_register_class_t *cls)
 
        irg_block_walk_graph(irg, NULL, collect_blocks, &env);
        obstack_ptr_grow(&env.ob, NULL);
-       env.blocks = obstack_finish(&env.ob);
+       env.blocks = (ir_node**)obstack_finish(&env.ob);
 
        /* renumbering in the blocks gives nicer debug output as number are smaller. */
 #ifdef DEBUG_libfirm