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