cleanup, simplify hungarian algorithm implementation
[libfirm] / ir / stat / dags.c
index 6ac7e92..debb813 100644 (file)
@@ -23,9 +23,7 @@
  * @author  Michael Beck
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include <assert.h>
 
@@ -104,14 +102,15 @@ static int is_arg(ir_node *node)
                return 0;
 
        node = get_Proj_pred(node);
-       return get_irn_op(node) == op_Start;
+       return is_Start(node);
 }  /* is_arg */
 
 /**
  * Allocate a new DAG entry.
  */
-static dag_entry_t *new_dag_entry(dag_env_t *dag_env, ir_node *node) {
-       dag_entry_t *entry = obstack_alloc(&dag_env->obst, sizeof(*entry));
+static dag_entry_t *new_dag_entry(dag_env_t *dag_env, ir_node *node)
+{
+       dag_entry_t *entry = OALLOC(&dag_env->obst, dag_entry_t);
 
        entry->num_nodes       = 1;
        entry->num_roots       = 1;
@@ -241,10 +240,10 @@ static void connect_dags(ir_node *node, void *env)
        }  /* if */
 
        /* if this option is set, Loads are always leaves */
-       if (dag_env->options & FIRMSTAT_LOAD_IS_LEAVE && get_irn_op(node) == op_Load)
+       if (dag_env->options & FIRMSTAT_LOAD_IS_LEAVE && is_Load(node))
                return;
 
-       if (dag_env->options & FIRMSTAT_CALL_IS_LEAVE && get_irn_op(node) == op_Call)
+       if (dag_env->options & FIRMSTAT_CALL_IS_LEAVE && is_Call(node))
                return;
 
        entry = get_irn_dag_entry(node);
@@ -380,7 +379,7 @@ void count_dags_in_graph(graph_entry_t *global, graph_entry_t *graph)
        /* connect and count them */
        irg_walk_graph(graph->irg, connect_dags, NULL, &root_env);
 
-       printf("Graph %p %s --- %d\n", (void *)graph->irg, get_entity_name(get_irg_entity(graph->irg)),
+       printf("Graph %p %s --- %u\n", (void *)graph->irg, get_entity_name(get_irg_entity(graph->irg)),
                root_env.num_of_dags);
 
        for (id = 0, entry = root_env.list_of_dags; entry; entry = entry->next) {
@@ -388,7 +387,7 @@ void count_dags_in_graph(graph_entry_t *global, graph_entry_t *graph)
                        continue;
                entry->id = id++;
 
-               printf("number of roots %d number of nodes %d inner %d tree %u %ld\n",
+               printf("number of roots %u number of nodes %u inner %u tree %u %ld\n",
                        entry->num_roots,
                        entry->num_nodes,
                        entry->num_inner_nodes,
@@ -400,7 +399,7 @@ void count_dags_in_graph(graph_entry_t *global, graph_entry_t *graph)
        /* dump for test */
        mark_options = root_env.options;
        set_dump_node_vcgattr_hook(stat_dag_mark_hook);
-       dump_ir_block_graph(graph->irg, "-dag");
+       dump_ir_graph(graph->irg, "-dag");
        set_dump_node_vcgattr_hook(NULL);
 #endif