X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbessadestr.c;h=d98f34ae6a447756ecc9b1ca3fce950bcf33ad75;hb=8ef2480ec4b8e4ab5af6819773b552e2c1371abc;hp=08f6841d4151f28cfba5e44fa6e3624f65e19b8f;hpb=ca21c59ea00ff05918de26952e91ac39f1589e01;p=libfirm diff --git a/ir/be/bessadestr.c b/ir/be/bessadestr.c index 08f6841d4..d98f34ae6 100644 --- a/ir/be/bessadestr.c +++ b/ir/be/bessadestr.c @@ -26,6 +26,8 @@ */ #include "config.h" +#include "bessadestr.h" + #include "debug.h" #include "set.h" #include "pmap.h" @@ -50,9 +52,6 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) -#define get_reg(irn) arch_get_irn_register(irn) -#define set_reg(irn, reg) arch_set_irn_register(irn, reg) - static void clear_link(ir_node *irn, void *data) { (void) data; @@ -110,7 +109,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) insert_all_perms_env_t *env = data; be_chordal_env_t *chordal_env = env->chordal_env; pmap *perm_map = env->perm_map; - be_lv_t *lv = chordal_env->birg->lv; + be_lv_t *lv = be_get_irg_liveness(chordal_env->irg); int i, n; assert(is_Block(bl)); @@ -135,13 +134,9 @@ static void insert_all_perms_walker(ir_node *bl, void *data) */ for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { ir_node *arg = get_irn_n(phi, i); - const arch_register_req_t *req = arch_get_register_req_out(arg); unsigned hash; perm_proj_t templ; - if (req->type & arch_register_req_type_ignore) - continue; - hash = hash_irn(arg); templ.arg = arg; pp = set_find(arg_set, &templ, sizeof(templ), hash); @@ -184,10 +179,10 @@ static void insert_all_perms_walker(ir_node *bl, void *data) for (pp = set_first(arg_set); pp; pp = set_next(arg_set)) { ir_node *proj = new_r_Proj(perm, get_irn_mode(pp->arg), pp->pos); pp->proj = proj; - assert(get_reg(pp->arg)); - set_reg(proj, get_reg(pp->arg)); + assert(arch_get_irn_register(pp->arg)); + arch_set_irn_register(proj, arch_get_irn_register(pp->arg)); insert_after = proj; - DBG((dbg, LEVEL_2, "Copy register assignment %s from %+F to %+F\n", get_reg(pp->arg)->name, pp->arg, pp->proj)); + DBG((dbg, LEVEL_2, "Copy register assignment %s from %+F to %+F\n", arch_get_irn_register(pp->arg)->name, pp->arg, pp->proj)); } /* @@ -230,16 +225,16 @@ static void insert_all_perms_walker(ir_node *bl, void *data) * Adjusts the register allocation for the (new) phi-operands * and insert duplicates iff necessary. */ -static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) +static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) { be_chordal_env_t *chordal_env = data; - be_lv_t *lv = chordal_env->birg->lv; + be_lv_t *lv = be_get_irg_liveness(chordal_env->irg); ir_node *phi; /* Consider all phis of this block */ for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { ir_node *phi_block = get_nodes_block(phi); - const arch_register_t *phi_reg = get_reg(phi); + const arch_register_t *phi_reg = arch_get_irn_register(phi); const arch_register_class_t *cls = phi_reg->reg_class; int max; int i; @@ -249,20 +244,25 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) /* process all arguments of the phi */ for (i = 0, max = get_irn_arity(phi); i < max; ++i) { ir_node *arg = get_irn_n(phi, i); - const arch_register_req_t *req = arch_get_register_req_out(arg); const arch_register_t *arg_reg; ir_node *arg_block; - if (req->type & arch_register_req_type_ignore) - continue; - arg_block = get_Block_cfgpred_block(phi_block, i); - arg_reg = get_reg(arg); + arg_reg = arch_get_irn_register(arg); assert(arg_reg && "Register must be set while placing perms"); DBG((dbg, LEVEL_1, " for %+F(%s) -- %+F(%s)\n", phi, phi_reg->name, arg, arg_reg->name)); + if (phi_reg == arg_reg + || (arg_reg->type & arch_register_type_joker) + || (arg_reg->type & arch_register_type_virtual)) { + /* Phi and arg have the same register, so pin and continue */ + pin_irn(arg, phi_block); + DBG((dbg, LEVEL_1, " arg has same reg: pin %+F(%s)\n", arg, arch_get_irn_register(arg)->name)); + continue; + } + if (be_values_interfere(lv, phi, arg)) { /* Insert a duplicate in arguments block, @@ -273,36 +273,16 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) */ ir_node *dupl = be_new_Copy(cls, arg_block, arg); - /* this is commented out because it will fail in case of unknown float */ -#if 0 - ir_mode *m_phi = get_irn_mode(phi), *m_dupl = get_irn_mode(dupl); - - /* - Conv signed <-> unsigned is killed on ia32 - check for: (both int OR both float) AND equal mode sizes - */ - assert(((mode_is_int(m_phi) && mode_is_int(m_dupl)) || - (mode_is_float(m_phi) && mode_is_float(m_dupl))) && - (get_mode_size_bits(m_phi) == get_mode_size_bits(m_dupl))); -#endif /* if 0 */ - set_irn_n(phi, i, dupl); - set_reg(dupl, phi_reg); + arch_set_irn_register(dupl, phi_reg); sched_add_after(sched_skip(sched_last(arg_block), 0, sched_skip_cf_predicator, NULL), dupl); pin_irn(dupl, phi_block); be_liveness_introduce(lv, dupl); be_liveness_update(lv, arg); - DBG((dbg, LEVEL_1, " they do interfere: insert %+F(%s)\n", dupl, get_reg(dupl)->name)); + DBG((dbg, LEVEL_1, " they do interfere: insert %+F(%s)\n", dupl, arch_get_irn_register(dupl)->name)); continue; /* with next argument */ } - if (phi_reg == arg_reg) { - /* Phi and arg have the same register, so pin and continue */ - pin_irn(arg, phi_block); - DBG((dbg, LEVEL_1, " arg has same reg: pin %+F(%s)\n", arg, get_reg(arg)->name)); - continue; - } - DBG((dbg, LEVEL_1, " they do not interfere\n")); assert(is_Proj(arg)); /* @@ -324,8 +304,8 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) get_nodes_block(phi) == get_nodes_block(other_phi) && "link fields are screwed up"); - if (get_irn_n(other_phi, i) == arg && get_reg(other_phi) == arg_reg) { - DBG((dbg, LEVEL_1, " found %+F(%s)\n", other_phi, get_reg(other_phi)->name)); + if (get_irn_n(other_phi, i) == arg && arch_get_irn_register(other_phi) == arg_reg) { + DBG((dbg, LEVEL_1, " found %+F(%s)\n", other_phi, arch_get_irn_register(other_phi)->name)); pin_irn(arg, phi_block); break; } @@ -344,37 +324,24 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) ir_node *dupl = be_new_Copy(cls, arg_block, arg); ir_node *ins; - /* this is commented out because it will fail in case of unknown float */ -#if 0 - ir_mode *m_phi = get_irn_mode(phi); - ir_mode *m_dupl = get_irn_mode(dupl); - - /* - Conv signed <-> unsigned is killed on ia32 - check for: (both int OR both float) AND equal mode sizes - */ - assert(((mode_is_int(m_phi) && mode_is_int(m_dupl)) || - (mode_is_float(m_phi) && mode_is_float(m_dupl))) && - (get_mode_size_bits(m_phi) == get_mode_size_bits(m_dupl))); -#endif /* if 0 */ - set_irn_n(phi, i, dupl); - set_reg(dupl, phi_reg); + arch_set_irn_register(dupl, phi_reg); /* skip the Perm's Projs and insert the copies behind. */ - for (ins = sched_next(perm); is_Proj(ins); ins = sched_next(ins)); + for (ins = sched_next(perm); is_Proj(ins); ins = sched_next(ins)) { + } sched_add_before(ins, dupl); pin_irn(dupl, phi_block); be_liveness_introduce(lv, dupl); be_liveness_update(lv, arg); - DBG((dbg, LEVEL_1, " arg is pinned: insert %+F(%s)\n", dupl, get_reg(dupl)->name)); + DBG((dbg, LEVEL_1, " arg is pinned: insert %+F(%s)\n", dupl, arch_get_irn_register(dupl)->name)); } else { /* No other phi has the same color (else arg would have been pinned), so just set the register and pin */ - set_reg(arg, phi_reg); + arch_set_irn_register(arg, phi_reg); pin_irn(arg, phi_block); - DBG((dbg, LEVEL_1, " arg is not pinned: so pin %+F(%s)\n", arg, get_reg(arg)->name)); + DBG((dbg, LEVEL_1, " arg is not pinned: so pin %+F(%s)\n", arg, arch_get_irn_register(arg)->name)); } } } @@ -383,9 +350,9 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) void be_ssa_destruction(be_chordal_env_t *chordal_env) { insert_all_perms_env_t insert_perms_env; - pmap *perm_map = pmap_create(); - ir_graph *irg = chordal_env->irg; - be_lv_t *lv = be_assure_liveness(chordal_env->birg); + pmap *perm_map = pmap_create(); + ir_graph *irg = chordal_env->irg; + be_lv_t *lv = be_assure_liveness(irg); FIRM_DBG_REGISTER(dbg, "ir.be.ssadestr"); @@ -404,7 +371,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) be_liveness_invalidate(lv); if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR) - be_dump(irg, "-ssa_destr_perms_placed", dump_ir_block_graph_sched); + dump_ir_graph(irg, "ssa_destr_perms_placed"); be_liveness_assure_chk(lv); @@ -415,7 +382,7 @@ void be_ssa_destruction(be_chordal_env_t *chordal_env) be_liveness_invalidate(lv); if (chordal_env->opts->dump_flags & BE_CH_DUMP_SSADESTR) - be_dump(irg, "-ssa_destr_regs_set", dump_ir_block_graph_sched); + dump_ir_graph(irg, "ssa_destr_regs_set"); pmap_destroy(perm_map); } @@ -429,7 +396,7 @@ static void ssa_destruction_check_walker(ir_node *bl, void *data) for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { const arch_register_t *phi_reg, *arg_reg; - phi_reg = get_reg(phi); + phi_reg = arch_get_irn_register(phi); /* iterate over all args of phi */ for (i = 0, max = get_irn_arity(phi); i < max; ++i) { ir_node *arg = get_irn_n(phi, i); @@ -438,7 +405,7 @@ static void ssa_destruction_check_walker(ir_node *bl, void *data) if (req->type & arch_register_req_type_ignore) continue; - arg_reg = get_reg(arg); + arg_reg = arch_get_irn_register(arg); if (phi_reg != arg_reg) { DBG((dbg, 0, "Error: Registers of %+F and %+F differ: %s %s\n", phi, arg, phi_reg->name, arg_reg->name));