2 * Author: Daniel Grund, Sebastian Hack
4 * Copyright: (c) Universitaet Karlsruhe
5 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
12 #include "irgraph_t.h"
19 #include "besched_t.h"
20 #include "beconstrperm.h"
22 static void check_constraints(const be_chordal_env_t *cenv, ir_node *base, ir_node *irn, ir_node **perm)
24 const arch_env_t *aenv = cenv->main_env->arch_env;
25 const be_main_env_t *menv = cenv->main_env;
26 arch_register_req_t req;
29 assert(is_Proj(irn) || (base == irn));
31 for(pos = -1, n = get_irn_arity(irn); pos < n; ++pos) {
32 arch_get_register_req(aenv, &req, irn, pos);
34 if(arch_irn_has_reg_class(aenv, irn, pos, cenv->cls) && arch_register_req_is(&req, limited)) {
37 * If we inserted a perm,
38 * we have to recompute liveness analysis since inserting
39 * a Perm changes the liveness situation at the end
41 * (its needed by successive calls to insert_Perm_after)
42 * Perhaps thinking about an online liveness analysis
46 *perm = insert_Perm_after(aenv, cenv->cls, cenv->dom_front, sched_prev(base));
47 be_liveness(cenv->irg);
51 * Turn an input constraint into an output constraint:
52 * The Proj of the Perm which corresponds to the input
53 * constraint will have the input constraint of the node
54 * as an output constraint
57 ir_node *op = get_irn_n(irn, pos);
60 * The operand must be a proj now, since a perm cut
64 be_set_Perm_out_req(*perm, get_Proj_proj(op), &req);
70 static void walker_insert_constr_perms(ir_node *bl, void *env) {
71 be_chordal_env_t *cenv = env;
74 for(irn = sched_first(bl); !sched_is_end(irn); irn = sched_next(irn)) {
77 if(get_irn_mode(irn) == mode_T) {
80 for(proj = sched_next(irn); is_Proj(proj); proj = sched_next(proj))
81 check_constraints(cenv, irn, proj, &perm);
83 irn = sched_prev(proj);
87 check_constraints(cenv, irn, irn, &perm);
91 void be_insert_constr_perms(be_chordal_env_t *cenv) {
92 irg_block_walk_graph(cenv->irg, walker_insert_constr_perms, NULL, cenv);