- DBG((env->dbg, LEVEL_2, "fixing ASAP/ALAP of %+F to %u/%u\n", irn, na->asap, na->alap));
-}
-
-#if 0
-/**
- * Calculate the ASAP scheduling step for current irn.
- */
-static void calculate_irn_asap(ir_node *irn, void *walk_env) {
- be_ilpsched_irn_t *node;
- be_ilpsched_env_t *env = walk_env;
- int i;
- ir_node *block;
- ilpsched_node_attr_t *na;
-
- /* These nodes are handled separate */
- if (! consider_for_sched(env->arch_env->isa, irn))
- return;
-
- DBG((env->dbg, LEVEL_2, "Calculating ASAP of node %+F\n", irn));
-
- node = get_ilpsched_irn(env, irn);
- block = get_nodes_block(irn);
- na = get_ilpsched_node_attr(node);
-
- /* accumulate all transitive predecessors of current node */
- 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));
- be_ilpsched_irn_t *pred_node;
- ilpsched_node_attr_t *pna;
- unsigned idx;
-
- if (be_is_Keep(pred))
- pred = skip_normal_Proj(env->arch_env->isa, get_irn_n(pred, 0));
-
- if (is_Phi(pred) || block != get_nodes_block(pred) || is_NoMem(pred))
- continue;
-
- pred_node = get_ilpsched_irn(env, pred);
- pna = get_ilpsched_node_attr(pred_node);
- idx = get_irn_idx(irn);
-
- assert(pna->asap && "missing ASAP of predecessor");
-
- /*
- We have not already visited this predecessor
- -> accumulate it's predecessors
- */
- if (pna->visit_idx != idx) {
- pna->visit_idx = idx;
- na->transitive_block_nodes = bitset_or(na->transitive_block_nodes, pna->transitive_block_nodes);
- DBG((env->dbg, LEVEL_3, "\taccumulating preds of %+F\n", pred));
- }
- }
-
- /* every node is it's own transitive predecessor in block */
- bitset_set(na->transitive_block_nodes, na->block_idx);
-
- /* asap = number of transitive predecessors in this block */
- na->asap = bitset_popcnt(na->transitive_block_nodes);
-
- DBG((env->dbg, LEVEL_2, "\tcalculated ASAP is %u\n", na->asap));
-}
-
-/**
- * Calculate the ALAP scheduling step for current irn.
- * @note: requires ASAP being calculated.
- */
-static void calculate_irn_alap(ir_node *irn, void *walk_env) {
- be_ilpsched_env_t *env = walk_env;
- int i, is_head;
- ir_node *block;
- be_ilpsched_irn_t *node;
- ilpsched_node_attr_t *na;
-
- /* These nodes are handled separate */
- if (! consider_for_sched(env->arch_env->isa, irn))
- return;
-
- DBG((env->dbg, LEVEL_2, "Calculating ALAP of node %+F ... ", irn));
-
- block = get_nodes_block(irn);
- node = get_ilpsched_irn(env, irn);
- na = get_ilpsched_node_attr(node);
- is_head = 1;
-
- for (i = get_irn_ins_or_deps(irn) - 1; i >= i; --i) {
- ir_node *pred = skip_normal_Proj(env->arch_env->isa, get_irn_in_or_dep(irn, i));
-
- /* check, if we have a head node */
- if (! is_Phi(pred) && ! is_NoMem(pred) && get_nodes_block(pred) == block) {
- be_ilpsched_irn_t *pred_node = get_ilpsched_irn(env, pred);
- ilpsched_node_attr_t *pna = get_ilpsched_node_attr(pred_node);
- unsigned lat;
-
- lat = fixed_latency(env->sel, pred, env->block_env);
- na->alap = MAX(na->alap, pna->alap + lat);
- is_head = 0;
- }
- }
-
- /* handle head nodes (no predecessor in same block) */
- if (is_head) {
- be_ilpsched_irn_t *block_node = get_ilpsched_irn(env, block);
- ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- plist_element_t *el;
-
- DB((env->dbg, LEVEL_2, "head node ... "));
-
- /*
- We have a head node here:
- ALAP(m) = sum_over_all_m(ASAP(m))
- where m is a root node and there is no path from m to n
- */
- foreach_plist(ba->root_nodes, el) {
- ir_node *root = plist_element_get_value(el);
-
- /* check if current root is independent from irn */
- if (! heights_reachable_in_block(env->height, root, irn)) {
- be_ilpsched_irn_t *root_node = get_ilpsched_irn(env, root);
- ilpsched_node_attr_t *rna = get_ilpsched_node_attr(root_node);
-
- na->alap = rna->asap + fixed_latency(env->sel, root, env->block_env);
- }
- }
- }
-
- DB((env->dbg, LEVEL_2, "%u\n", na->alap));
-}
-
-/**
- * Accumulate the successors of all nodes from irn on upwards.
- */
-static void accumulate_succs(be_ilpsched_env_t *env, ir_node *irn) {
- unsigned i, n;
- be_ilpsched_irn_t *node = get_ilpsched_irn(env, irn);
- ilpsched_node_attr_t *na = get_ilpsched_node_attr(node);
- ir_node *block = get_nodes_block(irn);
- waitq *wq = new_waitq();
-
- DBG((env->dbg, LEVEL_3, "\taccumulating succs of %+F\n", irn));
-
- /* enqueue node for final alap calculation */
- if (! na->enqueued) {
- be_ilpsched_irn_t *block_node = get_ilpsched_irn(env, block);
- ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
-
- na->enqueued = 1;
- na->alap = ba->max_steps;
- waitq_put(env->alap_queue, node);
-
- set_irn_link(irn, ba->head_ilp_nodes);
- ba->head_ilp_nodes = irn;
- DBG((env->dbg, LEVEL_5, "\t\tlinked %+F to ilp nodes of %+F, attr %p\n", irn, block, ba));
- DBG((env->dbg, LEVEL_4, "\t\tenqueueing %+F for final ALAP calculation\n", irn));
- }
-
- for (i = 0, n = get_irn_ins_or_deps(irn); i < n; ++i) {
- ir_node *pred = skip_normal_Proj(env->arch_env->isa, get_irn_in_or_dep(irn, i));
- unsigned idx;
- be_ilpsched_irn_t *pred_node;
- ilpsched_node_attr_t *pna;
-
- if (be_is_Keep(pred))
- pred = skip_normal_Proj(env->arch_env->isa, get_irn_n(pred, 0));
-
- if (is_Phi(pred) || block != get_nodes_block(pred) || is_NoMem(pred))
- continue;
-
- pred_node = get_ilpsched_irn(env, pred);
- pna = get_ilpsched_node_attr(pred_node);
- idx = get_irn_idx(irn);
-
- /* accumulate the successors */
- if (pna->visit_idx != idx) {
- pna->visit_idx = idx;
- pna->transitive_block_nodes = bitset_or(pna->transitive_block_nodes, na->transitive_block_nodes);
-
- /* set current node as successor */
- bitset_set(pna->transitive_block_nodes, na->block_idx);
- waitq_put(wq, pred);
-
- DBG((env->dbg, LEVEL_3, "\taccumulating succs of %+F to %+F\n", irn, pred));
- }
- }
-
- /* process all predecessors */
- while (! waitq_empty(wq)) {
- accumulate_succs(env, waitq_get(wq));
- }
-
- del_waitq(wq);
-}