*/
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif /* HAVE_CONFIG_H */
+#endif
#include "beblocksched.h"
#include <lpp/lpp_net.h>
#endif /* WITH_ILP */
+DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
+
typedef enum _blocksched_algos_t {
BLOCKSCHED_NAIV, BLOCKSCHED_EXTBB, BLOCKSCHED_GREEDY, BLOCKSCHED_ILP
} blocksched_algos_t;
edge_t *edges;
pdeq *worklist;
int blockcount;
- DEBUG_ONLY(firm_dbg_module_t *dbg;)
} blocksched_env_t;
/**
continue;
/* schedule the 2 blocks behind each other */
- DBG((env->dbg, LEVEL_1, "Coalesce (Jump) %+F -> %+F (%.3g)\n",
+ DBG((dbg, LEVEL_1, "Coalesce (Jump) %+F -> %+F (%.3g)\n",
pred_entry->block, entry->block, edge->execfreq));
pred_entry->next = entry;
entry->prev = pred_entry;
continue;
/* schedule the 2 blocks behind each other */
- DBG((env->dbg, LEVEL_1, "Coalesce (CondJump) %+F -> %+F (%.3g)\n",
+ DBG((dbg, LEVEL_1, "Coalesce (CondJump) %+F -> %+F (%.3g)\n",
pred_entry->block, entry->block, edge->execfreq));
pred_entry->next = entry;
entry->prev = pred_entry;
env->blockcount++;
mark_irn_visited(block);
- DBG((env->dbg, LEVEL_1, "Pick succ of %+F\n", block));
+ DBG((dbg, LEVEL_1, "Pick succ of %+F\n", block));
/* put all successors into the worklist */
foreach_block_succ(block, edge) {
if (irn_visited(succ_entry->block))
continue;
- DBG((env->dbg, LEVEL_1, "Put %+F into worklist\n", succ_entry->block));
+ DBG((dbg, LEVEL_1, "Put %+F into worklist\n", succ_entry->block));
pdeq_putr(env->worklist, succ_entry->block);
}
return;
}
- DBG((env->dbg, LEVEL_1, "deciding...\n"));
+ DBG((dbg, LEVEL_1, "deciding...\n"));
best_succ_execfreq = -1;
/* no successor yet: pick the successor block with the highest execution
}
if (succ == NULL) {
- DBG((env->dbg, LEVEL_1, "pick from worklist\n"));
+ DBG((dbg, LEVEL_1, "pick from worklist\n"));
do {
if (pdeq_empty(env->worklist)) {
- DBG((env->dbg, LEVEL_1, "worklist empty\n"));
+ DBG((dbg, LEVEL_1, "worklist empty\n"));
return;
}
succ = pdeq_getl(env->worklist);
ir_node *startblock = get_irg_start_block(irg);
blocksched_entry_t *entry = get_irn_link(startblock);
+ set_using_visited(irg);
inc_irg_visited(irg);
env->worklist = new_pdeq();
assert(pdeq_empty(env->worklist));
del_pdeq(env->worklist);
+ clear_using_visited(irg);
+
return entry;
}
blocksched_entry_t *entry;
block_list = NEW_ARR_D(ir_node *, obst, count);
- DBG((env->dbg, LEVEL_1, "Blockschedule:\n"));
+ DBG((dbg, LEVEL_1, "Blockschedule:\n"));
for (entry = first; entry != NULL; entry = entry->next) {
assert(i < count);
block_list[i++] = entry->block;
- DBG((env->dbg, LEVEL_1, "\t%+F\n", entry->block));
+ DBG((dbg, LEVEL_1, "\t%+F\n", entry->block));
}
assert(i == count);
env.edges = NEW_ARR_F(edge_t, 0);
env.worklist = NULL;
env.blockcount = 0;
- FIRM_DBG_REGISTER(env.dbg, "firm.be.blocksched");
// collect edge execution frequencies
irg_block_walk_graph(irg, collect_egde_frequency, NULL, &env);
pred = get_Block_cfgpred_block(block, edge->pos);
entry = get_irn_link(pred);
- DBG((env->env.dbg, LEVEL_1, "Adding out cst to %+F from %+F,%d\n",
+ DBG((dbg, LEVEL_1, "Adding out cst to %+F from %+F,%d\n",
pred, block, edge->pos));
lpp_set_factor_fast(env->lpp, entry->out_cst, edge->ilpvar, 1.0);
}
if (is_Bad(get_Block_cfgpred(block, 0)))
continue;
- is_jump = lpp_get_var_sol(env->lpp, edge->ilpvar);
+ is_jump = (int)lpp_get_var_sol(env->lpp, edge->ilpvar);
if (is_jump)
continue;
env.env.worklist = NULL;
env.env.blockcount = 0;
env.ilpedges = NEW_ARR_F(ilp_edge_t, 0);
- FIRM_DBG_REGISTER(env.env.dbg, "firm.be.blocksched");
env.lpp = new_lpp("blockschedule", lpp_minimize);
lpp_set_time_limit(env.lpp, 20);
if (list->start == NULL) {
list->start = block;
list->end = block;
- }
- else {
+ } else {
set_irn_link(list->end, block);
list->end = block;
}
list.start = NULL;
list.end = NULL;
list.n_blks = 0;
+
+ set_using_irn_link(irg);
+ set_using_visited(irg);
inc_irg_block_visited(irg);
+
create_block_list(get_irg_start_block(irg), &list);
/** create an array, so we can go forward and backward */
blk_list[i] = b;
}
+ clear_using_irn_link(irg);
+ clear_using_visited(irg);
+
return blk_list;
}
lc_opt_entry_t *blocksched_grp = lc_opt_get_grp(be_grp, "blocksched");
lc_opt_add_table(blocksched_grp, be_blocksched_options);
+
+ FIRM_DBG_REGISTER(dbg, "firm.be.blocksched");
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_blocksched);