cleanup, simplify hungarian algorithm implementation
[libfirm] / ir / stat / stat_dmp.c
index 6455498..fd03565 100644 (file)
@@ -28,6 +28,7 @@
 #include "stat_dmp.h"
 #include "irtools.h"
 #include "irhooks.h"
+#include "util.h"
 
 /**
  * names of the optimizations
@@ -99,6 +100,8 @@ static const struct {
        { FS_OPT_CONV,           "algebraic simplification: Conv could be removed" },
        { FS_OPT_CAST,           "algebraic simplification: a Cast could be removed" },
        { FS_OPT_MIN_MAX_EQ,     "algebraic simplification: Min(a,a) = Max(a,a) = a" },
+       { FS_OPT_MUX_COMBINE,    "boolean simplification: two Mux nodes where combined into one" },
+       { FS_OPT_MUX_CONV,       "boolean simplification: MuxI(sel, 1, 0) = (I)sel" },
        { FS_OPT_MUX_BOOL,       "boolean simplification: Muxb(sel, true, false) = sel" },
        { FS_OPT_MUX_NOT_BOOL,   "boolean simplification: Muxb(sel, false, true) = Not(sel)" },
        { FS_OPT_MUX_OR_BOOL,    "boolean simplification: Muxb(sel, true, x) = Or(sel, x)" },
@@ -138,6 +141,7 @@ static const struct {
        { FS_OPT_COMBO_CF,       "Combo: removed conditional control flow" },
        { FS_OPT_COMBO_FOLLOWER, "Combo: removed a follower" },
        { FS_OPT_COMBO_CONGRUENT,"Combo: replaced by congruent" },
+       { FS_OPT_JUMPTHREADING,  "Jump threading: removed conditional control flow" },
        { FS_OPT_RTS_ABS,        "RTS optimization: call to abs() replaced" },
        { FS_OPT_RTS_ALLOCA,     "RTS optimization: call to alloca() replaced" },
        { FS_OPT_RTS_SQRT,       "RTS optimization: call to sqrt() replaced" },
@@ -229,8 +233,9 @@ static void simple_dump_opcode_hash(dumper_t *dmp, pset *set)
 /**
  * Return the name of an optimization.
  */
