#include "config.h"
#endif
+#include "firm_config.h"
+
#ifdef WITH_ILP
#include <math.h>
#include "beutil.h"
#include "bestat.h"
#include "beirg_t.h"
-#include "benodesets.h"
typedef struct _ilpsched_options_t {
unsigned regpress;
LC_OPT_ENT_BOOL("regpress", "Use register pressure constraints", &ilp_opts.regpress),
LC_OPT_ENT_INT("time_limit", "ILP time limit per block", &ilp_opts.time_limit),
LC_OPT_ENT_STR("lpp_log", "LPP logfile (stderr and stdout are supported)", ilp_opts.log_file, sizeof(ilp_opts.log_file)),
- { NULL }
+ LC_OPT_LAST
};
/*
unsigned n_consumer = 0;
ir_edge_kind_t ekind[2] = { EDGE_KIND_NORMAL, EDGE_KIND_DEP };
ir_node **consumer;
- int idx;
+ unsigned idx;
if (! consider_for_sched(env->arch_env->isa, irn))
return;
static INLINE void check_for_keeps(waitq *keeps, ir_node *block, ir_node *irn) {
const ir_edge_t *edge;
+ (void) block;
foreach_out_edge(irn, edge) {
ir_node *user = get_edge_src_irn(edge);
* 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) {
+static void sta_collect_in_deps(ir_node *irn, ir_nodeset_t *deps) {
int i;
for (i = get_irn_ins_or_deps(irn) - 1; i >= 0; --i) {
p = get_Proj_pred(p);
foreach_out_edge(p, edge) {
ir_node *src = get_edge_src_irn(edge);
- nodeset_insert(deps, src);
+ ir_nodeset_insert(deps, src);
}
}
else {
- nodeset_insert(deps, p);
+ ir_nodeset_insert(deps, p);
}
}
-
- return deps;
}
/**
be_ilpsched_irn_t *node;
ilpsched_node_attr_t *na;
ir_node *pred;
- nodeset *deps = new_nodeset(16);
+ ir_nodeset_t deps;
+ ir_nodeset_iterator_t iter;
+
+ ir_nodeset_init(&deps);
node = get_ilpsched_irn(env, irn);
na = get_ilpsched_node_attr(node);
ilp_timer_push(t_cst_prec);
bs_block_irns = bitset_clear_all(bs_block_irns);
- deps = sta_collect_in_deps(irn, deps);
- foreach_nodeset(deps, pred) {
+ sta_collect_in_deps(irn, &deps);
+ foreach_ir_nodeset(&deps, pred, iter) {
unsigned t_low, t_high, t;
be_ilpsched_irn_t *pred_node;
ilpsched_node_attr_t *pna;
DEL_ARR_F(tmp_var_idx);
}
}
- del_nodeset(deps);
+ ir_nodeset_destroy(&deps);
ilp_timer_pop();
}
DBG((env->dbg, LEVEL_1, "\t%u assignement constraints (%g sec)\n",
DBG((env->dbg, LEVEL_1, "Creating LPP with estimated numbers: %d vars, %d cst\n",
estimated_n_var, estimated_n_cst));
+ (void) estimated_n_var;
/* set up the LPP object */
snprintf(name, sizeof(name), "ilp scheduling IRG %s", get_entity_ld_name(get_irg_entity(env->irg)));
DBG((env->dbg, LEVEL_1, "ILP to solve: %u variables, %u constraints\n", lpp->var_next, lpp->cst_next));
/* debug stuff, dump lpp when debugging is on */
- DEBUG_ONLY(
+ DEBUG_ONLY({
if (firm_dbg_get_mask(env->dbg) > 1) {
char buf[1024];
FILE *f;
snprintf(buf, sizeof(buf), "lpp_block_%lu.mps", get_irn_node_nr(block));
lpp_dump(lpp, buf);
}
- );
+ })
/* set solve time limit */
lpp_set_time_limit(lpp, env->opts->time_limit);
/* check for valid solution */
if (! lpp_is_sol_valid(lpp)) {
- char buf[1024];
- FILE *f;
-
- DEBUG_ONLY(
- if (firm_dbg_get_mask(env->dbg) >= 2) {
- snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.txt", get_irn_node_nr(block));
- f = fopen(buf, "w");
- lpp_dump_plain(lpp, f);
- fclose(f);
- snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.mps", get_irn_node_nr(block));
- lpp_dump(lpp, buf);
- dump_ir_block_graph(env->irg, "-infeasible");
- }
- )
+ DEBUG_ONLY({
+ char buf[1024];
+ FILE *f;
+
+ if (firm_dbg_get_mask(env->dbg) >= 2) {
+ snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.txt", get_irn_node_nr(block));
+ f = fopen(buf, "w");
+ lpp_dump_plain(lpp, f);
+ fclose(f);
+ snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.mps", get_irn_node_nr(block));
+ lpp_dump(lpp, buf);
+ dump_ir_block_graph(env->irg, "-infeasible");
+ }
+ })
ir_fprintf(stderr, "ILP found no solution within time (%+F, %+F), falling back to heuristics.\n", block, env->irg);
need_heur = 1;
}
/* apply solution */
-#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 */
+ 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);
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);
}
else {
-#ifdef FIRM_STATISTICS
- if (be_stat_ev_is_active()) {
- 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);
- be_stat_ev_dbl("opt", opt);
- }
- else {
- be_stat_ev_dbl("time", 0.0);
- be_stat_ev_dbl("opt", 100.0);
- }
+ 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);
+ 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);
}
FIRM_DBG_REGISTER(env.dbg, "firm.be.sched.ilp");
-#ifdef FIRM_STATISTICS
- if (be_stat_ev_is_active()) {
- be_stat_tags[STAT_TAG_CLS] = "ilpsched";
- be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
- }
-#endif /* FIRM_STATISTICS */
+ stat_ev_ctx_push("ilpsched");
// firm_dbg_set_mask(env.dbg, 1);
/* notify backend */
be_ilp_sched_finish_irg_ilp_schedule(sel, birg->irg, env.irg_env);
-#ifdef FIRM_STATISTICS
- if (be_stat_ev_is_active()) {
- be_stat_ev_pop();
- }
-#endif /* FIRM_STATISTICS */
+ stat_ev_ctx_pop("ilpsched");
}
/**