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