+ /* the ifg exists only if there are allocatable regs */
+ be_ifg_free(chordal_env->ifg);
+ }
+
+ /* free some always allocated data structures */
+ pmap_destroy(chordal_env->border_heads);
+ bitset_free(chordal_env->ignore_colors);
+}
+
+/**
+ * Performs chordal register allocation for each register class on given irg.
+ *
+ * @param irg the graph
+ * @return Structure containing timer for the single phases or NULL if no
+ * timing requested.
+ */
+static void be_ra_chordal_main(ir_graph *irg)
+{
+ const arch_env_t *arch_env = be_get_irg_arch_env(irg);
+ int j;
+ int m;
+ be_chordal_env_t chordal_env;
+ struct obstack obst;
+
+ be_timer_push(T_RA_OTHER);
+
+ be_timer_push(T_RA_PROLOG);
+
+ be_assure_liveness(irg);
+
+ chordal_env.obst = &obst;
+ chordal_env.opts = &options;
+ chordal_env.irg = irg;
+ chordal_env.border_heads = NULL;
+ chordal_env.ifg = NULL;
+ chordal_env.ignore_colors = NULL;
+
+ obstack_init(&obst);
+
+ be_timer_pop(T_RA_PROLOG);
+
+ stat_ev_if {
+ be_collect_node_stats(&last_node_stats, irg);
+ }
+
+ if (! arch_code_generator_has_spiller(be_get_irg_cg(irg))) {
+ /* use one of the generic spiller */
+
+ /* Perform the following for each register class. */
+ for (j = 0, m = arch_env_get_n_reg_class(arch_env); j < m; ++j) {
+ post_spill_env_t pse;
+ const arch_register_class_t *cls
+ = arch_env_get_reg_class(arch_env, j);
+
+ if (arch_register_class_flags(cls) & arch_register_class_flag_manual_ra)
+ continue;
+
+
+ stat_ev_ctx_push_str("bechordal_cls", cls->name);
+
+ stat_ev_if {
+ be_do_stat_reg_pressure(irg, cls);
+ }
+
+ memcpy(&pse.cenv, &chordal_env, sizeof(chordal_env));
+ pse.irg = irg;
+ pre_spill(&pse, cls);
+
+ be_timer_push(T_RA_SPILL);
+ be_do_spill(irg, cls);
+ be_timer_pop(T_RA_SPILL);
+
+ dump(BE_CH_DUMP_SPILL, irg, pse.cls, "spill");
+
+ post_spill(&pse, 0);
+
+ stat_ev_if {
+ be_node_stats_t node_stats;
+
+ be_collect_node_stats(&node_stats, irg);
+ be_subtract_node_stats(&node_stats, &last_node_stats);
+ be_emit_node_stats(&node_stats, "bechordal_");
+
+ be_copy_node_stats(&last_node_stats, &node_stats);
+ stat_ev_ctx_pop("bechordal_cls");
+ }