fixed string constant dumper (emit \ correct)
[libfirm] / ir / be / bechordal_main.c
1 /**
2  * @file   bechordal_main.c
3  * @date   29.11.2005
4  * @author Sebastian Hack
5  *
6  * Copyright (C) 2005 Universitaet Karlsruhe
7  * Released under the GPL
8  *
9  * Driver for the chordal register allocator.
10  */
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14
15 #include "obst.h"
16 #include "pset.h"
17 #include "list.h"
18 #include "bitset.h"
19 #include "iterator.h"
20 #include "firm_config.h"
21
22 #ifdef WITH_LIBCORE
23 #include <libcore/lc_opts.h>
24 #include <libcore/lc_opts_enum.h>
25 #include <libcore/lc_timing.h>
26 #endif /* WITH_LIBCORE */
27
28 #include "irmode_t.h"
29 #include "irgraph_t.h"
30 #include "irprintf_t.h"
31 #include "irgwalk.h"
32 #include "irdump.h"
33 #include "irdom.h"
34 #include "irbitset.h"
35 #include "debug.h"
36 #include "xmalloc.h"
37 #include "execfreq.h"
38
39 #include "bechordal_t.h"
40 #include "beabi.h"
41 #include "beutil.h"
42 #include "besched.h"
43 #include "benumb_t.h"
44 #include "besched_t.h"
45 #include "belive_t.h"
46 #include "bearch.h"
47 #include "beifg_t.h"
48 #include "beifg_impl.h"
49
50 #include "bespillbelady.h"
51 #include "bespillmorgan.h"
52 #include "belower.h"
53
54 #ifdef WITH_ILP
55 #include "bespillremat.h"
56 #endif /* WITH_ILP */
57
58 #include "becopystat.h"
59 #include "becopyopt.h"
60 #include "bessadestr.h"
61 #include "beverify.h"
62
63 void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
64         const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
65         struct obstack ob;
66         pmap_entry *pme;
67         ir_node **nodes, *n1, *n2;
68         int i, o;
69         DEBUG_ONLY(firm_dbg_module_t *dbg = chordal_env->dbg;)
70
71         /* Collect all irns */
72         obstack_init(&ob);
73         pmap_foreach(chordal_env->border_heads, pme) {
74                 border_t *curr;
75                 struct list_head *head = pme->value;
76                 list_for_each_entry(border_t, curr, head, list)
77                         if (curr->is_def && curr->is_real)
78                                 if (arch_get_irn_reg_class(arch_env, curr->irn, -1) == chordal_env->cls)
79                                         obstack_ptr_grow(&ob, curr->irn);
80         }
81         obstack_ptr_grow(&ob, NULL);
82         nodes = (ir_node **) obstack_finish(&ob);
83
84         /* Check them */
85         for (i = 0, n1 = nodes[i]; n1; n1 = nodes[++i]) {
86                 const arch_register_t *n1_reg, *n2_reg;
87
88                 n1_reg = arch_get_irn_register(arch_env, n1);
89                 if (!arch_reg_is_allocatable(arch_env, n1, -1, n1_reg)) {
90                         DBG((dbg, 0, "Register %s assigned to %+F is not allowed\n", n1_reg->name, n1));
91                         assert(0 && "Register constraint does not hold");
92                 }
93                 for (o = i+1, n2 = nodes[o]; n2; n2 = nodes[++o]) {
94                         n2_reg = arch_get_irn_register(arch_env, n2);
95                         if (values_interfere(n1, n2) && n1_reg == n2_reg) {
96                                 DBG((dbg, 0, "Values %+F and %+F interfere and have the same register assigned: %s\n", n1, n2, n1_reg->name));
97                                 assert(0 && "Interfering values have the same color!");
98                         }
99                 }
100         }
101         obstack_free(&ob, NULL);
102 }
103
104 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b)
105 {
106         if(env->ifg)
107                 return be_ifg_connected(env->ifg, a, b);
108         else
109                 return values_interfere(a, b);
110 }
111
112
113 static be_ra_chordal_opts_t options = {
114         BE_CH_DUMP_NONE,
115         BE_CH_SPILL_BELADY,
116         BE_CH_COPYMIN_HEUR2,
117         BE_CH_IFG_STD,
118         BE_CH_LOWER_PERM_SWAP,
119         BE_CH_VRFY_WARN,
120 };
121
122 static be_ra_timer_t ra_timer = {
123         NULL,
124         NULL,
125         NULL,
126         NULL,
127         NULL,
128         NULL,
129         NULL,
130         NULL,
131         NULL,
132         NULL,
133 };
134
135 #ifdef WITH_LIBCORE
136 static const lc_opt_enum_int_items_t spill_items[] = {
137         { "morgan", BE_CH_SPILL_MORGAN },
138         { "belady", BE_CH_SPILL_BELADY },
139 #ifdef WITH_ILP
140         { "remat",  BE_CH_SPILL_REMAT },
141 #endif /* WITH_ILP */
142         { NULL, 0 }
143 };
144
145 static const lc_opt_enum_int_items_t copymin_items[] = {
146         { "none",  BE_CH_COPYMIN_NONE      },
147         { "heur1", BE_CH_COPYMIN_HEUR1     },
148         { "heur2", BE_CH_COPYMIN_HEUR2     },
149         { "stat",  BE_CH_COPYMIN_STAT      },
150         { "park",  BE_CH_COPYMIN_PARK_MOON },
151 #ifdef WITH_ILP
152         { "ilp1",  BE_CH_COPYMIN_ILP1 },
153         { "ilp2",  BE_CH_COPYMIN_ILP2 },
154 #endif /* WITH_ILP */
155         { NULL, 0 }
156 };
157
158 static const lc_opt_enum_int_items_t ifg_flavor_items[] = {
159         { "std",     BE_CH_IFG_STD     },
160         { "fast",    BE_CH_IFG_FAST    },
161         { "clique",  BE_CH_IFG_CLIQUE  },
162         { "pointer", BE_CH_IFG_POINTER },
163         { "list",    BE_CH_IFG_LIST    },
164         { "check",   BE_CH_IFG_CHECK   },
165         { NULL,      0                 }
166 };
167
168 static const lc_opt_enum_int_items_t lower_perm_items[] = {
169         { "copy", BE_CH_LOWER_PERM_COPY },
170         { "swap", BE_CH_LOWER_PERM_SWAP },
171         { NULL, 0 }
172 };
173
174 static const lc_opt_enum_int_items_t lower_perm_stat_items[] = {
175         { NULL, 0 }
176 };
177
178 static const lc_opt_enum_int_items_t dump_items[] = {
179         { "spill",    BE_CH_DUMP_SPILL     },
180         { "live",     BE_CH_DUMP_LIVE      },
181         { "color",    BE_CH_DUMP_COLOR     },
182         { "copymin",  BE_CH_DUMP_COPYMIN   },
183         { "ssadestr", BE_CH_DUMP_SSADESTR  },
184         { "tree",     BE_CH_DUMP_TREE_INTV },
185         { "constr",   BE_CH_DUMP_CONSTR    },
186         { "lower",    BE_CH_DUMP_LOWER     },
187         { "all",      BE_CH_DUMP_ALL       },
188         { NULL, 0 }
189 };
190
191 static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
192         { "off",    BE_CH_VRFY_OFF    },
193         { "warn",   BE_CH_VRFY_WARN   },
194         { "assert", BE_CH_VRFY_ASSERT },
195         { NULL, 0 }
196 };
197
198 static lc_opt_enum_int_var_t spill_var = {
199         &options.spill_method, spill_items
200 };
201
202 static lc_opt_enum_int_var_t copymin_var = {
203         &options.copymin_method, copymin_items
204 };
205
206 static lc_opt_enum_int_var_t ifg_flavor_var = {
207         &options.ifg_flavor, ifg_flavor_items
208 };
209
210 static lc_opt_enum_int_var_t lower_perm_var = {
211         &options.lower_perm_opt, lower_perm_items
212 };
213
214 static lc_opt_enum_int_var_t dump_var = {
215         &options.dump_flags, dump_items
216 };
217
218 static lc_opt_enum_int_var_t be_ch_vrfy_var = {
219         &options.vrfy_option, be_ch_vrfy_items
220 };
221
222 static int be_copymin_stats = 0;
223
224 /** Assumed loop iteration count for execution frequency estimation. */
225 static int be_loop_weight = 9;
226
227 static const lc_opt_table_entry_t be_chordal_options[] = {
228         LC_OPT_ENT_ENUM_INT ("spill",         "spill method (belady, morgan or remat)", &spill_var),
229         LC_OPT_ENT_ENUM_PTR ("copymin",       "copymin method (none, heur1, heur2, ilp1, ilp2 or stat)", &copymin_var),
230         LC_OPT_ENT_ENUM_PTR ("ifg",           "interference graph flavour (std, fast, clique, pointer, list, check)", &ifg_flavor_var),
231         LC_OPT_ENT_ENUM_PTR ("perm",          "perm lowering options (copy or swap)", &lower_perm_var),
232         LC_OPT_ENT_ENUM_MASK("dump",          "select dump phases", &dump_var),
233         LC_OPT_ENT_ENUM_PTR ("vrfy",          "verify options (off, warn, assert)", &be_ch_vrfy_var),
234         LC_OPT_ENT_BOOL     ("copymin_stats", "dump statistics of copy minimization", &be_copymin_stats),
235         LC_OPT_ENT_INT      ("loop_weight",   "assumed amount of loop iterations for guessing the execution frequency", &be_loop_weight),
236         { NULL }
237 };
238
239 static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
240 {
241         static int run_once = 0;
242         lc_opt_entry_t *chordal_grp;
243
244         if (! run_once) {
245                 run_once    = 1;
246                 chordal_grp = lc_opt_get_grp(grp, "chordal");
247
248                 lc_opt_add_table(chordal_grp, be_chordal_options);
249         }
250
251         co_register_options(chordal_grp);
252 }
253 #endif /* WITH_LIBCORE */
254
255 static void dump(unsigned mask, ir_graph *irg,
256                                  const arch_register_class_t *cls,
257                                  const char *suffix,
258                                  void (*dump_func)(ir_graph *, const char *))
259 {
260         if((options.dump_flags & mask) == mask) {
261                 if (cls) {
262                         char buf[256];
263                         snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
264                         be_dump(irg, buf, dump_func);
265                 }
266                 else
267                         be_dump(irg, suffix, dump_func);
268         }
269 }
270
271 static void put_ignore_colors(be_chordal_env_t *chordal_env)
272 {
273         int n_colors = chordal_env->cls->n_regs;
274         int i;
275
276         bitset_clear_all(chordal_env->ignore_colors);
277         be_abi_put_ignore_regs(chordal_env->birg->abi, chordal_env->cls, chordal_env->ignore_colors);
278         for(i = 0; i < n_colors; ++i)
279                 if(arch_register_type_is(&chordal_env->cls->regs[i], ignore))
280                         bitset_set(chordal_env->ignore_colors, i);
281 }
282
283 FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const char *suffix)
284 {
285         char buf[1024];
286
287         ir_snprintf(buf, sizeof(buf), "%s%F_%s.%s", prefix, env->irg, env->cls->name, suffix);
288         return fopen(buf, "wt");
289 }
290
291 void check_ifg_implementations(be_chordal_env_t *chordal_env)
292 {
293         FILE *f;
294
295         f = be_chordal_open(chordal_env, "std", "log");
296         chordal_env->ifg = be_ifg_std_new(chordal_env);
297         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
298         fclose(f);
299
300         f = be_chordal_open(chordal_env, "list", "log");
301         be_ifg_free(chordal_env->ifg);
302         chordal_env->ifg = be_ifg_list_new(chordal_env);
303         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
304         fclose(f);
305
306         f = be_chordal_open(chordal_env, "clique", "log");
307         be_ifg_free(chordal_env->ifg);
308         chordal_env->ifg = be_ifg_clique_new(chordal_env);
309         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
310         fclose(f);
311
312         f = be_chordal_open(chordal_env, "pointer", "log");
313         be_ifg_free(chordal_env->ifg);
314         chordal_env->ifg = be_ifg_pointer_new(chordal_env);
315         be_ifg_check_sorted_to_file(chordal_env->ifg, f);
316         fclose(f);
317
318         chordal_env->ifg = NULL;
319 };
320
321 static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
322 {
323         const be_main_env_t *main_env  = bi->main_env;
324         const arch_isa_t    *isa       = arch_env_get_isa(main_env->arch_env);
325         ir_graph            *irg       = bi->irg;
326         be_options_t        *main_opts = main_env->options;
327         copy_opt_t          *co;
328
329         int j, m;
330         be_chordal_env_t chordal_env;
331
332         if (main_opts->timing == BE_TIME_ON) {
333                 ra_timer.t_prolog  = lc_timer_register("ra_prolog",   "regalloc prolog");
334                 ra_timer.t_epilog  = lc_timer_register("ra_epilog",   "regalloc epilog");
335                 ra_timer.t_live    = lc_timer_register("ra_liveness", "be liveness");
336                 ra_timer.t_spill   = lc_timer_register("ra_spill",    "spiller");
337                 ra_timer.t_color   = lc_timer_register("ra_color",    "graph coloring");
338                 ra_timer.t_ifg     = lc_timer_register("ra_ifg",      "interference graph");
339                 ra_timer.t_copymin = lc_timer_register("ra_copymin",  "copy minimization");
340                 ra_timer.t_ssa     = lc_timer_register("ra_ssadestr", "ssa destruction");
341                 ra_timer.t_verify  = lc_timer_register("ra_verify",   "graph verification");
342                 ra_timer.t_other   = lc_timer_register("ra_other",    "other time");
343
344                 LC_STOP_AND_RESET_TIMER(ra_timer.t_prolog);
345                 LC_STOP_AND_RESET_TIMER(ra_timer.t_epilog);
346                 LC_STOP_AND_RESET_TIMER(ra_timer.t_live);
347                 LC_STOP_AND_RESET_TIMER(ra_timer.t_spill);
348                 LC_STOP_AND_RESET_TIMER(ra_timer.t_color);
349                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ifg);
350                 LC_STOP_AND_RESET_TIMER(ra_timer.t_copymin);
351                 LC_STOP_AND_RESET_TIMER(ra_timer.t_ssa);
352                 LC_STOP_AND_RESET_TIMER(ra_timer.t_verify);
353                 LC_STOP_AND_RESET_TIMER(ra_timer.t_other);
354         }
355
356 #define BE_TIMER_PUSH(timer)                                                        \
357         if (main_opts->timing == BE_TIME_ON) {                                          \
358                 int res = lc_timer_push(timer);                                             \
359                 if (options.vrfy_option == BE_CH_VRFY_ASSERT)                               \
360                         assert(res && "Timer already on stack, cannot be pushed twice.");       \
361                 else if (options.vrfy_option == BE_CH_VRFY_WARN && ! res)                   \
362                         fprintf(stderr, "Timer %s already on stack, cannot be pushed twice.\n", \
363                                 lc_timer_get_name(timer));                                          \
364         }
365 #define BE_TIMER_POP(timer)                                                                    \
366         if (main_opts->timing == BE_TIME_ON) {                                                     \
367                 lc_timer_t *tmp = lc_timer_pop();                                                      \
368                 if (options.vrfy_option == BE_CH_VRFY_ASSERT)                                          \
369                         assert(tmp == timer && "Attempt to pop wrong timer.");                             \
370                 else if (options.vrfy_option == BE_CH_VRFY_WARN && tmp != timer)                       \
371                         fprintf(stderr, "Attempt to pop wrong timer. %s is on stack, trying to pop %s.\n", \
372                                 lc_timer_get_name(tmp), lc_timer_get_name(timer));                             \
373                 timer = tmp;                                                                           \
374         }
375
376         BE_TIMER_PUSH(ra_timer.t_other);
377         BE_TIMER_PUSH(ra_timer.t_prolog);
378
379         compute_doms(irg);
380
381         chordal_env.opts      = &options;
382         chordal_env.irg       = irg;
383         chordal_env.birg      = bi;
384         chordal_env.dom_front = be_compute_dominance_frontiers(irg);
385         chordal_env.exec_freq = compute_execfreq(irg, be_loop_weight);
386         FIRM_DBG_REGISTER(chordal_env.dbg, "firm.be.chordal");
387
388         obstack_init(&chordal_env.obst);
389
390         BE_TIMER_POP(ra_timer.t_prolog);
391
392         /* Perform the following for each register class. */
393         for(j = 0, m = arch_isa_get_n_reg_class(isa); j < m; ++j) {
394                 FILE *f;
395                 chordal_env.cls           = arch_isa_get_reg_class(isa, j);
396                 chordal_env.border_heads  = pmap_create();
397                 chordal_env.ignore_colors = bitset_malloc(chordal_env.cls->n_regs);
398
399                 BE_TIMER_PUSH(ra_timer.t_live);
400
401                 /* put all ignore registers into the ignore register set. */
402                 put_ignore_colors(&chordal_env);
403
404                 be_liveness(irg);
405
406                 BE_TIMER_POP(ra_timer.t_live);
407
408                 dump(BE_CH_DUMP_LIVE, irg, chordal_env.cls, "-live", dump_ir_block_graph_sched);
409
410                 BE_TIMER_PUSH(ra_timer.t_spill);
411
412                 /* spilling */
413                 switch(options.spill_method) {
414                 case BE_CH_SPILL_MORGAN:
415                         be_spill_morgan(&chordal_env);
416                         break;
417                 case BE_CH_SPILL_BELADY:
418                         be_spill_belady(&chordal_env);
419                         break;
420 #ifdef WITH_ILP
421                 case BE_CH_SPILL_REMAT:
422                         be_spill_remat(&chordal_env);
423                         break;
424 #endif /* WITH_ILP */
425                 default:
426                         fprintf(stderr, "no valid spiller selected. falling back to belady\n");
427                         be_spill_belady(&chordal_env);
428                 }
429
430                 BE_TIMER_POP(ra_timer.t_spill);
431
432                 dump(BE_CH_DUMP_SPILL, irg, chordal_env.cls, "-spill", dump_ir_block_graph_sched);
433                 be_abi_fix_stack_nodes(bi->abi);
434
435                 BE_TIMER_PUSH(ra_timer.t_verify);
436
437                 /* verify schedule and register pressure */
438                 if (options.vrfy_option == BE_CH_VRFY_WARN) {
439                         be_verify_schedule(irg);
440                         be_verify_register_pressure(chordal_env.birg->main_env->arch_env, chordal_env.cls, irg);
441                 }
442                 else if (options.vrfy_option == BE_CH_VRFY_ASSERT) {
443                         assert(be_verify_schedule(irg) && "Schedule verification failed");
444                         assert(be_verify_register_pressure(chordal_env.birg->main_env->arch_env, chordal_env.cls, irg)
445                                 && "Register pressure verification failed");
446                 }
447
448                 BE_TIMER_POP(ra_timer.t_verify);
449                 BE_TIMER_PUSH(ra_timer.t_live);
450                 be_liveness(irg);
451                 BE_TIMER_POP(ra_timer.t_live);
452                 BE_TIMER_PUSH(ra_timer.t_color);
453
454                 /* Color the graph. */
455                 be_ra_chordal_color(&chordal_env);
456
457                 BE_TIMER_POP(ra_timer.t_color);
458
459                 dump(BE_CH_DUMP_CONSTR, irg, chordal_env.cls, "-color", dump_ir_block_graph_sched);
460
461                 BE_TIMER_PUSH(ra_timer.t_ifg);
462
463                 /* Create the ifg with the selected flavor */
464                 switch (options.ifg_flavor) {
465                         default:
466                                 fprintf(stderr, "no valid ifg flavour selected. falling back to std\n");
467                         case BE_CH_IFG_STD:
468                         case BE_CH_IFG_FAST:
469                                 chordal_env.ifg = be_ifg_std_new(&chordal_env);
470                                 break;
471                         case BE_CH_IFG_CLIQUE:
472                                 chordal_env.ifg = be_ifg_clique_new(&chordal_env);
473                                 break;
474                         case BE_CH_IFG_POINTER:
475                                 chordal_env.ifg = be_ifg_pointer_new(&chordal_env);
476                                 break;
477                         case BE_CH_IFG_LIST:
478                                 chordal_env.ifg = be_ifg_list_new(&chordal_env);
479                                 break;
480                         case BE_CH_IFG_CHECK:
481                                 check_ifg_implementations(&chordal_env);
482                                 /* Build the interference graph. */
483                                 chordal_env.ifg = be_ifg_std_new(&chordal_env);
484                                 break;
485                 }
486
487
488 #if 0
489                 {
490                         be_ifg_t *std = be_ifg_std_new(&chordal_env);
491                         f = be_chordal_open(&chordal_env, "std", "csv");
492                         be_ifg_check_sorted_to_file(std, f);
493                         be_ifg_free(std);
494                         fclose(f);
495                 }
496
497                 f = be_chordal_open(&chordal_env, "clique", "csv");
498                 be_ifg_check_sorted_to_file(chordal_env.ifg, f);
499                 fclose(f);
500 #endif
501                 BE_TIMER_POP(ra_timer.t_ifg);
502
503                 BE_TIMER_PUSH(ra_timer.t_verify);
504
505                 if (options.vrfy_option != BE_CH_VRFY_OFF)
506                         be_ra_chordal_check(&chordal_env);
507
508 //              be_ifg_check_sorted(chordal_env.ifg);
509                 BE_TIMER_POP(ra_timer.t_verify);
510                 BE_TIMER_PUSH(ra_timer.t_copymin);
511
512                 /* copy minimization */
513                 co = NULL;
514                 if (options.copymin_method != BE_CH_COPYMIN_NONE && options.copymin_method != BE_CH_COPYMIN_STAT) {
515                         FILE *f;
516                         co = new_copy_opt(&chordal_env, co_get_costs_loop_depth);
517                         co_build_ou_structure(co);
518                         co_build_graph_structure(co);
519                         if(be_copymin_stats) {
520                                 ir_printf("%40F %20s\n", current_ir_graph, chordal_env.cls->name);
521                                 printf("max copy costs:         %d\n", co_get_max_copy_costs(co));
522                                 printf("init copy costs:        %d\n", co_get_copy_costs(co));
523                                 printf("inevit copy costs:      %d\n", co_get_inevit_copy_costs(co));
524                                 printf("copy costs lower bound: %d\n", co_get_lower_bound(co));
525                         }
526
527 #if 0
528                         f = be_chordal_open(&chordal_env, "appel-", "apl");
529                         co_dump_appel_graph(co, f);
530                         fclose(f);
531                         f = be_chordal_open(&chordal_env, "appel-clique-", "p");
532                         co_dump_appel_graph_cliques(co, f);
533                         fclose(f);
534 #endif
535                 }
536
537                 switch(options.copymin_method) {
538                         case BE_CH_COPYMIN_HEUR1:
539                                 co_solve_heuristic(co);
540                                 break;
541                         case BE_CH_COPYMIN_HEUR2:
542                                 co_solve_heuristic_new(co);
543                                 break;
544                         case BE_CH_COPYMIN_PARK_MOON:
545                                 co_solve_park_moon(co);
546                                 break;
547                         case BE_CH_COPYMIN_STAT:
548                                 co_compare_solvers(&chordal_env);
549                                 break;
550 #ifdef WITH_ILP
551                         case BE_CH_COPYMIN_ILP1:
552                                 printf("FIXME: %s:%d ILP1 not yet implemented!\n", __FILE__, __LINE__);
553                                 co_solve_ilp1(co, 60.0);
554                                 break;
555                         case BE_CH_COPYMIN_ILP2:
556                                 co_solve_ilp2(co, 60.0);
557                                 break;
558 #endif /* WITH_ILP */
559                         case BE_CH_COPYMIN_NONE:
560                         default:
561                                 break;
562                 }
563
564                 if (co) {
565                         if(be_copymin_stats) {
566                                 printf("final copy costs      : %d\n", co_get_copy_costs(co));
567                         }
568                         co_free_graph_structure(co);
569                         co_free_ou_structure(co);
570                         free_copy_opt(co);
571                 }
572
573                 BE_TIMER_POP(ra_timer.t_copymin);
574
575                 dump(BE_CH_DUMP_COPYMIN, irg, chordal_env.cls, "-copymin", dump_ir_block_graph_sched);
576
577                 BE_TIMER_PUSH(ra_timer.t_verify);
578
579                 if (options.vrfy_option != BE_CH_VRFY_OFF)
580                         be_ra_chordal_check(&chordal_env);
581
582                 BE_TIMER_POP(ra_timer.t_verify);
583                 BE_TIMER_PUSH(ra_timer.t_ssa);
584
585                 /* ssa destruction */
586                 be_ssa_destruction(&chordal_env);
587
588                 BE_TIMER_POP(ra_timer.t_ssa);
589
590                 dump(BE_CH_DUMP_SSADESTR, irg, chordal_env.cls, "-ssadestr", dump_ir_block_graph_sched);
591
592                 BE_TIMER_PUSH(ra_timer.t_verify);
593                 if (options.vrfy_option != BE_CH_VRFY_OFF) {
594                         be_ssa_destruction_check(&chordal_env);
595                         be_ra_chordal_check(&chordal_env);
596                 }
597                 BE_TIMER_POP(ra_timer.t_verify);
598
599                 if (options.copymin_method == BE_CH_COPYMIN_STAT)
600                         copystat_dump(irg);
601
602                 be_ifg_free(chordal_env.ifg);
603                 pmap_destroy(chordal_env.border_heads);
604                 bitset_free(chordal_env.ignore_colors);
605         }
606
607         BE_TIMER_PUSH(ra_timer.t_epilog);
608
609         be_compute_spill_offsets(&chordal_env);
610
611         dump(BE_CH_DUMP_LOWER, irg, NULL, "-spilloff", dump_ir_block_graph_sched);
612
613         lower_nodes_after_ra(&chordal_env, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
614         dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
615
616         obstack_free(&chordal_env.obst, NULL);
617         be_free_dominance_frontiers(chordal_env.dom_front);
618         free_execfreq(chordal_env.exec_freq);
619
620         BE_TIMER_POP(ra_timer.t_epilog);
621         BE_TIMER_POP(ra_timer.t_other);
622
623 #undef BE_TIMER_PUSH
624 #undef BE_TIMER_POP
625
626         return main_opts->timing == BE_TIME_ON ? &ra_timer : NULL;
627 }
628
629 const be_ra_t be_ra_chordal_allocator = {
630 #ifdef WITH_LIBCORE
631         be_ra_chordal_register_options,
632 #endif
633         be_ra_chordal_main
634 };