X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbessadestr.c;h=a1f2f7bdf407377991f293ba0f728fe5aa4350fd;hb=4764ebb82834c3370640980c9299f0dbb1ac598d;hp=554e91136dc33bd3be8827c5286e9f008ec84382;hpb=101b434d36cc11cbd8ab2ddb8554a41d57114d30;p=libfirm diff --git a/ir/be/bessadestr.c b/ir/be/bessadestr.c index 554e91136..a1f2f7bdf 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" @@ -42,7 +44,7 @@ #include "bechordal_t.h" #include "bearch.h" #include "belive_t.h" -#include "benode_t.h" +#include "benode.h" #include "besched.h" #include "bestatevent.h" #include "beirg.h" @@ -53,7 +55,8 @@ 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) { +static void clear_link(ir_node *irn, void *data) +{ (void) data; set_irn_link(irn, NULL); } @@ -64,7 +67,8 @@ static void clear_link(ir_node *irn, void *data) { * - have the current register class * The list is rooted at get_irn_link(BB). */ -static void collect_phis_walker(ir_node *irn, void *data) { +static void collect_phis_walker(ir_node *irn, void *data) +{ be_chordal_env_t *env = data; if (is_Phi(irn) && chordal_has_class(env, irn)) { ir_node *bl = get_nodes_block(irn); @@ -86,7 +90,8 @@ typedef struct { ir_node *proj; /**< The proj created for @p arg. */ } perm_proj_t; -static int cmp_perm_proj(const void *a, const void *b, size_t n) { +static int cmp_perm_proj(const void *a, const void *b, size_t n) +{ const perm_proj_t *p = a; const perm_proj_t *q = b; (void) n; @@ -102,21 +107,22 @@ typedef struct insert_all_perms_env_t { /** * Insert Perms in all predecessors of a block containing a phi */ -static void insert_all_perms_walker(ir_node *bl, void *data) { +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)); /* If the link flag is NULL, this block has no phis. */ - if(!get_irn_link(bl)) + if (!get_irn_link(bl)) return; /* Look at all predecessors of the phi block */ - for(i = 0, n = get_irn_arity(bl); i < n; ++i) { + for (i = 0, n = get_irn_arity(bl); i < n; ++i) { ir_node *phi, *perm, *insert_after, **in; perm_proj_t *pp; set *arg_set = new_set(cmp_perm_proj, chordal_env->cls->n_regs); @@ -129,7 +135,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) { * Note that all phis in the list are in the same * register class by construction. */ - for(phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { + 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; @@ -149,7 +155,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) { * interferes with the phi and must thus not be member of a * Perm. A copy will be inserted for this argument later on. */ - if(!pp && !be_is_live_in(lv, bl, arg)) { + if (!pp && !be_is_live_in(lv, bl, arg)) { templ.pos = n_projs++; set_insert(arg_set, &templ, sizeof(templ), hash); } @@ -162,7 +168,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) { * above in the arg_set and insert it into the schedule. */ in = XMALLOCN(ir_node*, n_projs); - for(pp = set_first(arg_set); pp; pp = set_next(arg_set)) + for (pp = set_first(arg_set); pp; pp = set_next(arg_set)) in[pp->pos] = pp->arg; perm = be_new_Perm(chordal_env->cls, pred_bl, n_projs, in); @@ -177,8 +183,8 @@ static void insert_all_perms_walker(ir_node *bl, void *data) { * arguments to the projs (new phi arguments). */ insert_after = perm; - for(pp = set_first(arg_set); pp; pp = set_next(arg_set)) { - ir_node *proj = new_r_Proj(pred_bl, perm, get_irn_mode(pp->arg), pp->pos); + 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)); @@ -189,7 +195,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) { /* * Set the phi nodes to their new arguments: The Projs of the Perm */ - for(phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { + for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) { perm_proj_t templ; templ.arg = get_irn_n(phi, i); @@ -226,9 +232,10 @@ 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 */ @@ -313,7 +320,7 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) { DBG((dbg, LEVEL_1, " searching for phi with same arg having args register\n")); - for(other_phi = get_irn_link(phi_block); other_phi; other_phi = get_irn_link(other_phi)) { + for (other_phi = get_irn_link(phi_block); other_phi; other_phi = get_irn_link(other_phi)) { assert(is_Phi(other_phi) && get_nodes_block(phi) == get_nodes_block(other_phi) && @@ -356,7 +363,8 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) { set_irn_n(phi, i, dupl); set_reg(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); @@ -375,11 +383,12 @@ static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) { } } -void be_ssa_destruction(be_chordal_env_t *chordal_env) { +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"); @@ -398,7 +407,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); @@ -409,12 +418,13 @@ 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); } -static void ssa_destruction_check_walker(ir_node *bl, void *data) { +static void ssa_destruction_check_walker(ir_node *bl, void *data) +{ ir_node *phi; int i, max; (void)data; @@ -446,6 +456,7 @@ static void ssa_destruction_check_walker(ir_node *bl, void *data) { } } -void be_ssa_destruction_check(be_chordal_env_t *chordal_env) { +void be_ssa_destruction_check(be_chordal_env_t *chordal_env) +{ irg_block_walk_graph(chordal_env->irg, ssa_destruction_check_walker, NULL, NULL); }