removed unused header
[libfirm] / ir / be / beblocksched.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       Block-scheduling strategies.
23  * @author      Matthias Braun, Christoph Mallon
24  * @date        27.09.2006
25  * @version     $Id$
26  */
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include "beblocksched.h"
32
33 #include <stdlib.h>
34
35 #include "array.h"
36 #include "pdeq.h"
37
38 #include "iredges.h"
39 #include "irgwalk.h"
40 #include "irgraph_t.h"
41 #include "irloop.h"
42 #include "irprintf.h"
43 #include "irdump_t.h"
44 #include "irtools.h"
45 #include "debug.h"
46 #include "beirgmod.h"
47 #include "bemodule.h"
48 #include "be.h"
49
50 #include <libcore/lc_opts.h>
51 #include <libcore/lc_opts_enum.h>
52 #include <libcore/lc_timing.h>
53
54 #ifdef WITH_ILP
55 #include <lpp/lpp.h>
56 #include <lpp/lpp_net.h>
57 #endif /* WITH_ILP */
58
59 DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
60
61 typedef enum _blocksched_algos_t {
62         BLOCKSCHED_NAIV, BLOCKSCHED_EXTBB, BLOCKSCHED_GREEDY, BLOCKSCHED_ILP
63 } blocksched_algos_t;
64
65 static int algo = BLOCKSCHED_GREEDY;
66
67 static const lc_opt_enum_int_items_t blockschedalgo_items[] = {
68         { "naiv",       BLOCKSCHED_NAIV },
69         { "extbb",      BLOCKSCHED_EXTBB },
70         { "greedy", BLOCKSCHED_GREEDY },
71 #ifdef WITH_ILP
72         { "ilp",    BLOCKSCHED_ILP },
73 #endif /* WITH_ILP */
74         { NULL,     0 }
75 };
76
77 static lc_opt_enum_int_var_t algo_var = {
78         &algo, blockschedalgo_items
79 };
80
81 static const lc_opt_table_entry_t be_blocksched_options[] = {
82         LC_OPT_ENT_ENUM_INT ("algo", "the block scheduling algorithm", &algo_var),
83         { NULL }
84 };
85
86 /*
87  *   ____                   _
88  *  / ___|_ __ ___  ___  __| |_   _
89  * | |  _| '__/ _ \/ _ \/ _` | | | |
90  * | |_| | | |  __/  __/ (_| | |_| |
91  *  \____|_|  \___|\___|\__,_|\__, |
92  *                            |___/
93  */
94
95 typedef struct _blocksched_entry_t {
96         ir_node *block;
97         struct _blocksched_entry_t *next;
98         struct _blocksched_entry_t *prev;
99 } blocksched_entry_t;
100
101 typedef struct _edge_t {
102         ir_node *block;             /**< source block */
103         int     pos;                /**< number of cfg predecessor (target) */
104         double  execfreq;           /**< the frequency */
105         int     highest_execfreq;   /**< flag that indicates wether this edge is the edge with the highest
106                                                                      execfreq pointing away from this block */
107 } edge_t;
108
109 typedef struct _blocksched_env_t {
110         ir_graph       *irg;
111         struct obstack *obst;
112         ir_exec_freq   *execfreqs;
113         edge_t         *edges;
114         pdeq           *worklist;
115         int            blockcount;
116 } blocksched_env_t;
117
118 /**
119  * Collect cfg frequencies of all edges between blocks.
120  * Also determines edge with highest frequency.
121  */
122 static void collect_egde_frequency(ir_node *block, void *data)
123 {
124         blocksched_env_t   *env = data;
125         int                arity;
126         edge_t             edge;
127         blocksched_entry_t *entry;
128
129         entry        = obstack_alloc(env->obst, sizeof(entry[0]));
130         entry->block = block;
131         entry->next  = NULL;
132         entry->prev  = NULL;
133         set_irn_link(block, entry);
134
135         if (block == get_irg_start_block(env->irg))
136                 return;
137
138         arity = get_irn_arity(block);
139
140         if (arity == 1) {
141                 edge.block            = block;
142                 edge.pos              = 0;
143                 edge.execfreq         = get_block_execfreq(env->execfreqs, block);
144                 edge.highest_execfreq = 1;
145                 ARR_APP1(edge_t, env->edges, edge);
146         } else {
147                 int    i;
148                 double highest_execfreq = -1.0;
149                 int    highest_edge_num = -1;
150
151                 edge.block = block;
152                 for (i = 0; i < arity; ++i) {
153                         double  execfreq;
154                         ir_node *pred_block = get_Block_cfgpred_block(block, i);
155
156                         execfreq = get_block_execfreq(env->execfreqs, pred_block);
157
158                         edge.pos              = i;
159                         edge.execfreq         = execfreq;
160                         edge.highest_execfreq = 0;
161                         ARR_APP1(edge_t, env->edges, edge);
162
163                         if (execfreq > highest_execfreq) {
164                                 highest_execfreq = execfreq;
165                                 highest_edge_num = ARR_LEN(env->edges) - 1;
166                         }
167                 }
168
169                 if(highest_edge_num >= 0)
170                         env->edges[highest_edge_num].highest_execfreq = 1;
171         }
172 }
173
174 static int cmp_edges(const void *d1, const void *d2)
175 {
176         const edge_t *e1 = d1;
177         const edge_t *e2 = d2;
178
179         return QSORT_CMP(e2->execfreq, e1->execfreq);
180 }
181
182 static void coalesce_blocks(blocksched_env_t *env)
183 {
184         int i;
185         int edge_count = ARR_LEN(env->edges);
186
187         /* run1: only look at jumps */
188         for (i = 0; i < edge_count; ++i) {
189                 const edge_t *edge  = &env->edges[i];
190                 ir_node      *block = edge->block;
191                 ir_node      *pred_block;
192                 blocksched_entry_t *entry, *pred_entry;
193
194                 /* the block might have been removed already... */
195                 if (is_Bad(get_Block_cfgpred(block, 0)))
196                         continue;
197
198                 /* only check edge with highest frequency */
199                 if (! edge->highest_execfreq)
200                         continue;
201
202                 pred_block = get_Block_cfgpred_block(block, edge->pos);
203                 entry      = get_irn_link(block);
204                 pred_entry = get_irn_link(pred_block);
205
206                 if (pred_entry->next != NULL || entry->prev != NULL)
207                         continue;
208
209                 /* only coalesce jumps */
210                 if (get_block_succ_next(pred_block, get_block_succ_first(pred_block)) != NULL)
211                         continue;
212
213                 /* schedule the 2 blocks behind each other */
214                 DBG((dbg, LEVEL_1, "Coalesce (Jump) %+F -> %+F (%.3g)\n",
215                            pred_entry->block, entry->block, edge->execfreq));
216                 pred_entry->next = entry;
217                 entry->prev      = pred_entry;
218         }
219
220         /* run2: remaining edges */
221         for (i = 0; i < edge_count; ++i) {
222                 const edge_t *edge  = &env->edges[i];
223                 ir_node      *block = edge->block;
224                 ir_node      *pred_block;
225                 blocksched_entry_t *entry, *pred_entry;
226
227                 /* the block might have been removed already... */
228                 if (is_Bad(get_Block_cfgpred(block, 0)))
229                         continue;
230
231                 pred_block = get_Block_cfgpred_block(block, edge->pos);
232                 entry      = get_irn_link(block);
233                 pred_entry = get_irn_link(pred_block);
234
235                 /* is 1 of the blocks already attached to another block? */
236                 if (pred_entry->next != NULL || entry->prev != NULL)
237                         continue;
238
239                 /* schedule the 2 blocks behind each other */
240                 DBG((dbg, LEVEL_1, "Coalesce (CondJump) %+F -> %+F (%.3g)\n",
241                            pred_entry->block, entry->block, edge->execfreq));
242                 pred_entry->next = entry;
243                 entry->prev      = pred_entry;
244         }
245 }
246
247 static void pick_block_successor(blocksched_entry_t *entry, blocksched_env_t *env)
248 {
249         ir_node            *block = entry->block;
250         ir_node            *succ  = NULL;
251         blocksched_entry_t *succ_entry;
252         const ir_edge_t    *edge;
253         double             best_succ_execfreq;
254
255         if (irn_visited(block))
256                 return;
257
258         env->blockcount++;
259         mark_irn_visited(block);
260
261         DBG((dbg, LEVEL_1, "Pick succ of %+F\n", block));
262
263         /* put all successors into the worklist */
264         foreach_block_succ(block, edge) {
265                 ir_node *succ_block = get_edge_src_irn(edge);
266
267                 if (irn_visited(succ_block))
268                         continue;
269
270                 /* we only need to put the first of a series of already connected
271                  * blocks into the worklist */
272                 succ_entry = get_irn_link(succ_block);
273                 while (succ_entry->prev != NULL) {
274                         /* break cycles... */
275                         if (succ_entry->prev->block == succ_block) {
276                                 succ_entry->prev->next = NULL;
277                                 succ_entry->prev       = NULL;
278                                 break;
279                         }
280                         succ_entry = succ_entry->prev;
281                 };
282
283                 if (irn_visited(succ_entry->block))
284                         continue;
285
286                 DBG((dbg, LEVEL_1, "Put %+F into worklist\n", succ_entry->block));
287                 pdeq_putr(env->worklist, succ_entry->block);
288         }
289
290         if (entry->next != NULL) {
291                 pick_block_successor(entry->next, env);
292                 return;
293         }
294
295         DBG((dbg, LEVEL_1, "deciding...\n"));
296         best_succ_execfreq = -1;
297
298         /* no successor yet: pick the successor block with the highest execution
299          * frequency which has no predecessor yet */
300
301         foreach_block_succ(block, edge) {
302                 ir_node *succ_block = get_edge_src_irn(edge);
303                 double  execfreq;
304
305                 if (irn_visited(succ_block))
306                         continue;
307
308                 succ_entry = get_irn_link(succ_block);
309                 if (succ_entry->prev != NULL)
310                         continue;
311
312                 execfreq = get_block_execfreq(env->execfreqs, succ_block);
313                 if (execfreq > best_succ_execfreq) {
314                         best_succ_execfreq = execfreq;
315                         succ = succ_block;
316                 }
317         }
318
319         if (succ == NULL) {
320                 DBG((dbg, LEVEL_1, "pick from worklist\n"));
321
322                 do {
323                         if (pdeq_empty(env->worklist)) {
324                                 DBG((dbg, LEVEL_1, "worklist empty\n"));
325                                 return;
326                         }
327                         succ = pdeq_getl(env->worklist);
328                 } while (irn_visited(succ));
329         }
330
331         succ_entry       = get_irn_link(succ);
332         entry->next      = succ_entry;
333         succ_entry->prev = entry;
334
335         pick_block_successor(succ_entry, env);
336 }
337
338 static blocksched_entry_t *finish_block_schedule(blocksched_env_t *env)
339 {
340         ir_graph           *irg        = env->irg;
341         ir_node            *startblock = get_irg_start_block(irg);
342         blocksched_entry_t *entry      = get_irn_link(startblock);
343
344         set_using_visited(irg);
345         inc_irg_visited(irg);
346
347         env->worklist = new_pdeq();
348         pick_block_successor(entry, env);
349         assert(pdeq_empty(env->worklist));
350         del_pdeq(env->worklist);
351
352         clear_using_visited(irg);
353
354         return entry;
355 }
356
357 static ir_node **create_blocksched_array(blocksched_env_t *env, blocksched_entry_t *first,
358                                                                                 int count, struct obstack* obst)
359 {
360         int                i = 0;
361         ir_node            **block_list;
362         blocksched_entry_t *entry;
363
364         block_list = NEW_ARR_D(ir_node *, obst, count);
365         DBG((dbg, LEVEL_1, "Blockschedule:\n"));
366
367         for (entry = first; entry != NULL; entry = entry->next) {
368                 assert(i < count);
369                 block_list[i++] = entry->block;
370                 DBG((dbg, LEVEL_1, "\t%+F\n", entry->block));
371         }
372         assert(i == count);
373
374         return block_list;
375 }
376
377 static ir_node **create_block_schedule_greedy(ir_graph *irg, ir_exec_freq *execfreqs)
378 {
379         blocksched_env_t   env;
380         struct obstack     obst;
381         blocksched_entry_t *start_entry;
382         ir_node            **block_list;
383
384         obstack_init(&obst);
385
386         env.irg        = irg;
387         env.obst       = &obst;
388         env.execfreqs  = execfreqs;
389         env.edges      = NEW_ARR_F(edge_t, 0);
390         env.worklist   = NULL;
391         env.blockcount = 0;
392
393         // collect edge execution frequencies
394         irg_block_walk_graph(irg, collect_egde_frequency, NULL, &env);
395
396         // sort interblock edges by execution frequency
397         qsort(env.edges, ARR_LEN(env.edges), sizeof(env.edges[0]), cmp_edges);
398
399         (void)be_remove_empty_blocks(irg);
400
401         if (algo != BLOCKSCHED_NAIV)
402                 coalesce_blocks(&env);
403
404         start_entry = finish_block_schedule(&env);
405         block_list  = create_blocksched_array(&env, start_entry, env.blockcount, get_irg_obstack(irg));
406
407         DEL_ARR_F(env.edges);
408         obstack_free(&obst, NULL);
409
410         return block_list;
411 }
412
413 /*
414  *  ___ _     ____
415  * |_ _| |   |  _ \
416  *  | || |   | |_) |
417  *  | || |___|  __/
418  * |___|_____|_|
419  *
420  */
421
422 #ifdef WITH_ILP
423 typedef struct _ilp_edge_t {
424         ir_node *block;   /**< source block */
425         int     pos;      /**< number of cfg predecessor (target) */
426         int     ilpvar;
427 } ilp_edge_t;
428
429 typedef struct _blocksched_ilp_env_t {
430         blocksched_env_t env;
431         ilp_edge_t       *ilpedges;
432         lpp_t            *lpp;
433 } blocksched_ilp_env_t;
434
435 typedef struct _blocksched_ilp_entry_t {
436         ir_node *block;
437         struct _blocksched_entry_t *next;
438         struct _blocksched_entry_t *prev;
439
440         int out_cst;
441 } blocksched_ilp_entry_t;
442
443 static int add_ilp_edge(ir_node *block, int pos, double execfreq, blocksched_ilp_env_t *env)
444 {
445         char       name[64];
446         ilp_edge_t edge;
447         int        edgeidx = ARR_LEN(env->ilpedges);
448
449         snprintf(name, sizeof(name), "edge%d", edgeidx);
450
451         edge.block  = block;
452         edge.pos    = pos;
453         edge.ilpvar = lpp_add_var_default(env->lpp, name, lpp_binary, execfreq, 1.0);
454
455         ARR_APP1(ilp_edge_t, env->ilpedges, edge);
456         return edgeidx;
457 }
458
459 static void collect_egde_frequency_ilp(ir_node *block, void *data)
460 {
461         blocksched_ilp_env_t *env        = data;
462         ir_graph             *irg        = env->env.irg;
463         ir_node              *startblock = get_irg_start_block(irg);
464         int                  arity;
465         lpp_cst_t            cst;
466         char                 name[64];
467         int                  out_count;
468         blocksched_ilp_entry_t *entry;
469
470         snprintf(name, sizeof(name), "block_out_constr_%ld", get_irn_node_nr(block));
471         out_count = get_irn_n_edges_kind(block, EDGE_KIND_BLOCK);
472
473         entry          = obstack_alloc(env->env.obst, sizeof(entry[0]));
474         entry->block   = block;
475         entry->next    = NULL;
476         entry->prev    = NULL;
477         entry->out_cst = lpp_add_cst_uniq(env->lpp, name, lpp_greater, out_count - 1);
478         set_irn_link(block, entry);
479
480         if (block == startblock)
481                 return;
482
483         arity = get_irn_arity(block);
484         if (arity == 1) {
485                 double execfreq = get_block_execfreq(env->env.execfreqs, block);
486                 add_ilp_edge(block, 0, execfreq, env);
487         }
488         else {
489                 int i;
490                 int *edgenums = alloca(sizeof(edgenums[0]) * arity);
491
492                 snprintf(name, sizeof(name), "block_in_constr_%ld", get_irn_node_nr(block));
493                 cst = lpp_add_cst_uniq(env->lpp, name, lpp_greater, arity - 1);
494
495                 for (i = 0; i < arity; ++i) {
496                         double     execfreq;
497                         int        edgenum;
498                         ilp_edge_t *edge;
499                         ir_node    *pred_block = get_Block_cfgpred_block(block, i);
500
501                         execfreq = get_block_execfreq(env->env.execfreqs, pred_block);
502                         edgenum  = add_ilp_edge(block, i, execfreq, env);
503                         edge     = &env->ilpedges[edgenum];
504                         lpp_set_factor_fast(env->lpp, cst, edge->ilpvar, 1.0);
505                 }
506         }
507 }
508
509
510 static void coalesce_blocks_ilp(blocksched_ilp_env_t *env)
511 {
512         int  i;
513         int  edge_count = ARR_LEN(env->ilpedges);
514
515         /* complete out constraints */
516         for(i = 0; i < edge_count; ++i) {
517                 const ilp_edge_t *edge  = &env->ilpedges[i];
518                 ir_node          *block = edge->block;
519                 ir_node          *pred;
520                 blocksched_ilp_entry_t *entry;
521
522                 /* the block might have been removed already... */
523                 if (is_Bad(get_Block_cfgpred(block, 0)))
524                         continue;
525
526                 pred  = get_Block_cfgpred_block(block, edge->pos);
527                 entry = get_irn_link(pred);
528
529                 DBG((dbg, LEVEL_1, "Adding out cst to %+F from %+F,%d\n",
530                                   pred, block, edge->pos));
531                 lpp_set_factor_fast(env->lpp, entry->out_cst, edge->ilpvar, 1.0);
532         }
533
534 #if 0
535         {
536                 FILE *f;
537                 char fname[256];
538                 lpp_dump(env->lpp, "lpp.out");
539                 snprintf(fname, sizeof(fname), "lpp_%s.plain", get_irg_dump_name(env->env.irg));
540                 f = fopen(fname, "w");
541                 lpp_dump_plain(env->lpp, f);
542                 fclose(f);
543         }
544 #endif
545
546         //lpp_solve_net(env->lpp, main_env->options->ilp_server, main_env->options->ilp_solver);
547         lpp_solve_net(env->lpp, "i44pc52", "cplex");
548         assert(lpp_is_sol_valid(env->lpp));
549
550         /* Apply results to edges */
551         for (i = 0; i < edge_count; ++i) {
552                 const ilp_edge_t   *edge  = &env->ilpedges[i];
553                 ir_node            *block = edge->block;
554                 ir_node            *pred;
555                 int                is_jump;
556                 blocksched_entry_t *entry;
557                 blocksched_entry_t *pred_entry;
558
559                 /* the block might have been removed already... */
560                 if (is_Bad(get_Block_cfgpred(block, 0)))
561                         continue;
562
563                 is_jump = (int)lpp_get_var_sol(env->lpp, edge->ilpvar);
564                 if (is_jump)
565                         continue;
566
567                 pred       = get_Block_cfgpred_block(block, edge->pos);
568                 entry      = get_irn_link(block);
569                 pred_entry = get_irn_link(pred);
570
571                 assert(entry->prev == NULL && pred_entry->next == NULL);
572                 entry->prev      = pred_entry;
573                 pred_entry->next = entry;
574         }
575 }
576
577 static ir_node **create_block_schedule_ilp(ir_graph *irg, ir_exec_freq *execfreqs)
578 {
579         blocksched_ilp_env_t env;
580         struct obstack       obst;
581         blocksched_entry_t   *start_entry;
582         ir_node              **block_list;
583
584         obstack_init(&obst);
585
586         env.env.irg        = irg;
587         env.env.obst       = &obst;
588         env.env.execfreqs  = execfreqs;
589         env.env.worklist   = NULL;
590         env.env.blockcount = 0;
591         env.ilpedges       = NEW_ARR_F(ilp_edge_t, 0);
592
593         env.lpp = new_lpp("blockschedule", lpp_minimize);
594         lpp_set_time_limit(env.lpp, 20);
595         lpp_set_log(env.lpp, stdout);
596
597         irg_block_walk_graph(irg, collect_egde_frequency_ilp, NULL, &env);
598
599         (void)be_remove_empty_blocks(irg);
600         coalesce_blocks_ilp(&env);
601
602         start_entry = finish_block_schedule(&env.env);
603         block_list  = create_blocksched_array(&env.env, start_entry, env.env.blockcount, get_irg_obstack(irg));
604
605         DEL_ARR_F(env.ilpedges);
606         free_lpp(env.lpp);
607         obstack_free(&obst, NULL);
608
609         return block_list;
610 }
611 #endif /* WITH_ILP */
612
613 /*
614  *  _____      _   ____  ____
615  * | ____|_  _| |_| __ )| __ )
616  * |  _| \ \/ / __|  _ \|  _ \
617  * | |___ >  <| |_| |_) | |_) |
618  * |_____/_/\_\\__|____/|____/
619  *
620  */
621
622 /** A simple forward single linked list. */
623 typedef struct {
624         ir_node  *start;   /**< start of the list */
625         ir_node  *end;     /**< last block in the list */
626         unsigned n_blks;  /**< number of blocks in the list */
627 } anchor;
628
629 static void add_block(anchor *list, ir_node *block) {
630         if (list->start == NULL) {
631                 list->start = block;
632                 list->end   = block;
633         } else {
634                 set_irn_link(list->end, block);
635                 list->end = block;
636         }
637
638         list->n_blks++;
639 }
640
641 static void create_block_list(ir_node *leader_block, anchor *list) {
642         int             i;
643         const ir_edge_t *edge;
644         ir_node         *block = NULL;
645         ir_extblk       *extbb = get_Block_extbb(leader_block);
646
647         if (extbb_visited(extbb))
648                 return;
649         mark_extbb_visited(extbb);
650
651         for (i = 0; i < get_extbb_n_blocks(extbb); ++i) {
652                 block = get_extbb_block(extbb, i);
653                 add_block(list, block);
654         }
655
656         assert(block != NULL);
657
658         /* pick successor extbbs */
659         foreach_block_succ(block, edge) {
660                 ir_node *succ = get_edge_src_irn(edge);
661                 create_block_list(succ, list);
662         }
663
664         for (i = 0; i < get_extbb_n_blocks(extbb) - 1; ++i) {
665                 block = get_extbb_block(extbb, i);
666
667                 foreach_block_succ(block, edge) {
668                         ir_node *succ = get_edge_src_irn(edge);
669                         create_block_list(succ, list);
670                 }
671         }
672 }
673
674 void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
675
676 /*
677  * Calculates a block schedule. The schedule is stored as a linked
678  * list starting at the start_block of the irg.
679  */
680 static ir_node **create_extbb_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs)
681 {
682         anchor list;
683         ir_node **blk_list, *b, *n;
684         unsigned i;
685
686         /* schedule extended basic blocks */
687         compute_extbb_execfreqs(irg, execfreqs);
688         //compute_extbb(irg);
689
690         list.start  = NULL;
691         list.end    = NULL;
692         list.n_blks = 0;
693
694         set_using_irn_link(irg);
695         set_using_visited(irg);
696         inc_irg_block_visited(irg);
697
698         create_block_list(get_irg_start_block(irg), &list);
699
700         /** create an array, so we can go forward and backward */
701         blk_list = NEW_ARR_D(ir_node *, irg->obst,list.n_blks);
702
703         for (i = 0, b = list.start; b; b = n, ++i) {
704                 n = get_irn_link(b);
705                 blk_list[i] = b;
706         }
707
708         clear_using_irn_link(irg);
709         clear_using_visited(irg);
710
711         return blk_list;
712 }
713
714 /*
715  *  __  __       _
716  * |  \/  | __ _(_)_ __
717  * | |\/| |/ _` | | '_ \
718  * | |  | | (_| | | | | |
719  * |_|  |_|\__,_|_|_| |_|
720  *
721  */
722 void be_init_blocksched(void)
723 {
724         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
725         lc_opt_entry_t *blocksched_grp = lc_opt_get_grp(be_grp, "blocksched");
726
727         lc_opt_add_table(blocksched_grp, be_blocksched_options);
728
729         FIRM_DBG_REGISTER(dbg, "firm.be.blocksched");
730 }
731
732 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_blocksched);
733
734 ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs)
735 {
736         switch(algo) {
737         case BLOCKSCHED_GREEDY:
738         case BLOCKSCHED_NAIV:
739                 return create_block_schedule_greedy(irg, execfreqs);
740         case BLOCKSCHED_EXTBB:
741                 return create_extbb_block_schedule(irg, execfreqs);
742 #ifdef WITH_ILP
743         case BLOCKSCHED_ILP:
744                 return create_block_schedule_ilp(irg, execfreqs);
745 #endif /* WITH_ILP */
746         }
747
748         assert(0 && "unknown blocksched algo");
749         return NULL;
750 }