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"
52 #include "besched_t.h"
56 #include "beifg_impl.h"
58 #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"
79 static be_ra_chordal_opts_t options = {
82 BE_CH_LOWER_PERM_SWAP,
86 /** Enable extreme live range splitting. */
87 static int be_elr_split = 0;
89 /** Assumed loop iteration count for execution frequency estimation. */
90 static int be_loop_weight = 9;
92 typedef struct _post_spill_env_t {
93 be_chordal_env_t cenv;
94 double pre_spill_cost;
97 static be_ra_timer_t ra_timer = {
111 static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
112 { "std", BE_CH_IFG_STD },
113 { "fast", BE_CH_IFG_FAST },
114 { "clique", BE_CH_IFG_CLIQUE },
115 { "pointer", BE_CH_IFG_POINTER },
116 { "list", BE_CH_IFG_LIST },
117 { "check", BE_CH_IFG_CHECK },
121 static const lc_opt_enum_int_items_t lower_perm_items[] = {
122 { "copy", BE_CH_LOWER_PERM_COPY },
123 { "swap", BE_CH_LOWER_PERM_SWAP },
127 static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
131 static const lc_opt_enum_int_items_t dump_items[] = {
132 { "spill", BE_CH_DUMP_SPILL },
133 { "live", BE_CH_DUMP_LIVE },
134 { "color", BE_CH_DUMP_COLOR },
135 { "copymin", BE_CH_DUMP_COPYMIN },
136 { "ssadestr", BE_CH_DUMP_SSADESTR },
137 { "tree", BE_CH_DUMP_TREE_INTV },
138 { "constr", BE_CH_DUMP_CONSTR },
139 { "lower", BE_CH_DUMP_LOWER },
140 { "spillslots", BE_CH_DUMP_SPILLSLOTS },
141 { "appel", BE_CH_DUMP_APPEL },
142 { "all", BE_CH_DUMP_ALL },
146 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
147 { "off", BE_CH_VRFY_OFF },
148 { "warn", BE_CH_VRFY_WARN },
149 { "assert", BE_CH_VRFY_ASSERT },
153 static lc_opt_enum_int_var_t ifg_flavor_var = {
154 &options.ifg_flavor, ifg_flavor_items
157 static lc_opt_enum_int_var_t lower_perm_var = {
158 &options.lower_perm_opt, lower_perm_items
161 static lc_opt_enum_int_var_t dump_var = {
162 &options.dump_flags, dump_items
165 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
166 &options.vrfy_option, be_ch_vrfy_items
169 static const lc_opt_table_entry_t be_chordal_options[] = {
170 LC_OPT_ENT_ENUM_PTR ("ifg", "interference graph flavour", &ifg_flavor_var),
171 LC_OPT_ENT_ENUM_PTR ("perm", "perm lowering options", &lower_perm_var),
172 LC_OPT_ENT_ENUM_MASK("dump", "select dump phases", &dump_var),
173 LC_OPT_ENT_ENUM_PTR ("vrfy", "verify options", &be_ch_vrfy_var),
174 LC_OPT_ENT_BOOL ("elrsplit", "enable extreme live range splitting", &be_elr_split),
175 LC_OPT_ENT_INT ("loop_weight", "assumed amount of loop iterations for guessing the execution frequency", &be_loop_weight),
179 void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
180 const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
183 ir_node **nodes, *n1, *n2;
185 be_lv_t *lv = chordal_env->birg->lv;
186 DEBUG_ONLY(firm_dbg_module_t *dbg = chordal_env->dbg;)
188 /* Collect all irns */
190 pmap_foreach(chordal_env->border_heads, pme) {
192 struct list_head *head = pme->value;
193 list_for_each_entry(border_t, curr, head, list)
194 if (curr->is_def && curr->is_real)
195 if (arch_get_irn_reg_class(arch_env, curr->irn, -1) == chordal_env->cls)
196 obstack_ptr_grow(&ob, curr->irn);
198 obstack_ptr_grow(&ob, NULL);
199 nodes = (ir_node **) obstack_finish(&ob);
202 for (i = 0, n1 = nodes[i]; n1; n1 = nodes[++i]) {
203 const arch_register_t *n1_reg, *n2_reg;
205 n1_reg = arch_get_irn_register(arch_env, n1);
206 if (!arch_reg_is_allocatable(arch_env, n1, -1, n1_reg)) {
207 DBG((dbg, 0, "Register %s assigned to %+F is not allowed\n", n1_reg->name, n1));
208 assert(0 && "Register constraint does not hold");
210 for (o = i+1, n2 = nodes[o]; n2; n2 = nodes[++o]) {
211 n2_reg = arch_get_irn_register(arch_env, n2);
212 if (values_interfere(lv, n1, n2) && n1_reg == n2_reg) {
213 DBG((dbg, 0, "Values %+F and %+F interfere and have the same register assigned: %s\n", n1, n2, n1_reg->name));
214 assert(0 && "Interfering values have the same color!");
218 obstack_free(&ob, NULL);
221 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b)
224 return be_ifg_connected(env->ifg, a, b);
226 return values_interfere(env->birg->lv, a, b);
229 static void dump(unsigned mask, ir_graph *irg,
230 const arch_register_class_t *cls,
232 void (*dump_func)(ir_graph *, const char *))
234 if((options.dump_flags & mask) == mask) {
237 snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
238 be_dump(irg, buf, dump_func);
241 be_dump(irg, suffix, dump_func);
245 static void put_ignore_colors(be_chordal_env_t *chordal_env)
247 int n_colors = chordal_env->cls->n_regs;
250 bitset_clear_all(chordal_env->ignore_colors);
251 be_abi_put_ignore_regs(chordal_env->birg->abi, chordal_env->cls, chordal_env->ignore_colors);
252 for(i = 0; i < n_colors; ++i)
253 if(arch_register_type_is(&chordal_env->cls->regs[i], ignore))
254 bitset_set(chordal_env->ignore_colors, i);
257 FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const char *suffix)
261 ir_snprintf(buf, sizeof(buf), "%s%F_%s%s", prefix, env->irg, env->cls->name, suffix);
262 return fopen(buf, "wt");
265 void check_ifg_implementations(be_chordal_env_t *chordal_env)
269 f = be_chordal_open(chordal_env, "std", ".log");
270 chordal_env->ifg = be_ifg_std_new(chordal_env);
271 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
274 f = be_chordal_open(chordal_env, "list", ".log");
275 be_ifg_free(chordal_env->ifg);
276 chordal_env->ifg = be_ifg_list_new(chordal_env);
277 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
280 f = be_chordal_open(chordal_env, "clique", ".log");
281 be_ifg_free(chordal_env->ifg);
282 chordal_env->ifg = be_ifg_clique_new(chordal_env);
283 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
286 f = be_chordal_open(chordal_env, "pointer", ".log");
287 be_ifg_free(chordal_env->ifg);
288 chordal_env->ifg = be_ifg_pointer_new(chordal_env);
289 be_ifg_check_sorted_to_file(chordal_env->ifg, f);
292 chordal_env->ifg = NULL;
296 * Checks for every reload if it's user can perform the load on itself.
298 static void memory_operand_walker(ir_node *irn, void *env) {
299 be_chordal_env_t *cenv = env;
300 const arch_env_t *aenv = cenv->birg->main_env->arch_env;
301 const ir_edge_t *edge, *ne;
305 if (! be_is_Reload(irn))
308 /* only use memory operands, if the reload is only used by 1 node */
309 if(get_irn_n_edges(irn) > 1)
312 spill = be_get_Reload_mem(irn);
313 block = get_nodes_block(irn);
315 foreach_out_edge_safe(irn, edge, ne) {
316 ir_node *src = get_edge_src_irn(edge);
317 int pos = get_edge_src_pos(edge);
319 assert(src && "outedges broken!");
321 if (get_nodes_block(src) == block && arch_possible_memory_operand(aenv, src, pos)) {
322 DBG((cenv->dbg, LEVEL_3, "performing memory operand %+F at %+F\n", irn, src));
323 arch_perform_memory_operand(aenv, src, spill, pos);
327 /* kill the Reload */
328 if (get_irn_n_edges(irn) == 0) {
330 set_irn_n(irn, be_pos_Reload_mem, new_Bad());
335 * Starts a walk for memory operands if supported by the backend.
337 static INLINE void check_for_memory_operands(be_chordal_env_t *chordal_env) {
338 irg_walk_graph(chordal_env->irg, NULL, memory_operand_walker, chordal_env);
342 * Sorry for doing stats again...
344 typedef struct _node_stat_t {
345 unsigned int n_phis; /**< Phis of the current register class. */
346 unsigned int n_mem_phis; /**< Memory Phis (Phis with spill operands). */
347 unsigned int n_copies; /**< Copies */
348 unsigned int n_perms; /**< Perms */
349 unsigned int n_spills; /**< Spill nodes */
350 unsigned int n_reloads; /**< Reloads */
353 struct node_stat_walker {
355 const be_chordal_env_t *cenv;
359 static void node_stat_walker(ir_node *irn, void *data)
361 struct node_stat_walker *env = data;
362 const arch_env_t *aenv = env->cenv->birg->main_env->arch_env;
364 if(arch_irn_consider_in_reg_alloc(aenv, env->cenv->cls, irn)) {
366 /* if the node is a normal phi */
370 else if(arch_irn_classify(aenv, irn) & arch_irn_class_spill)
371 ++env->stat->n_spills;
373 else if(arch_irn_classify(aenv, irn) & arch_irn_class_reload)
374 ++env->stat->n_reloads;
376 else if(arch_irn_classify(aenv, irn) & arch_irn_class_copy)
377 ++env->stat->n_copies;
379 else if(arch_irn_classify(aenv, irn) & arch_irn_class_perm)
380 ++env->stat->n_perms;
383 /* a mem phi is a PhiM with a mem phi operand or a Spill operand */
384 else if(is_Phi(irn) && get_irn_mode(irn) == mode_M) {
387 for(i = get_irn_arity(irn) - 1; i >= 0; --i) {
388 ir_node *op = get_irn_n(irn, i);
390 if((is_Phi(op) && bitset_contains_irn(env->mem_phis, op)) || (arch_irn_classify(aenv, op) & arch_irn_class_spill)) {
391 bitset_add_irn(env->mem_phis, irn);
392 env->stat->n_mem_phis++;
399 static void node_stats(const be_chordal_env_t *cenv, node_stat_t *stat)
401 struct node_stat_walker env;
403 memset(stat, 0, sizeof(stat[0]));
405 env.mem_phis = bitset_irg_malloc(cenv->irg);
407 irg_walk_graph(cenv->irg, NULL, node_stat_walker, &env);
408 bitset_free(env.mem_phis);
411 static void insn_count_walker(ir_node *irn, void *data)
415 switch(get_irn_opcode(irn)) {
426 static unsigned int count_insns(ir_graph *irg)
429 irg_walk_graph(irg, insn_count_walker, NULL, &cnt);
435 * Initialize all timers.
437 static void be_init_timer(be_options_t *main_opts)
439 if (main_opts->timing == BE_TIME_ON) {
440 ra_timer.t_prolog = lc_timer_register("ra_prolog", "regalloc prolog");
441 ra_timer.t_epilog = lc_timer_register("ra_epilog", "regalloc epilog");
442 ra_timer.t_live = lc_timer_register("ra_liveness", "be liveness");
443 ra_timer.t_spill = lc_timer_register("ra_spill", "spiller");
444 ra_timer.t_spillslots = lc_timer_register("ra_spillslots", "spillslots");
445 ra_timer.t_color = lc_timer_register("ra_color", "graph coloring");
446 ra_timer.t_ifg = lc_timer_register("ra_ifg", "interference graph");
447 ra_timer.t_copymin = lc_timer_register("ra_copymin", "copy minimization");
448 ra_timer.t_ssa = lc_timer_register("ra_ssadestr", "ssa destruction");
449 ra_timer.t_verify = lc_timer_register("ra_verify", "graph verification");
450 ra_timer.t_other = lc_timer_register("ra_other", "other time");
452 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
453 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
454 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
455 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
456 LC_STOP_AND_RESET_TIMER(ra_timer.t_spillslots);
457 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
458 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
459 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
460 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
461 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
462 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
466 #define BE_TIMER_INIT(main_opts) be_init_timer(main_opts)
468 #define BE_TIMER_PUSH(timer) \
469 if (main_opts->timing == BE_TIME_ON) { \
470 if (! lc_timer_push(timer)) { \
471 if (options.vrfy_option == BE_CH_VRFY_ASSERT) \
472 assert(!"Timer already on stack, cannot be pushed twice."); \
473 else if (options.vrfy_option == BE_CH_VRFY_WARN) \
474 fprintf(stderr, "Timer %s already on stack, cannot be pushed twice.\n", \
475 lc_timer_get_name(timer)); \
478 #define BE_TIMER_POP(timer) \
479 if (main_opts->timing == BE_TIME_ON) { \
480 lc_timer_t *tmp = lc_timer_pop(); \
481 if (options.vrfy_option == BE_CH_VRFY_ASSERT) \
482 assert(tmp == timer && "Attempt to pop wrong timer."); \
483 else if (options.vrfy_option == BE_CH_VRFY_WARN && tmp != timer) \
484 fprintf(stderr, "Attempt to pop wrong timer. %s is on stack, trying to pop %s.\n", \
485 lc_timer_get_name(tmp), lc_timer_get_name(timer)); \
490 #define BE_TIMER_INIT(main_opts)
491 #define BE_TIMER_PUSH(timer)
492 #define BE_TIMER_POP(timer)
494 #endif /* WITH_LIBCORE */
497 * Perform things which need to be done per register class before spilling.
499 static void pre_spill(const arch_isa_t *isa, int cls_idx, post_spill_env_t *pse) {
500 be_chordal_env_t *chordal_env = &pse->cenv;
501 node_stat_t node_stat;
503 chordal_env->cls = arch_isa_get_reg_class(isa, cls_idx);
504 chordal_env->border_heads = pmap_create();
505 chordal_env->ignore_colors = bitset_malloc(chordal_env->cls->n_regs);
507 #ifdef FIRM_STATISTICS
508 if (be_stat_ev_is_active()) {
509 be_stat_tags[STAT_TAG_CLS] = chordal_env->cls->name;
510 be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
512 /* perform some node statistics. */
513 node_stats(chordal_env, &node_stat);
514 be_stat_ev("phis_before_spill", node_stat.n_phis);
516 #endif /* FIRM_STATISTICS */
518 /* put all ignore registers into the ignore register set. */
519 put_ignore_colors(chordal_env);
521 be_pre_spill_prepare_constr(chordal_env);
522 dump(BE_CH_DUMP_CONSTR, chordal_env->irg, chordal_env->cls, "-constr-pre", dump_ir_block_graph_sched);
524 #ifdef FIRM_STATISTICS
525 if (be_stat_ev_is_active()) {
526 pse->pre_spill_cost = be_estimate_irg_costs(chordal_env->irg,
527 chordal_env->birg->main_env->arch_env, chordal_env->birg->exec_freq);
529 #endif /* FIRM_STATISTICS */
533 * Perform things which need to be done per register class after spilling.
535 static void post_spill(post_spill_env_t *pse) {
536 be_chordal_env_t *chordal_env = &pse->cenv;
537 ir_graph *irg = chordal_env->irg;
538 be_irg_t *birg = chordal_env->birg;
539 const be_main_env_t *main_env = birg->main_env;
540 be_options_t *main_opts = main_env->options;
541 static int splitted = 0;
542 node_stat_t node_stat;
544 #ifdef FIRM_STATISTICS
545 if (be_stat_ev_is_active()) {
546 double spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost;
548 be_stat_ev_l("spillcosts", (long) spillcosts);
550 node_stats(chordal_env, &node_stat);
551 be_stat_ev("phis_after_spill", node_stat.n_phis);
552 be_stat_ev("mem_phis", node_stat.n_mem_phis);
553 be_stat_ev("reloads", node_stat.n_reloads);
554 be_stat_ev("spills", node_stat.n_spills);
556 #endif /* FIRM_STATISTICS */
558 check_for_memory_operands(chordal_env);
560 be_abi_fix_stack_nodes(birg->abi, birg->lv);
562 BE_TIMER_PUSH(ra_timer.t_verify);
564 /* verify schedule and register pressure */
565 if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
566 be_verify_schedule(irg);
567 be_verify_register_pressure(chordal_env->birg, chordal_env->cls, irg);
569 else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
570 assert(be_verify_schedule(irg) && "Schedule verification failed");
571 assert(be_verify_register_pressure(chordal_env->birg, chordal_env->cls, irg)
572 && "Register pressure verification failed");
574 BE_TIMER_POP(ra_timer.t_verify);
576 if (be_elr_split && ! splitted) {
577 extreme_liverange_splitting(chordal_env);
581 /* Color the graph. */
582 BE_TIMER_PUSH(ra_timer.t_color);
583 be_ra_chordal_color(chordal_env);
584 BE_TIMER_POP(ra_timer.t_color);
586 dump(BE_CH_DUMP_CONSTR, irg, chordal_env->cls, "-color", dump_ir_block_graph_sched);
588 /* Create the ifg with the selected flavor */
589 BE_TIMER_PUSH(ra_timer.t_ifg);
590 switch (chordal_env->opts->ifg_flavor) {
592 fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
595 chordal_env->ifg = be_ifg_std_new(chordal_env);
597 case BE_CH_IFG_CLIQUE:
598 chordal_env->ifg = be_ifg_clique_new(chordal_env);
600 case BE_CH_IFG_POINTER:
601 chordal_env->ifg = be_ifg_pointer_new(chordal_env);
604 chordal_env->ifg = be_ifg_list_new(chordal_env);
606 case BE_CH_IFG_CHECK:
607 check_ifg_implementations(chordal_env);
608 /* Build the interference graph. */
609 chordal_env->ifg = be_ifg_std_new(chordal_env);
612 BE_TIMER_POP(ra_timer.t_ifg);
614 #ifdef FIRM_STATISTICS
615 if (be_stat_ev_is_active()) {
617 be_ifg_stat(chordal_env, &stat);
618 be_stat_ev("ifg_nodes", stat.n_nodes);
619 be_stat_ev("ifg_edges", stat.n_edges);
620 be_stat_ev("ifg_comps", stat.n_comps);
622 node_stats(chordal_env, &node_stat);
623 be_stat_ev("perms_before_coal", node_stat.n_perms);
624 be_stat_ev("copies_before_coal", node_stat.n_copies);
626 #endif /* FIRM_STATISTICS */
628 /* copy minimization */
629 BE_TIMER_PUSH(ra_timer.t_copymin);
630 co_driver(chordal_env);
631 BE_TIMER_POP(ra_timer.t_copymin);
633 dump(BE_CH_DUMP_COPYMIN, irg, chordal_env->cls, "-copymin", dump_ir_block_graph_sched);
635 BE_TIMER_PUSH(ra_timer.t_ssa);
637 /* ssa destruction */
638 be_ssa_destruction(chordal_env);
640 BE_TIMER_POP(ra_timer.t_ssa);
642 dump(BE_CH_DUMP_SSADESTR, irg, chordal_env->cls, "-ssadestr", dump_ir_block_graph_sched);
644 BE_TIMER_PUSH(ra_timer.t_verify);
645 if (chordal_env->opts->vrfy_option != BE_CH_VRFY_OFF) {
646 be_ssa_destruction_check(chordal_env);
648 BE_TIMER_POP(ra_timer.t_verify);
650 be_ifg_free(chordal_env->ifg);
651 pmap_destroy(chordal_env->border_heads);
652 bitset_free(chordal_env->ignore_colors);
654 #ifdef FIRM_STATISTICS
655 if (be_stat_ev_is_active()) {
656 node_stats(chordal_env, &node_stat);
657 be_stat_ev("perms_after_coal", node_stat.n_perms);
658 be_stat_ev("copies_after_coal", node_stat.n_copies);
661 #endif /* FIRM_STATISTICS */
665 * Performs chordal register allocation for each register class on given irg.
667 * @param birg Backend irg object
668 * @return Structure containing timer for the single phases or NULL if no timing requested.
670 static void be_ra_chordal_main(be_irg_t *birg)
672 const be_main_env_t *main_env = birg->main_env;
673 const arch_isa_t *isa = arch_env_get_isa(main_env->arch_env);
674 ir_graph *irg = birg->irg;
675 be_options_t *main_opts = main_env->options;
677 be_chordal_env_t chordal_env;
679 BE_TIMER_INIT(main_opts);
680 BE_TIMER_PUSH(ra_timer.t_other);
681 BE_TIMER_PUSH(ra_timer.t_prolog);
683 be_assure_dom_front(birg);
684 be_assure_liveness(birg);
686 chordal_env.opts = &options;
687 chordal_env.irg = irg;
688 chordal_env.birg = birg;
689 FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
691 obstack_init(&chordal_env.obst);
693 BE_TIMER_POP(ra_timer.t_prolog);
695 be_stat_ev("insns_before", count_insns(irg));
697 if (! arch_code_generator_has_spiller(birg->cg)) {
698 /* use one of the generic spiller */
700 /* Perform the following for each register class. */
701 for (j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
702 post_spill_env_t pse;
704 memcpy(&pse.cenv, &chordal_env, sizeof(chordal_env));
705 pre_spill(isa, j, &pse);
707 BE_TIMER_PUSH(ra_timer.t_spill);
708 be_do_spill(&pse.cenv);
709 BE_TIMER_POP(ra_timer.t_spill);
711 dump(BE_CH_DUMP_SPILL, irg, pse.cenv.cls, "-spill", dump_ir_block_graph_sched);
717 post_spill_env_t *pse;
719 /* the backend has it's own spiller */
720 m = arch_isa_get_n_reg_class(isa);
722 pse = alloca(m * sizeof(pse[0]));
724 for (j = 0; j < m; ++j) {
725 memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env));
726 pre_spill(isa, j, &pse[j]);
729 BE_TIMER_PUSH(ra_timer.t_spill);
730 arch_code_generator_spill(birg->cg, &chordal_env);
731 BE_TIMER_POP(ra_timer.t_spill);
732 dump(BE_CH_DUMP_SPILL, irg, NULL, "-spill", dump_ir_block_graph_sched);
734 for (j = 0; j < m; ++j) {
739 BE_TIMER_PUSH(ra_timer.t_spillslots);
741 be_coalesce_spillslots(&chordal_env);
742 dump(BE_CH_DUMP_SPILLSLOTS, irg, NULL, "-spillslots", dump_ir_block_graph_sched);
744 BE_TIMER_POP(ra_timer.t_spillslots);
746 BE_TIMER_PUSH(ra_timer.t_verify);
747 /* verify spillslots */
748 if (options.vrfy_option == BE_CH_VRFY_WARN) {
749 be_verify_spillslots(main_env->arch_env, irg);
751 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
752 assert(be_verify_spillslots(main_env->arch_env, irg) && "Spillslot verification failed");
754 BE_TIMER_POP(ra_timer.t_verify);
756 BE_TIMER_PUSH(ra_timer.t_epilog);
757 dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
759 lower_nodes_after_ra(&chordal_env, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
760 dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
762 obstack_free(&chordal_env.obst, NULL);
763 BE_TIMER_POP(ra_timer.t_epilog);
765 BE_TIMER_POP(ra_timer.t_other);
767 be_stat_ev("insns_after", count_insns(irg));
772 static be_ra_t be_ra_chordal_allocator = {
776 void be_init_chordal(void)
778 lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
779 lc_opt_entry_t *ra_grp = lc_opt_get_grp(be_grp, "ra");
780 lc_opt_entry_t *chordal_grp = lc_opt_get_grp(ra_grp, "chordal");
782 lc_opt_add_table(chordal_grp, be_chordal_options);
784 be_register_allocator("chordal", &be_ra_chordal_allocator);
787 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_chordal);