Adapt to latest libfirm.
[libfirm] / optimal.c
index cb4ef75..01c8fe1 100644 (file)
--- a/optimal.c
+++ b/optimal.c
@@ -109,8 +109,8 @@ void fill_node_buckets(pbqp *pbqp)
        node_len = pbqp->num_nodes;
 
        #if KAPS_TIMING
-               ir_timer_t *t_fill_buckets = ir_timer_register("be_pbqp_fill_buckets", "PBQP Fill Nodes into buckets");
-               ir_timer_reset_and_start(t_fill_buckets);
+               ir_timer_t *t_fill_buckets = ir_timer_new();
+               ir_timer_start(t_fill_buckets);
        #endif
 
        for (node_index = 0; node_index < node_len; ++node_index) {
@@ -133,7 +133,7 @@ void fill_node_buckets(pbqp *pbqp)
 
        #if KAPS_TIMING
                ir_timer_stop(t_fill_buckets);
-               printf("%-20s: %8.3lf msec\n", ir_timer_get_description(t_fill_buckets), (double)ir_timer_elapsed_usec(t_fill_buckets) / 1000.0);
+               printf("PBQP Fill Nodes into buckets: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_fill_buckets) / 1000.0);
        #endif
 }
 
@@ -339,6 +339,7 @@ static void merge_source_into_target(pbqp *pbqp, pbqp_edge *edge)
                pbqp_matrix *old_matrix;
                pbqp_matrix *new_matrix;
                pbqp_node   *other_node;
+               vector      *other_vec;
                unsigned     other_len;
                unsigned     other_index;
                unsigned     tgt_index;
@@ -352,14 +353,15 @@ static void merge_source_into_target(pbqp *pbqp, pbqp_edge *edge)
                assert(old_matrix);
 
                if (old_edge->tgt == src_node) {
-                       other_node = edge->src;
+                       other_node = old_edge->src;
                        other_len  = old_matrix->rows;
                }
                else {
-                       other_node = edge->tgt;
+                       other_node = old_edge->tgt;
                        other_len = old_matrix->cols;
                }
                assert(other_node);
+               other_vec = other_node->costs;
 
                new_matrix = pbqp_matrix_alloc(pbqp, tgt_len, other_len);
 
@@ -368,7 +370,13 @@ static void merge_source_into_target(pbqp *pbqp, pbqp_edge *edge)
                        for (tgt_index = 0; tgt_index < tgt_len; ++tgt_index) {
                                unsigned src_index = mapping[tgt_index];
 
+                               if (tgt_vec->entries[tgt_index].data == INF_COSTS)
+                                       continue;
+
                                for (other_index = 0; other_index < other_len; ++other_index) {
+                                       if (other_vec->entries[other_index].data == INF_COSTS)
+                                               continue;
+
                                        new_matrix->entries[tgt_index*other_len+other_index] = old_matrix->entries[other_index*src_len+src_index];
                                }
                        }
@@ -378,7 +386,13 @@ static void merge_source_into_target(pbqp *pbqp, pbqp_edge *edge)
                        for (tgt_index = 0; tgt_index < tgt_len; ++tgt_index) {
                                unsigned src_index = mapping[tgt_index];
 
+                               if (tgt_vec->entries[tgt_index].data == INF_COSTS)
+                                       continue;
+
                                for (other_index = 0; other_index < other_len; ++other_index) {
+                                       if (other_vec->entries[other_index].data == INF_COSTS)
+                                               continue;
+
                                        new_matrix->entries[tgt_index*other_len+other_index] = old_matrix->entries[src_index*other_len+other_index];
                                }
                        }
@@ -386,8 +400,9 @@ static void merge_source_into_target(pbqp *pbqp, pbqp_edge *edge)
 
                add_edge_costs(pbqp, tgt_node->index, other_node->index, new_matrix);
 
-               disconnect_edge(src_node, old_edge);
-               disconnect_edge(other_node, old_edge);
+               delete_edge(old_edge);
+               reorder_node(src_node);
+               reorder_node(other_node);
 
                new_edge = get_edge(pbqp, tgt_node->index, other_node->index);
                insert_into_rm_bucket(new_edge);
@@ -482,6 +497,7 @@ static void merge_target_into_source(pbqp *pbqp, pbqp_edge *edge)
                pbqp_matrix *old_matrix;
                pbqp_matrix *new_matrix;
                pbqp_node   *other_node;
+               vector      *other_vec;
                unsigned     other_len;
                unsigned     other_index;
                unsigned     src_index;
@@ -495,14 +511,15 @@ static void merge_target_into_source(pbqp *pbqp, pbqp_edge *edge)
                assert(old_matrix);
 
                if (old_edge->tgt == tgt_node) {
-                       other_node = edge->src;
+                       other_node = old_edge->src;
                        other_len  = old_matrix->rows;
                }
                else {
-                       other_node = edge->tgt;
+                       other_node = old_edge->tgt;
                        other_len = old_matrix->cols;
                }
                assert(other_node);
+               other_vec = other_node->costs;
 
                new_matrix = pbqp_matrix_alloc(pbqp, src_len, other_len);
 
@@ -511,7 +528,13 @@ static void merge_target_into_source(pbqp *pbqp, pbqp_edge *edge)
                        for (src_index = 0; src_index < src_len; ++src_index) {
                                unsigned tgt_index = mapping[src_index];
 
+                               if (src_vec->entries[src_index].data == INF_COSTS)
+                                       continue;
+
                                for (other_index = 0; other_index < other_len; ++other_index) {
+                                       if (other_vec->entries[other_index].data == INF_COSTS)
+                                               continue;
+
                                        new_matrix->entries[src_index*other_len+other_index] = old_matrix->entries[other_index*tgt_len+tgt_index];
                                }
                        }
@@ -521,7 +544,13 @@ static void merge_target_into_source(pbqp *pbqp, pbqp_edge *edge)
                        for (src_index = 0; src_index < src_len; ++src_index) {
                                unsigned tgt_index = mapping[src_index];
 
+                               if (src_vec->entries[src_index].data == INF_COSTS)
+                                       continue;
+
                                for (other_index = 0; other_index < other_len; ++other_index) {
+                                       if (other_vec->entries[other_index].data == INF_COSTS)
+                                               continue;
+
                                        new_matrix->entries[src_index*other_len+other_index] = old_matrix->entries[tgt_index*other_len+other_index];
                                }
                        }
@@ -529,8 +558,9 @@ static void merge_target_into_source(pbqp *pbqp, pbqp_edge *edge)
 
                add_edge_costs(pbqp, src_node->index, other_node->index, new_matrix);
 
-               disconnect_edge(tgt_node, old_edge);
-               disconnect_edge(other_node, old_edge);
+               delete_edge(old_edge);
+               reorder_node(tgt_node);
+               reorder_node(other_node);
 
                new_edge = get_edge(pbqp, src_node->index, other_node->index);
                insert_into_rm_bucket(new_edge);
@@ -683,8 +713,8 @@ void initial_simplify_edges(pbqp *pbqp)
        assert(pbqp);
 
        #if KAPS_TIMING
-               ir_timer_t *t_int_simpl = ir_timer_register("be_pbqp_init_simp", "PBQP Initial simplify edges");
-               ir_timer_reset_and_start(t_int_simpl);
+               ir_timer_t *t_int_simpl = ir_timer_new();
+               ir_timer_start(t_int_simpl);
        #endif
 
 #if    KAPS_DUMP
@@ -722,7 +752,7 @@ void initial_simplify_edges(pbqp *pbqp)
 
        #if KAPS_TIMING
                ir_timer_stop(t_int_simpl);
-               printf("%-20s: %8.3lf msec\n", ir_timer_get_description(t_int_simpl), (double)ir_timer_elapsed_usec(t_int_simpl) / 1000.0);
+               printf("PBQP Initial simplify edges: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_int_simpl) / 1000.0);
        #endif
 }
 
@@ -733,7 +763,7 @@ num determine_solution(pbqp *pbqp)
        num      solution   = 0;
 
        #if KAPS_TIMING
-               ir_timer_t *t_det_solution = ir_timer_register("be_det_solution", "PBQP Determine Solution");
+               ir_timer_t *t_det_solution = ir_timer_new();
                ir_timer_reset_and_start(t_det_solution);
        #endif
 
@@ -788,7 +818,7 @@ num determine_solution(pbqp *pbqp)
 
        #if KAPS_TIMING
                ir_timer_stop(t_det_solution);
-               printf("%-20s: %8.3lf msec\n", ir_timer_get_description(t_det_solution), (double)ir_timer_elapsed_usec(t_det_solution) / 1000.0);
+               printf("PBQP Determine Solution: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_det_solution) / 1000.0);
        #endif
 
        return solution;