#include "config.h"
#endif /* HAVE_CONFIG_H */
+#include "firm_config.h"
+
#ifdef WITH_ILP
#include "bitset.h"
#include "becopyilp_t.h"
#include "beifg_t.h"
#include "besched_t.h"
-#include "benodesets.h"
#define DEBUG_LVL 1
typedef struct _local_env_t {
double time_limit;
int first_x_var, last_x_var;
+ int n_colors;
+ bitset_t *normal_colors;
pmap *nr_2_irn;
DEBUG_ONLY(firm_dbg_module_t *dbg;)
} local_env_t;
static void build_coloring_cstr(ilp_env_t *ienv) {
- be_ifg_t *ifg = ienv->co->cenv->ifg;
- void *iter = be_ifg_nodes_iter_alloca(ifg);
+ be_ifg_t *ifg = ienv->co->cenv->ifg;
+ void *iter = be_ifg_nodes_iter_alloca(ifg);
bitset_t *colors;
ir_node *irn;
char buf[16];
be_ifg_foreach_node(ifg, iter, irn)
if (!sr_is_removed(ienv->sr, irn)) {
- int col, cst_idx;
+ bitset_pos_t col;
+ int cst_idx;
const arch_register_req_t *req;
int curr_node_color = get_irn_col(ienv->co, irn);
int node_nr = (int)get_irn_node_nr(irn);
req = arch_get_register_req(ienv->co->aenv, irn, -1);
+ bitset_clear_all(colors);
+
/* get assignable colors */
if (arch_register_req_is(req, limited)) {
rbitset_copy_to_bitset(req->limited, colors);
} else {
- arch_register_class_put(req->cls, colors);
- // bitset_andnot(colors, ienv->co->cenv->ignore_colors);
+ bitset_copy(colors, lenv->normal_colors);
}
/* add the coloring constraint */
bitset_foreach(colors, col) {
int var_idx = lpp_add_var(ienv->lp, name_cdd(buf, 'x', node_nr, col), lpp_binary, 0.0);
- lpp_set_start_value(ienv->lp, var_idx, (col == curr_node_color) ? 1.0 : 0.0);
+ lpp_set_start_value(ienv->lp, var_idx, (col == (unsigned) curr_node_color) ? 1.0 : 0.0);
lpp_set_factor_fast(ienv->lp, cst_idx, var_idx, 1);
lenv->last_x_var = var_idx;
}
static void build_interference_cstr(ilp_env_t *ienv) {
- lpp_t *lpp = ienv->lp;
- be_ifg_t *ifg = ienv->co->cenv->ifg;
- int n_colors = arch_register_class_n_regs(ienv->co->cls);
+ lpp_t *lpp = ienv->lp;
+ local_env_t *lenv = ienv->env;
+ be_ifg_t *ifg = ienv->co->cenv->ifg;
+ int n_colors = lenv->n_colors;
int i, col;
void *iter = be_ifg_cliques_iter_alloca(ifg);
* does not provide this walker, yet.
*/
static void build_affinity_cstr(ilp_env_t *ienv) {
+ local_env_t *lenv = ienv->env;
+ int n_colors = lenv->n_colors;
unit_t *curr;
- int n_colors = arch_register_class_n_regs(ienv->co->cls);
/* for all optimization units */
list_for_each_entry(unit_t, curr, &ienv->co->units, units) {
static int compare_edge_t(const void *k1, const void *k2, size_t size) {
const edge_t *e1 = k1;
const edge_t *e2 = k2;
+ (void) size;
return ! (e1->n1 == e2->n1 && e1->n2 == e2->n2);
}
-#define HASH_EDGE(e) (nodeset_hash((e)->n1) ^ nodeset_hash((e)->n2))
+#define HASH_EDGE(e) (hash_irn((e)->n1) ^ hash_irn((e)->n2))
static INLINE edge_t *add_edge(set *edges, ir_node *n1, ir_node *n2, int *counter) {
edge_t new_edge;
my.nr_2_irn = pmap_create();
FIRM_DBG_REGISTER(my.dbg, "firm.be.coilp2");
+ my.normal_colors = bitset_alloca(arch_register_class_n_regs(co->cls));
+ bitset_clear_all(my.normal_colors);
+ arch_put_non_ignore_regs(co->aenv, co->cls, my.normal_colors);
+ my.n_colors = bitset_popcnt(my.normal_colors);
+
ienv = new_ilp_env(co, ilp2_build, ilp2_apply, &my);
sol_state = ilp_go(ienv);