fixed precedence constraint
[libfirm] / ir / be / beblocksched.c
index 1995eb9..abec354 100644 (file)
 #include "irtools.h"
 #include "debug.h"
 #include "beirgmod.h"
+#include "bemodule.h"
+#include "be.h"
 
-#ifdef WITH_LIBCORE
 #include <libcore/lc_opts.h>
 #include <libcore/lc_opts_enum.h>
 #include <libcore/lc_timing.h>
-#endif /* WITH_LIBCORE */
 
 #ifdef WITH_ILP
 #include <lpp/lpp.h>
@@ -43,7 +43,6 @@ typedef enum _blocksched_algos_t {
 
 static int algo = BLOCKSCHED_GREEDY;
 
-#ifdef WITH_LIBCORE
 static const lc_opt_enum_int_items_t blockschedalgo_items[] = {
        { "naiv",       BLOCKSCHED_NAIV },
        { "extbb",      BLOCKSCHED_EXTBB },
@@ -62,7 +61,6 @@ static const lc_opt_table_entry_t be_blocksched_options[] = {
        LC_OPT_ENT_ENUM_INT ("algo", "the block scheduling algorithm", &algo_var),
        { NULL }
 };
-#endif
 
 /*
  *   ____                   _
@@ -103,9 +101,7 @@ typedef struct _blocksched_env_t {
  */
 static void collect_egde_frequency(ir_node *block, void *data)
 {
-       blocksched_env_t   *env        = data;
-       ir_graph           *irg        = env->irg;
-       ir_node            *startblock = get_irg_start_block(irg);
+       blocksched_env_t   *env = data;
        int                arity;
        edge_t             edge;
        blocksched_entry_t *entry;
@@ -116,7 +112,7 @@ static void collect_egde_frequency(ir_node *block, void *data)
        entry->prev  = NULL;
        set_irn_link(block, entry);
 
-       if (block == startblock)
+       if (block == get_irg_start_block(env->irg))
                return;
 
        arity = get_irn_arity(block);
@@ -129,7 +125,7 @@ static void collect_egde_frequency(ir_node *block, void *data)
                ARR_APP1(edge_t, env->edges, edge);
        } else {
                int    i;
-               double highest_execfreq = -1;
+               double highest_execfreq = -1.0;
                int    highest_edge_num = -1;
 
                edge.block = block;
@@ -216,7 +212,7 @@ static void coalesce_blocks(blocksched_env_t *env)
                entry      = get_irn_link(block);
                pred_entry = get_irn_link(pred_block);
 
-               /* TODO: what's this check for? */
+               /* is 1 of the blocks already attached to another block? */
                if (pred_entry->next != NULL || entry->prev != NULL)
                        continue;
 
@@ -378,7 +374,7 @@ static ir_node **create_block_schedule_greedy(ir_graph *irg, ir_exec_freq *execf
        // sort interblock edges by execution frequency
        qsort(env.edges, ARR_LEN(env.edges), sizeof(env.edges[0]), cmp_edges);
 
-       be_remove_empty_blocks(irg);
+       (void)be_remove_empty_blocks(irg);
 
        if (algo != BLOCKSCHED_NAIV)
                coalesce_blocks(&env);
@@ -579,7 +575,7 @@ static ir_node **create_block_schedule_ilp(ir_graph *irg, ir_exec_freq *execfreq
 
        irg_block_walk_graph(irg, collect_egde_frequency_ilp, NULL, &env);
 
-       be_remove_empty_blocks(irg);
+       (void)be_remove_empty_blocks(irg);
        coalesce_blocks_ilp(&env);
 
        start_entry = finish_block_schedule(&env.env);
@@ -696,22 +692,15 @@ static ir_node **create_extbb_block_schedule(ir_graph *irg, ir_exec_freq *execfr
  * |_|  |_|\__,_|_|_| |_|
  *
  */
-
-#ifdef WITH_LIBCORE
-void be_block_schedule_register_options(lc_opt_entry_t *grp)
+void be_init_blocksched(void)
 {
-       static int     run_once = 0;
-       lc_opt_entry_t *blocksched_grp;
-
-       if (run_once)
-               return;
-
-       run_once       = 1;
-       blocksched_grp = lc_opt_get_grp(grp, "blocksched");
+       lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+       lc_opt_entry_t *blocksched_grp = lc_opt_get_grp(be_grp, "blocksched");
 
        lc_opt_add_table(blocksched_grp, be_blocksched_options);
 }
-#endif /* WITH_LIBCORE */
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_blocksched);
 
 ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs)
 {