-static const char *get_opt_name(int index) {
-       assert(index < (int) ARR_SIZE(opt_names) && "index out of range");
+static const char *get_opt_name(int index)
+{
+       assert(index < (int) ARRAY_SIZE(opt_names) && "index out of range");
        assert((int) opt_names[index].kind == index && "opt_names broken");
        return opt_names[index].name;
 }  /* get_opt_name */
@@ -287,9 +292,10 @@ static void simple_dump_be_block_reg_pressure(dumper_t *dmp, graph_entry_t *entr
 }  /* simple_dump_be_block_reg_pressure */
 
 /** prints a distribution entry */
-static void simple_dump_distrib_entry(const distrib_entry_t *entry, void *env) {
+static void simple_dump_distrib_entry(const distrib_entry_t *entry, void *env)
+{
        dumper_t *dmp = env;
-       fprintf(dmp->f, "%12d", cnt_to_uint(&entry->cnt));
+       fprintf(dmp->f, "%12u", cnt_to_uint(&entry->cnt));
 }  /* simple_dump_distrib_entry */
 
 /**
@@ -321,7 +327,8 @@ static void simple_dump_be_block_sched_ready(dumper_t *dmp, graph_entry_t *entry
 /**
  * Adds the counter for given entry to another distribution table.
  */
-static void add_distrib_entry(const distrib_entry_t *entry, void *env) {
+static void add_distrib_entry(const distrib_entry_t *entry, void *env)
+{
        distrib_tbl_t *sum_tbl = env;
 
        stat_add_int_distrib_tbl(sum_tbl, PTR_TO_INT(entry->object), &entry->cnt);
@@ -458,7 +465,7 @@ static void simple_dump_edges(dumper_t *dmp, counter_t *cnt)
        if (! dmp->f)
                return;
 
-       fprintf(dmp->f, "%-16s %8d\n", "Edges", cnt_to_uint(cnt));
+       fprintf(dmp->f, "%-16s %8u\n", "Edges", cnt_to_uint(cnt));
 }  /* simple_dump_edges */
 
 /**
@@ -618,7 +625,7 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
        fprintf(dmp->f, "\nBit usage for integer constants\n");
        fprintf(dmp->f, "-------------------------------\n");
 
-       for (i = 0; i < ARR_SIZE(tbl->int_bits_count); ++i) {
+       for (i = 0; i < ARRAY_SIZE(tbl->int_bits_count); ++i) {
                fprintf(dmp->f, "%5u %12u\n", (unsigned) (i + 1), cnt_to_uint(&tbl->int_bits_count[i]));
                cnt_add(&sum, &tbl->int_bits_count[i]);
        }  /* for */
@@ -626,7 +633,7 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
 
        fprintf(dmp->f, "\nFloating point constants classification\n");
        fprintf(dmp->f, "--------------------------------------\n");
-       for (i = 0; i < ARR_SIZE(tbl->floats); ++i) {
+       for (i = 0; i < ARRAY_SIZE(tbl->floats); ++i) {
                fprintf(dmp->f, "%-10s %12u\n", stat_fc_name(i), cnt_to_uint(&tbl->floats[i]));
                cnt_add(&sum, &tbl->floats[i]);
        }  /* for */
@@ -642,7 +649,8 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
 /**
  * Dumps a line of the parameter table
  */
-static void dump_tbl_line(const distrib_entry_t *entry, void *env) {
+static void dump_tbl_line(const distrib_entry_t *entry, void *env)
+{
        dumper_t *dmp = env;
 
        fprintf(dmp->f, "%d : %u\n", PTR_TO_INT(entry->object), cnt_to_uint(&entry->cnt));
@@ -651,7 +659,8 @@ static void dump_tbl_line(const distrib_entry_t *entry, void *env) {
 /**
  * dumps the parameter distribution table
  */
-static void simple_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global) {
+static void simple_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global)
+{
        fprintf(dmp->f, "\nCall parameter Information:\n");
        fprintf(dmp->f, "---------------------\n");
 
@@ -669,7 +678,8 @@ static void simple_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph
 /**
  * dumps the optimization counter table
  */
-static void simple_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len) {
+static void simple_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len)
+{
        unsigned i;
 
        fprintf(dmp->f, "\nOptimization counts:\n");
@@ -687,7 +697,8 @@ static void simple_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned le
 /**
  * initialize the simple dumper
  */
-static void simple_init(dumper_t *dmp, const char *name) {
+static void simple_init(dumper_t *dmp, const char *name)
+{
        char fname[2048];
 
        snprintf(fname, sizeof(fname), "%s.txt", name);
@@ -700,7 +711,8 @@ static void simple_init(dumper_t *dmp, const char *name) {
 /**
  * finishes the simple dumper
  */
-static void simple_finish(dumper_t *dmp) {
+static void simple_finish(dumper_t *dmp)
+{
        if (dmp->f)
                fclose(dmp->f);
        dmp->f = NULL;
@@ -784,7 +796,7 @@ static void csv_dump_graph(dumper_t *dmp, graph_entry_t *entry)
 
                csv_count_nodes(dmp, entry, cnt);
 
-               fprintf(dmp->f, "%-40s, %p, %d, %d, %d, %d\n",
+               fprintf(dmp->f, "%-40s, %p, %u, %u, %u, %u\n",
                        name,
                        (void *)entry->irg,
                        cnt_to_uint(&cnt[0]),
@@ -808,7 +820,8 @@ static void csv_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl)
 /**
  * dumps the parameter distribution table
  */
-static void csv_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global) {
+static void csv_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global)
+{
        (void) dmp;
        (void) tbl;
        (void) global;
@@ -818,7 +831,8 @@ static void csv_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_en
 /**
  * dumps the optimization counter
  */
-static void csv_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len) {
+static void csv_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len)
+{
        (void) dmp;
        (void) tbl;
        (void) len;