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