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 walker_insert_constr_perms(ir_node *bl, void *env) {
24 be_chordal_env_t *cenv = env;
25 const be_main_env_t *menv = cenv->main_env;
26 const arch_env_t *aenv = menv->arch_env;
27 arch_register_req_t req;
30 sched_foreach(bl, irn) {
33 /* check for a restriction of the result (-1) or one of the operands (0..n) */
34 max = get_irn_arity(irn);
35 for(pos=-1; pos<max; ++pos) {
36 arch_get_register_req(aenv, &req, irn, pos);
37 /* if a restriction is found, insert a perm before the irn */
38 if (cenv->cls == arch_get_irn_reg_class(aenv, irn, pos) && req.type == arch_register_req_type_limited) {
41 perm = insert_Perm_after(menv, cenv->cls, cenv->dom_front, sched_prev(irn));
44 * Turn an input constraint into an output constraint:
45 * The Proj of the Perm which corresponds to the input
46 * constraint will have the input constraint of the node
47 * as an output constraint
50 ir_node *op = get_irn_n(irn, pos);
53 * The operand must be a proj now, since a perm cut
57 be_set_Perm_out_req(perm, get_Proj_proj(op), &req);
63 * If we inserted a perm,
64 * we have to recompute liveness analysis since inserting
65 * a Perm changes the liveness situation at the end
67 * (its needed by successive calls to insert_Perm_after)
68 * Perhaps thinking about an online liveness analysis
72 be_liveness(get_irn_irg(bl));
76 void be_insert_constr_perms(be_chordal_env_t *cenv) {
77 irg_block_walk_graph(cenv->irg, walker_insert_constr_perms, NULL, cenv);