+ constraint_env_t cenv;
+ op_copy_assoc_t *entry;
+ dom_front_info_t *dom;
+ ir_node **nodes;
+ FIRM_DBG_REGISTER(firm_dbg_module_t *mod, "firm.be.lower");
+
+ cenv.birg = birg;
+ cenv.op_set = new_pset(cmp_op_copy_assoc, 16);
+ obstack_init(&cenv.obst);
+
+ irg_walk_blkwise_graph(birg->irg, NULL, assure_constraints_walker, &cenv);
+
+ /* introduce copies needs dominance information */
+ dom = be_compute_dominance_frontiers(birg->irg);
+
+ /* for all */
+ foreach_pset(cenv.op_set, entry) {
+ int n;
+ ir_node *cp;
+
+ n = pset_count(entry->copies);
+ nodes = alloca((n + 1) * sizeof(nodes[0]));
+
+ /* put the node in an array */
+ n = 0;
+ nodes[n++] = entry->op;
+ DBG((mod, LEVEL_1, "introduce copies for %+F ", entry->op));
+
+ /* collect all copies */
+ foreach_pset(entry->copies, cp) {
+ nodes[n++] = cp;
+ DB((mod, LEVEL_1, ", %+F ", cp));
+ }
+
+ DB((mod, LEVEL_1, "\n"));
+
+ /* introduce the copies for the operand and it's copies */
+ be_ssa_constr(dom, NULL, n, nodes);
+
+
+ /* Could be that not all CopyKeeps are really needed, */
+ /* so we transform unnecessary ones into Keeps. */
+ foreach_pset(entry->copies, cp) {
+ if (be_is_CopyKeep(cp) && get_irn_n_edges(cp) < 1) {
+ ir_node *keep;
+ int n = get_irn_arity(cp);
+
+ keep = be_new_Keep(arch_get_irn_reg_class(birg->main_env->arch_env, cp, -1),
+ birg->irg, get_nodes_block(cp), n, (ir_node **)&get_irn_in(cp)[1]);
+ sched_add_before(cp, keep);
+ sched_remove(cp);
+
+ /* Set all ins (including the block) of the CopyKeep BAD to keep the verifier happy. */
+ while (--n >= -1)
+ set_irn_n(cp, n, get_irg_bad(birg->irg));
+ }
+ }
+
+ del_pset(entry->copies);
+ }
+
+ be_free_dominance_frontiers(dom);
+
+ del_pset(cenv.op_set);
+ obstack_free(&cenv.obst, NULL);