- ir_node *res;
- if(is_Reload(node_to_spill))
- res = get_irn_n(node_to_spill, 0);
- else {
- ir_node *bl = get_nodes_block(node_to_spill);
- ir_graph *irg = get_irn_irg(bl);
-
- res = new_Spill(factory, cls, irg, bl, node_to_spill);
+ const arch_env_t *arch_env = env->main_env->arch_env;
+ ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
+ ir_graph *irg = get_irn_irg(bl);
+ pset *live = put_live_end(bl, pset_new_ptr_default());
+ ir_node *curr, *irn, *perm, **nodes;
+ int i, n;
+
+ ir_printf("Insert Perm after: %+F\n", pos);
+
+ sched_foreach_reverse(bl, irn) {
+
+ if(arch_irn_has_reg_class(arch_env, irn, arch_pos_make_out(0), cls))
+ pset_remove_ptr(live, irn);
+
+ for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
+ ir_node *op = get_irn_n(irn, i);
+
+ if(arch_irn_has_reg_class(arch_env, op, arch_pos_make_out(0), cls))
+ pset_insert_ptr(live, op);
+ }
+
+ if(sched_prev(irn) == pos)
+ break;