2 * @file bechordal_main.c
4 * @author Sebastian Hack
7 * Copyright (C) 2005-2006 Universitaet Karlsruhe
8 * Released under the GPL
10 * Driver for the chordal register allocator.
23 #include "firm_config.h"
26 #include <libcore/lc_opts.h>
27 #include <libcore/lc_opts_enum.h>
28 #include <libcore/lc_timing.h>
29 #endif /* WITH_LIBCORE */
33 #include "irgraph_t.h"
34 #include "irprintf_t.h"
47 #include "bechordal_t.h"
49 #include "bejavacoal.h"
53 #include "besched_t.h"
57 #include "beifg_impl.h"
59 #include "bestatevent.h"
62 #include "bespillbelady.h"
63 #include "bespillmorgan.h"
64 #include "bespillslots.h"
65 #include "bespilloptions.h"
69 #include "bespillremat.h"
72 #include "bejavacoal.h"
73 #include "becopystat.h"
74 #include "becopyopt.h"
75 #include "bessadestr.h"
77 #include "bespillcost.h"
80 void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
81 const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
84 ir_node **nodes, *n1, *n2;
86 DEBUG_ONLY(firm_dbg_module_t *dbg = chordal_env->dbg;)
88 /* Collect all irns */
90 pmap_foreach(chordal_env->border_heads, pme) {
92 struct list_head *head = pme->value;
93 list_for_each_entry(border_t, curr, head, list)
94 if (curr->is_def && curr->is_real)
95 if (arch_get_irn_reg_class(arch_env, curr->irn, -1) == chordal_env->cls)
96 obstack_ptr_grow(&ob, curr->irn);
98 obstack_ptr_grow(&ob, NULL);
99 nodes = (ir_node **) obstack_finish(&ob);
102 for (i = 0, n1 = nodes[i]; n1; n1 = nodes[++i]) {
103 const arch_register_t *n1_reg, *n2_reg;
105 n1_reg = arch_get_irn_register(arch_env, n1);
106 if (!arch_reg_is_allocatable(arch_env, n1, -1, n1_reg)) {
107 DBG((dbg, 0, "Register %s assigned to %+F is not allowed\n", n1_reg->name, n1));
108 assert(0 && "Register constraint does not hold");
110 for (o = i+1, n2 = nodes[o]; n2; n2 = nodes[++o]) {
111 n2_reg = arch_get_irn_register(arch_env, n2);
112 if (values_interfere(chordal_env->lv, n1, n2) && n1_reg == n2_reg) {
113 DBG((dbg, 0, "Values %+F and %+F interfere and have the same register assigned: %s\n", n1, n2, n1_reg->name));
114 assert(0 && "Interfering values have the same color!");
118 obstack_free(&ob, NULL);
121 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b)
124 return be_ifg_connected(env->ifg, a, b);
126 return values_interfere(env->lv, a, b);
130 static be_ra_chordal_opts_t options = {
134 BE_CH_LOWER_PERM_SWAP,
138 /** Enable extreme live range splitting. */
139 static int be_elr_split = 0;
141 /** Assumed loop iteration count for execution frequency estimation. */
142 static int be_loop_weight = 9;
145 static be_ra_timer_t ra_timer = {
159 static const lc_opt_enum_int_items_t spill_items[] = {
160 { "morgan", BE_CH_SPILL_MORGAN },
161 { "belady", BE_CH_SPILL_BELADY },
163 { "remat", BE_CH_SPILL_REMAT },
164 #endif /* WITH_ILP */
168 static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
169 { "std", BE_CH_IFG_STD },
170 { "fast", BE_CH_IFG_FAST },
171 { "clique", BE_CH_IFG_CLIQUE },
172 { "pointer", BE_CH_IFG_POINTER },
173 { "list", BE_CH_IFG_LIST },
174 { "check", BE_CH_IFG_CHECK },
178 static const lc_opt_enum_int_items_t lower_perm_items[] = {
179 { "copy", BE_CH_LOWER_PERM_COPY },
180 { "swap", BE_CH_LOWER_PERM_SWAP },
184 static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
188 static const lc_opt_enum_int_items_t dump_items[] = {
189 { "spill", BE_CH_DUMP_SPILL },
190 { "live", BE_CH_DUMP_LIVE },
191 { "color", BE_CH_DUMP_COLOR },
192 { "copymin", BE_CH_DUMP_COPYMIN },
193 { "ssadestr", BE_CH_DUMP_SSADESTR },
194 { "tree", BE_CH_DUMP_TREE_INTV },
195 { "constr", BE_CH_DUMP_CONSTR },
196 { "lower", BE_CH_DUMP_LOWER },
197 { "spillslots", BE_CH_DUMP_SPILLSLOTS },
198 { "appel", BE_CH_DUMP_APPEL },
199 { "all", BE_CH_DUMP_ALL },
203 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
204 { "off", BE_CH_VRFY_OFF },
205 { "warn", BE_CH_VRFY_WARN },
206 { "assert", BE_CH_VRFY_ASSERT },
210 static lc_opt_enum_int_var_t spill_var = {
211 &options.spill_method, spill_items
214 static lc_opt_enum_int_var_t ifg_flavor_var = {
215 &options.ifg_flavor, ifg_flavor_items
218 static lc_opt_enum_int_var_t lower_perm_var = {
219 &options.lower_perm_opt, lower_perm_items
222 static lc_opt_enum_int_var_t dump_var = {
223 &options.dump_flags, dump_items
226 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
227 &options.vrfy_option, be_ch_vrfy_items
230 static const lc_opt_table_entry_t be_chordal_options[] = {
231 LC_OPT_ENT_ENUM_INT ("spill", "spill method", &spill_var),
232 LC_OPT_ENT_ENUM_PTR ("ifg", "interference graph flavour", &ifg_flavor_var),
233 LC_OPT_ENT_ENUM_PTR ("perm", "perm lowering options", &lower_perm_var),
234 LC_OPT_ENT_ENUM_MASK("dump", "select dump phases", &dump_var),
235 LC_OPT_ENT_ENUM_PTR ("vrfy", "verify options", &be_ch_vrfy_var),
236 LC_OPT_ENT_BOOL ("elrsplit", "enable extreme live range splitting", &be_elr_split),
237 LC_OPT_ENT_INT ("loop_weight", "assumed amount of loop iterations for guessing the execution frequency", &be_loop_weight),
241 extern void be_spill_remat_register_options(lc_opt_entry_t *ent);
244 static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
246 static int run_once = 0;
247 lc_opt_entry_t *chordal_grp;
251 chordal_grp = lc_opt_get_grp(grp, "chordal");
253 lc_opt_add_table(chordal_grp, be_chordal_options);
255 co_register_options(chordal_grp);
256 be_java_coal_register_options(chordal_grp);
258 be_spill_remat_register_options(chordal_grp);
260 be_spill_register_options(chordal_grp);
263 #endif /* WITH_LIBCORE */
265 static void dump(unsigned mask, ir_graph *irg,
266 const arch_register_class_t *cls,
268 void (*dump_func)(ir_graph *, const char *))
270 if((options.dump_flags & mask) == mask) {
273 snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
274 be_dump(irg, buf, dump_func);
277 be_dump(irg, suffix, dump_func);
281 static void put_ignore_colors(be_chordal_env_t *chordal_env)
283 int n_colors = chordal_env->cls->n_regs;
286 bitset_clear_all(chordal_env->ignore_colors);
287 be_abi_put_ignore_regs(chordal_env->birg->abi, chordal_env->cls, chordal_env->ignore_colors);
288 for(i = 0; i < n_colors; ++i)
289 if(arch_register_type_is(&chordal_env->cls->regs[i], ignore))
290 bitset_set(chordal_env->ignore_colors, i);
293 FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const char *suffix)
297 ir_snprintf(buf, sizeof(buf), "%s%F_%s%s", prefix, env->irg, env->cls->name, suffix);
298 return fopen(buf, "wt");
301 void check_ifg_implementations(be_chordal_env_t *chordal_env)
305 f = be_chordal_open(chordal_env, "std", ".log");
306 chordal_env->ifg = be_ifg_std_new(chordal_env);
307 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
310 f = be_chordal_open(chordal_env, "list", ".log");
311 be_ifg_free(chordal_env->ifg);
312 chordal_env->ifg = be_ifg_list_new(chordal_env);
313 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
316 f = be_chordal_open(chordal_env, "clique", ".log");
317 be_ifg_free(chordal_env->ifg);
318 chordal_env->ifg = be_ifg_clique_new(chordal_env);
319 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
322 f = be_chordal_open(chordal_env, "pointer", ".log");
323 be_ifg_free(chordal_env->ifg);
324 chordal_env->ifg = be_ifg_pointer_new(chordal_env);
325 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
328 chordal_env->ifg = NULL;
332 * Checks for every reload if it's user can perform the load on itself.
334 static void memory_operand_walker(ir_node *irn, void *env) {
335 be_chordal_env_t *cenv = env;
336 const arch_env_t *aenv = cenv->birg->main_env->arch_env;
337 const ir_edge_t *edge, *ne;
341 if (! be_is_Reload(irn))
344 /* always use addressmode, it's good for x86 */
346 /* only use memory operands, if the reload is only used by 1 node */
347 if(get_irn_n_edges(irn) > 1)
351 spill = be_get_Reload_mem(irn);
352 block = get_nodes_block(irn);
354 foreach_out_edge_safe(irn, edge, ne) {
355 ir_node *src = get_edge_src_irn(edge);
356 int pos = get_edge_src_pos(edge);
358 assert(src && "outedges broken!");
360 if (get_nodes_block(src) == block && arch_possible_memory_operand(aenv, src, pos)) {
361 DBG((cenv->dbg, LEVEL_3, "performing memory operand %+F at %+F\n", irn, src));
362 arch_perform_memory_operand(aenv, src, spill, pos);
366 /* kill the Reload */
367 if (get_irn_n_edges(irn) == 0) {
369 set_irn_n(irn, 0, new_Bad());
370 set_irn_n(irn, 1, new_Bad());
375 * Starts a walk for memory operands if supported by the backend.
377 static INLINE void check_for_memory_operands(be_chordal_env_t *chordal_env) {
378 irg_walk_graph(chordal_env->irg, NULL, memory_operand_walker, chordal_env);
382 * Sorry for doing stats again...
384 typedef struct _node_stat_t {
385 unsigned int n_phis; /**< Phis of the current register class. */
386 unsigned int n_mem_phis; /**< Memory Phis (Phis with spill operands). */
387 unsigned int n_copies; /**< Copies */
388 unsigned int n_perms; /**< Perms */
389 unsigned int n_spills; /**< Spill nodes */
390 unsigned int n_reloads; /**< Reloads */
393 struct node_stat_walker {
395 const be_chordal_env_t *cenv;
399 static void node_stat_walker(ir_node *irn, void *data)
401 struct node_stat_walker *env = data;
402 const arch_env_t *aenv = env->cenv->birg->main_env->arch_env;
404 if(arch_irn_consider_in_reg_alloc(aenv, env->cenv->cls, irn)) {
406 /* if the node is a normal phi */
410 else if(arch_irn_classify(aenv, irn) & arch_irn_class_spill)
411 ++env->stat->n_spills;
413 else if(arch_irn_classify(aenv, irn) & arch_irn_class_reload)
414 ++env->stat->n_reloads;
416 else if(arch_irn_classify(aenv, irn) & arch_irn_class_copy)
417 ++env->stat->n_copies;
419 else if(arch_irn_classify(aenv, irn) & arch_irn_class_perm)
420 ++env->stat->n_perms;
423 /* a mem phi is a PhiM with a mem phi operand or a Spill operand */
424 else if(is_Phi(irn) && get_irn_mode(irn) == mode_M) {
427 for(i = get_irn_arity(irn) - 1; i >= 0; --i) {
428 ir_node *op = get_irn_n(irn, i);
430 if((is_Phi(op) && bitset_contains_irn(env->mem_phis, op)) || (arch_irn_classify(aenv, op) & arch_irn_class_spill)) {
431 bitset_add_irn(env->mem_phis, irn);
432 env->stat->n_mem_phis++;
439 static void node_stats(const be_chordal_env_t *cenv, node_stat_t *stat)
441 struct node_stat_walker env;
443 memset(stat, 0, sizeof(stat[0]));
445 env.mem_phis = bitset_irg_malloc(cenv->irg);
447 irg_walk_graph(cenv->irg, NULL, node_stat_walker, &env);
448 bitset_free(env.mem_phis);
451 static void insn_count_walker(ir_node *irn, void *data)
455 switch(get_irn_opcode(irn)) {
466 static unsigned int count_insns(ir_graph *irg)
469 irg_walk_graph(irg, insn_count_walker, NULL, &cnt);
475 * Initialize all timers.
477 static void be_init_timer(be_options_t *main_opts)
479 if (main_opts->timing == BE_TIME_ON) {
480 ra_timer.t_prolog = lc_timer_register("ra_prolog", "regalloc prolog");
481 ra_timer.t_epilog = lc_timer_register("ra_epilog", "regalloc epilog");
482 ra_timer.t_live = lc_timer_register("ra_liveness", "be liveness");
483 ra_timer.t_spill = lc_timer_register("ra_spill", "spiller");
484 ra_timer.t_spillslots = lc_timer_register("ra_spillslots", "spillslots");
485 ra_timer.t_color = lc_timer_register("ra_color", "graph coloring");
486 ra_timer.t_ifg = lc_timer_register("ra_ifg", "interference graph");
487 ra_timer.t_copymin = lc_timer_register("ra_copymin", "copy minimization");
488 ra_timer.t_ssa = lc_timer_register("ra_ssadestr", "ssa destruction");
489 ra_timer.t_verify = lc_timer_register("ra_verify", "graph verification");
490 ra_timer.t_other = lc_timer_register("ra_other", "other time");
492 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
493 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
494 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
495 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
496 LC_STOP_AND_RESET_TIMER(ra_timer.t_spillslots);
497 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
498 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
499 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
500 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
501 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
502 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
506 #define BE_TIMER_INIT(main_opts) be_init_timer(main_opts)
508 #define BE_TIMER_PUSH(timer) \
509 if (main_opts->timing == BE_TIME_ON) { \
510 if (! lc_timer_push(timer)) { \
511 if (options.vrfy_option == BE_CH_VRFY_ASSERT) \
512 assert(!"Timer already on stack, cannot be pushed twice."); \
513 else if (options.vrfy_option == BE_CH_VRFY_WARN) \
514 fprintf(stderr, "Timer %s already on stack, cannot be pushed twice.\n", \
515 lc_timer_get_name(timer)); \
518 #define BE_TIMER_POP(timer) \
519 if (main_opts->timing == BE_TIME_ON) { \
520 lc_timer_t *tmp = lc_timer_pop(); \
521 if (options.vrfy_option == BE_CH_VRFY_ASSERT) \
522 assert(tmp == timer && "Attempt to pop wrong timer."); \
523 else if (options.vrfy_option == BE_CH_VRFY_WARN && tmp != timer) \
524 fprintf(stderr, "Attempt to pop wrong timer. %s is on stack, trying to pop %s.\n", \
525 lc_timer_get_name(tmp), lc_timer_get_name(timer)); \
530 #define BE_TIMER_INIT(main_opts)
531 #define BE_TIMER_PUSH(timer)
532 #define BE_TIMER_POP(timer)
534 #endif /* WITH_LIBCORE */
537 * Performs chordal register allocation for each register class on given irg.
539 * @param bi Backend irg object
540 * @return Structure containing timer for the single phases or NULL if no timing requested.
542 static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
544 const be_main_env_t *main_env = bi->main_env;
545 const arch_isa_t *isa = arch_env_get_isa(main_env->arch_env);
546 ir_graph *irg = bi->irg;
547 be_options_t *main_opts = main_env->options;
551 be_chordal_env_t chordal_env;
553 BE_TIMER_INIT(main_opts);
554 BE_TIMER_PUSH(ra_timer.t_other);
555 BE_TIMER_PUSH(ra_timer.t_prolog);
559 chordal_env.opts = &options;
560 chordal_env.irg = irg;
561 chordal_env.birg = bi;
562 chordal_env.dom_front = be_compute_dominance_frontiers(irg);
563 chordal_env.exec_freq = bi->execfreqs;
564 chordal_env.lv = be_liveness(irg);
565 FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
567 obstack_init(&chordal_env.obst);
569 BE_TIMER_POP(ra_timer.t_prolog);
571 be_stat_ev("insns_before", count_insns(irg));
573 /* Perform the following for each register class. */
574 for (j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
575 node_stat_t node_stat;
576 double spillcosts = 0;
578 chordal_env.cls = arch_isa_get_reg_class(isa, j);
579 chordal_env.border_heads = pmap_create();
580 chordal_env.ignore_colors = bitset_malloc(chordal_env.cls->n_regs);
582 if(be_stat_ev_is_active()) {
583 be_stat_tags[STAT_TAG_CLS] = chordal_env.cls->name;
584 be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
586 /* perform some node statistics. */
587 node_stats(&chordal_env, &node_stat);
588 be_stat_ev("phis_before_spill", node_stat.n_phis);
591 /* put all ignore registers into the ignore register set. */
592 put_ignore_colors(&chordal_env);
594 BE_TIMER_PUSH(ra_timer.t_live);
595 be_liveness_recompute(chordal_env.lv);
596 BE_TIMER_POP(ra_timer.t_live);
597 dump(BE_CH_DUMP_LIVE, irg, chordal_env.cls, "-live", dump_ir_block_graph_sched);
599 be_pre_spill_prepare_constr(&chordal_env);
600 dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-constr-pre", dump_ir_block_graph_sched);
602 if(be_stat_ev_is_active()) {
603 spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, chordal_env.exec_freq);
606 BE_TIMER_PUSH(ra_timer.t_spill);
609 switch(options.spill_method) {
610 case BE_CH_SPILL_MORGAN:
611 be_spill_morgan(&chordal_env);
613 case BE_CH_SPILL_BELADY:
614 be_spill_belady(&chordal_env);
617 case BE_CH_SPILL_REMAT:
618 be_spill_remat(&chordal_env);
620 #endif /* WITH_ILP */
622 fprintf(stderr, "no valid spiller selected. falling back to belady\n");
623 be_spill_belady(&chordal_env);
626 BE_TIMER_POP(ra_timer.t_spill);
628 if(be_stat_ev_is_active()) {
629 spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, chordal_env.exec_freq) - spillcosts;
630 be_stat_ev_l("spillcosts", (long) spillcosts);
632 node_stats(&chordal_env, &node_stat);
633 be_stat_ev("phis_after_spill", node_stat.n_phis);
634 be_stat_ev("mem_phis", node_stat.n_mem_phis);
635 be_stat_ev("reloads", node_stat.n_reloads);
636 be_stat_ev("spills", node_stat.n_spills);
639 DBG((chordal_env.dbg, LEVEL_1, "spill costs for %+F in regclass %s: %g\n",irg, chordal_env.cls->name, get_irg_spill_cost(&chordal_env)));
641 dump(BE_CH_DUMP_SPILL, irg, chordal_env.cls, "-spill", dump_ir_block_graph_sched);
643 check_for_memory_operands(&chordal_env);
645 be_abi_fix_stack_nodes(bi->abi, chordal_env.lv);
647 BE_TIMER_PUSH(ra_timer.t_verify);
649 /* verify schedule and register pressure */
650 if (options.vrfy_option == BE_CH_VRFY_WARN) {
651 be_verify_schedule(irg);
652 be_verify_register_pressure(chordal_env.birg, chordal_env.cls, irg);
654 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
655 assert(be_verify_schedule(irg) && "Schedule verification failed");
656 assert(be_verify_register_pressure(chordal_env.birg, chordal_env.cls, irg)
657 && "Register pressure verification failed");
659 BE_TIMER_POP(ra_timer.t_verify);
661 if (be_elr_split && ! splitted) {
662 extreme_liverange_splitting(&chordal_env);
667 /* Color the graph. */
668 BE_TIMER_PUSH(ra_timer.t_color);
669 be_ra_chordal_color(&chordal_env);
670 BE_TIMER_POP(ra_timer.t_color);
672 dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
674 /* Create the ifg with the selected flavor */
675 BE_TIMER_PUSH(ra_timer.t_ifg);
676 switch (options.ifg_flavor) {
678 fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
681 chordal_env.ifg = be_ifg_std_new(&chordal_env);
683 case BE_CH_IFG_CLIQUE:
684 chordal_env.ifg = be_ifg_clique_new(&chordal_env);
686 case BE_CH_IFG_POINTER:
687 chordal_env.ifg = be_ifg_pointer_new(&chordal_env);
690 chordal_env.ifg = be_ifg_list_new(&chordal_env);
692 case BE_CH_IFG_CHECK:
693 check_ifg_implementations(&chordal_env);
694 /* Build the interference graph. */
695 chordal_env.ifg = be_ifg_std_new(&chordal_env);
698 BE_TIMER_POP(ra_timer.t_ifg);
700 if(be_stat_ev_is_active()) {
702 be_ifg_stat(&chordal_env, &stat);
703 be_stat_ev("ifg_nodes", stat.n_nodes);
704 be_stat_ev("ifg_edges", stat.n_edges);
705 be_stat_ev("ifg_comps", stat.n_comps);
708 BE_TIMER_PUSH(ra_timer.t_verify);
709 if (options.vrfy_option != BE_CH_VRFY_OFF) {
710 //be_ra_chordal_check(&chordal_env);
713 BE_TIMER_POP(ra_timer.t_verify);
715 if(be_stat_ev_is_active()) {
716 node_stats(&chordal_env, &node_stat);
717 be_stat_ev("perms_before_coal", node_stat.n_perms);
718 be_stat_ev("copies_before_coal", node_stat.n_copies);
721 /* copy minimization */
722 BE_TIMER_PUSH(ra_timer.t_copymin);
723 co_driver(&chordal_env);
724 BE_TIMER_POP(ra_timer.t_copymin);
726 dump(BE_CH_DUMP_COPYMIN, irg, chordal_env.cls, "-copymin", dump_ir_block_graph_sched);
728 BE_TIMER_PUSH(ra_timer.t_verify);
730 if (options.vrfy_option != BE_CH_VRFY_OFF) {
731 //be_ra_chordal_check(&chordal_env);
734 BE_TIMER_POP(ra_timer.t_verify);
735 BE_TIMER_PUSH(ra_timer.t_ssa);
737 /* ssa destruction */
738 be_ssa_destruction(&chordal_env);
740 BE_TIMER_POP(ra_timer.t_ssa);
742 dump(BE_CH_DUMP_SSADESTR, irg, chordal_env.cls, "-ssadestr", dump_ir_block_graph_sched);
744 BE_TIMER_PUSH(ra_timer.t_verify);
745 if (options.vrfy_option != BE_CH_VRFY_OFF) {
746 be_ssa_destruction_check(&chordal_env);
747 //be_ra_chordal_check(&chordal_env);
749 BE_TIMER_POP(ra_timer.t_verify);
751 be_ifg_free(chordal_env.ifg);
752 pmap_destroy(chordal_env.border_heads);
753 bitset_free(chordal_env.ignore_colors);
755 if(be_stat_ev_is_active()) {
756 node_stats(&chordal_env, &node_stat);
757 be_stat_ev("perms_after_coal", node_stat.n_perms);
758 be_stat_ev("copies_after_coal", node_stat.n_copies);
764 BE_TIMER_PUSH(ra_timer.t_spillslots);
766 be_coalesce_spillslots(&chordal_env);
767 dump(BE_CH_DUMP_SPILLSLOTS, irg, NULL, "-spillslots", dump_ir_block_graph_sched);
769 BE_TIMER_POP(ra_timer.t_spillslots);
771 BE_TIMER_PUSH(ra_timer.t_verify);
773 /* verify spillslots */
774 if (options.vrfy_option == BE_CH_VRFY_WARN) {
775 be_verify_spillslots(main_env->arch_env, irg);
777 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
778 assert(be_verify_spillslots(main_env->arch_env, irg) && "Spillslot verification failed");
780 BE_TIMER_POP(ra_timer.t_verify);
782 BE_TIMER_PUSH(ra_timer.t_epilog);
784 dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
786 lower_nodes_after_ra(&chordal_env, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
787 dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
789 obstack_free(&chordal_env.obst, NULL);
790 be_free_dominance_frontiers(chordal_env.dom_front);
791 be_liveness_free(chordal_env.lv);
793 BE_TIMER_POP(ra_timer.t_epilog);
794 BE_TIMER_POP(ra_timer.t_other);
796 be_stat_ev("insns_after", count_insns(irg));
799 return main_opts->timing == BE_TIME_ON ? &ra_timer : NULL;
800 #endif /* WITH_LIBCORE */
804 const be_ra_t be_ra_chordal_allocator = {
806 be_ra_chordal_register_options,