- const be_chordal_env_t *chordal_env;
- struct obstack obst;
- set *spill_ctxs;
- set *spills; /**< all spill_info_t's, which must be placed */
- pset *mem_phis; /**< set of all special spilled phis. allocated and freed separately */
- decide_irn_t is_spilled_phi;/**< callback func to decide if a phi needs special spilling */
- void *data; /**< data passed to all callbacks */
- DEBUG_ONLY(firm_dbg_module_t *dbg;)
-};
-
-/* associated Phi -> Spill*/
-typedef struct _phi_spill_assoc_t {
- ir_node *phi;
- ir_node *spill;
-} phi_spill_assoc_t;
-
-/**
- * Compare two Phi->Spill associations.
- */
-static int cmp_phi_spill_assoc(const void *a, const void *b, size_t n) {
- const phi_spill_assoc_t *p1 = a;
- const phi_spill_assoc_t *p2 = b;
- return p1->phi != p2->phi;
-}
-
-/**
- * compare two spill contexts.
- */
-static int cmp_spillctx(const void *a, const void *b, size_t n) {
- const spill_ctx_t *p = a;
- const spill_ctx_t *q = b;
- return p->user != q->user || p->spilled != q->spilled;
-}
-
-/**
- * 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;
-}
-
-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, decide_irn_t is_spilled_phi, void *data) {
- spill_env_t *env = xmalloc(sizeof(env[0]));
- env->spill_ctxs = new_set(cmp_spillctx, 1024);
- env->spills = new_set(cmp_spillinfo, 1024);
- env->cls = chordal_env->cls;
- env->is_spilled_phi = is_spilled_phi;
- env->data = data;
- env->chordal_env = chordal_env;
- obstack_init(&env->obst);
- return env;
-}
-
-void be_set_is_spilled_phi(spill_env_t *env, decide_irn_t is_spilled_phi, void *data) {
- env->is_spilled_phi = is_spilled_phi;
- env->data = data;
-}
-
-/* Deletes a spill environment. */
-void be_delete_spill_env(spill_env_t *senv) {
- del_set(senv->spill_ctxs);
- del_set(senv->spills);
- obstack_free(&senv->obst, NULL);
- free(senv);
-}
-
-/**
- * Returns a spill context. If the context did not exists, create one.
- *
- * @param sc the set containing all spill contexts
- * @param to_spill the node that should be spilled
- * @param ctx_irn an user of the spilled node
- *
- * @return a spill context.
- */
-static spill_ctx_t *be_get_spill_ctx(set *sc, ir_node *to_spill, ir_node *ctx_irn) {
- spill_ctx_t templ;
-
- templ.spilled = to_spill;
- templ.user = ctx_irn;
- templ.spill = NULL;
-
- return set_insert(sc, &templ, sizeof(templ), HASH_COMBINE(HASH_PTR(to_spill), HASH_PTR(ctx_irn)));
-}
-
-/**
- * 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 ir_node *be_spill_irn(spill_env_t *senv, ir_node *irn, ir_node *ctx_irn) {
- spill_ctx_t *ctx;
- const be_main_env_t *env = senv->chordal_env->birg->main_env;
- DBG((senv->dbg, LEVEL_1, "%+F in ctx %+F\n", irn, ctx_irn));
-
- // Has the value already been spilled?
- ctx = be_get_spill_ctx(senv->spill_ctxs, irn, ctx_irn);
- if(ctx->spill)
- return ctx->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 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