+static void prepare_constr_insn(be_pre_spill_env_t *env, ir_node *node)
+{
+ const arch_register_class_t *cls = env->cls;
+ ir_node *block = get_nodes_block(node);
+ const ir_graph *irg = env->irg;
+ be_irg_t *birg = be_birg_from_irg(irg);
+ be_lv_t *lv = be_get_irg_liveness(irg);
+ unsigned *tmp = NULL;
+ unsigned *def_constr = NULL;
+ int arity = get_irn_arity(node);
+ ir_node *def;
+
+ int i, i2;
+
+ /* Insert a copy for constraint inputs attached to a value which can't
+ * fulfill the constraint
+ * (typical example: stack pointer as input to copyb)
+ * TODO: This really just checks precolored registers at the moment and
+ * ignores the general case of not matching in/out constraints
+ */
+ for (i = 0; i < arity; ++i) {
+ ir_node *op = get_irn_n(node, i);
+ const arch_register_req_t *req = arch_get_irn_register_req_in(node, i);
+ const arch_register_t *reg;
+ ir_node *copy;
+
+ if (req->cls != cls)
+ continue;
+ reg = arch_get_irn_register(op);
+ if (reg == NULL)
+ continue;
+
+ /* precolored with an ignore register (which is not a joker like
+ unknown/noreg) */
+ if ((reg->type & arch_register_type_joker) ||
+ rbitset_is_set(birg->allocatable_regs, reg->global_index))
+ continue;
+
+ if (! (req->type & arch_register_req_type_limited))
+ continue;
+ if (rbitset_is_set(req->limited, reg->index))
+ continue;
+
+ copy = be_new_Copy(block, op);
+ stat_ev_int("constr_copy", 1);
+ sched_add_before(node, copy);
+ set_irn_n(node, i, copy);
+ DBG((dbg, LEVEL_3, "inserting ignore arg copy %+F for %+F pos %d\n",
+ copy, node, i));
+ }