29ca472cd71b04eb933234e8aa53b819eb4a7d4f
[libfirm] / ir / be / bechordal_main.c
1 /**
2  * @file   bechordal_main.c
3  * @date   29.11.2005
4  * @author Sebastian Hack
5  * @cvs-id $Id$
6  *
7  * Copyright (C) 2005-2006 Universitaet Karlsruhe
8  * Released under the GPL
9  *
10  * Driver for the chordal register allocator.
11  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <time.h>
17
18 #include "obst.h"
19 #include "pset.h"
20 #include "list.h"
21 #include "bitset.h"
22 #include "iterator.h"
23 #include "firm_config.h"
24
25 #ifdef WITH_LIBCORE
26 #include <libcore/lc_opts.h>
27 #include <libcore/lc_opts_enum.h>
28 #include <libcore/lc_timing.h>
29 #endif /* WITH_LIBCORE */
30
31 #include "ircons_t.h"
32 #include "irmode_t.h"
33 #include "irgraph_t.h"
34 #include "irprintf_t.h"
35 #include "irgwalk.h"
36 #include "ircons.h"
37 #include "irdump.h"
38 #include "irdom.h"
39 #include "ircons.h"
40 #include "irbitset.h"
41 #include "irnode.h"
42 #include "ircons.h"
43 #include "debug.h"
44 #include "xmalloc.h"
45 #include "execfreq.h"
46
47 #include "bechordal_t.h"
48 #include "beabi.h"
49 #include "bejavacoal.h"
50 #include "beutil.h"
51 #include "besched.h"
52 #include "besched_t.h"
53 #include "belive_t.h"
54 #include "bearch.h"
55 #include "beifg_t.h"
56 #include "beifg_impl.h"
57 #include "benode_t.h"
58 #include "bestatevent.h"
59 #include "bestat.h"
60 #include "bemodule.h"
61
62 #include "bespillbelady.h"
63 #include "bespillmorgan.h"
64 #include "bespillslots.h"
65 #include "bespilloptions.h"
66 #include "belower.h"
67
68 #ifdef WITH_ILP
69 #include "bespillremat.h"
70 #endif /* WITH_ILP */
71
72 #include "bejavacoal.h"
73 #include "becopystat.h"
74 #include "becopyopt.h"
75 #include "bessadestr.h"
76 #include "beverify.h"
77 #include "benode_t.h"
78
79 static be_ra_chordal_opts_t options = {
80         BE_CH_DUMP_NONE,
81         BE_CH_LOWER_PERM_SWAP,
82         BE_CH_VRFY_WARN,
83 };
84
85 /** Enable extreme live range splitting. */
86 static int be_elr_split = 0;
87
88 typedef struct _post_spill_env_t {
89         be_chordal_env_t            cenv;
90         be_irg_t                    *birg;
91         const arch_register_class_t *cls;
92         double                      pre_spill_cost;
93 } post_spill_env_t;
94
95 static be_ra_timer_t ra_timer = {
96         NULL,
97         NULL,
98         NULL,
99         NULL,
100         NULL,
101         NULL,
102         NULL,
103         NULL,
104         NULL,
105         NULL,
106         NULL,
107 };
108
109 static const lc_opt_enum_int_items_t lower_perm_items[] = {
110         { "copy", BE_CH_LOWER_PERM_COPY },
111         { "swap", BE_CH_LOWER_PERM_SWAP },
112         { NULL, 0 }
113 };
114
115 static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
116         { NULL, 0 }
117 };
118
119 static const lc_opt_enum_int_items_t dump_items[] = {
120         { "spill",      BE_CH_DUMP_SPILL      },
121         { "live",       BE_CH_DUMP_LIVE       },
122         { "color",      BE_CH_DUMP_COLOR      },
123         { "copymin",    BE_CH_DUMP_COPYMIN    },
124         { "ssadestr",   BE_CH_DUMP_SSADESTR   },
125         { "tree",       BE_CH_DUMP_TREE_INTV  },
126         { "constr",     BE_CH_DUMP_CONSTR     },
127         { "lower",      BE_CH_DUMP_LOWER      },
128         { "spillslots", BE_CH_DUMP_SPILLSLOTS },
129         { "appel",      BE_CH_DUMP_APPEL      },
130         { "all",        BE_CH_DUMP_ALL        },
131         { NULL, 0 }
132 };
133
134 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
135         { "off",    BE_CH_VRFY_OFF    },
136         { "warn",   BE_CH_VRFY_WARN   },
137         { "assert", BE_CH_VRFY_ASSERT },
138         { NULL, 0 }
139 };
140
141 static lc_opt_enum_int_var_t lower_perm_var = {
142         &options.lower_perm_opt, lower_perm_items
143 };
144
145 static lc_opt_enum_int_var_t dump_var = {
146         &options.dump_flags, dump_items
147 };
148
149 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
150         &options.vrfy_option, be_ch_vrfy_items
151 };
152
153 static const lc_opt_table_entry_t be_chordal_options[] = {
154         LC_OPT_ENT_ENUM_PTR ("perm",          "perm lowering options", &lower_perm_var),
155         LC_OPT_ENT_ENUM_MASK("dump",          "select dump phases", &dump_var),
156         LC_OPT_ENT_ENUM_PTR ("vrfy",          "verify options", &be_ch_vrfy_var),
157         LC_OPT_ENT_BOOL     ("elrsplit",      "enable extreme live range splitting", &be_elr_split),
158         { NULL }
159 };
160
161 static void dump(unsigned mask, ir_graph *irg,
162                                  const arch_register_class_t *cls,
163                                  const char *suffix,
164                                  void (*dump_func)(ir_graph *, const char *))
165 {
166         if((options.dump_flags & mask) == mask) {
167                 if (cls) {
168                         char buf[256];
169                         snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
170                         be_dump(irg, buf, dump_func);
171                 }
172                 else
173                         be_dump(irg, suffix, dump_func);
174         }
175 }
176
177 /**
178  * Checks for every reload if it's user can perform the load on itself.
179  */
180 static void memory_operand_walker(ir_node *irn, void *env) {
181         be_chordal_env_t *cenv = env;
182         const arch_env_t *aenv = cenv->birg->main_env->arch_env;
183         const ir_edge_t  *edge, *ne;
184         ir_node          *block;
185         ir_node          *spill;
186
187         if (! be_is_Reload(irn))
188                 return;
189
190         /* only use memory operands, if the reload is only used by 1 node */
191         if(get_irn_n_edges(irn) > 1)
192                 return;
193
194         spill = be_get_Reload_mem(irn);
195         block = get_nodes_block(irn);
196
197         foreach_out_edge_safe(irn, edge, ne) {
198                 ir_node *src = get_edge_src_irn(edge);
199                 int     pos  = get_edge_src_pos(edge);
200
201                 assert(src && "outedges broken!");
202
203                 if (get_nodes_block(src) == block && arch_possible_memory_operand(aenv, src, pos)) {
204                         DBG((cenv->dbg, LEVEL_3, "performing memory operand %+F at %+F\n", irn, src));
205                         arch_perform_memory_operand(aenv, src, spill, pos);
206                 }
207         }
208
209         /* kill the Reload */
210         if (get_irn_n_edges(irn) == 0) {
211                 sched_remove(irn);
212                 set_irn_n(irn, be_pos_Reload_mem, new_Bad());
213         }
214 }
215
216 /**
217  * Starts a walk for memory operands if supported by the backend.
218  */
219 static INLINE void check_for_memory_operands(be_chordal_env_t *chordal_env) {
220         irg_walk_graph(chordal_env->irg, NULL, memory_operand_walker, chordal_env);
221 }
222
223 /**
224  * Sorry for doing stats again...
225  */
226 typedef struct _node_stat_t {
227         unsigned int n_phis;      /**< Phis of the current register class. */
228         unsigned int n_mem_phis;  /**< Memory Phis (Phis with spill operands). */
229         unsigned int n_copies;    /**< Copies */
230         unsigned int n_perms;     /**< Perms */
231         unsigned int n_spills;    /**< Spill nodes */
232         unsigned int n_reloads;   /**< Reloads */
233 } node_stat_t;
234
235 struct node_stat_walker {
236         node_stat_t      *stat;
237         const arch_env_t *arch_env;
238         bitset_t         *mem_phis;
239         const arch_register_class_t *cls;
240 };
241
242 static void node_stat_walker(ir_node *irn, void *data)
243 {
244         struct node_stat_walker *env  = data;
245         const arch_env_t        *aenv = env->arch_env;
246
247         if (arch_irn_consider_in_reg_alloc(aenv, env->cls, irn)) {
248
249                 /* if the node is a normal phi */
250                 if(is_Phi(irn))
251                         env->stat->n_phis++;
252
253                 else if(arch_irn_classify(aenv, irn) & arch_irn_class_spill)
254                         ++env->stat->n_spills;
255
256                 else if(arch_irn_classify(aenv, irn) & arch_irn_class_reload)
257                         ++env->stat->n_reloads;
258
259                 else if(arch_irn_classify(aenv, irn) & arch_irn_class_copy)
260                         ++env->stat->n_copies;
261
262                 else if(arch_irn_classify(aenv, irn) & arch_irn_class_perm)
263                         ++env->stat->n_perms;
264         }
265
266         /* a mem phi is a PhiM with a mem phi operand or a Spill operand */
267         else if(is_Phi(irn) && get_irn_mode(irn) == mode_M) {
268                 int i;
269
270                 for(i = get_irn_arity(irn) - 1; i >= 0; --i) {
271                         ir_node *op = get_irn_n(irn, i);
272
273                         if((is_Phi(op) && bitset_contains_irn(env->mem_phis, op)) || (arch_irn_classify(aenv, op) & arch_irn_class_spill)) {
274                                 bitset_add_irn(env->mem_phis, irn);
275                                 env->stat->n_mem_phis++;
276                                 break;
277                         }
278                 }
279         }
280 }
281
282 static void node_stats(be_irg_t *birg, const arch_register_class_t *cls, node_stat_t *stat)
283 {
284         struct node_stat_walker env;
285
286         memset(stat, 0, sizeof(stat[0]));
287         env.arch_env = birg->main_env->arch_env;
288         env.mem_phis = bitset_irg_malloc(birg->irg);
289         env.stat     = stat;
290         env.cls      = cls;
291         irg_walk_graph(birg->irg, NULL, node_stat_walker, &env);
292         bitset_free(env.mem_phis);
293 }
294
295 static void insn_count_walker(ir_node *irn, void *data)
296 {
297         int *cnt = data;
298
299         switch(get_irn_opcode(irn)) {
300         case iro_Proj:
301         case iro_Phi:
302         case iro_Start:
303         case iro_End:
304                 break;
305         default:
306                 (*cnt)++;
307         }
308 }
309
310 static unsigned int count_insns(ir_graph *irg)
311 {
312         int cnt = 0;
313         irg_walk_graph(irg, insn_count_walker, NULL, &cnt);
314         return cnt;
315 }
316
317 #ifdef WITH_LIBCORE
318 /**
319  * Initialize all timers.
320  */
321 static void be_init_timer(be_options_t *main_opts)
322 {
323         if (main_opts->timing == BE_TIME_ON) {
324                 ra_timer.t_prolog     = lc_timer_register("ra_prolog",     "regalloc prolog");
325                 ra_timer.t_epilog     = lc_timer_register("ra_epilog",     "regalloc epilog");
326                 ra_timer.t_live       = lc_timer_register("ra_liveness",   "be liveness");
327                 ra_timer.t_spill      = lc_timer_register("ra_spill",      "spiller");
328                 ra_timer.t_spillslots = lc_timer_register("ra_spillslots", "spillslots");
329                 ra_timer.t_color      = lc_timer_register("ra_color",      "graph coloring");
330                 ra_timer.t_ifg        = lc_timer_register("ra_ifg",        "interference graph");
331                 ra_timer.t_copymin    = lc_timer_register("ra_copymin",    "copy minimization");
332                 ra_timer.t_ssa        = lc_timer_register("ra_ssadestr",   "ssa destruction");
333                 ra_timer.t_verify     = lc_timer_register("ra_verify",     "graph verification");
334                 ra_timer.t_other      = lc_timer_register("ra_other",      "other time");
335
336                 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
337                 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
338                 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
339                 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
340                 LC_STOP_AND_RESET_TIMER(ra_timer.t_spillslots);
341                 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
342                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
343                 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
344                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
345                 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
346                 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
347         }
348 }
349
350 #define BE_TIMER_INIT(main_opts)        be_init_timer(main_opts)
351
352 #define BE_TIMER_PUSH(timer)                                                            \
353         if (main_opts->timing == BE_TIME_ON) {                                              \
354                 if (! lc_timer_push(timer)) {                                                   \
355                         if (options.vrfy_option == BE_CH_VRFY_ASSERT)                               \
356                                 assert(!"Timer already on stack, cannot be pushed twice.");             \
357                         else if (options.vrfy_option == BE_CH_VRFY_WARN)                            \
358                                 fprintf(stderr, "Timer %s already on stack, cannot be pushed twice.\n", \
359                                         lc_timer_get_name(timer));                                          \
360                 }                                                                               \
361         }
362 #define BE_TIMER_POP(timer)                                                                    \
363         if (main_opts->timing == BE_TIME_ON) {                                                     \
364                 lc_timer_t *tmp = lc_timer_pop();                                                      \
365                 if (options.vrfy_option == BE_CH_VRFY_ASSERT)                                          \
366                         assert(tmp == timer && "Attempt to pop wrong timer.");                             \
367                 else if (options.vrfy_option == BE_CH_VRFY_WARN && tmp != timer)                       \
368                         fprintf(stderr, "Attempt to pop wrong timer. %s is on stack, trying to pop %s.\n", \
369                                 lc_timer_get_name(tmp), lc_timer_get_name(timer));                             \
370                 timer = tmp;                                                                           \
371         }
372 #else
373
374 #define BE_TIMER_INIT(main_opts)
375 #define BE_TIMER_PUSH(timer)
376 #define BE_TIMER_POP(timer)
377
378 #endif /* WITH_LIBCORE */
379
380 /**
381  * Perform things which need to be done per register class before spilling.
382  */
383 static void pre_spill(const arch_isa_t *isa, int cls_idx, post_spill_env_t *pse) {
384         be_chordal_env_t *chordal_env = &pse->cenv;
385         be_irg_t         *birg        = pse->birg;
386         node_stat_t      node_stat;
387
388         pse->cls                   = arch_isa_get_reg_class(isa, cls_idx);
389         chordal_env->cls           = pse->cls;
390         chordal_env->border_heads  = pmap_create();
391         chordal_env->ignore_colors = bitset_malloc(chordal_env->cls->n_regs);
392
393 #ifdef FIRM_STATISTICS
394         if (be_stat_ev_is_active()) {
395                 be_stat_tags[STAT_TAG_CLS] = pse->cls->name;
396                 be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
397
398                 /* perform some node statistics. */
399                 node_stats(birg, pse->cls, &node_stat);
400                 be_stat_ev("phis_before_spill", node_stat.n_phis);
401         }
402 #endif /* FIRM_STATISTICS */
403
404         /* put all ignore registers into the ignore register set. */
405         be_put_ignore_regs(birg, pse->cls, chordal_env->ignore_colors);
406
407         be_pre_spill_prepare_constr(chordal_env);
408         dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "-constr-pre", dump_ir_block_graph_sched);
409
410 #ifdef FIRM_STATISTICS
411         if (be_stat_ev_is_active()) {
412                 pse->pre_spill_cost = be_estimate_irg_costs(birg->irg,
413                         birg->main_env->arch_env, birg->exec_freq);
414         }
415 #endif /* FIRM_STATISTICS */
416 }
417
418 /**
419  * Perform things which need to be done per register class after spilling.
420  */
421 static void post_spill(post_spill_env_t *pse) {
422         be_chordal_env_t    *chordal_env = &pse->cenv;
423         be_irg_t            *birg        = pse->birg;
424         ir_graph            *irg         = birg->irg;
425         const be_main_env_t *main_env    = birg->main_env;
426         be_options_t        *main_opts   = main_env->options;
427         static int          splitted     = 0;
428         node_stat_t         node_stat;
429
430 #ifdef FIRM_STATISTICS
431         if (be_stat_ev_is_active()) {
432                 double spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost;
433
434                 be_stat_ev_l("spillcosts", (long) spillcosts);
435
436                 node_stats(birg, pse->cls, &node_stat);
437                 be_stat_ev("phis_after_spill", node_stat.n_phis);
438                 be_stat_ev("mem_phis", node_stat.n_mem_phis);
439                 be_stat_ev("reloads", node_stat.n_reloads);
440                 be_stat_ev("spills", node_stat.n_spills);
441         }
442 #endif /* FIRM_STATISTICS */
443
444         check_for_memory_operands(chordal_env);
445
446         be_abi_fix_stack_nodes(birg->abi, birg->lv);
447
448         BE_TIMER_PUSH(ra_timer.t_verify);
449
450         /* verify schedule and register pressure */
451         if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
452                 be_verify_schedule(irg);
453                 be_verify_register_pressure(birg, pse->cls, irg);
454         }
455         else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
456                 assert(be_verify_schedule(irg) && "Schedule verification failed");
457                 assert(be_verify_register_pressure(birg, pse->cls, irg)
458                         && "Register pressure verification failed");
459         }
460         BE_TIMER_POP(ra_timer.t_verify);
461
462         if (be_elr_split && ! splitted) {
463                 extreme_liverange_splitting(chordal_env);
464                 splitted = 1;
465         }
466
467         /* Color the graph. */
468         BE_TIMER_PUSH(ra_timer.t_color);
469         be_ra_chordal_color(chordal_env);
470         BE_TIMER_POP(ra_timer.t_color);
471
472         dump(BE_CH_DUMP_CONSTR, irg, pse->cls, "-color", dump_ir_block_graph_sched);
473
474         /* Create the ifg with the selected flavor */
475         BE_TIMER_PUSH(ra_timer.t_ifg);
476         chordal_env->ifg = be_create_ifg(chordal_env);
477         BE_TIMER_POP(ra_timer.t_ifg);
478
479 #ifdef FIRM_STATISTICS
480         if (be_stat_ev_is_active()) {
481                 be_ifg_stat_t stat;
482
483                 be_ifg_stat(birg, chordal_env->ifg, &stat);
484                 be_stat_ev("ifg_nodes", stat.n_nodes);
485                 be_stat_ev("ifg_edges", stat.n_edges);
486                 be_stat_ev("ifg_comps", stat.n_comps);
487
488                 node_stats(birg, pse->cls, &node_stat);
489                 be_stat_ev("perms_before_coal", node_stat.n_perms);
490                 be_stat_ev("copies_before_coal", node_stat.n_copies);
491         }
492 #endif /* FIRM_STATISTICS */
493
494         /* copy minimization */
495         BE_TIMER_PUSH(ra_timer.t_copymin);
496         co_driver(chordal_env);
497         BE_TIMER_POP(ra_timer.t_copymin);
498
499         dump(BE_CH_DUMP_COPYMIN, irg, pse->cls, "-copymin", dump_ir_block_graph_sched);
500
501         BE_TIMER_PUSH(ra_timer.t_ssa);
502
503         /* ssa destruction */
504         be_ssa_destruction(chordal_env);
505
506         BE_TIMER_POP(ra_timer.t_ssa);
507
508         dump(BE_CH_DUMP_SSADESTR, irg, pse->cls, "-ssadestr", dump_ir_block_graph_sched);
509
510         BE_TIMER_PUSH(ra_timer.t_verify);
511         if (chordal_env->opts->vrfy_option != BE_CH_VRFY_OFF) {
512                 be_ssa_destruction_check(chordal_env);
513         }
514         BE_TIMER_POP(ra_timer.t_verify);
515
516         /* free some data structures */
517         be_ifg_free(chordal_env->ifg);
518         pmap_destroy(chordal_env->border_heads);
519         bitset_free(chordal_env->ignore_colors);
520
521 #ifdef FIRM_STATISTICS
522         if (be_stat_ev_is_active()) {
523                 node_stats(birg, pse->cls, &node_stat);
524                 be_stat_ev("perms_after_coal", node_stat.n_perms);
525                 be_stat_ev("copies_after_coal", node_stat.n_copies);
526                 be_stat_ev_pop();
527         }
528 #endif /* FIRM_STATISTICS */
529 }
530
531 /**
532  * Performs chordal register allocation for each register class on given irg.
533  *
534  * @param birg  Backend irg object
535  * @return Structure containing timer for the single phases or NULL if no timing requested.
536  */
537 static void be_ra_chordal_main(be_irg_t *birg)
538 {
539         const be_main_env_t *main_env  = birg->main_env;
540         const arch_isa_t    *isa       = arch_env_get_isa(main_env->arch_env);
541         ir_graph            *irg       = birg->irg;
542         be_options_t        *main_opts = main_env->options;
543         int                 j, m;
544         be_chordal_env_t    chordal_env;
545
546         BE_TIMER_INIT(main_opts);
547         BE_TIMER_PUSH(ra_timer.t_other);
548         BE_TIMER_PUSH(ra_timer.t_prolog);
549
550         be_assure_dom_front(birg);
551         be_assure_liveness(birg);
552
553         chordal_env.opts      = &options;
554         chordal_env.irg       = irg;
555         chordal_env.birg      = birg;
556         FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
557
558         obstack_init(&chordal_env.obst);
559
560         BE_TIMER_POP(ra_timer.t_prolog);
561
562         be_stat_ev("insns_before", count_insns(irg));
563
564         if (! arch_code_generator_has_spiller(birg->cg)) {
565                 /* use one of the generic spiller */
566
567                 /* Perform the following for each register class. */
568                 for (j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
569                         post_spill_env_t pse;
570
571                         memcpy(&pse.cenv, &chordal_env, sizeof(chordal_env));
572                         pse.birg = birg;
573                         pre_spill(isa, j, &pse);
574
575                         BE_TIMER_PUSH(ra_timer.t_spill);
576                         be_do_spill(&pse.cenv);
577                         BE_TIMER_POP(ra_timer.t_spill);
578
579                         dump(BE_CH_DUMP_SPILL, irg, pse.cls, "-spill", dump_ir_block_graph_sched);
580
581                         post_spill(&pse);
582                 }
583         }
584         else {
585                 post_spill_env_t *pse;
586
587                 /* the backend has it's own spiller */
588                 m = arch_isa_get_n_reg_class(isa);
589
590                 pse = alloca(m * sizeof(pse[0]));
591
592                 for (j = 0; j < m; ++j) {
593                         memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env));
594                         pse[j].birg = birg;
595                         pre_spill(isa, j, &pse[j]);
596                 }
597
598                 BE_TIMER_PUSH(ra_timer.t_spill);
599                 arch_code_generator_spill(birg->cg, birg);
600                 BE_TIMER_POP(ra_timer.t_spill);
601                 dump(BE_CH_DUMP_SPILL, irg, NULL, "-spill", dump_ir_block_graph_sched);
602
603                 for (j = 0; j < m; ++j) {
604                         post_spill(&pse[j]);
605                 }
606         }
607
608         BE_TIMER_PUSH(ra_timer.t_spillslots);
609
610         be_coalesce_spillslots(&chordal_env);
611         dump(BE_CH_DUMP_SPILLSLOTS, irg, NULL, "-spillslots", dump_ir_block_graph_sched);
612
613         BE_TIMER_POP(ra_timer.t_spillslots);
614
615         BE_TIMER_PUSH(ra_timer.t_verify);
616         /* verify spillslots */
617         if (options.vrfy_option == BE_CH_VRFY_WARN) {
618                 be_verify_spillslots(main_env->arch_env, irg);
619         }
620         else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
621                 assert(be_verify_spillslots(main_env->arch_env, irg) && "Spillslot verification failed");
622         }
623         BE_TIMER_POP(ra_timer.t_verify);
624
625         BE_TIMER_PUSH(ra_timer.t_epilog);
626         dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
627
628         lower_nodes_after_ra(birg, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
629         dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
630
631         obstack_free(&chordal_env.obst, NULL);
632         BE_TIMER_POP(ra_timer.t_epilog);
633
634         BE_TIMER_POP(ra_timer.t_other);
635
636         be_stat_ev("insns_after", count_insns(irg));
637
638         return;
639 }
640
641 static be_ra_t be_ra_chordal_allocator = {
642         be_ra_chordal_main,
643 };
644
645 void be_init_chordal(void)
646 {
647         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
648         lc_opt_entry_t *ra_grp = lc_opt_get_grp(be_grp, "ra");
649         lc_opt_entry_t *chordal_grp = lc_opt_get_grp(ra_grp, "chordal");
650
651         lc_opt_add_table(chordal_grp, be_chordal_options);
652
653         be_register_allocator("chordal", &be_ra_chordal_allocator);
654 }
655
656 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_chordal);