- chordal_env.opts = &options;
- chordal_env.irg = irg;
- chordal_env.birg = bi;
- chordal_env.dom_front = be_compute_dominance_frontiers(irg);
- FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
-
- obstack_init(&chordal_env.obst);
-
- /* Perform the following for each register class. */
- for(j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
- chordal_env.cls = arch_isa_get_reg_class(isa, j);
- chordal_env.border_heads = pmap_create();
- chordal_env.ignore_colors = bitset_malloc(chordal_env.cls->n_regs);
-
- /* put all ignore registers into the ignore register set. */
- put_ignore_colors(&chordal_env);
-
- be_liveness(irg);
- dump(BE_CH_DUMP_LIVE, irg, chordal_env.cls, "-live", dump_ir_block_graph_sched);
-
- /* spilling */
- switch(options.spill_method) {
- case BE_CH_SPILL_MORGAN:
- be_spill_morgan(&chordal_env);
- break;
- case BE_CH_SPILL_BELADY:
- be_spill_belady(&chordal_env);
- break;
-#ifdef WITH_ILP
- case BE_CH_SPILL_ILP:
- be_spill_ilp(&chordal_env);
- break;
- case BE_CH_SPILL_REMAT:
- be_spill_remat(&chordal_env);
- break;
- case BE_CH_SPILL_APPEL:
- be_spill_appel(&chordal_env);
- break;
-#endif /* WITH_ILP */
- default:
- fprintf(stderr, "no valid spiller selected. falling back to belady\n");
- be_spill_belady(&chordal_env);
+ /* put all ignore registers into the ignore register set. */
+ be_put_ignore_regs(birg, pse->cls, chordal_env->ignore_colors);
+
+ be_pre_spill_prepare_constr(chordal_env);
+ dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "-constr-pre", dump_ir_block_graph_sched);
+
+#ifdef FIRM_STATISTICS
+ if (be_stat_ev_is_active()) {
+ pse->pre_spill_cost = be_estimate_irg_costs(birg->irg,
+ birg->main_env->arch_env, birg->exec_freq);
+ be_stat_ev_pop();
+ }
+#endif /* FIRM_STATISTICS */
+}
+
+/**
+ * Perform things which need to be done per register class after spilling.
+ */
+static void post_spill(post_spill_env_t *pse, int iteration) {
+ be_chordal_env_t *chordal_env = &pse->cenv;
+ be_irg_t *birg = pse->birg;
+ ir_graph *irg = birg->irg;
+ const be_main_env_t *main_env = birg->main_env;
+ be_options_t *main_opts = main_env->options;
+ node_stat_t node_stat;
+ int colors_n = arch_register_class_n_regs(chordal_env->cls);
+ int allocatable_regs = colors_n - be_put_ignore_regs(birg, chordal_env->cls, NULL);
+
+ /* some special classes contain only ignore regs, no work to be done */
+ if (allocatable_regs > 0) {
+
+#ifdef FIRM_STATISTICS
+ if (be_stat_ev_is_active()) {
+ double spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost;
+
+ be_stat_tags[STAT_TAG_CLS] = pse->cls->name;
+ be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
+
+ be_stat_ev_l("spillcosts", (long) spillcosts);
+
+ node_stats(birg, pse->cls, &node_stat);
+ be_stat_ev("phis_after_spill", node_stat.n_phis);
+ be_stat_ev("mem_phis", node_stat.n_mem_phis);
+ be_stat_ev("reloads", node_stat.n_reloads);
+ be_stat_ev("spills", node_stat.n_spills);
+ }
+#endif /* FIRM_STATISTICS */
+
+ /*
+ If we have a backend provided spiller, post spill is
+ called in a loop after spilling for each register class.
+ But we only need to fix stack nodes once in this case.
+ */
+ if (iteration == 0) {
+ check_for_memory_operands(chordal_env);
+ be_abi_fix_stack_nodes(birg->abi);