* @date 20.10.2004
* @author Sebastian Hack
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <stdio.h>
#include <stdarg.h>
#include "iterator.h"
#include "irdump.h"
#include "irprintf_t.h"
+#include "debug.h"
#include "besched_t.h"
#include "beutil.h"
pset *ready_set;
pset *already_scheduled;
ir_node *block;
+ firm_dbg_module_t *dbg;
} block_sched_env_t;
return 0;
}
- ir_debugf("\tmaking ready: %n\n", irn);
+ DBG((env->dbg, LEVEL_2, "\tmaking ready: %n\n", irn));
pset_insert_ptr(env->ready_set, irn);
return 1;
for(i = 0, n = get_irn_n_outs(irn); i < n; ++i) {
ir_node *user = get_irn_out(irn, i);
- make_ready(env, user);
+ if(!is_Phi(user))
+ make_ready(env, user);
}
}
if(to_appear_in_schedule(irn)) {
sched_info_t *info = get_irn_sched_info(irn);
INIT_LIST_HEAD(&info->list);
+ info->time_step = env->curr_time;
sched_add(env->block, irn);
- ir_debugf("\tadding %n\n", irn);
+ DBG((env->dbg, LEVEL_2, "\tadding %n\n", irn));
}
/* Insert the node in the set of all already scheduled nodes. */
block_sched_env_t be;
ir_node *irn;
- int j, m;
+ int i, n, j, m;
int phi_seen = 0;
sched_info_t *info = get_irn_sched_info(block);
INIT_LIST_HEAD(&info->list);
/* Initialize the block scheduling environment */
+ be.dbg = firm_dbg_register("firm.be.sched");
be.block = block;
be.curr_time = 0;
be.ready_set = new_pset(node_cmp_func, get_irn_n_outs(block));
be.already_scheduled = new_pset(node_cmp_func, get_irn_n_outs(block));
- ir_debugf("scheduling %n\n", block);
+ DBG((be.dbg, LEVEL_1, "scheduling %n\n", block));
/* Then one can add all nodes are ready to the set. */
- int i;
- int n;
for(i = 0, n = get_irn_n_outs(block); i < n; ++i) {
ir_node *irn = get_irn_out(block, i);
+ /* Skip the end node because of keepalive edges. */
+ if(get_irn_opcode(irn) == iro_End)
+ continue;
+
/* Phi functions are scheduled immediately, since they only transfer
* data flow from the predecessors to this block. */
if(is_Phi(irn)) {
/* Make the node ready, if all operands live in a foreign block */
if(ready) {
- ir_debugf("\timmediately ready: %n\n", irn);
+ DBG((be.dbg, LEVEL_2, "\timmediately ready: %n\n", irn));
make_ready(&be, irn);
}
}
be.curr_time += phi_seen;
while(pset_count(be.ready_set) > 0) {
- ir_debugf("\tready set: %*n\n", pset_iterator, be.ready_set);
+ DBG((be.dbg, LEVEL_2, "\tready set: %*n\n", pset_iterator, be.ready_set));
// pset_print(stdout, be.ready_set, irn_printer);
/* select a node to be scheduled and check if it was ready */
irn = env->select(env->select_env, block, be.curr_time,
be.already_scheduled, be.ready_set);
- ir_debugf("\tpicked node %n\n", irn);
+ DBG((be.dbg, LEVEL_3, "\tpicked node %n\n", irn));
/* Add the node to the schedule. */
add_to_sched(&be, irn);
del_pset(be.ready_set);
del_pset(be.already_scheduled);
-
- {
- sched_info_t *inf;
- list_for_each_entry(sched_info_t, inf, &info->list, list) {
- ir_node *irn = get_sched_info_irn(inf);
- ir_debugf("node: %n, pos: %d\n", irn, inf->time_step);
- }
- }
}