be: let begnuas call be_dbg_method_begin/end
[libfirm] / ir / be / bepbqpcoloring.c
index 22fc0df..070e255 100644 (file)
@@ -28,8 +28,6 @@
 /* miscellaneous includes */
 #include "config.h"
 
-#ifdef FIRM_KAPS
-
 #include "debug.h"
 #include "error.h"
 
@@ -38,6 +36,7 @@
 #include "iredges_t.h"
 #include "irprintf.h"
 #include "irgwalk.h"
+#include "irtools.h"
 #include "time.h"
 
 /* libfirm/ir/adt includes */
@@ -157,7 +156,10 @@ static void create_pbqp_node(be_pbqp_alloc_env_t *pbqp_alloc_env, ir_node *irn)
        /* set costs depending on register constrains */
        unsigned idx;
        for (idx = 0; idx < colors_n; idx++) {
-               if (!bitset_is_set(allocatable_regs, idx) || !arch_reg_out_is_allocatable(irn, arch_register_for_index(cls, idx))) {
+               const arch_register_req_t *req = arch_get_irn_register_req(irn);
+               const arch_register_t     *reg = arch_register_for_index(cls, idx);
+               if (!bitset_is_set(allocatable_regs, idx)
+                   || !arch_reg_is_allocatable(req, reg)) {
                        /* constrained */
                        vector_set(costs_vector, idx, INF_COSTS);
                        cntConstrains++;
@@ -261,7 +263,7 @@ static void create_affinity_edges(ir_node *irn, void *env)
 {
        be_pbqp_alloc_env_t         *pbqp_alloc_env = (be_pbqp_alloc_env_t*)env;
        const arch_register_class_t *cls            = pbqp_alloc_env->cls;
-       const arch_register_req_t   *req            = arch_get_register_req_out(irn);
+       const arch_register_req_t   *req            = arch_get_irn_register_req(irn);
        unsigned                     pos;
        unsigned                     max;
 
@@ -602,10 +604,6 @@ static void insert_perms(ir_node *block, void *data)
        be_chordal_env_t *env    = (be_chordal_env_t*)data;
        ir_node          *irn;
 
-       /*
-        * If the block is the start block search the barrier and
-        * start handling constraints from there.
-        */
        for (irn = sched_first(block); !sched_is_end(irn);) {
                be_insn_t *insn = chordal_scan_insn(env, irn);
                irn             = insn->next_insn;
@@ -627,7 +625,11 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
        be_pbqp_alloc_env_t          pbqp_alloc_env;
        unsigned                     col;
        unsigned                     row;
-
+       pbqp_matrix_t               *ife_matrix;
+       num                          solution;
+#if KAPS_DUMP
+       FILE                        *file_before;
+#endif
 #if TIMER
        ir_timer_t *t_ra_pbqp_alloc_create     = ir_timer_new();
        ir_timer_t *t_ra_pbqp_alloc_solve      = ir_timer_new();
@@ -665,7 +667,7 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
 
 
        /* create costs matrix template for interference edges */
-       pbqp_matrix_t *ife_matrix = pbqp_matrix_alloc(pbqp_alloc_env.pbqp_inst, colors_n, colors_n);
+       ife_matrix = pbqp_matrix_alloc(pbqp_alloc_env.pbqp_inst, colors_n, colors_n);
        /* set costs */
        for (row = 0, col = 0; row < colors_n; row++, col++)
                pbqp_matrix_set(ife_matrix, row, col, INF_COSTS);
@@ -715,18 +717,20 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
 
 #if KAPS_DUMP
        // dump graph before solving pbqp
-       FILE *file_before = my_open(env, "", "-pbqp_coloring.html");
+       file_before = my_open(env, "", "-pbqp_coloring.html");
        set_dumpfile(pbqp_alloc_env.pbqp_inst, file_before);
 #endif
 
-       /* print out reverse perfect eleminiation order */
+       /* print out reverse perfect elimination order */
 #if PRINT_RPEO
-       plist_element_t *elements;
-       foreach_plist(pbqp_alloc_env.rpeo, elements) {
-               pbqp_node *node = elements->data;
-               printf(" %d(%lu);", node->index, get_idx_irn(irg, node->index)->node_nr);
+       {
+               plist_element_t *elements;
+               foreach_plist(pbqp_alloc_env.rpeo, elements) {
+                       pbqp_node_t *node = elements->data;
+                       printf(" %d(%ld);", node->index, get_idx_irn(irg, node->index)->node_nr);
+               }
+               printf("\n");
        }
-       printf("\n");
 #endif
 
        /* solve pbqp instance */
@@ -744,7 +748,7 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
 #endif
 
 
-       num solution = get_solution(pbqp_alloc_env.pbqp_inst);
+       solution = get_solution(pbqp_alloc_env.pbqp_inst);
        if (solution == INF_COSTS)
                panic("No PBQP solution found");
 
@@ -785,7 +789,7 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
 /**
  * Initializes this module.
  */
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_pbqp_coloring);
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_pbqp_coloring)
 void be_init_pbqp_coloring(void)
 {
        lc_opt_entry_t *be_grp       = lc_opt_get_grp(firm_opt_get_root(), "be");
@@ -801,5 +805,3 @@ void be_init_pbqp_coloring(void)
        lc_opt_add_table(pbqp_grp, options);
        be_register_chordal_coloring("pbqp", &coloring);
 }
-
-#endif