- const be_chordal_env_t *chordal_env;
- struct obstack obst;
- set *spills; /**< all spill_info_t's, which must be placed */
- pset *mem_phis; /**< set of all special spilled phis. allocated and freed separately */
-
- DEBUG_ONLY(firm_dbg_module_t *dbg;)
-};
-
-/**
- * Compare two spill infos.
- */
-static int cmp_spillinfo(const void *x, const void *y, size_t size) {
- const spill_info_t *xx = x;
- const spill_info_t *yy = y;
- return xx->spilled_node != yy->spilled_node;
-}
-
-/**
- * Returns spill info for a specific value (the value that is to be spilled)
- */
-static spill_info_t *get_spillinfo(const spill_env_t *env, ir_node *value) {
- spill_info_t info, *res;
- int hash = HASH_PTR(value);
-
- info.spilled_node = value;
- res = set_find(env->spills, &info, sizeof(info), hash);
-
- if (res == NULL) {
- info.reloaders = NULL;
- info.spill = NULL;
- res = set_insert(env->spills, &info, sizeof(info), hash);
- }
-
- return res;
-}
-
-DEBUG_ONLY(
-/* Sets the debug module of a spill environment. */
-void be_set_spill_env_dbg_module(spill_env_t *env, firm_dbg_module_t *dbg) {
- env->dbg = dbg;
-}
-)
-
-/* Creates a new spill environment. */
-spill_env_t *be_new_spill_env(const be_chordal_env_t *chordal_env) {
- spill_env_t *env = xmalloc(sizeof(env[0]));
- env->spills = new_set(cmp_spillinfo, 1024);
- env->cls = chordal_env->cls;
- env->chordal_env = chordal_env;
- env->mem_phis = pset_new_ptr_default();
- obstack_init(&env->obst);
- return env;
-}
-
-/* Deletes a spill environment. */
-void be_delete_spill_env(spill_env_t *env) {
- del_set(env->spills);
- del_pset(env->mem_phis);
- obstack_free(&env->obst, NULL);
- free(env);
-}
-
-/**
- * Schedules a node after an instruction. (That is the place after all projs and phis
- * that are scheduled after the instruction)
- */
-static void sched_add_after_insn(ir_node *sched_after, ir_node *node) {
- ir_node *next = sched_next(sched_after);
- while(!sched_is_end(next)) {
- if(!is_Proj(next) && !is_Phi(next))
- break;
- next = sched_next(next);
- }
-
- if(sched_is_end(next)) {
- next = sched_last(get_nodes_block(sched_after));
- sched_add_after(next, node);
- } else {
- sched_add_before(next, node);
- }
-}
-
-/**
- * Creates a spill.
- *
- * @param senv the spill environment
- * @param irn the node that should be spilled
- * @param ctx_irn an user of the spilled node
- *
- * @return a be_Spill node
- */
-static void spill_irn(spill_env_t *env, spill_info_t *spillinfo) {
- const be_main_env_t *mainenv = env->chordal_env->birg->main_env;
- ir_node *to_spill = spillinfo->spilled_node;
-
- DBG((env->dbg, LEVEL_1, "%+F\n", to_spill));
-
- /* Trying to spill an already spilled value, no need for a new spill
- * node then, we can simply connect to the same one for this reload
+} be_pre_spill_env_t;
+
+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 be_irg_t *birg = env->birg;
+ be_lv_t *lv = birg->lv;
+ unsigned *tmp = NULL;
+ unsigned *def_constr = NULL;
+ int arity = get_irn_arity(node);
+
+ int i, i2;
+
+ /* Insert a copy for constraint inputs attached to a value which can't
+ * fullfil the constraint
+ * (typical example: stack pointer as input to copyb)
+ * TODO: This really just checks precolored registers at the moment and
+ * ignore the general case of not matching in/out constraints