Dump partitions before adding them to the worklist.
[libfirm] / ir / be / belistsched.h
1 /*
2  * Copyright (C) 1995-2008 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       Common functions for creating listscheduling algorithms
23  * @author      Sebastian Hack
24  * @date        20.10.2004
25  */
26 #ifndef FIRM_BE_BELISTSCHED_H
27 #define FIRM_BE_BELISTSCHED_H
28
29 #include "firm_types.h"
30 #include "irnodeset.h"
31
32 #include "be.h"
33 #include "be_types.h"
34 #include "bearch.h"
35 #include "beirg.h"
36
37 /**
38  * A selector interface which is used by the list schedule framework.
39  * You can implement your own list scheduler by implementing these
40  * functions.
41  */
42 typedef struct list_sched_selector_t {
43
44         /**
45          * Called before a graph is being scheduled.
46          * May be NULL.
47          *
48          * @param irg      The backend graph.
49          * @return         The environment pointer that is passed to all other
50          *                 functions in this struct.
51          */
52         void *(*init_graph)(ir_graph *irg);
53
54         /**
55          * Called before scheduling starts on a block.
56          * May be NULL.
57          *
58          * @param graph_env   The environment.
59          * @param block       The block which is to be scheduled.
60          * @return A per-block pointer that is additionally passed to select.
61          */
62         void *(*init_block)(void *graph_env, ir_node *block);
63
64         /**
65          * The selection function.
66          * It picks one node out of the ready list to be scheduled next.
67          * The function does not have to delete the node from the ready set.
68          * MUST be implemented.
69          *
70          * @param block_env   Some private information as returned by init_block().
71          * @param sched_head  The schedule so far.
72          * @param ready_set   A set containing all ready nodes. Pick one of these nodes.
73          * @return The chosen node.
74          */
75         ir_node *(*select)(void *block_env, ir_nodeset_t *ready_set);
76
77         /**
78          * This function gets executed after a node finally has been made ready.
79          * May be NULL.
80          *
81          * @param block_env The block environment.
82          * @param irn       The node made ready.
83          * @param pred      The previously scheduled node.
84          */
85         void (*node_ready)(void *block_env, ir_node *irn, ir_node *pred);
86
87         /**
88          * This function gets executed after a node finally has been selected.
89          * May be NULL.
90          *
91          * @param block_env The block environment.
92          * @param irn       The selected node.
93          */
94         void (*node_selected)(void *block_env, ir_node *irn);
95
96         /**
97          * Called after a block has been scheduled.
98          * May be NULL.
99          *
100          * @param env The environment.
101          * @param block_env The per block environment as returned by init_block().
102          */
103         void (*finish_block)(void *block_env);
104
105         /**
106          * Called after a whole graph has been scheduled.
107          * May be NULL.
108          *
109          * @param env The environment.
110          */
111         void (*finish_graph)(void *env);
112 } list_sched_selector_t;
113
114 /**
115  * List schedule a graph.
116  * Each block in the graph gets a list head to its link field being the
117  * head of the schedule. You can walk this list using the functions in
118  * list.h.
119  *
120  * @param irg     The backend irg.
121  */
122 void be_list_sched_graph(ir_graph *irg, const list_sched_selector_t *selector);
123
124 #endif