/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
#include "config.h"
#endif
+#include "firm_config.h"
+
#ifdef WITH_ILP
#include <math.h>
#include "irprintf.h"
#include "plist.h"
#include "irprintf.h"
+#include "timing.h"
#include <lpp/lpp.h>
#include <lpp/lpp_net.h>
-#include <libcore/lc_opts.h>
-#include <libcore/lc_opts_enum.h>
-#include <libcore/lc_timing.h>
+#include "lc_opts.h"
+#include "lc_opts_enum.h"
#include "be.h"
#include "benode_t.h"
#include "beutil.h"
#include "bestat.h"
#include "beirg_t.h"
-#include "benodesets.h"
typedef struct _ilpsched_options_t {
unsigned regpress;
/* A irn for the phase and it's attributes (either node or block) */
typedef struct {
- ir_node *irn;
+ const ir_node *irn;
ilpsched_attr_t attr;
} be_ilpsched_irn_t;
/* check if a double value is within an epsilon environment of 0 */
#define LPP_VALUE_IS_0(dbl) (fabs((dbl)) <= 1e-10)
-#define ilp_timer_push(t) lc_timer_push((t))
-#define ilp_timer_pop() lc_timer_pop()
-#define ilp_timer_elapsed_usec(t) lc_timer_elapsed_usec((t))
+#define ilp_timer_push(t) ir_timer_push((t))
+#define ilp_timer_pop() ir_timer_pop()
+#define ilp_timer_elapsed_usec(t) ir_timer_elapsed_usec((t))
/* option variable */
static ilpsched_options_t ilp_opts = {
ilpsched_node_attr_t *n2_a = get_ilpsched_node_attr(n2);
if (n1_a->sched_point == n2_a->sched_point) {
- ir_node *irn_a = n1->irn;
- ir_node *irn_b = n2->irn;
+ const ir_node *irn_a = n1->irn;
+ const ir_node *irn_b = n2->irn;
if (heights_reachable_in_block(glob_heights, irn_a, irn_b))
return 1;
/**
* In case there is no phase information for irn, initialize it.
*/
-static void *init_ilpsched_irn(ir_phase *ph, ir_node *irn, void *old) {
+static void *init_ilpsched_irn(ir_phase *ph, const ir_node *irn, void *old) {
be_ilpsched_irn_t *res = old ? old : phase_alloc(ph, sizeof(res[0]));
if (res == old) {
*
*******************************************/
-static INLINE void check_for_keeps(waitq *keeps, ir_node *block, ir_node *irn) {
+static INLINE void check_for_keeps(waitq *keeps, const ir_node *block, const ir_node *irn) {
const ir_edge_t *edge;
+ (void) block;
foreach_out_edge(irn, edge) {
ir_node *user = get_edge_src_irn(edge);
* Inserts @p irn before @p before into schedule and notifies backend.
*/
static INLINE void notified_sched_add_before(be_ilpsched_env_t *env,
- ir_node *before, ir_node *irn, unsigned cycle)
+ const ir_node *before, const ir_node *irn, unsigned cycle)
{
be_ilp_sched_node_scheduled(env->sel, irn, cycle, env->block_env);
sched_add_before(before, irn);
* Adds a node, it's Projs (in case of mode_T nodes) and
* it's Keeps to schedule.
*/
-static void add_to_sched(be_ilpsched_env_t *env, ir_node *block, ir_node *irn, unsigned cycle) {
+static void add_to_sched(be_ilpsched_env_t *env, const ir_node *block, const ir_node *irn, unsigned cycle) {
const ir_edge_t *edge;
waitq *keeps = new_waitq();
* Returns the largest alap time of a user of @p irn.
* The user must be in block @p block.
*/
-static unsigned be_ilpsched_get_max_alap_user(be_ilpsched_env_t *env, ir_node *irn, ir_node *block) {
+static unsigned be_ilpsched_get_max_alap_user(be_ilpsched_env_t *env, const ir_node *irn, const ir_node *block) {
const ir_edge_t *edge;
unsigned max_alap = 0;
ilp_livein_node_t *livein;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
unsigned weigth_y = ba->n_interesting_nodes * ba->n_interesting_nodes;
- lc_timer_t *t_var = lc_timer_register("beilpsched_var", "create ilp variables");
+ ir_timer_t *t_var = ir_timer_register("beilpsched_var", "create ilp variables");
ilp_timer_push(t_var);
num_block_var = num_nodes = 0;
* 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;
}
/**
ir_node *irn;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
bitset_t *bs_block_irns = bitset_alloca(ba->block_last_idx);
- lc_timer_t *t_cst_assign = lc_timer_register("beilpsched_cst_assign", "create assignment constraints");
- lc_timer_t *t_cst_prec = lc_timer_register("beilpsched_cst_prec", "create precedence constraints");
+ ir_timer_t *t_cst_assign = ir_timer_register("beilpsched_cst_assign", "create assignment constraints");
+ ir_timer_t *t_cst_prec = ir_timer_register("beilpsched_cst_prec", "create precedence constraints");
num_cst_assign = num_cst_prec = num_cst_dead = 0;
foreach_linked_irns(ba->head_ilp_nodes, irn) {
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",
char buf[1024];
unsigned num_cst_resrc = 0;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst_rsrc = lc_timer_register("beilpsched_cst_rsrc", "create resource constraints");
+ ir_timer_t *t_cst_rsrc = ir_timer_register("beilpsched_cst_rsrc", "create resource constraints");
ilp_timer_push(t_cst_rsrc);
for (glob_type_idx = env->cpu->n_unit_types - 1; glob_type_idx >= 0; --glob_type_idx) {
unsigned num_cst_bundle = 0;
unsigned n_instr_max = env->cpu->bundle_size * env->cpu->bundels_per_cycle;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst_bundle = lc_timer_register("beilpsched_cst_bundle", "create bundle constraints");
+ ir_timer_t *t_cst_bundle = ir_timer_register("beilpsched_cst_bundle", "create bundle constraints");
ilp_timer_push(t_cst_bundle);
for (t = 0; t < ba->max_steps; ++t) {
ir_node *irn;
unsigned num_cst = 0;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst = lc_timer_register("beilpsched_cst_alive_nodes", "create alive nodes constraints");
+ ir_timer_t *t_cst = ir_timer_register("beilpsched_cst_alive_nodes", "create alive nodes constraints");
ilp_timer_push(t_cst);
/* for each node */
ilp_livein_node_t *livein;
unsigned num_cst = 0;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst = lc_timer_register("beilpsched_cst_alive_livein_nodes", "create alive livein nodes constraints");
+ ir_timer_t *t_cst = ir_timer_register("beilpsched_cst_alive_livein_nodes", "create alive livein nodes constraints");
ilp_timer_push(t_cst);
/* for each node */
ir_node *cur_irn;
unsigned num_cst = 0;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst = lc_timer_register("beilpsched_cst_pressure", "create pressure constraints");
+ ir_timer_t *t_cst = ir_timer_register("beilpsched_cst_pressure", "create pressure constraints");
ilp_timer_push(t_cst);
/* y_{nt}^k is set for each node and timestep and unit type */
unsigned num_cst = 0;
unsigned num_non_branches = 0;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst = lc_timer_register("beilpsched_cst_branch", "create branch constraints");
+ ir_timer_t *t_cst = ir_timer_register("beilpsched_cst_branch", "create branch constraints");
ilp_timer_push(t_cst);
cfop = NULL;
ir_node *irn;
unsigned num_cst = 0;
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
- lc_timer_t *t_cst = lc_timer_register("beilpsched_cst_projkeep", "create proj and keep constraints");
+ ir_timer_t *t_cst = ir_timer_register("beilpsched_cst_projkeep", "create proj and keep constraints");
ilp_timer_push(t_cst);
/* check all nodes */
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)));
/* 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");
- }
+ 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);
FIRM_DBG_REGISTER(env.dbg, "firm.be.sched.ilp");
- stat_ev_ctx_push("phase", "ilpsched");
+ 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);
- stat_ev_ctx_pop();
+ stat_ev_ctx_pop("ilpsched");
}
/**