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