- be_options_t *main_opts = main_env->options;
- static int splitted = 0;
- node_stat_t node_stat;
-
-#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_ev_l("spillcosts", (long) spillcosts);
-
- node_stats(chordal_env, &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 */
-
- check_for_memory_operands(chordal_env);
-
- be_abi_fix_stack_nodes(birg->abi, birg->lv);
-
- BE_TIMER_PUSH(ra_timer.t_verify);
-
- /* verify schedule and register pressure */
- if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
- be_verify_schedule(irg);
- be_verify_register_pressure(chordal_env->birg, chordal_env->cls, irg);
- }
- else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
- assert(be_verify_schedule(irg) && "Schedule verification failed");
- assert(be_verify_register_pressure(chordal_env->birg, chordal_env->cls, irg)
- && "Register pressure verification failed");
- }
- BE_TIMER_POP(ra_timer.t_verify);
-
- if (be_elr_split && ! splitted) {
- extreme_liverange_splitting(chordal_env);
- splitted = 1;
- }
-
- /* Color the graph. */
- BE_TIMER_PUSH(ra_timer.t_color);
- be_ra_chordal_color(chordal_env);
- BE_TIMER_POP(ra_timer.t_color);
-
- dump(BE_CH_DUMP_CONSTR, irg, chordal_env->cls, "-color", dump_ir_block_graph_sched);
-
- /* Create the ifg with the selected flavor */
- BE_TIMER_PUSH(ra_timer.t_ifg);
- switch (chordal_env->opts->ifg_flavor) {
- default:
- fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
- case BE_CH_IFG_STD:
- case BE_CH_IFG_FAST:
- chordal_env->ifg = be_ifg_std_new(chordal_env);
- break;
- case BE_CH_IFG_CLIQUE:
- chordal_env->ifg = be_ifg_clique_new(chordal_env);
- break;
- case BE_CH_IFG_POINTER:
- chordal_env->ifg = be_ifg_pointer_new(chordal_env);
- break;
- case BE_CH_IFG_LIST:
- chordal_env->ifg = be_ifg_list_new(chordal_env);
- break;
- case BE_CH_IFG_CHECK:
- check_ifg_implementations(chordal_env);
- /* Build the interference graph. */
- chordal_env->ifg = be_ifg_std_new(chordal_env);
- break;
- }
- BE_TIMER_POP(ra_timer.t_ifg);
-
-#ifdef FIRM_STATISTICS
- if (be_stat_ev_is_active()) {
- be_ifg_stat_t stat;
- be_ifg_stat(chordal_env, &stat);
- be_stat_ev("ifg_nodes", stat.n_nodes);
- be_stat_ev("ifg_edges", stat.n_edges);
- be_stat_ev("ifg_comps", stat.n_comps);
-
- node_stats(chordal_env, &node_stat);
- be_stat_ev("perms_before_coal", node_stat.n_perms);
- be_stat_ev("copies_before_coal", node_stat.n_copies);
- }
-#endif /* FIRM_STATISTICS */
+ 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) {
+ stat_ev_dbl("bechordal_spillcosts", be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost);
+
+ /*
+ 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.
+ */
+ BE_TIMER_PUSH(t_ra_spill);
+ check_for_memory_operands(chordal_env);
+ if (iteration == 0) {
+ be_abi_fix_stack_nodes(birg->abi);
+ }
+ BE_TIMER_POP(t_ra_spill);
+
+ BE_TIMER_PUSH(t_verify);
+
+ /* verify schedule and register pressure */
+ if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
+ be_verify_schedule(birg);
+ be_verify_register_pressure(birg, pse->cls, irg);
+ } else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
+ assert(be_verify_schedule(birg) && "Schedule verification failed");
+ assert(be_verify_register_pressure(birg, pse->cls, irg)
+ && "Register pressure verification failed");
+ }
+ BE_TIMER_POP(t_verify);
+
+ /* Color the graph. */
+ BE_TIMER_PUSH(t_ra_color);
+ be_ra_chordal_color(chordal_env);
+ BE_TIMER_POP(t_ra_color);
+
+ dump(BE_CH_DUMP_CONSTR, irg, pse->cls, "-color", dump_ir_block_graph_sched);
+
+ /* Create the ifg with the selected flavor */
+ BE_TIMER_PUSH(t_ra_ifg);
+ chordal_env->ifg = be_create_ifg(chordal_env);
+ BE_TIMER_POP(t_ra_ifg);
+
+ stat_ev_if {
+ be_ifg_stat_t stat;
+ node_stat_t node_stat;
+
+ be_ifg_stat(birg, chordal_env->ifg, &stat);
+ stat_ev_dbl("bechordal_ifg_nodes", stat.n_nodes);
+ stat_ev_dbl("bechordal_ifg_edges", stat.n_edges);
+ stat_ev_dbl("bechordal_ifg_comps", stat.n_comps);
+
+ node_stats(birg, &node_stat);
+ stat_ev_dbl("bechordal_perms_before_coal",
+ node_stat.n_perms - last_node_stat.n_perms);
+ stat_ev_dbl("bechordal_copies_before_coal",
+ node_stat.n_copies - last_node_stat.n_copies);
+ }