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"
61 #include "bespillbelady.h"
62 #include "bespillmorgan.h"
63 #include "bespillslots.h"
67 #include "bespillremat.h"
70 #include "bejavacoal.h"
71 #include "becopystat.h"
72 #include "becopyopt.h"
73 #include "bessadestr.h"
75 #include "bespillcost.h"
78 void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
79 const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
82 ir_node **nodes, *n1, *n2;
84 DEBUG_ONLY(firm_dbg_module_t *dbg = chordal_env->dbg;)
86 /* Collect all irns */
88 pmap_foreach(chordal_env->border_heads, pme) {
90 struct list_head *head = pme->value;
91 list_for_each_entry(border_t, curr, head, list)
92 if (curr->is_def && curr->is_real)
93 if (arch_get_irn_reg_class(arch_env, curr->irn, -1) == chordal_env->cls)
94 obstack_ptr_grow(&ob, curr->irn);
96 obstack_ptr_grow(&ob, NULL);
97 nodes = (ir_node **) obstack_finish(&ob);
100 for (i = 0, n1 = nodes[i]; n1; n1 = nodes[++i]) {
101 const arch_register_t *n1_reg, *n2_reg;
103 n1_reg = arch_get_irn_register(arch_env, n1);
104 if (!arch_reg_is_allocatable(arch_env, n1, -1, n1_reg)) {
105 DBG((dbg, 0, "Register %s assigned to %+F is not allowed\n", n1_reg->name, n1));
106 assert(0 && "Register constraint does not hold");
108 for (o = i+1, n2 = nodes[o]; n2; n2 = nodes[++o]) {
109 n2_reg = arch_get_irn_register(arch_env, n2);
110 if (values_interfere(chordal_env->lv, n1, n2) && n1_reg == n2_reg) {
111 DBG((dbg, 0, "Values %+F and %+F interfere and have the same register assigned: %s\n", n1, n2, n1_reg->name));
112 assert(0 && "Interfering values have the same color!");
116 obstack_free(&ob, NULL);
119 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b)
122 return be_ifg_connected(env->ifg, a, b);
124 return values_interfere(env->lv, a, b);
128 static be_ra_chordal_opts_t options = {
132 BE_CH_LOWER_PERM_SWAP,
136 /* coalesce spill slots */
137 static int coalesce_spill_slots = 1;
139 /** The name of the file where the statistics are put to. */
140 static char stat_file_name[2048];
142 /** Enable extreme live range splitting. */
143 static int be_elr_split = 0;
145 /** Assumed loop iteration count for execution frequency estimation. */
146 static int be_loop_weight = 9;
149 static be_ra_timer_t ra_timer = {
163 static const lc_opt_enum_int_items_t spill_items[] = {
164 { "morgan", BE_CH_SPILL_MORGAN },
165 { "belady", BE_CH_SPILL_BELADY },
167 { "remat", BE_CH_SPILL_REMAT },
168 #endif /* WITH_ILP */
172 static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
173 { "std", BE_CH_IFG_STD },
174 { "fast", BE_CH_IFG_FAST },
175 { "clique", BE_CH_IFG_CLIQUE },
176 { "pointer", BE_CH_IFG_POINTER },
177 { "list", BE_CH_IFG_LIST },
178 { "check", BE_CH_IFG_CHECK },
182 static const lc_opt_enum_int_items_t lower_perm_items[] = {
183 { "copy", BE_CH_LOWER_PERM_COPY },
184 { "swap", BE_CH_LOWER_PERM_SWAP },
188 static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
192 static const lc_opt_enum_int_items_t dump_items[] = {
193 { "spill", BE_CH_DUMP_SPILL },
194 { "live", BE_CH_DUMP_LIVE },
195 { "color", BE_CH_DUMP_COLOR },
196 { "copymin", BE_CH_DUMP_COPYMIN },
197 { "ssadestr", BE_CH_DUMP_SSADESTR },
198 { "tree", BE_CH_DUMP_TREE_INTV },
199 { "constr", BE_CH_DUMP_CONSTR },
200 { "lower", BE_CH_DUMP_LOWER },
201 { "spillslots", BE_CH_DUMP_SPILLSLOTS },
202 { "appel", BE_CH_DUMP_APPEL },
203 { "all", BE_CH_DUMP_ALL },
207 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
208 { "off", BE_CH_VRFY_OFF },
209 { "warn", BE_CH_VRFY_WARN },
210 { "assert", BE_CH_VRFY_ASSERT },
214 static lc_opt_enum_int_var_t spill_var = {
215 &options.spill_method, spill_items
218 static lc_opt_enum_int_var_t ifg_flavor_var = {
219 &options.ifg_flavor, ifg_flavor_items
222 static lc_opt_enum_int_var_t lower_perm_var = {
223 &options.lower_perm_opt, lower_perm_items
226 static lc_opt_enum_int_var_t dump_var = {
227 &options.dump_flags, dump_items
230 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
231 &options.vrfy_option, be_ch_vrfy_items
234 static const lc_opt_table_entry_t be_chordal_options[] = {
235 LC_OPT_ENT_STR ("statfile", "the name of the statisctics file", stat_file_name, sizeof(stat_file_name)),
236 LC_OPT_ENT_BOOL ("spill.coal", "coalesce the spill slots (default: yes)", &coalesce_spill_slots),
237 LC_OPT_ENT_ENUM_INT ("spill", "spill method (belady, morgan or remat)", &spill_var),
238 LC_OPT_ENT_ENUM_PTR ("ifg", "interference graph flavour (std, fast, clique, pointer, list, check)", &ifg_flavor_var),
239 LC_OPT_ENT_ENUM_PTR ("perm", "perm lowering options (copy or swap)", &lower_perm_var),
240 LC_OPT_ENT_ENUM_MASK("dump", "select dump phases", &dump_var),
241 LC_OPT_ENT_ENUM_PTR ("vrfy", "verify options (off, warn, assert)", &be_ch_vrfy_var),
242 LC_OPT_ENT_BOOL ("elrsplit", "enable extreme live range splitting", &be_elr_split),
243 LC_OPT_ENT_INT ("loop_weight", "assumed amount of loop iterations for guessing the execution frequency", &be_loop_weight),
247 extern void be_spill_remat_register_options(lc_opt_entry_t *ent);
250 static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
252 static int run_once = 0;
253 lc_opt_entry_t *chordal_grp;
257 chordal_grp = lc_opt_get_grp(grp, "chordal");
259 lc_opt_add_table(chordal_grp, be_chordal_options);
261 co_register_options(chordal_grp);
262 be_java_coal_register_options(chordal_grp);
264 be_spill_remat_register_options(chordal_grp);
268 #endif /* WITH_LIBCORE */
270 static void dump(unsigned mask, ir_graph *irg,
271 const arch_register_class_t *cls,
273 void (*dump_func)(ir_graph *, const char *))
275 if((options.dump_flags & mask) == mask) {
278 snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
279 be_dump(irg, buf, dump_func);
282 be_dump(irg, suffix, dump_func);
286 static void put_ignore_colors(be_chordal_env_t *chordal_env)
288 int n_colors = chordal_env->cls->n_regs;
291 bitset_clear_all(chordal_env->ignore_colors);
292 be_abi_put_ignore_regs(chordal_env->birg->abi, chordal_env->cls, chordal_env->ignore_colors);
293 for(i = 0; i < n_colors; ++i)
294 if(arch_register_type_is(&chordal_env->cls->regs[i], ignore))
295 bitset_set(chordal_env->ignore_colors, i);
298 FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const char *suffix)
302 ir_snprintf(buf, sizeof(buf), "%s%F_%s%s", prefix, env->irg, env->cls->name, suffix);
303 return fopen(buf, "wt");
306 void check_ifg_implementations(be_chordal_env_t *chordal_env)
310 f = be_chordal_open(chordal_env, "std", ".log");
311 chordal_env->ifg = be_ifg_std_new(chordal_env);
312 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
315 f = be_chordal_open(chordal_env, "list", ".log");
316 be_ifg_free(chordal_env->ifg);
317 chordal_env->ifg = be_ifg_list_new(chordal_env);
318 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
321 f = be_chordal_open(chordal_env, "clique", ".log");
322 be_ifg_free(chordal_env->ifg);
323 chordal_env->ifg = be_ifg_clique_new(chordal_env);
324 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
327 f = be_chordal_open(chordal_env, "pointer", ".log");
328 be_ifg_free(chordal_env->ifg);
329 chordal_env->ifg = be_ifg_pointer_new(chordal_env);
330 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
333 chordal_env->ifg = NULL;
337 * Checks for every reload if it's user can perform the load on itself.
339 static void memory_operand_walker(ir_node *irn, void *env) {
340 be_chordal_env_t *cenv = env;
341 const arch_env_t *aenv = cenv->birg->main_env->arch_env;
342 const ir_edge_t *edge, *ne;
346 if (! be_is_Reload(irn))
349 /* always use addressmode, it's good for x86 */
351 /* only use memory operands, if the reload is only used by 1 node */
352 if(get_irn_n_edges(irn) > 1)
356 spill = be_get_Reload_mem(irn);
357 block = get_nodes_block(irn);
359 foreach_out_edge_safe(irn, edge, ne) {
360 ir_node *src = get_edge_src_irn(edge);
361 int pos = get_edge_src_pos(edge);
366 if (get_nodes_block(src) == block && arch_possible_memory_operand(aenv, src, pos)) {
367 DBG((cenv->dbg, LEVEL_3, "performing memory operand %+F at %+F\n", irn, src));
368 arch_perform_memory_operand(aenv, src, spill, pos);
372 /* kill the Reload */
373 if (get_irn_n_edges(irn) == 0) {
375 set_irn_n(irn, 0, new_Bad());
376 set_irn_n(irn, 1, new_Bad());
381 * Starts a walk for memory operands if supported by the backend.
383 static INLINE void check_for_memory_operands(be_chordal_env_t *chordal_env) {
384 irg_walk_graph(chordal_env->irg, NULL, memory_operand_walker, chordal_env);
388 * Sorry for doing stats again...
390 typedef struct _node_stat_t {
391 unsigned int n_phis; /**< Phis of the current register class. */
392 unsigned int n_mem_phis; /**< Memory Phis (Phis with spill operands). */
393 unsigned int n_copies; /**< Copies */
394 unsigned int n_perms; /**< Perms */
395 unsigned int n_spills; /**< Spill nodes */
396 unsigned int n_reloads; /**< Reloads */
399 struct node_stat_walker {
401 const be_chordal_env_t *cenv;
405 static void node_stat_walker(ir_node *irn, void *data)
407 struct node_stat_walker *env = data;
408 const arch_env_t *aenv = env->cenv->birg->main_env->arch_env;
410 if(arch_irn_consider_in_reg_alloc(aenv, env->cenv->cls, irn)) {
412 /* if the node is a normal phi */
416 else if(arch_irn_classify(aenv, irn) & arch_irn_class_spill)
417 ++env->stat->n_spills;
419 else if(arch_irn_classify(aenv, irn) & arch_irn_class_reload)
420 ++env->stat->n_reloads;
422 else if(arch_irn_classify(aenv, irn) & arch_irn_class_copy)
423 ++env->stat->n_copies;
425 else if(arch_irn_classify(aenv, irn) & arch_irn_class_perm)
426 ++env->stat->n_perms;
429 /* a mem phi is a PhiM with a mem phi operand or a Spill operand */
430 else if(is_Phi(irn) && get_irn_mode(irn) == mode_M) {
433 for(i = get_irn_arity(irn) - 1; i >= 0; --i) {
434 ir_node *op = get_irn_n(irn, i);
436 if((is_Phi(op) && bitset_contains_irn(env->mem_phis, op)) || (arch_irn_classify(aenv, op) & arch_irn_class_spill)) {
437 bitset_add_irn(env->mem_phis, irn);
438 env->stat->n_mem_phis++;
445 static void node_stats(const be_chordal_env_t *cenv, node_stat_t *stat)
447 struct node_stat_walker env;
449 memset(stat, 0, sizeof(stat[0]));
451 env.mem_phis = bitset_irg_malloc(cenv->irg);
453 irg_walk_graph(cenv->irg, NULL, node_stat_walker, &env);
454 bitset_free(env.mem_phis);
457 static void insn_count_walker(ir_node *irn, void *data)
461 switch(get_irn_opcode(irn)) {
472 static unsigned int count_insns(ir_graph *irg)
475 irg_walk_graph(irg, insn_count_walker, NULL, &cnt);
481 * Initialize all timers.
483 static void be_init_timer(be_options_t *main_opts)
485 if (main_opts->timing == BE_TIME_ON) {
486 ra_timer.t_prolog = lc_timer_register("ra_prolog", "regalloc prolog");
487 ra_timer.t_epilog = lc_timer_register("ra_epilog", "regalloc epilog");
488 ra_timer.t_live = lc_timer_register("ra_liveness", "be liveness");
489 ra_timer.t_spill = lc_timer_register("ra_spill", "spiller");
490 ra_timer.t_spillslots = lc_timer_register("ra_spillslots", "spillslots");
491 ra_timer.t_color = lc_timer_register("ra_color", "graph coloring");
492 ra_timer.t_ifg = lc_timer_register("ra_ifg", "interference graph");
493 ra_timer.t_copymin = lc_timer_register("ra_copymin", "copy minimization");
494 ra_timer.t_ssa = lc_timer_register("ra_ssadestr", "ssa destruction");
495 ra_timer.t_verify = lc_timer_register("ra_verify", "graph verification");
496 ra_timer.t_other = lc_timer_register("ra_other", "other time");
498 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
499 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
500 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
501 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
502 LC_STOP_AND_RESET_TIMER(ra_timer.t_spillslots);
503 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
504 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
505 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
506 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
507 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
508 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
512 #define BE_TIMER_INIT(main_opts) be_init_timer(main_opts)
514 #define BE_TIMER_PUSH(timer) \
515 if (main_opts->timing == BE_TIME_ON) { \
516 if (! lc_timer_push(timer)) { \
517 if (options.vrfy_option == BE_CH_VRFY_ASSERT) \
518 assert(!"Timer already on stack, cannot be pushed twice."); \
519 else if (options.vrfy_option == BE_CH_VRFY_WARN) \
520 fprintf(stderr, "Timer %s already on stack, cannot be pushed twice.\n", \
521 lc_timer_get_name(timer)); \
524 #define BE_TIMER_POP(timer) \
525 if (main_opts->timing == BE_TIME_ON) { \
526 lc_timer_t *tmp = lc_timer_pop(); \
527 if (options.vrfy_option == BE_CH_VRFY_ASSERT) \
528 assert(tmp == timer && "Attempt to pop wrong timer."); \
529 else if (options.vrfy_option == BE_CH_VRFY_WARN && tmp != timer) \
530 fprintf(stderr, "Attempt to pop wrong timer. %s is on stack, trying to pop %s.\n", \
531 lc_timer_get_name(tmp), lc_timer_get_name(timer)); \
536 #define BE_TIMER_INIT(main_opts)
537 #define BE_TIMER_PUSH(timer)
538 #define BE_TIMER_POP(timer)
540 #endif /* WITH_LIBCORE */
551 * Performs chordal register allocation for each register class on given irg.
553 * @param bi Backend irg object
554 * @return Structure containing timer for the single phases or NULL if no timing requested.
556 static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
558 const be_main_env_t *main_env = bi->main_env;
559 const arch_isa_t *isa = arch_env_get_isa(main_env->arch_env);
560 ir_graph *irg = bi->irg;
561 be_options_t *main_opts = main_env->options;
563 FILE *stat_file = NULL;
568 be_chordal_env_t chordal_env;
569 const char *stat_tags[STAT_TAG_LAST];
571 /* if we want to do some statistics, push the environment. */
572 if(strlen(stat_file_name) > 0 && (stat_file = fopen(stat_file_name, "at")) != NULL) {
574 /* initialize the statistics tags */
575 ir_snprintf(time_str, sizeof(time_str),"%u", time(NULL));
576 ir_snprintf(irg_name, sizeof(irg_name), "%F", irg);
578 stat_tags[STAT_TAG_FILE] = be_retrieve_dbg_info(get_entity_dbg_info(get_irg_entity(irg)), &line);
579 stat_tags[STAT_TAG_TIME] = time_str;
580 stat_tags[STAT_TAG_IRG] = irg_name;
581 stat_tags[STAT_TAG_CLS] = "<all>";
583 be_stat_ev_push(stat_tags, STAT_TAG_LAST, stat_file);
586 BE_TIMER_INIT(main_opts);
587 BE_TIMER_PUSH(ra_timer.t_other);
588 BE_TIMER_PUSH(ra_timer.t_prolog);
592 chordal_env.opts = &options;
593 chordal_env.irg = irg;
594 chordal_env.birg = bi;
595 chordal_env.dom_front = be_compute_dominance_frontiers(irg);
596 chordal_env.exec_freq = bi->execfreqs;
597 /*compute_execfreq(irg, be_loop_weight);*/
598 chordal_env.lv = be_liveness(irg);
599 FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
601 obstack_init(&chordal_env.obst);
603 BE_TIMER_POP(ra_timer.t_prolog);
605 be_stat_ev("insns_before", count_insns(irg));
607 /* Perform the following for each register class. */
608 for (j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
609 node_stat_t node_stat;
611 chordal_env.cls = arch_isa_get_reg_class(isa, j);
612 chordal_env.border_heads = pmap_create();
613 chordal_env.ignore_colors = bitset_malloc(chordal_env.cls->n_regs);
615 stat_tags[STAT_TAG_CLS] = chordal_env.cls->name;
618 be_stat_ev_push(stat_tags, STAT_TAG_LAST, stat_file);
620 /* perform some node statistics. */
621 node_stats(&chordal_env, &node_stat);
622 be_stat_ev("phis_before_spill", node_stat.n_phis);
625 /* put all ignore registers into the ignore register set. */
626 put_ignore_colors(&chordal_env);
628 BE_TIMER_PUSH(ra_timer.t_live);
629 be_liveness_recompute(chordal_env.lv);
630 BE_TIMER_POP(ra_timer.t_live);
631 dump(BE_CH_DUMP_LIVE, irg, chordal_env.cls, "-live", dump_ir_block_graph_sched);
633 be_pre_spill_prepare_constr(&chordal_env);
634 dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-constr-pre", dump_ir_block_graph_sched);
636 BE_TIMER_PUSH(ra_timer.t_spill);
639 switch(options.spill_method) {
640 case BE_CH_SPILL_MORGAN:
641 be_spill_morgan(&chordal_env);
643 case BE_CH_SPILL_BELADY:
644 be_spill_belady(&chordal_env);
647 case BE_CH_SPILL_REMAT:
648 be_spill_remat(&chordal_env);
650 #endif /* WITH_ILP */
652 fprintf(stderr, "no valid spiller selected. falling back to belady\n");
653 be_spill_belady(&chordal_env);
656 BE_TIMER_POP(ra_timer.t_spill);
659 node_stats(&chordal_env, &node_stat);
660 be_stat_ev("phis_after_spill", node_stat.n_phis);
661 be_stat_ev("mem_phis", node_stat.n_mem_phis);
662 be_stat_ev("reloads", node_stat.n_reloads);
663 be_stat_ev("spills", node_stat.n_spills);
666 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)));
668 dump(BE_CH_DUMP_SPILL, irg, chordal_env.cls, "-spill", dump_ir_block_graph_sched);
670 check_for_memory_operands(&chordal_env);
672 be_abi_fix_stack_nodes(bi->abi, chordal_env.lv);
674 BE_TIMER_PUSH(ra_timer.t_verify);
676 /* verify schedule and register pressure */
677 if (options.vrfy_option == BE_CH_VRFY_WARN) {
678 be_verify_schedule(irg);
679 be_verify_register_pressure(chordal_env.birg, chordal_env.cls, irg);
681 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
682 assert(be_verify_schedule(irg) && "Schedule verification failed");
683 assert(be_verify_register_pressure(chordal_env.birg, chordal_env.cls, irg)
684 && "Register pressure verification failed");
686 BE_TIMER_POP(ra_timer.t_verify);
688 if (be_elr_split && ! splitted) {
689 extreme_liverange_splitting(&chordal_env);
694 /* Color the graph. */
695 BE_TIMER_PUSH(ra_timer.t_color);
696 be_ra_chordal_color(&chordal_env);
697 BE_TIMER_POP(ra_timer.t_color);
699 dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
701 /* Create the ifg with the selected flavor */
702 BE_TIMER_PUSH(ra_timer.t_ifg);
703 switch (options.ifg_flavor) {
705 fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
708 chordal_env.ifg = be_ifg_std_new(&chordal_env);
710 case BE_CH_IFG_CLIQUE:
711 chordal_env.ifg = be_ifg_clique_new(&chordal_env);
713 case BE_CH_IFG_POINTER:
714 chordal_env.ifg = be_ifg_pointer_new(&chordal_env);
717 chordal_env.ifg = be_ifg_list_new(&chordal_env);
719 case BE_CH_IFG_CHECK:
720 check_ifg_implementations(&chordal_env);
721 /* Build the interference graph. */
722 chordal_env.ifg = be_ifg_std_new(&chordal_env);
725 BE_TIMER_POP(ra_timer.t_ifg);
729 be_ifg_stat(&chordal_env, &stat);
730 be_stat_ev("ifg_nodes", stat.n_nodes);
731 be_stat_ev("ifg_edges", stat.n_edges);
732 be_stat_ev("ifg_comps", stat.n_comps);
735 BE_TIMER_PUSH(ra_timer.t_verify);
736 if (options.vrfy_option != BE_CH_VRFY_OFF) {
737 //be_ra_chordal_check(&chordal_env);
740 BE_TIMER_POP(ra_timer.t_verify);
743 node_stats(&chordal_env, &node_stat);
744 be_stat_ev("perms_before_coal", node_stat.n_perms);
745 be_stat_ev("copies_before_coal", node_stat.n_copies);
748 /* copy minimization */
749 BE_TIMER_PUSH(ra_timer.t_copymin);
750 co_driver(&chordal_env);
751 BE_TIMER_POP(ra_timer.t_copymin);
753 dump(BE_CH_DUMP_COPYMIN, irg, chordal_env.cls, "-copymin", dump_ir_block_graph_sched);
755 BE_TIMER_PUSH(ra_timer.t_verify);
757 if (options.vrfy_option != BE_CH_VRFY_OFF) {
758 //be_ra_chordal_check(&chordal_env);
761 BE_TIMER_POP(ra_timer.t_verify);
762 BE_TIMER_PUSH(ra_timer.t_ssa);
764 /* ssa destruction */
765 be_ssa_destruction(&chordal_env);
767 BE_TIMER_POP(ra_timer.t_ssa);
769 dump(BE_CH_DUMP_SSADESTR, irg, chordal_env.cls, "-ssadestr", dump_ir_block_graph_sched);
771 BE_TIMER_PUSH(ra_timer.t_verify);
772 if (options.vrfy_option != BE_CH_VRFY_OFF) {
773 be_ssa_destruction_check(&chordal_env);
774 //be_ra_chordal_check(&chordal_env);
776 BE_TIMER_POP(ra_timer.t_verify);
778 be_ifg_free(chordal_env.ifg);
779 pmap_destroy(chordal_env.border_heads);
780 bitset_free(chordal_env.ignore_colors);
783 node_stats(&chordal_env, &node_stat);
784 be_stat_ev("perms_after_coal", node_stat.n_perms);
785 be_stat_ev("copies_after_coal", node_stat.n_copies);
791 BE_TIMER_PUSH(ra_timer.t_spillslots);
793 be_coalesce_spillslots(&chordal_env, coalesce_spill_slots);
794 dump(BE_CH_DUMP_SPILLSLOTS, irg, NULL, "-spillslots", dump_ir_block_graph_sched);
796 BE_TIMER_POP(ra_timer.t_spillslots);
798 BE_TIMER_PUSH(ra_timer.t_verify);
800 /* verify spillslots */
801 if (options.vrfy_option == BE_CH_VRFY_WARN) {
802 be_verify_spillslots(main_env->arch_env, irg);
804 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
805 assert(be_verify_spillslots(main_env->arch_env, irg) && "Spillslot verification failed");
807 BE_TIMER_POP(ra_timer.t_verify);
809 BE_TIMER_PUSH(ra_timer.t_epilog);
811 dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
813 lower_nodes_after_ra(&chordal_env, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
814 dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
816 obstack_free(&chordal_env.obst, NULL);
817 be_free_dominance_frontiers(chordal_env.dom_front);
818 be_liveness_free(chordal_env.lv);
819 //free_execfreq(chordal_env.exec_freq);
821 BE_TIMER_POP(ra_timer.t_epilog);
822 BE_TIMER_POP(ra_timer.t_other);
824 be_stat_ev("insns_after", count_insns(irg));
831 return main_opts->timing == BE_TIME_ON ? &ra_timer : NULL;
832 #endif /* WITH_LIBCORE */
836 const be_ra_t be_ra_chordal_allocator = {
838 be_ra_chordal_register_options,