remove irsimpletype stuff (unused/broken)
[libfirm] / ir / be / beschedrss.c
index b04586f..b70a83d 100644 (file)
@@ -53,7 +53,7 @@
 #include "plist.h"
 #include "array_t.h"
 
-#include "height.h"
+#include "heights.h"
 
 #include "beabi.h"
 #include "bemodule.h"
 #define BLOCK_IDX_MAP(rss, irn) bsearch_for_index(get_irn_idx((irn)), (rss)->idx_map, ARR_LEN_SAFE((rss)->idx_map), 1)
 
 /* the rss options */
-typedef struct _rss_opts_t {
+typedef struct rss_opts_t {
        int dump_flags;
 } rss_opts_t;
 
 /* Represents a child with associated costs */
-typedef struct _child {
+typedef struct child {
        ir_node *irn;
        float   cost;
 } child_t;
 
 /* We need edges for several purposes. */
-typedef struct _rss_edge {
+typedef struct rss_edge {
        ir_node *src;
        ir_node *tgt;
        void    *next;
 } rss_edge_t;
 
 /* Represents a connected bipartite component. */
-typedef struct _cbc {
+typedef struct cbc {
        ir_nodeset_t parents;       /**< = S  a set of value producers */
        ir_nodeset_t children;      /**< = T  a set of value consumers */
        pset    *kill_edges;    /**< = E  a set of edges (t in T, s in S) such as each s in S gets killed by at least one t in T */
@@ -101,18 +101,18 @@ typedef struct _cbc {
 } cbc_t;
 
 /* Represents a disjoint value DAG. */
-typedef struct _dvg {
+typedef struct dvg {
        ir_nodeset_t nodes;
        pset    *edges;
 } dvg_t;
 
 /* Represents a chain of nodes. */
-typedef struct _chain {
+typedef struct chain {
        plist_t *elements;   /**< List of chain elements */
        int     nr;          /**< a deterministic index for set insertion (used as hash) */
 } chain_t;
 
-typedef struct _rss_irn {
+typedef struct rss_irn {
        plist_t  *consumer_list;    /**< List of consumers */
        const ir_node **consumer;   /**< Sorted consumer array (needed for faster access) */
 
@@ -138,7 +138,7 @@ typedef struct _rss_irn {
 } rss_irn_t;
 
 /* Represents a serialization edge with associated costs. */
-typedef struct _serialization {
+typedef struct serialization {
        rss_irn_t  *u;       /* the top node */
        rss_irn_t  *v;       /* the node about to be serialized after u */
        rss_edge_t *edge;    /* the edge selected for the serialization */
@@ -147,9 +147,9 @@ typedef struct _serialization {
        int        new_killer;
 } serialization_t;
 
-typedef struct _rss {
+typedef struct rss {
        ir_phase          ph;              /**< Phase to hold some data */
-       heights_t        *h;              /**< The current height object */
+       ir_heights_t     *h;              /**< The current height object */
        ir_graph         *irg;            /**< The irg to preprocess */
        plist_t          *nodes;          /**< The list of interesting nodes */
        const arch_env_t *arch_env;       /**< The architecture environment */
@@ -597,9 +597,9 @@ static void debug_vcg_dump_dvg_pkiller(rss_t *rss, dvg_t *dvg)
 /**
  * In case there is no rss information for irn, initialize it.
  */
-static void *init_rss_irn(ir_phase *ph, const ir_node *irn, void *old)
+static void *init_rss_irn(ir_phase *ph, const ir_node *irn)
 {
-       rss_irn_t *res = old ? old : phase_alloc(ph, sizeof(res[0]));
+       rss_irn_t *res = phase_alloc(ph, sizeof(res[0]));
 
        res->descendant_list = plist_obstack_new(phase_obst(ph));
        res->descendants     = NULL;
@@ -760,7 +760,6 @@ static void collect_node_info(rss_t *rss, ir_node *irn)
        /* check if node info is already available */
        if (rss_irn->handled)
                return;
-               //phase_reinit_single_irn_data(&rss->ph, irn);
 
        DBG((rss->dbg, LEVEL_1, "\tcomputing consumers of %+F:\n", irn));
 
@@ -1487,15 +1486,17 @@ static void build_dvg_pkiller_list(rss_t *rss, dvg_t *dvg)
  */
 static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int iteration)
 {
-       int         n               = ir_nodeset_size(&dvg->nodes);
-       int         *assignment     = ALLOCAN(int, n);
-       int         *assignment_rev = ALLOCAN(int, n);
+       unsigned    n               = ir_nodeset_size(&dvg->nodes);
+       unsigned    *assignment     = ALLOCAN(unsigned, n);
+       unsigned    *assignment_rev = ALLOCAN(unsigned, n);
        int         *idx_map        = ALLOCAN(int, n);
        hungarian_problem_t *bp;
        ir_nodeset_t *values, *temp;
        ir_nodeset_iterator_t iter;
        ir_node     *u_irn;
-       int         i, j, cost, cur_chain, res;
+       unsigned    i, j;
+       unsigned    cost;
+       int         cur_chain, res;
        rss_edge_t  *dvg_edge;
 
 #define MAP_IDX(irn) bsearch_for_index(get_irn_idx(irn), idx_map,  n,  1)
@@ -1589,16 +1590,16 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
 
        /* build the reverse assignment, ie. foreach i -> j, add j -> i */
        for (i = 0; i < n; ++i) {
-               if (assignment[i] >= 0) {
-                       int j = assignment[i];
+               if (assignment[i] != (unsigned)-1) {
+                       unsigned j = assignment[i];
                        assignment_rev[j] = i;
                }
        }
 
-       DBG((rss->dbg, LEVEL_2, "\t\tgot assignment with cost %d\n", cost));
-       DBG((rss->dbg, LEVEL_3, "\t\t\tassignment   ---   reverse assignment\n", cost));
+       DBG((rss->dbg, LEVEL_2, "\t\tgot assignment with cost %u\n", cost));
+       DBG((rss->dbg, LEVEL_3, "\t\t\tassignment   ---   reverse assignment\n"));
        for (i = 0; i < n; ++i) {
-               DBG((rss->dbg, LEVEL_3, "\t\t\t%3d -> %3d         %3d -> %3d\n", i, assignment[i], i, assignment_rev[i]));
+               DBG((rss->dbg, LEVEL_3, "\t\t\t%3u -> %3u         %3u -> %3u\n", i, assignment[i], i, assignment_rev[i]));
        }
 
        values    = XMALLOC(ir_nodeset_t);
@@ -1607,12 +1608,12 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
        /* Construction of the minimal chain partition */
        for (j = 0; j < n; ++j) {
                /* check nodes, which did not occur as target */
-               if (assignment_rev[j] == -1) {
+               if (assignment_rev[j] == (unsigned)-1) {
                        int       xj      = idx_map[j];
                        ir_node   *xj_irn = get_idx_irn(rss->irg, xj);
                        rss_irn_t *xj_rss = get_rss_irn(rss, xj_irn);
                        chain_t   *c      = OALLOC(phase_obst(&rss->ph), chain_t);
-                       int       source;
+                       unsigned  source;
 
                        /* there was no source for j -> we have a source of a new chain */
                        ir_nodeset_insert(values, xj_irn);
@@ -1624,11 +1625,11 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
                        xj_rss->chain = c;
 
                        DBG((rss->dbg, LEVEL_2, "\t\tstarting chain %d:\n", c->nr));
-                       DBG((rss->dbg, LEVEL_2, "\t\t\t%+F (%d)", xj_irn, j));
+                       DBG((rss->dbg, LEVEL_2, "\t\t\t%+F (%u)", xj_irn, j));
 
                        /* follow chain, having j as source */
                        source = j;
-                       while (assignment[source] >= 0) {
+                       while (assignment[source] != (unsigned)-1) {
                                int       target  = assignment[source];
                                int       irn_idx = idx_map[target];
                                ir_node   *irn    = get_idx_irn(rss->irg, irn_idx);
@@ -1667,8 +1668,8 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
                        set at the same time. :-(((((
                        TODO Matze: now we can, so rewrite this...
                */
-               int     n         = ir_nodeset_size(values);
-               int     i         = 0;
+               unsigned n         = ir_nodeset_size(values);
+               unsigned i         = 0;
                ir_node **val_arr = NEW_ARR_F(ir_node *, n);
 
                foreach_ir_nodeset(values, u_irn, iter)
@@ -1894,14 +1895,16 @@ static serialization_t *compute_best_admissible_serialization(rss_t *rss, ir_nod
                                                be simultaneously alive with u
                                        */
                                        bitset_copy(bs_tmp, bs_vdesc);
-                                       mu1 = bitset_popcnt(bitset_and(bs_tmp, bs_sv));
+                                       bitset_and(bs_tmp, bs_sv);
+                                       mu1 = bitset_popcount(bs_tmp);
 
                                        /*
                                                mu2 = | accum_desc_all_pkiller(u) without descendants(v) |
                                        */
                                        if (is_pkiller) {
                                                bitset_copy(bs_tmp, bs_ukilldesc);
-                                               mu2 = bitset_popcnt(bitset_andnot(bs_tmp, bs_vdesc));
+                                               bitset_andnot(bs_tmp, bs_vdesc);
+                                               mu2 = bitset_popcount(bs_tmp);
                                        }
                                        else {
                                                mu2 = 0;
@@ -2000,7 +2003,7 @@ static void perform_value_serialization_heuristic(rss_t *rss)
        arch_put_non_ignore_regs(rss->cls, arch_nonign_bs);
        be_abi_put_ignore_regs(rss->abi, rss->cls, abi_ign_bs);
        bitset_andnot(arch_nonign_bs, abi_ign_bs);
-       available_regs  = bitset_popcnt(arch_nonign_bs);
+       available_regs  = bitset_popcount(arch_nonign_bs);
        //num_live = pset_count(rss->live_block);
        //available_regs -= num_live < available_regs ? num_live : 0;
 
@@ -2101,8 +2104,8 @@ static void process_block(ir_node *block, void *env)
        rss->max_height = heights_recompute_block(rss->h, block);
 
        /* loop over all register classes */
-       for (i = arch_env_get_n_reg_class(rss->arch_env) - 1; i >= 0; --i) {
-               const arch_register_class_t *cls = arch_env_get_reg_class(rss->arch_env, i);
+       for (i = rss->arch_env->n_register_classes - 1; i >= 0; --i) {
+               const arch_register_class_t *cls = &rss->arch_env->register_classes[i];
 
                rss->cls = cls;
                DBG((rss->dbg, LEVEL_1, "register class %s\n", arch_register_class_name(cls)));
@@ -2186,9 +2189,8 @@ void be_init_schedrss(void)
 /**
  * Preprocess the irg for scheduling.
  */
-void rss_schedule_preparation(be_irg_t *birg)
+void rss_schedule_preparation(ir_graph *irg)
 {
-       ir_graph *irg = be_get_birg_irg(birg);
        rss_t rss;
 
        FIRM_DBG_REGISTER(rss.dbg, "firm.be.sched.rss");
@@ -2198,8 +2200,8 @@ void rss_schedule_preparation(be_irg_t *birg)
        init_rss_special_nodes(irg);
 
        rss.irg      = irg;
-       rss.arch_env = be_get_birg_arch_env(birg);
-       rss.abi      = birg->abi;
+       rss.arch_env = be_get_irg_arch_env(irg);
+       rss.abi      = be_get_irg_abi(irg);
        rss.h        = heights_new(irg);
        rss.nodes    = plist_new();
        rss.opts     = &rss_options;
@@ -2210,6 +2212,6 @@ void rss_schedule_preparation(be_irg_t *birg)
        plist_free(rss.nodes);
        be_liveness_free(rss.liveness);
 
-       if (birg->main_env->options->dump_flags & DUMP_SCHED)
-               be_dump(rss.irg, "-rss", dump_ir_block_graph);
+       if (be_get_irg_options(irg)->dump_flags & DUMP_SCHED)
+               dump_ir_graph(irg, "rss");
 }