+ /* ssa destruction */
+ be_ssa_destruction(chordal_env);
+
+ BE_TIMER_POP(ra_timer.t_ssa);
+
+ dump(BE_CH_DUMP_SSADESTR, irg, pse->cls, "-ssadestr", dump_ir_block_graph_sched);
+
+ BE_TIMER_PUSH(ra_timer.t_verify);
+ if (chordal_env->opts->vrfy_option != BE_CH_VRFY_OFF) {
+ be_ssa_destruction_check(chordal_env);
+ }
+ BE_TIMER_POP(ra_timer.t_verify);
+
+ /* free some data structures */
+ be_ifg_free(chordal_env->ifg);
+ pmap_destroy(chordal_env->border_heads);
+ bitset_free(chordal_env->ignore_colors);
+
+#ifdef FIRM_STATISTICS
+ if (be_stat_ev_is_active()) {
+ node_stats(birg, pse->cls, &node_stat);
+ be_stat_ev("perms_after_coal", node_stat.n_perms);
+ be_stat_ev("copies_after_coal", node_stat.n_copies);
+ be_stat_ev_pop();
+ }
+#endif /* FIRM_STATISTICS */
+}
+
+/**
+ * Performs chordal register allocation for each register class on given irg.
+ *
+ * @param birg Backend irg object
+ * @return Structure containing timer for the single phases or NULL if no timing requested.
+ */
+static void be_ra_chordal_main(be_irg_t *birg)
+{
+ const be_main_env_t *main_env = birg->main_env;
+ const arch_isa_t *isa = arch_env_get_isa(main_env->arch_env);
+ ir_graph *irg = birg->irg;
+ be_options_t *main_opts = main_env->options;
+ int j, m;
+ be_chordal_env_t chordal_env;
+
+ BE_TIMER_INIT(main_opts);
+ BE_TIMER_PUSH(ra_timer.t_other);
+ BE_TIMER_PUSH(ra_timer.t_prolog);
+
+ be_assure_dom_front(birg);
+ be_assure_liveness(birg);
+
+ chordal_env.opts = &options;
+ chordal_env.irg = irg;
+ chordal_env.birg = birg;
+ FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
+
+ obstack_init(&chordal_env.obst);
+
+ BE_TIMER_POP(ra_timer.t_prolog);
+
+ be_stat_ev("insns_before", count_insns(irg));
+
+ if (! arch_code_generator_has_spiller(birg->cg)) {
+ /* use one of the generic spiller */
+
+ /* Perform the following for each register class. */
+ for (j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
+ post_spill_env_t pse;
+
+ memcpy(&pse.cenv, &chordal_env, sizeof(chordal_env));
+ pse.birg = birg;
+ pre_spill(isa, j, &pse);
+
+ BE_TIMER_PUSH(ra_timer.t_spill);
+ be_do_spill(&pse.cenv);
+ BE_TIMER_POP(ra_timer.t_spill);
+
+ dump(BE_CH_DUMP_SPILL, irg, pse.cls, "-spill", dump_ir_block_graph_sched);
+
+ post_spill(&pse, 0);