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)
35 && arch_register_req_is(&req, limited)
36 && !arch_irn_is_ignore(aenv, irn)) {
39 * If we inserted a perm,
40 * we have to recompute liveness analysis since inserting
41 * a Perm changes the liveness situation at the end
43 * (its needed by successive calls to insert_Perm_after)
44 * Perhaps thinking about an online liveness analysis
48 *perm = insert_Perm_after(aenv, cenv->cls, cenv->dom_front, sched_prev(base));
49 be_liveness(cenv->irg);
53 * Turn an input constraint into an output constraint:
54 * The Proj of the Perm which corresponds to the input
55 * constraint will have the input constraint of the node
56 * as an output constraint
59 ir_node *op = get_irn_n(irn, pos);
62 * The operand must be a proj now, since a perm cut
66 be_set_Perm_out_req(*perm, get_Proj_proj(op), &req);
72 static void walker_insert_constr_perms(ir_node *bl, void *env) {
73 be_chordal_env_t *cenv = env;
76 for(irn = sched_first(bl); !sched_is_end(irn); irn = sched_next(irn)) {
79 if(get_irn_mode(irn) == mode_T) {
82 for(proj = sched_next(irn); is_Proj(proj); proj = sched_next(proj))
83 check_constraints(cenv, irn, proj, &perm);
85 irn = sched_prev(proj);
89 check_constraints(cenv, irn, irn, &perm);
93 void be_insert_constr_perms(be_chordal_env_t *cenv) {
94 irg_block_walk_graph(cenv->irg, walker_insert_constr_perms, NULL, cenv);