-void be_compute_spill_offsets(be_chordal_env_t *cenv) {
- ss_env_t ssenv;
- spill_slot_t **ss;
- int ss_size;
- pmap_entry *pme;
-
- obstack_init(&ssenv.ob);
- ssenv.cenv = cenv;
- ssenv.slots = pmap_create();
- ssenv.types = pmap_create();
- ssenv.dbg = firm_dbg_register("ir.be.spillslots");
-
- /* Get initial spill slots */
- irg_walk_graph(cenv->irg, NULL, compute_spill_slots_walker, &ssenv);
-
- /* Build an empty array for optimized spill slots */
- ss_size = pmap_count(ssenv.slots);
- ss = obstack_alloc(&ssenv.ob, ss_size * sizeof(*ss));
- optimize_slots(&ssenv, ss_size, ss);
-
- /* Integrate slots into the stack frame entity */
- assign_entities(&ssenv, ss_size, ss);
-
- /* Clean up */
- pmap_foreach(ssenv.slots, pme)
- del_pset(((spill_slot_t *)pme->value)->members);
- pmap_destroy(ssenv.slots);
- pmap_destroy(ssenv.types);
- obstack_free(&ssenv.ob, NULL);
+int be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block, int pos) {
+ ir_node *before = get_reload_insertion_point(block, pos);
+ return be_get_reload_costs(env, to_spill, before);
+}
+
+/*
+ * ___ _ ____ _ _
+ * |_ _|_ __ ___ ___ _ __| |_ | _ \ ___| | ___ __ _ __| |___
+ * | || '_ \/ __|/ _ \ '__| __| | |_) / _ \ |/ _ \ / _` |/ _` / __|
+ * | || | | \__ \ __/ | | |_ | _ < __/ | (_) | (_| | (_| \__ \
+ * |___|_| |_|___/\___|_| \__| |_| \_\___|_|\___/ \__,_|\__,_|___/
+ *
+ */
+
+void be_insert_spills_reloads(spill_env_t *env) {
+ const arch_env_t *arch_env = env->arch_env;
+ int remats = 0;
+ int reloads = 0;
+ int spills = 0;
+ spill_info_t *si;
+
+ /* process each spilled node */
+ for (si = set_first(env->spills); si; si = set_next(env->spills)) {
+ reloader_t *rld;
+ ir_mode *mode = get_irn_mode(si->spilled_node);
+ pset *values = pset_new_ptr(16);
+
+ /* go through all reloads for this spill */
+ for (rld = si->reloaders; rld; rld = rld->next) {
+ ir_node *new_val;
+
+ if (rld->rematted_node != NULL) {
+ new_val = rld->rematted_node;
+ remats++;
+ sched_add_before(rld->reloader, new_val);
+ }
+ else if (be_do_remats && rld->allow_remat && check_remat_conditions(env, si->spilled_node, rld->reloader)) {
+ new_val = do_remat(env, si->spilled_node, rld->reloader);
+ remats++;
+ }
+ else {
+ /* make sure we have a spill */
+ if (si->spill == NULL) {
+ spill_node(env, si);
+ spills++;
+ }
+
+ /* create a reload */
+ new_val = be_reload(arch_env, si->reload_cls, rld->reloader, mode, si->spill);
+ reloads++;
+ }
+
+ DBG((env->dbg, LEVEL_1, " %+F of %+F before %+F\n", new_val, si->spilled_node, rld->reloader));
+ pset_insert_ptr(values, new_val);
+ }
+
+ if (pset_count(values) > 0) {
+ /* introduce copies, rewire the uses */
+ pset_insert_ptr(values, si->spilled_node);
+ be_ssa_constr_set_ignore(env->birg->dom_front, env->birg->lv, values, env->mem_phis);
+ }
+
+ del_pset(values);
+
+ si->reloaders = NULL;
+ }
+
+#ifdef FIRM_STATISTICS
+ if (be_stat_ev_is_active()) {
+ be_stat_ev("spill_spills", spills);
+ be_stat_ev("spill_reloads", reloads);
+ be_stat_ev("spill_remats", remats);
+ }
+#endif /* FIRM_STATISTICS */
+
+ be_remove_dead_nodes_from_schedule(env->irg);
+ //be_liveness_recompute(env->birg->lv);
+ be_invalidate_liveness(env->birg);