Make spiller more deterministic.
[libfirm] / ir / opt / combo.c
index ba7deb5..3e834b2 100644 (file)
@@ -83,7 +83,6 @@
 #include "irpass.h"
 #include "tv_t.h"
 #include "irtools.h"
-#include "opt_manage.h"
 
 #include "irprintf.h"
 #include "irdump.h"
@@ -454,9 +453,9 @@ static void dump_split_list(const partition_t *list)
 /**
  * Dump partition and type for a node.
  */
-static int dump_partition_hook(FILE *F, ir_node *n, ir_node *local)
+static int dump_partition_hook(FILE *F, const ir_node *n, const ir_node *local)
 {
-       ir_node *irn = local != NULL ? local : n;
+       const ir_node *irn = local != NULL ? local : n;
        node_t *node = get_irn_node(irn);
 
        ir_fprintf(F, "info2 : \"partition %u type %+F\"\n", node->part->nr, node->type);
@@ -544,7 +543,7 @@ static listmap_entry_t *listmap_find(listmap_t *map, void *id)
        key.id   = id;
        key.list = NULL;
        key.next = NULL;
-       entry = (listmap_entry_t*)set_insert(map->map, &key, sizeof(key), HASH_PTR(id));
+       entry = (listmap_entry_t*)set_insert(map->map, &key, sizeof(key), hash_ptr(id));
 
        if (entry->list == NULL) {
                /* a new entry, put into the list */
@@ -571,7 +570,7 @@ static unsigned opcode_hash(const opcode_key_t *entry)
        unsigned hash = (unsigned)(PTR_TO_INT(mode) * 9 + code) + get_irn_arity(n);
 
        if (code == iro_Const)
-               hash ^= (unsigned)HASH_PTR(get_Const_tarval(n));
+               hash ^= (unsigned)hash_ptr(get_Const_tarval(n));
        else if (code == iro_Proj)
                hash += (unsigned)get_Proj_proj(n);
        return hash;
@@ -1929,7 +1928,7 @@ static void compute_Block(node_t *node)
        int     i;
        ir_node *block = node->node;
 
-       if (block == get_irg_start_block(current_ir_graph) || has_Block_entity(block)) {
+       if (block == get_irg_start_block(current_ir_graph) || get_Block_entity(block) != NULL) {
                /* start block and labelled blocks are always reachable */
                node->type.tv = tarval_reachable;
                return;
@@ -2990,7 +2989,7 @@ static int only_one_reachable_proj(ir_node *n)
  */
 static int can_exchange(ir_node *pred, ir_node *block)
 {
-       if (is_Start(pred) || has_Block_entity(block))
+       if (is_Start(pred) || get_Block_entity(block) != NULL)
                return 0;
        else if (is_Jmp(pred))
                return 1;
@@ -3463,8 +3462,8 @@ static void set_compute_functions(void)
        size_t i, n;
 
        /* set the default compute function */
-       for (i = 0, n = get_irp_n_opcodes(); i < n; ++i) {
-               ir_op *op = get_irp_opcode(i);
+       for (i = 0, n = ir_get_n_opcodes(); i < n; ++i) {
+               ir_op *op = ir_get_opcode(i);
                op->ops.generic = (op_func)default_compute;
        }
 
@@ -3512,7 +3511,7 @@ static void add_memory_keeps(ir_node **kept_memory, size_t len)
        ir_nodeset_destroy(&set);
 }  /* add_memory_keeps */
 
-static ir_graph_state_t do_combo(ir_graph *irg)
+void combo(ir_graph *irg)
 {
        environment_t env;
        ir_node       *initial_bl;
@@ -3520,6 +3519,11 @@ static ir_graph_state_t do_combo(ir_graph *irg)
        ir_graph      *rem = current_ir_graph;
        size_t        len;
 
+       assure_irg_properties(irg,
+               IR_GRAPH_PROPERTY_NO_BADS
+               | IR_GRAPH_PROPERTY_CONSISTENT_OUTS
+               | IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
+
        current_ir_graph = irg;
 
        /* register a debug mask */
@@ -3622,20 +3626,9 @@ static ir_graph_state_t do_combo(ir_graph *irg)
        set_value_of_func(NULL);
        current_ir_graph = rem;
 
-       return 0; // cannot guarantee anything
+       confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
 }  /* combo */
 
-static optdesc_t opt_combo = {
-       "combo",
-       IR_GRAPH_STATE_NO_BADS | IR_GRAPH_STATE_CONSISTENT_OUTS | IR_GRAPH_STATE_CONSISTENT_LOOPINFO,
-       do_combo,
-};
-
-void combo(ir_graph *irg)
-{
-       perform_irg_optimization(irg, &opt_combo);
-}
-
 /* Creates an ir_graph pass for combo. */
 ir_graph_pass_t *combo_pass(const char *name)
 {