X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeconstrperm.c;h=92311a2657e9b104520023c3dd818b663abdc24c;hb=ba873a5483697d4ff93e3980d7b6a1b5cbc491b5;hp=e7e16a706120635fe1658dc6685cae6a62e541e0;hpb=b4677f5bb0e1cf6934b883d5c841de3490930bbd;p=libfirm diff --git a/ir/be/beconstrperm.c b/ir/be/beconstrperm.c index e7e16a706..92311a265 100644 --- a/ir/be/beconstrperm.c +++ b/ir/be/beconstrperm.c @@ -14,29 +14,67 @@ #include "irgwalk.h" #include "bearch.h" +#include "belive_t.h" #include "benode_t.h" #include "besched_t.h" #include "beconstrperm.h" -static void walker_insert_constr_perms(ir_node *irn, void *env) { - be_chordal_env_t *cenv = env; - const be_main_env_t *menv = cenv->main_env; - const arch_env_t *aenv = menv->arch_env; +static void walker_insert_constr_perms(ir_node *bl, void *env) { + ir_node *irn; + int pos, max, cnt = 0; arch_register_req_t req; - int pos, max; - - /* check for a restriction of the result (-1) and the operands (0..n) */ - max = get_irn_arity(irn); - for(pos=-1; poscls, cenv->dom_front, sched_prev(irn)); - break; + ir_graph *irg = get_irn_irg(bl); + be_chordal_env_t *cenv = env; + const be_main_env_t *menv = cenv->main_env; + const arch_env_t *aenv = menv->arch_env; + + sched_foreach(bl, irn) { + ir_node *perm = NULL; + + /* check for a restriction of the result (-1) or one of the operands (0..n) */ + max = get_irn_arity(irn); + for(pos=-1; poscls == arch_get_irn_reg_class(aenv, irn, pos) && req.type == arch_register_req_type_limited) { + + /* + * If we inserted a perm, + * we have to recompute liveness analysis since inserting + * a Perm changes the liveness situation at the end + * of the block. + * (its needed by successive calls to insert_Perm_after) + * Perhaps thinking about an online liveness analysis + * would help. + */ + if(!perm) { + perm = insert_Perm_after(menv, cenv->cls, cenv->dom_front, sched_prev(irn)); + be_liveness(irg); + } + + /* + * Turn an input constraint into an output constraint: + * The Proj of the Perm which corresponds to the input + * constraint will have the input constraint of the node + * as an output constraint + */ + if(pos >= 0) { + ir_node *op = get_irn_n(irn, pos); + + /* + * The operand must be a proj now, since a perm cut + * all live ranges. + */ + assert(is_Proj(op)); + be_set_Perm_out_req(perm, get_Proj_proj(op), &req); + } + } } } } void be_insert_constr_perms(be_chordal_env_t *cenv) { - irg_walk_graph(cenv->irg, walker_insert_constr_perms, NULL, cenv); + irg_block_walk_graph(cenv->irg, walker_insert_constr_perms, NULL, cenv); }