X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fberaextern.c;h=d35c2f346e095b632f354c00feb1836694a6ce09;hb=72ae1ac93c6cc7988db8cfa919ae147e10f98e82;hp=903b629017850a1e76ef287b3f68b1b4c6a29e70;hpb=ea64ddabccc512b21b425e4d89fda5e4ffe124a6;p=libfirm diff --git a/ir/be/beraextern.c b/ir/be/beraextern.c index 903b62901..d35c2f346 100644 --- a/ir/be/beraextern.c +++ b/ir/be/beraextern.c @@ -94,6 +94,7 @@ alloc ::= node-nr reg-nr . #include "besched_t.h" #include "beutil.h" #include "belive_t.h" +#include "beinsn_t.h" #define DBG_LEVEL 2 @@ -193,46 +194,65 @@ static int get_loop_weight(ir_node *irn) { |_| *****************************************************************************/ -static void handle_constraints_walker(ir_node *irn, void *env) { - be_raext_env_t *raenv = env; - arch_register_req_t req; - int pos, max; +static void handle_constraints_insn(be_raext_env_t *env, be_insn_t *insn) +{ + ir_node *bl = get_nodes_block(insn->irn); + int i; - /* handle output constraints - * user -> irn becomes user -> cpy -> irn - */ - arch_get_register_req(raenv->aenv, &req, irn, -1); - if (arch_register_req_is(&req, limited)) { - ir_node *cpy = be_new_Copy(req.cls, raenv->irg, get_nodes_block(irn), irn); + for(i = 0; i < insn->use_start; ++i) { + be_operand_t *op = &insn->ops[i]; - /* all users of the irn use the copy instead */ - sched_add_after(irn, cpy); - edges_reroute(irn, cpy, raenv->irg); + if(op->has_constraints) { + ir_node *cpy = be_new_Copy(op->req.cls, env->irg, bl, op->carrier); + sched_add_before(insn->next_insn, cpy); + edges_reroute(op->carrier, cpy, env->irg); + } } + for(i = insn->use_start; i < insn->n_ops; ++i) { + be_operand_t *op = &insn->ops[i]; - /* handle input constraints by converting them into output constraints - * of copies of the former argument - * irn -> arg becomes irn -> copy -> arg - */ - for (pos = 0, max = get_irn_arity(irn); posaenv, &req, irn, pos); - if (arch_register_req_is(&req, limited)) { - ir_node *arg = get_irn_n(irn, pos); - ir_node *cpy = be_new_Copy(req.cls, raenv->irg, get_nodes_block(irn), arg); + if(op->has_constraints) { + ir_node *cpy = be_new_Copy(op->req.cls, env->irg, bl, op->carrier); + sched_add_before(insn->irn, cpy); + set_irn_n(insn->irn, op->pos, cpy); + be_set_constr_limited(cpy, BE_OUT_POS(0), &op->req); + } + } +} - /* use the copy instead */ - sched_add_before(irn, cpy); - set_irn_n(irn, pos, cpy); +static void handle_constraints_block(ir_node *bl, void *data) +{ + be_raext_env_t *raenv = data; + int active = bl != get_irg_start_block(raenv->irg); - /* set an out constraint for the copy */ - be_set_constr_limited(cpy, -1, &req); - } + ir_node *irn; + be_insn_env_t ie; + struct obstack obst; + + ie.cls = raenv->cls; + ie.aenv = raenv->aenv; + ie.obst = &obst; + ie.ignore_colors = NULL; + obstack_init(&obst); + + irn = sched_first(bl); + while(!sched_is_end(irn)) { + be_insn_t *insn = be_scan_insn(&ie, irn); + + if(insn->has_constraints) + handle_constraints_insn(raenv, insn); + + if(be_is_Barrier(irn)) + active = !active; + + irn = insn->next_insn; + obstack_free(&obst, insn); } } static void handle_constraints(be_raext_env_t *raenv) { - irg_walk_graph(raenv->irg, NULL, handle_constraints_walker, raenv); + irg_block_walk_graph(raenv->irg, NULL, handle_constraints_block, raenv); } @@ -627,7 +647,7 @@ static void dump_affinities_walker(ir_node *irn, void *env) { /* copies have affinities */ if (arch_irn_classify(raenv->aenv, irn) == arch_irn_class_copy) { - ir_node *other = get_irn_n(irn, be_pos_Copy_orig); + ir_node *other = be_get_Copy_op(irn); if (! arch_irn_is(raenv->aenv, other, ignore)) { vi2 = get_var_info(other); @@ -942,7 +962,11 @@ static void be_ra_extern_main(const be_irg_t *bi) { FIRM_DBG_REGISTER(raenv.dbg, "firm.be.raextern"); /* Insert copies for constraints */ - handle_constraints(&raenv); + for(clsnr = 0, clss = arch_isa_get_n_reg_class(raenv.aenv->isa); clsnr < clss; ++clsnr) { + raenv.cls = arch_isa_get_reg_class(raenv.aenv->isa, clsnr); + handle_constraints(&raenv); + } + be_dump(irg, "-extern-constr", dump_ir_block_graph_sched); /* SSA destruction respectively transformation into "Conventional SSA" */