Fixed Makefiles
[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 #include <libcore/lc_opts.h>
26 #include <libcore/lc_opts_enum.h>
27 #include <libcore/lc_timing.h>
28
29 #include "ircons_t.h"
30 #include "irmode_t.h"
31 #include "irgraph_t.h"
32 #include "irprintf_t.h"
33 #include "irgwalk.h"
34 #include "ircons.h"
35 #include "irdump.h"
36 #include "irdom.h"
37 #include "ircons.h"
38 #include "irbitset.h"
39 #include "irnode.h"
40 #include "ircons.h"
41 #include "debug.h"
42 #include "xmalloc.h"
43 #include "execfreq.h"
44
45 #include "bechordal_t.h"
46 #include "beabi.h"
47 #include "bejavacoal.h"
48 #include "beutil.h"
49 #include "besched.h"
50 #include "besched_t.h"
51 #include "belive_t.h"
52 #include "bearch.h"
53 #include "beifg_t.h"
54 #include "beifg_impl.h"
55 #include "benode_t.h"
56 #include "bestatevent.h"
57 #include "bestat.h"
58 #include "bemodule.h"
59
60 #include "bespillbelady.h"
61 #include "bespillmorgan.h"
62 #include "bespillslots.h"
63 #include "bespilloptions.h"
64 #include "belower.h"
65
66 #ifdef WITH_ILP
67 #include "bespillremat.h"
68 #endif /* WITH_ILP */
69
70 #include "bejavacoal.h"
71 #include "becopystat.h"
72 #include "becopyopt.h"
73 #include "bessadestr.h"
74 #include "beverify.h"
75 #include "benode_t.h"
76
77 static be_ra_chordal_opts_t options = {
78         BE_CH_DUMP_NONE,
79         BE_CH_LOWER_PERM_SWAP,
80         BE_CH_VRFY_WARN,
81 };
82
83 /** Enable extreme live range splitting. */
84 static int be_elr_split = 0;
85
86 typedef struct _post_spill_env_t {
87         be_chordal_env_t            cenv;
88         be_irg_t                    *birg;
89         const arch_register_class_t *cls;
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         { "none",       BE_CH_DUMP_NONE       },
119         { "spill",      BE_CH_DUMP_SPILL      },
120         { "live",       BE_CH_DUMP_LIVE       },
121         { "color",      BE_CH_DUMP_COLOR      },
122         { "copymin",    BE_CH_DUMP_COPYMIN    },
123         { "ssadestr",   BE_CH_DUMP_SSADESTR   },
124         { "tree",       BE_CH_DUMP_TREE_INTV  },
125         { "constr",     BE_CH_DUMP_CONSTR     },
126         { "lower",      BE_CH_DUMP_LOWER      },
127         { "spillslots", BE_CH_DUMP_SPILLSLOTS },
128         { "appel",      BE_CH_DUMP_APPEL      },
129         { "all",        BE_CH_DUMP_ALL        },
130         { NULL, 0 }
131 };
132
133 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
134         { "off",    BE_CH_VRFY_OFF    },
135         { "warn",   BE_CH_VRFY_WARN   },
136         { "assert", BE_CH_VRFY_ASSERT },
137         { NULL, 0 }
138 };
139
140 static lc_opt_enum_int_var_t lower_perm_var = {
141         &options.lower_perm_opt, lower_perm_items
142 };
143
144 static lc_opt_enum_int_var_t dump_var = {
145         &options.dump_flags, dump_items
146 };
147
148 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
149         &options.vrfy_option, be_ch_vrfy_items
150 };
151
152 static const lc_opt_table_entry_t be_chordal_options[] = {
153         LC_OPT_ENT_ENUM_PTR ("perm",          "perm lowering options", &lower_perm_var),
154         LC_OPT_ENT_ENUM_MASK("dump",          "select dump phases", &dump_var),
155         LC_OPT_ENT_ENUM_PTR ("vrfy",          "verify options", &be_ch_vrfy_var),
156         LC_OPT_ENT_BOOL     ("elrsplit",      "enable extreme live range splitting", &be_elr_split),
157         { NULL }
158 };
159
160 static void dump(unsigned mask, ir_graph *irg,
161                                  const arch_register_class_t *cls,
162                                  const char *suffix,
163                                  void (*dump_func)(ir_graph *, const char *))
164 {
165         if((options.dump_flags & mask) == mask) {
166                 if (cls) {
167                         char buf[256];
168                         snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
169                         be_dump(irg, buf, dump_func);
170                 }
171                 else
172                         be_dump(irg, suffix, dump_func);
173         }
174 }
175
176 /**
177  * Checks for every reload if it's user can perform the load on itself.
178  */
179 static void memory_operand_walker(ir_node *irn, void *env) {
180         be_chordal_env_t *cenv = env;
181         const arch_env_t *aenv = cenv->birg->main_env->arch_env;
182         const ir_edge_t  *edge, *ne;
183         ir_node          *block;
184         ir_node          *spill;
185
186         if (! be_is_Reload(irn))
187                 return;
188
189         /* only use memory operands, if the reload is only used by 1 node */
190         if(get_irn_n_edges(irn) > 1)
191                 return;
192
193         spill = be_get_Reload_mem(irn);
194         block = get_nodes_block(irn);
195
196         foreach_out_edge_safe(irn, edge, ne) {
197                 ir_node *src = get_edge_src_irn(edge);
198                 int     pos  = get_edge_src_pos(edge);
199
200                 assert(src && "outedges broken!");
201
202                 if (get_nodes_block(src) == block && arch_possible_memory_operand(aenv, src, pos)) {
203                         DBG((cenv->dbg, LEVEL_3, "performing memory operand %+F at %+F\n", irn, src));
204                         arch_perform_memory_operand(aenv, src, spill, pos);
205                 }
206         }
207
208         /* kill the Reload */
209         if (get_irn_n_edges(irn) == 0) {
210                 sched_remove(irn);
211                 set_irn_n(irn, be_pos_Reload_mem, new_Bad());
212                 set_irn_n(irn, be_pos_Reload_frame, 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 /**
318  * Initialize all timers.
319  */
320 static void be_init_timer(be_options_t *main_opts)
321 {
322         if (main_opts->timing == BE_TIME_ON) {
323                 ra_timer.t_prolog     = lc_timer_register("ra_prolog",     "regalloc prolog");
324                 ra_timer.t_epilog     = lc_timer_register("ra_epilog",     "regalloc epilog");
325                 ra_timer.t_live       = lc_timer_register("ra_liveness",   "be liveness");
326                 ra_timer.t_spill      = lc_timer_register("ra_spill",      "spiller");
327                 ra_timer.t_spillslots = lc_timer_register("ra_spillslots", "spillslots");
328                 ra_timer.t_color      = lc_timer_register("ra_color",      "graph coloring");
329                 ra_timer.t_ifg        = lc_timer_register("ra_ifg",        "interference graph");
330                 ra_timer.t_copymin    = lc_timer_register("ra_copymin",    "copy minimization");
331                 ra_timer.t_ssa        = lc_timer_register("ra_ssadestr",   "ssa destruction");
332                 ra_timer.t_verify     = lc_timer_register("ra_verify",     "graph verification");
333                 ra_timer.t_other      = lc_timer_register("ra_other",      "other time");
334
335                 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
336                 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
337                 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
338                 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
339                 LC_STOP_AND_RESET_TIMER(ra_timer.t_spillslots);
340                 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
341                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
342                 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
343                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
344                 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
345                 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
346
347                 global_ra_timer = &ra_timer;
348         }
349 }
350
351 #define BE_TIMER_INIT(main_opts)        be_init_timer(main_opts)
352
353 #define BE_TIMER_PUSH(timer)                                                            \
354         if (main_opts->timing == BE_TIME_ON) {                                              \
355                 if (! lc_timer_push(timer)) {                                                   \
356                         if (options.vrfy_option == BE_CH_VRFY_ASSERT)                               \
357                                 assert(!"Timer already on stack, cannot be pushed twice.");             \
358                         else if (options.vrfy_option == BE_CH_VRFY_WARN)                            \
359                                 fprintf(stderr, "Timer %s already on stack, cannot be pushed twice.\n", \
360                                         lc_timer_get_name(timer));                                          \
361                 }                                                                               \
362         }
363 #define BE_TIMER_POP(timer)                                                                    \
364         if (main_opts->timing == BE_TIME_ON) {                                                     \
365                 lc_timer_t *tmp = lc_timer_pop();                                                      \
366                 if (options.vrfy_option == BE_CH_VRFY_ASSERT)                                          \
367                         assert(tmp == timer && "Attempt to pop wrong timer.");                             \
368                 else if (options.vrfy_option == BE_CH_VRFY_WARN && tmp != timer)                       \
369                         fprintf(stderr, "Attempt to pop wrong timer. %s is on stack, trying to pop %s.\n", \
370                                 lc_timer_get_name(tmp), lc_timer_get_name(timer));                             \
371                 timer = tmp;                                                                           \
372         }
373
374 /**
375  * Perform things which need to be done per register class before spilling.
376  */
377 static void pre_spill(const arch_isa_t *isa, int cls_idx, post_spill_env_t *pse) {
378         be_chordal_env_t *chordal_env = &pse->cenv;
379         be_irg_t         *birg        = pse->birg;
380         node_stat_t      node_stat;
381
382         pse->cls                   = arch_isa_get_reg_class(isa, cls_idx);
383         chordal_env->cls           = pse->cls;
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] = pse->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(birg, pse->cls, &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(birg, pse->cls, chordal_env->ignore_colors);
400
401         be_pre_spill_prepare_constr(chordal_env);
402         dump(BE_CH_DUMP_CONSTR, birg->irg, pse->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(birg->irg,
407                         birg->main_env->arch_env, birg->exec_freq);
408                 be_stat_ev_pop();
409         }
410 #endif /* FIRM_STATISTICS */
411 }
412
413 /**
414  * Perform things which need to be done per register class after spilling.
415  */
416 static void post_spill(post_spill_env_t *pse, int iteration) {
417         be_chordal_env_t    *chordal_env = &pse->cenv;
418         be_irg_t            *birg        = pse->birg;
419         ir_graph            *irg         = birg->irg;
420         const be_main_env_t *main_env    = birg->main_env;
421         be_options_t        *main_opts   = main_env->options;
422         static int          splitted     = 0;
423         node_stat_t         node_stat;
424
425 #ifdef FIRM_STATISTICS
426         if (be_stat_ev_is_active()) {
427                 double spillcosts = be_estimate_irg_costs(irg, main_env->arch_env, birg->exec_freq) - pse->pre_spill_cost;
428
429                 be_stat_tags[STAT_TAG_CLS] = pse->cls->name;
430                 be_stat_ev_push(be_stat_tags, STAT_TAG_LAST, be_stat_file);
431
432                 be_stat_ev_l("spillcosts", (long) spillcosts);
433
434                 node_stats(birg, pse->cls, &node_stat);
435                 be_stat_ev("phis_after_spill", node_stat.n_phis);
436                 be_stat_ev("mem_phis", node_stat.n_mem_phis);
437                 be_stat_ev("reloads", node_stat.n_reloads);
438                 be_stat_ev("spills", node_stat.n_spills);
439         }
440 #endif /* FIRM_STATISTICS */
441
442         /*
443                 If we have a backend provided spiller, post spill is
444                 called in a loop after spilling for each register class.
445                 But we only need to fix stack nodes once in this case.
446         */
447         if (iteration == 0) {
448                 check_for_memory_operands(chordal_env);
449                 be_abi_fix_stack_nodes(birg->abi, birg->lv);
450         }
451
452         BE_TIMER_PUSH(ra_timer.t_verify);
453
454         /* verify schedule and register pressure */
455         if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
456                 be_verify_schedule(irg);
457                 be_verify_register_pressure(birg, pse->cls, irg);
458         }
459         else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
460                 assert(be_verify_schedule(irg) && "Schedule verification failed");
461                 assert(be_verify_register_pressure(birg, pse->cls, irg)
462                         && "Register pressure verification failed");
463         }
464         BE_TIMER_POP(ra_timer.t_verify);
465
466         if (be_elr_split && ! splitted) {
467                 extreme_liverange_splitting(chordal_env);
468                 splitted = 1;
469         }
470
471         /* Color the graph. */
472         BE_TIMER_PUSH(ra_timer.t_color);
473         be_ra_chordal_color(chordal_env);
474         BE_TIMER_POP(ra_timer.t_color);
475
476         dump(BE_CH_DUMP_CONSTR, irg, pse->cls, "-color", dump_ir_block_graph_sched);
477
478         /* Create the ifg with the selected flavor */
479         BE_TIMER_PUSH(ra_timer.t_ifg);
480         chordal_env->ifg = be_create_ifg(chordal_env);
481         BE_TIMER_POP(ra_timer.t_ifg);
482
483 #ifdef FIRM_STATISTICS
484         if (be_stat_ev_is_active()) {
485                 be_ifg_stat_t stat;
486
487                 be_ifg_stat(birg, chordal_env->ifg, &stat);
488                 be_stat_ev("ifg_nodes", stat.n_nodes);
489                 be_stat_ev("ifg_edges", stat.n_edges);
490                 be_stat_ev("ifg_comps", stat.n_comps);
491
492                 node_stats(birg, pse->cls, &node_stat);
493                 be_stat_ev("perms_before_coal", node_stat.n_perms);
494                 be_stat_ev("copies_before_coal", node_stat.n_copies);
495         }
496 #endif /* FIRM_STATISTICS */
497
498         /* copy minimization */
499         BE_TIMER_PUSH(ra_timer.t_copymin);
500         co_driver(chordal_env);
501         BE_TIMER_POP(ra_timer.t_copymin);
502
503         dump(BE_CH_DUMP_COPYMIN, irg, pse->cls, "-copymin", dump_ir_block_graph_sched);
504
505         BE_TIMER_PUSH(ra_timer.t_ssa);
506
507         /* ssa destruction */
508         be_ssa_destruction(chordal_env);
509
510         BE_TIMER_POP(ra_timer.t_ssa);
511
512         dump(BE_CH_DUMP_SSADESTR, irg, pse->cls, "-ssadestr", dump_ir_block_graph_sched);
513
514         BE_TIMER_PUSH(ra_timer.t_verify);
515         if (chordal_env->opts->vrfy_option != BE_CH_VRFY_OFF) {
516                 be_ssa_destruction_check(chordal_env);
517         }
518         BE_TIMER_POP(ra_timer.t_verify);
519
520         /* free some data structures */
521         be_ifg_free(chordal_env->ifg);
522         pmap_destroy(chordal_env->border_heads);
523         bitset_free(chordal_env->ignore_colors);
524
525 #ifdef FIRM_STATISTICS
526         if (be_stat_ev_is_active()) {
527                 node_stats(birg, pse->cls, &node_stat);
528                 be_stat_ev("perms_after_coal", node_stat.n_perms);
529                 be_stat_ev("copies_after_coal", node_stat.n_copies);
530                 be_stat_ev_pop();
531         }
532 #endif /* FIRM_STATISTICS */
533 }
534
535 /**
536  * Performs chordal register allocation for each register class on given irg.
537  *
538  * @param birg  Backend irg object
539  * @return Structure containing timer for the single phases or NULL if no timing requested.
540  */
541 static void be_ra_chordal_main(be_irg_t *birg)
542 {
543         const be_main_env_t *main_env  = birg->main_env;
544         const arch_isa_t    *isa       = arch_env_get_isa(main_env->arch_env);
545         ir_graph            *irg       = birg->irg;
546         be_options_t        *main_opts = main_env->options;
547         int                 j, m;
548         be_chordal_env_t    chordal_env;
549
550         BE_TIMER_INIT(main_opts);
551         BE_TIMER_PUSH(ra_timer.t_other);
552         BE_TIMER_PUSH(ra_timer.t_prolog);
553
554         be_assure_dom_front(birg);
555         be_assure_liveness(birg);
556
557         chordal_env.opts      = &options;
558         chordal_env.irg       = irg;
559         chordal_env.birg      = birg;
560         FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
561
562         obstack_init(&chordal_env.obst);
563
564         BE_TIMER_POP(ra_timer.t_prolog);
565
566         be_stat_ev("insns_before", count_insns(irg));
567
568         if (! arch_code_generator_has_spiller(birg->cg)) {
569                 /* use one of the generic spiller */
570
571                 /* Perform the following for each register class. */
572                 for (j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
573                         post_spill_env_t pse;
574
575                         memcpy(&pse.cenv, &chordal_env, sizeof(chordal_env));
576                         pse.birg = birg;
577                         pre_spill(isa, j, &pse);
578
579                         BE_TIMER_PUSH(ra_timer.t_spill);
580                         be_do_spill(birg, pse.cls);
581                         BE_TIMER_POP(ra_timer.t_spill);
582
583                         dump(BE_CH_DUMP_SPILL, irg, pse.cls, "-spill", dump_ir_block_graph_sched);
584
585                         post_spill(&pse, 0);
586                 }
587         } else {
588                 post_spill_env_t *pse;
589
590                 /* the backend has it's own spiller */
591                 m = arch_isa_get_n_reg_class(isa);
592
593                 pse = alloca(m * sizeof(pse[0]));
594
595                 for (j = 0; j < m; ++j) {
596                         memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env));
597                         pse[j].birg = birg;
598                         pre_spill(isa, j, &pse[j]);
599                 }
600
601                 BE_TIMER_PUSH(ra_timer.t_spill);
602                 arch_code_generator_spill(birg->cg, birg);
603                 BE_TIMER_POP(ra_timer.t_spill);
604                 dump(BE_CH_DUMP_SPILL, irg, NULL, "-spill", dump_ir_block_graph_sched);
605
606                 for (j = 0; j < m; ++j) {
607                         post_spill(&pse[j], j);
608                 }
609         }
610
611         BE_TIMER_PUSH(ra_timer.t_epilog);
612         lower_nodes_after_ra(birg, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
613         dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
614
615         obstack_free(&chordal_env.obst, NULL);
616         be_invalidate_liveness(birg);
617         BE_TIMER_POP(ra_timer.t_epilog);
618
619         BE_TIMER_POP(ra_timer.t_other);
620
621         be_stat_ev("insns_after", count_insns(irg));
622
623         return;
624 }
625
626 static be_ra_t be_ra_chordal_allocator = {
627         be_ra_chordal_main,
628 };
629
630 void be_init_chordal(void)
631 {
632         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
633         lc_opt_entry_t *ra_grp = lc_opt_get_grp(be_grp, "ra");
634         lc_opt_entry_t *chordal_grp = lc_opt_get_grp(ra_grp, "chordal");
635
636         lc_opt_add_table(chordal_grp, be_chordal_options);
637
638         be_register_allocator("chordal", &be_ra_chordal_allocator);
639 }
640
641 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_chordal);