X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeconstrperm.c;h=d6d982124124ebabeb83ef44f71badef3b4091f8;hb=bdf3df765e0e63a604e9ec8b91f997c8c98b2959;hp=bfb1fe94a09a96f08449debaa67f18e9a264b1aa;hpb=8b76d0442b62176e562d9dbffbb469d804273392;p=libfirm diff --git a/ir/be/beconstrperm.c b/ir/be/beconstrperm.c index bfb1fe94a..d6d982124 100644 --- a/ir/be/beconstrperm.c +++ b/ir/be/beconstrperm.c @@ -1,5 +1,5 @@ /** - * Author: Daniel Grund + * Author: Daniel Grund, Sebastian Hack * Date: 15.12.2005 * Copyright: (c) Universitaet Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. @@ -19,57 +19,72 @@ #include "besched_t.h" #include "beconstrperm.h" -static void walker_insert_constr_perms(ir_node *bl, void *env) { - ir_node *irn; - be_chordal_env_t *cenv = env; +static void check_constraints(const be_chordal_env_t *cenv, ir_node *base, ir_node *irn, ir_node **perm) +{ + const arch_env_t *aenv = cenv->main_env->arch_env; const be_main_env_t *menv = cenv->main_env; - const arch_env_t *aenv = menv->arch_env; arch_register_req_t req; - int pos, max; + int pos, n; - sched_foreach(bl, irn) { - ir_node *perm = NULL; + assert(is_Proj(irn) || (base == irn)); + + for(pos = -1, n = get_irn_arity(irn); pos < n; ++pos) { + arch_get_register_req(aenv, &req, irn, pos); + + if(arch_irn_has_reg_class(aenv, irn, pos, cenv->cls) && req.type == arch_register_req_type_limited) { - /* 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 == NULL) { + *perm = insert_Perm_after(menv, cenv->cls, cenv->dom_front, sched_prev(base)); + be_liveness(cenv->irg); + } - if(!perm) - perm = insert_Perm_after(menv, cenv->cls, cenv->dom_front, sched_prev(irn)); + /* + * 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); /* - * 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); - } + * 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); } } + } +} - /* - * 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) - be_liveness(get_irn_irg(bl)); +static void walker_insert_constr_perms(ir_node *bl, void *env) { + be_chordal_env_t *cenv = env; + ir_node *irn; + + for(irn = sched_first(bl); !sched_is_end(irn); irn = sched_next(irn)) { + ir_node *perm = NULL; + + if(get_irn_mode(irn) == mode_T) { + ir_node *proj; + + for(proj = sched_next(irn); is_Proj(proj); proj = sched_next(proj)) + check_constraints(cenv, irn, proj, &perm); + + irn = sched_prev(proj); + } + + else + check_constraints(cenv, irn, irn, &perm); } }