-static void adjust_phi_arguments(be_main_session_env_t *session, be_chordal_env_t *chordal_env, ir_node *phi) {
- int i, max;
- ir_node *arg, *phi_block, *arg_block;
- arch_env_t *arch_env = session->main_env->arch_env;
- const arch_register_t *phi_reg, *arg_reg;
- const arch_register_class_t *cls;
-
- assert(is_Phi(phi) && "Can only handle phi-destruction :)");
- DBG((dbg, LEVEL_1, " for %+F\n", phi));
-
- cls = arch_get_irn_reg_class(session->main_env->arch_env, phi, arch_pos_make_out(0));
- phi_block = get_nodes_block(phi);
- phi_reg = get_reg(phi);
-
- /* process all arguments of the phi */
- for(i=0, max=get_irn_arity(phi); i<max; ++i) {
- ir_node *perm;
-
- arg = get_irn_n(phi, i);
- arg_block = get_nodes_block(arg);
- arg_reg = get_reg(arg);
- perm = get_Proj_pred(arg);
- assert(is_Perm(perm));
-
- DBG((dbg, LEVEL_1, " arg %+F has perm %+F\n", arg, perm));
- /* if registers don't match ...*/
- if (phi_reg != arg_reg) {
- DBG((dbg, LEVEL_1, " regs don't match %d %d\n", phi_reg, arg_reg));
-
- /* First check if there is another phi in the same block
- * having arg at the same pos in its arg-list and the same color as arg */
- if (!is_pinned(arg)) {
- DBG((dbg, LEVEL_1, " arg is not pinned\n"));
- ir_node *other_phi = phi;
- while ((other_phi = get_irn_link(other_phi)) != phi) {
- assert(is_Phi(other_phi) && get_nodes_block(phi) == get_nodes_block(other_phi) && "link fields are screwed up");
- if (get_irn_n(other_phi, i) == arg && get_reg(other_phi) == arg_reg) {
- DBG((dbg, LEVEL_1, " other phi pinned the argument\n"));
- pin_irn(arg, phi_block);
- }
- }
+static void set_regs_or_place_dupls_walker(ir_node *bl, void *data)
+{
+ be_chordal_env_t *chordal_env = (be_chordal_env_t*)data;
+ be_lv_t *lv = be_get_irg_liveness(chordal_env->irg);
+ ir_node *phi;
+
+ /* Consider all phis of this block */
+ for (phi = (ir_node*)get_irn_link(bl); phi != NULL;
+ phi = (ir_node*)get_irn_link(phi)) {
+ ir_node *phi_block = get_nodes_block(phi);
+ const arch_register_t *phi_reg = arch_get_irn_register(phi);
+ int max;
+ int i;
+
+ assert(is_Phi(phi) && "Can only handle phi-destruction :)");
+
+ /* process all arguments of the phi */
+ for (i = 0, max = get_irn_arity(phi); i < max; ++i) {
+ ir_node *arg = get_irn_n(phi, i);
+ const arch_register_t *arg_reg;
+ ir_node *arg_block;
+
+ arg_block = get_Block_cfgpred_block(phi_block, i);
+ arg_reg = arch_get_irn_register(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 (phi_reg == arg_reg
+ || (arg_reg->type & arch_register_type_virtual)) {
+ /* 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, arch_get_irn_register(arg)->name));
+ continue;