Commit 6ee1fce9 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

becopyopt: Use the set of admissible registers from bechordal.

Each copyopt algorithm recalculated the set of admissible colours, which bechordal already did.
parent 8940e281
......@@ -94,13 +94,13 @@ typedef struct {
} col_cost_pair_t;
typedef struct {
ir_nodemap map;
struct obstack obst;
copy_opt_t *co;
bitset_t *allocatable_regs;
co2_irn_t *touched;
int visited;
int n_regs;
ir_nodemap map;
struct obstack obst;
copy_opt_t *co;
unsigned const *allocatable_regs;
co2_irn_t *touched;
int visited;
int n_regs;
struct list_head cloud_head;
DEBUG_ONLY(firm_dbg_module_t *dbg;)
} co2_t;
......@@ -173,7 +173,7 @@ static co2_irn_t *get_co2_irn(co2_t *env, const ir_node *node)
ci->aff = NULL;
arch_register_req_t const *const req = arch_get_irn_register_req(node);
ci->admissible = arch_register_req_is(req, limited) ? req->limited : env->allocatable_regs->data;
ci->admissible = arch_register_req_is(req, limited) ? req->limited : env->allocatable_regs;
ir_nodemap_insert(&env->map, node, ci);
}
......@@ -1000,12 +1000,11 @@ static int co_solve_heuristic_new(copy_opt_t *co)
ir_nodemap_init(&env.map, co->irg);
obstack_init(&env.obst);
env.touched = NULL;
env.visited = 0;
env.co = co;
env.n_regs = co->cls->n_regs;
env.allocatable_regs = bitset_alloca(co->cls->n_regs);
be_put_allocatable_regs(co->irg, co->cls, env.allocatable_regs);
env.touched = NULL;
env.visited = 0;
env.co = co;
env.n_regs = co->cls->n_regs;
env.allocatable_regs = co->cenv->allocatable_regs->data;
FIRM_DBG_REGISTER(env.dbg, "firm.be.co2");
INIT_LIST_HEAD(&env.cloud_head);
......
......@@ -95,7 +95,7 @@ typedef struct aff_edge_t {
/* main coalescing environment */
typedef struct co_mst_env_t {
int n_regs; /**< number of regs in class */
bitset_t *allocatable_regs; /**< set containing all global ignore registers */
bitset_t const *allocatable_regs; /**< set containing all global ignore registers */
ir_nodemap map; /**< phase object holding data for nodes */
struct obstack obst;
pqueue_t *chunks; /**< priority queue for chunks */
......@@ -1403,37 +1403,31 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c)
*/
static int co_solve_heuristic_mst(copy_opt_t *co)
{
unsigned n_regs = co->cls->n_regs;
bitset_t *allocatable_regs = bitset_alloca(n_regs);
unsigned i, j;
size_t pn;
ir_node *irn;
co_mst_env_t mst_env;
last_chunk_id = 0;
stat_ev_tim_push();
/* init phase */
co_mst_env_t mst_env;
ir_nodemap_init(&mst_env.map, co->irg);
obstack_init(&mst_env.obst);
be_put_allocatable_regs(co->irg, co->cls, allocatable_regs);
unsigned const n_regs = co->cls->n_regs;
mst_env.n_regs = n_regs;
mst_env.chunks = new_pqueue();
mst_env.co = co;
mst_env.allocatable_regs = allocatable_regs;
mst_env.allocatable_regs = co->cenv->allocatable_regs;
mst_env.ifg = co->cenv->ifg;
INIT_LIST_HEAD(&mst_env.chunklist);
mst_env.chunk_visited = 0;
mst_env.single_cols = OALLOCN(&mst_env.obst, col_cost_t*, n_regs);
for (i = 0; i < n_regs; ++i) {
for (unsigned i = 0; i < n_regs; ++i) {
col_cost_t *vec = OALLOCN(&mst_env.obst, col_cost_t, n_regs);
mst_env.single_cols[i] = vec;
for (j = 0; j < n_regs; ++j) {
for (unsigned j = 0; j < n_regs; ++j) {
vec[j].col = j;
vec[j].cost = REAL(0.0);
}
......@@ -1459,12 +1453,12 @@ static int co_solve_heuristic_mst(copy_opt_t *co)
}
/* apply coloring */
for (pn = 0; pn < ARR_LEN(mst_env.map.data); ++pn) {
for (size_t pn = 0; pn < ARR_LEN(mst_env.map.data); ++pn) {
co_mst_irn_t *mirn = (co_mst_irn_t*)mst_env.map.data[pn];
const arch_register_t *reg;
if (mirn == NULL)
continue;
irn = get_idx_irn(co->irg, pn);
ir_node *const irn = get_idx_irn(co->irg, pn);
if (arch_irn_is_ignore(irn))
continue;
......
......@@ -70,7 +70,7 @@ typedef struct be_pbqp_alloc_env_t {
ir_graph *irg; /**< The graph under examination. */
const arch_register_class_t *cls; /**< Current processed register class */
be_lv_t *lv;
bitset_t *allocatable_regs;
bitset_t const *allocatable_regs;
pbqp_matrix_t *ife_matrix_template;
pbqp_matrix_t *aff_matrix_template;
plist_t *rpeo;
......@@ -124,11 +124,11 @@ static FILE *my_open(const be_chordal_env_t *env, const char *prefix, const char
static void create_pbqp_node(be_pbqp_alloc_env_t *pbqp_alloc_env, ir_node *irn)
{
const arch_register_class_t *cls = pbqp_alloc_env->cls;
pbqp_t *pbqp_inst = pbqp_alloc_env->pbqp_inst;
bitset_t *allocatable_regs = pbqp_alloc_env->allocatable_regs;
unsigned colors_n = arch_register_class_n_regs(cls);
unsigned cntConstrains = 0;
arch_register_class_t const *const cls = pbqp_alloc_env->cls;
pbqp_t *const pbqp_inst = pbqp_alloc_env->pbqp_inst;
bitset_t const *const allocatable_regs = pbqp_alloc_env->allocatable_regs;
unsigned const colors_n = arch_register_class_n_regs(cls);
unsigned cntConstrains = 0;
/* create costs vector depending on register constrains */
vector_t *costs_vector = vector_alloc(pbqp_inst, colors_n);
......@@ -591,13 +591,11 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
pbqp_alloc_env.cls = cls;
pbqp_alloc_env.irg = irg;
pbqp_alloc_env.lv = lv;
pbqp_alloc_env.allocatable_regs = bitset_malloc(colors_n);
pbqp_alloc_env.allocatable_regs = env->allocatable_regs;
pbqp_alloc_env.rpeo = plist_new();
pbqp_alloc_env.restr_nodes = XMALLOCNZ(unsigned, get_irg_last_idx(irg));
pbqp_alloc_env.ife_edge_num = XMALLOCNZ(unsigned, get_irg_last_idx(irg));
pbqp_alloc_env.env = env;
be_put_allocatable_regs(irg, cls, pbqp_alloc_env.allocatable_regs);
/* create costs matrix template for interference edges */
ife_matrix = pbqp_matrix_alloc(pbqp_alloc_env.pbqp_inst, colors_n, colors_n);
......@@ -711,7 +709,6 @@ static void be_pbqp_coloring(be_chordal_env_t *env)
#if KAPS_DUMP
fclose(file_before);
#endif
bitset_free(pbqp_alloc_env.allocatable_regs);
free_pbqp(pbqp_alloc_env.pbqp_inst);
plist_free(pbqp_alloc_env.rpeo);
xfree(pbqp_alloc_env.restr_nodes);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment