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