we save entities not idents in ia32 symconsts now
[libfirm] / ir / be / beilpsched.c
index b507a5a..8c9ebdf 100644 (file)
@@ -3,6 +3,7 @@
  * An ILP scheduler based on
  * "ILP-based Instruction Scheduling for IA-64"
  * by Daniel Kaestner and Sebastian Winkel
+ * extended with register pressure constraints by Christian Wuerdig
  *
  * @date   22.10.2005
  * @author Christian Wuerdig
@@ -30,6 +31,7 @@
 #include "debug.h"
 #include "irtools.h"
 #include "irdump.h"
+#include "irprintf.h"
 #include "plist.h"
 #include "irprintf.h"
 
@@ -1096,6 +1098,33 @@ static void create_variables(be_ilpsched_env_t *env, lpp_t *lpp, be_ilpsched_irn
  *
  *******************************************************/
 
+/**
+ * Collect all operands and nodes @p irn depends on.
+ * If there is a Proj within the dependencies, all other Projs of the parent node are added as well.
+ */
+static nodeset *sta_collect_in_deps(ir_node *irn, nodeset *deps) {
+       int i;
+
+       for (i = get_irn_ins_or_deps(irn) - 1; i >= 0; --i) {
+               ir_node *p = get_irn_in_or_dep(irn, i);
+
+               if (is_Proj(p)) {
+                       const ir_edge_t *edge;
+
+                       p = get_Proj_pred(p);
+                       foreach_out_edge(p, edge) {
+                               ir_node *src = get_edge_src_irn(edge);
+                               nodeset_insert(deps, src);
+                       }
+               }
+               else {
+                       nodeset_insert(deps, p);
+               }
+       }
+
+       return deps;
+}
+
 /**
  * Create following ILP constraints:
  * - the assignment constraints:
@@ -1116,10 +1145,12 @@ static void create_assignment_and_precedence_constraints(be_ilpsched_env_t *env,
 
        num_cst_assign = num_cst_prec = num_cst_dead = 0;
        foreach_linked_irns(ba->head_ilp_nodes, irn) {
-               int                  cst, tp_idx, i;
+               int                  cst, tp_idx;
                unsigned             cur_var;
                be_ilpsched_irn_t    *node;
                ilpsched_node_attr_t *na;
+               ir_node              *pred;
+               nodeset              *deps = new_nodeset(16);
 
                node    = get_ilpsched_irn(env, irn);
                na      = get_ilpsched_node_attr(node);
@@ -1143,13 +1174,15 @@ static void create_assignment_and_precedence_constraints(be_ilpsched_env_t *env,
                /* the precedence constraints */
                ilp_timer_push(t_cst_prec);
                bs_block_irns = bitset_clear_all(bs_block_irns);
-               for (i = get_irn_ins_or_deps(irn) - 1; i >= 0; --i) {
-                       ir_node              *pred = skip_normal_Proj(env->arch_env->isa, get_irn_in_or_dep(irn, i));
+
+               deps = sta_collect_in_deps(irn, deps);
+               foreach_nodeset(deps, pred) {
                        unsigned             t_low, t_high, t;
                        be_ilpsched_irn_t    *pred_node;
                        ilpsched_node_attr_t *pna;
                        unsigned             delay;
 
+                       pred = skip_normal_Proj(env->arch_env->isa, pred);
                        if (is_Phi(pred) || block_node->irn != get_nodes_block(pred) || is_NoMem(pred))
                                continue;
 
@@ -1216,6 +1249,7 @@ static void create_assignment_and_precedence_constraints(be_ilpsched_env_t *env,
                                DEL_ARR_F(tmp_var_idx);
                        }
                }
+               del_nodeset(deps);
                ilp_timer_pop();
        }
        DBG((env->dbg, LEVEL_1, "\t%u assignement constraints (%g sec)\n",
@@ -1920,12 +1954,15 @@ static void create_ilp(ir_node *block, void *walk_env) {
 #ifdef FIRM_STATISTICS
        if (be_stat_ev_is_active()) {
                be_stat_ev("nodes", ba->block_last_idx);
+               be_stat_ev("vars", lpp ? lpp->var_next : 0);
+               be_stat_ev("csts", lpp ? lpp->cst_next : 0);
        }
 #endif /* FIRM_STATISTICS */
        if (need_heur) {
 #ifdef FIRM_STATISTICS
                if (be_stat_ev_is_active()) {
                        be_stat_ev("time", -1);
+                       be_stat_ev_dbl("opt", 0.0);
                }
 #endif /* FIRM_STATISTICS */
                list_sched_single_block(env->birg, block, env->be_opts);
@@ -1933,10 +1970,15 @@ static void create_ilp(ir_node *block, void *walk_env) {
        else {
 #ifdef FIRM_STATISTICS
                if (be_stat_ev_is_active()) {
-                       if (lpp)
+                       if (lpp) {
+                               double opt = lpp->sol_state == lpp_optimal ? 100.0 : 100.0 * lpp->best_bound / lpp->objval;
                                be_stat_ev_dbl("time", lpp->sol_time);
-                       else
-                               be_stat_ev("time", 0);
+                               be_stat_ev_dbl("opt", opt);
+                       }
+                       else {
+                               be_stat_ev_dbl("time", 0.0);
+                               be_stat_ev_dbl("opt", 100.0);
+                       }
                }
 #endif /* FIRM_STATISTICS */
                apply_solution(env, lpp, block);