-static void adjust_phi_arguments(be_chordal_env_t *chordal_env, ir_node *phi) {
- int i, max;
- ir_node *arg, *phi_block, *arg_block;
- const arch_register_t *phi_reg, *arg_reg;
- const arch_register_class_t *cls;
-
- assert(is_Phi(phi) && "Can only handle phi-destruction :)");
-
- phi_block = get_nodes_block(phi);
- phi_reg = get_reg(phi);
- cls = arch_get_irn_reg_class(get_chordal_arch(chordal_env), phi, -1);
-
- /* process all arguments of the phi */
- for(i=0, max=get_irn_arity(phi); i<max; ++i) {
- arg = get_irn_n(phi, i);
- arg_block = get_Block_cfgpred_block(phi_block, i);
- arg_reg = get_reg(arg);
- assert(arg_reg && "Register must be set while placing perms");
-
- DBG((dbg, LEVEL_1, " for %+F(%s) -- %+F(%s)\n", phi, phi_reg->name, arg, arg_reg->name));
-
- if(nodes_interfere(chordal_env, phi, arg)) {
- /* Insert a duplicate in arguments block,
- * make it the new phi arg,
- * set its register,
- * insert it into schedule,
- * pin it
- */
- ir_node *dupl = new_Copy(chordal_env->main_env->node_factory, cls, chordal_env->irg, arg_block, arg);
- assert(get_irn_mode(phi) == get_irn_mode(dupl));
- set_irn_n(phi, i, dupl);
- set_reg(dupl, phi_reg);
- sched_add_after(sched_skip(sched_last(arg_block), 0, sched_skip_cf_predicator, chordal_env->main_env->arch_env), dupl);
- pin_irn(dupl, phi_block);
- DBG((dbg, LEVEL_1, " they do interfere: insert %+F(%s)\n", dupl, get_reg(dupl)->name));
- } else {
- /*
- * First check if there is a phi
- * - in the same block
- * - having arg at the current pos in its arg-list
- * - having the same color as arg
- *
- * If found, then pin the arg
- */
+static void set_regs_or_place_dupls_walker(ir_node *bl, void *data) {
+ be_chordal_env_t *chordal_env = data;
+ ir_node *phi;
+
+ /* Consider all phis of this block */
+ for (phi = get_irn_link(bl); phi; phi = get_irn_link(phi)) {
+ int i, max;
+ ir_node *arg, *phi_block, *arg_block;
+ const arch_register_t *phi_reg, *arg_reg;
+ const arch_register_class_t *cls;
+
+ assert(is_Phi(phi) && "Can only handle phi-destruction :)");
+
+ phi_block = get_nodes_block(phi);
+ phi_reg = get_reg(phi);
+ cls = arch_get_irn_reg_class(get_chordal_arch(chordal_env), phi, -1);
+
+ /* process all arguments of the phi */
+ for (i = 0, max = get_irn_arity(phi); i < max; ++i) {
+ arg = get_irn_n(phi, i);
+ arg_block = get_Block_cfgpred_block(phi_block, i);
+ arg_reg = get_reg(arg);
+
+ assert(arg_reg && "Register must be set while placing perms");
+
+ DBG((dbg, LEVEL_1, " for %+F(%s) -- %+F(%s)\n", phi, phi_reg->name, arg, arg_reg->name));
+
+ if(values_interfere(phi, arg)) {
+ /*
+ Insert a duplicate in arguments block,
+ make it the new phi arg,
+ set its register,
+ insert it into schedule,
+ pin it
+ */
+ ir_node *dupl = be_new_Copy(cls, chordal_env->irg, arg_block, arg);
+
+ /* this is commented out because it will fail in case of unknown float */
+#if 0
+ ir_mode *m_phi = get_irn_mode(phi), *m_dupl = get_irn_mode(dupl);
+
+ /*
+ Conv signed <-> unsigned is killed on ia32
+ check for: (both int OR both float) AND equal mode sizes
+ */
+ assert(((mode_is_int(m_phi) && mode_is_int(m_dupl)) ||
+ (mode_is_float(m_phi) && mode_is_float(m_dupl))) &&
+ (get_mode_size_bits(m_phi) == get_mode_size_bits(m_dupl)));
+#endif /* if 0 */
+
+ set_irn_n(phi, i, dupl);
+ set_reg(dupl, phi_reg);
+ sched_add_after(sched_skip(sched_last(arg_block), 0, sched_skip_cf_predicator, chordal_env->birg->main_env->arch_env), dupl);
+ pin_irn(dupl, phi_block);
+ DBG((dbg, LEVEL_1, " they do interfere: insert %+F(%s)\n", dupl, get_reg(dupl)->name));
+ continue; /* with next argument */
+ }
+
+ if (phi_reg == arg_reg) {
+ /* Phi and arg have the same register, so pin and continue */
+ pin_irn(arg, phi_block);
+ DBG((dbg, LEVEL_1, " arg has same reg: pin %+F(%s)\n", arg, get_reg(arg)->name));
+ continue;
+ }
+