-)
-
-/* Creates a new spill environment. */
-spill_env_t *be_new_spill_env(const be_chordal_env_t *chordal_env, decide_irn_t is_mem_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_mem_phi = is_mem_phi;
- env->data = data;
- env->chordal_env = chordal_env;
- obstack_init(&env->obst);
- return env;
+
+void be_add_reload2(spill_env_t *env, ir_node *to_spill, ir_node *before,
+ ir_node *can_spill_after, const arch_register_class_t *reload_cls,
+ int allow_remat)
+{
+ spill_info_t *info;
+ reloader_t *rel;
+
+ assert(! arch_irn_is(env->arch_env, to_spill, dont_spill));
+
+ info = get_spillinfo(env, to_spill);
+
+ if (is_Phi(to_spill)) {
+ int i, arity;
+
+ /* create spillinfos for the phi arguments */
+ for (i = 0, arity = get_irn_arity(to_spill); i < arity; ++i) {
+ ir_node *arg = get_irn_n(to_spill, i);
+ get_spillinfo(env, arg);
+ }
+ }
+
+ assert(!is_Proj(before) && !be_is_Keep(before));
+
+ /* put reload into list */
+ rel = obstack_alloc(&env->obst, sizeof(rel[0]));
+ rel->next = info->reloaders;
+ rel->reloader = before;
+ rel->rematted_node = NULL;
+ rel->can_spill_after = can_spill_after;
+ rel->remat_cost_delta = allow_remat ? 0 : REMAT_COST_INFINITE;
+
+ info->reloaders = rel;
+ assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
+ info->reload_cls = reload_cls;
+
+ DBG((dbg, LEVEL_1, "creating spillinfo for %+F, will be reloaded before %+F, may%s be rematerialized\n",
+ to_spill, before, allow_remat ? "" : " not"));
+}
+
+void be_add_reload(spill_env_t *senv, ir_node *to_spill, ir_node *before,
+ const arch_register_class_t *reload_cls, int allow_remat)
+{
+ be_add_reload2(senv, to_spill, before, to_spill, reload_cls, allow_remat);
+
+}
+
+ir_node *be_get_end_of_block_insertion_point(const ir_node *block)
+{
+ ir_node *last = sched_last(block);
+
+ /* we might have keeps behind the jump... */
+ while (be_is_Keep(last)) {
+ last = sched_prev(last);
+ assert(!sched_is_end(last));
+ }
+
+ assert(is_cfop(last));
+
+ /* add the reload before the (cond-)jump */
+ return last;