- else
-#endif
- /* do a reload */
- new_val = be_reload(arch_env, env->cls, rld->reloader, mode, spill);
-
- DBG((env->dbg, LEVEL_1, " %+F of %+F before %+F\n", new_val, si->spilled_node, rld->reloader));
- pset_insert_ptr(values, new_val);
- }
-
- /* introduce copies, rewire the uses */
- assert(pset_count(values) > 0 && "???");
- pset_insert_ptr(values, si->spilled_node);
- be_ssa_constr_set_ignore(env->chordal_env->dom_front, values, env->mem_phis);
-
- del_pset(values);
- }
-
- remove_copies(env);
-
- // reloads are placed now, but we might reuse the spill environment for further spilling decisions
- del_set(env->spills);
- env->spills = new_set(cmp_spillinfo, 1024);
-}
-
-void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before) {
- spill_info_t templ, *res;
- reloader_t *rel;
-
- assert(arch_irn_consider_in_reg_alloc(env->chordal_env->birg->main_env->arch_env, env->cls, to_spill));
-
- templ.spilled_node = to_spill;
- templ.reloaders = NULL;
- res = set_insert(env->spills, &templ, sizeof(templ), HASH_PTR(to_spill));
-
- rel = obstack_alloc(&env->obst, sizeof(rel[0]));
- rel->reloader = before;
- rel->next = res->reloaders;
- res->reloaders = rel;
-}
-
-void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *bl, int pos) {
- ir_node *insert_bl = get_irn_arity(bl) == 1 ? sched_first(bl) : get_Block_cfgpred_block(bl, pos);
- be_add_reload(env, to_spill, insert_bl);
-}
-
-
-
-/****************************************
-
- SPILL SLOT MANAGEMENT AND OPTS
-
-****************************************/
-
-typedef struct _spill_slot_t {
- unsigned size;
- unsigned align;
- pset *members;
- ir_mode *largest_mode; /* the mode of all members with largest size */
-} spill_slot_t;
-
-typedef struct _ss_env_t {
- struct obstack ob;
- be_chordal_env_t *cenv;
- pmap *slots; /* maps spill_contexts to spill_slots */
- pmap *types; /* maps modes to types */
- DEBUG_ONLY(firm_dbg_module_t *dbg;)
-} ss_env_t;
-
-
-/**
- * Walker: compute the spill slots
- */
-static void compute_spill_slots_walker(ir_node *spill, void *env) {
- ss_env_t *ssenv = env;
- ir_node *ctx;
- pmap_entry *entry;
- spill_slot_t *ss;
-
- if (!be_is_Spill(spill))
- return;
-
- /* check, if this spill is for a context already known */
- ctx = be_get_Spill_context(spill);
- entry = pmap_find(ssenv->slots, ctx);
-
- if (!entry) {
- struct _arch_env_t *arch_env = ssenv->cenv->birg->main_env->arch_env;
- const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, spill, be_pos_Spill_val);
- ir_mode *largest_mode = arch_register_class_mode(cls);
-
- /* this is a new spill context */
- ss = obstack_alloc(&ssenv->ob, sizeof(*ss));
- ss->members = pset_new_ptr(8);
- ss->largest_mode = largest_mode;
- ss->size = get_mode_size_bytes(ss->largest_mode);
- ss->align = arch_isa_get_reg_class_alignment(arch_env->isa, cls);
- pmap_insert(ssenv->slots, ctx, ss);
- } else {
- /* values with the same spill_ctx must go into the same spill slot */
- ss = entry->value;