X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbecopyopt.c;h=019106a3ab08a8f259678fbaa58886a2f8c051e2;hb=ed73d993f7df08a4e968e86e97224283ea781c64;hp=1b1c52b0274998812e91cbb5c58e826ba55c3fdd;hpb=4794cb5f95f18ed6afee5c1cc33aaf5f39d3e4a2;p=libfirm diff --git a/ir/be/becopyopt.c b/ir/be/becopyopt.c index 1b1c52b02..019106a3a 100644 --- a/ir/be/becopyopt.c +++ b/ir/be/becopyopt.c @@ -31,7 +31,19 @@ #include "becopystat.h" -#define QUICK_AND_DIRTY_HACK +#ifdef WITH_LIBCORE + +/* Insert additional options registration functions here. */ +extern void be_co2_register_options(lc_opt_entry_t *grp); + +void co_register_options(lc_opt_entry_t *grp) +{ + be_co2_register_options(grp); +} +#endif + + +#undef QUICK_AND_DIRTY_HACK /****************************************************************************** _____ _ @@ -43,7 +55,7 @@ ******************************************************************************/ -static firm_dbg_module_t *dbg = NULL; +DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) void be_copy_opt_init(void) { } @@ -53,7 +65,7 @@ copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, int (*get_costs)(ir_node int len; copy_opt_t *co; - dbg = firm_dbg_register("ir.be.copyopt"); + FIRM_DBG_REGISTER(dbg, "ir.be.copyopt"); co = xcalloc(1, sizeof(*co)); co->cenv = chordal_env; @@ -390,10 +402,12 @@ static int compare_ous(const void *k1, const void *k2) { return u2_has_constr - u1_has_constr; /* Now check, whether the two units are connected */ +#if 0 for (i=0; inode_count; ++i) for (o=0; onode_count; ++o) if (u1->nodes[i] == u2->nodes[o]) return 0; +#endif /* After all, the sort key decides. Greater keys come first. */ return u2->sort_key - u1->sort_key; @@ -404,27 +418,38 @@ static int compare_ous(const void *k1, const void *k2) { * Sort the ou's according to constraints and their sort_key */ static void co_sort_units(copy_opt_t *co) { - int i, count = 0; - unit_t *tmp, *ou, **ous; + int i, count = 0, costs; + unit_t *ou, **ous; /* get the number of ous, remove them form the list and fill the array */ list_for_each_entry(unit_t, ou, &co->units, units) count++; ous = alloca(count * sizeof(*ous)); + costs = co_get_max_copy_costs(co); + i = 0; - list_for_each_entry_safe(unit_t, ou, tmp, &co->units, units) { + list_for_each_entry(unit_t, ou, &co->units, units) ous[i++] = ou; - list_del(&ou->units); - } - assert(count == i); + INIT_LIST_HEAD(&co->units); + + assert(count == i && list_empty(&co->units)); + + for (i=0; inodes[0]); qsort(ous, count, sizeof(*ous), compare_ous); + ir_printf("\n\n"); + for (i=0; inodes[0]); + /* reinsert into list in correct order */ for (i=0; iunits, &co->units); + + assert(costs == co_get_max_copy_costs(co)); } #endif @@ -624,3 +649,50 @@ int co_gs_is_optimizable(copy_opt_t *co, ir_node *irn) { } else return 0; } + +void co_dump_appel_graph(const copy_opt_t *co, FILE *f) +{ + be_ifg_t *ifg = co->cenv->ifg; + + ir_node *irn; + void *it, *nit; + int n; + + it = be_ifg_nodes_iter_alloca(ifg); + nit = be_ifg_neighbours_iter_alloca(ifg); + + n = 0; + be_ifg_foreach_node(ifg, it, irn) { + set_irn_link(irn, INT_TO_PTR(n++)); + } + + fprintf(f, "%d %d\n", n, co->cls->n_regs); + + be_ifg_foreach_node(ifg, it, irn) { + int idx = PTR_TO_INT(get_irn_link(irn)); + affinity_node_t *a = get_affinity_info(co, irn); + + ir_node *adj; + + be_ifg_foreach_neighbour(ifg, nit, irn, adj) { + int adj_idx = PTR_TO_INT(get_irn_link(adj)); + if(idx < adj_idx) + fprintf(f, "%d %d -1\n", idx, adj_idx); + } + + if(a) { + neighb_t *n; + + co_gs_foreach_neighb(a, n) { + int n_idx = PTR_TO_INT(get_irn_link(n->irn)); + if(idx < n_idx) + fprintf(f, "%d %d %d\n", idx, n_idx, n->costs); + } + } + } +} + +void co_solve_park_moon(copy_opt_t *opt) +{ + +}