Bugfix
[libfirm] / ir / be / belistsched.h
1 /**
2  * Primitive list scheduling.
3  * @date 20.10.2004
4  * @author Sebastian Hack
5  */
6
7 #ifndef _FIRM_LIST_SCHED
8 #define _FIRM_LIST_SCHED
9
10 #include "irgraph.h"
11 #include "irnode.h"
12
13 #include "pset.h"
14 #include "pmap.h"
15 #include "list.h"
16
17 /**
18  * A selector interface which is used by the list schedule framework.
19  * You can implement your own list scheduler by implementing these
20  * functions.
21  */
22 typedef struct _list_sched_selector_t {
23         /**
24          * Called before a graph is being scheduled.
25          * @param irg The graph.
26          * @return The environment pointer that is passed to all other
27          * functions in this struct.
28          */
29         void *(*init_graph)(ir_graph *irg);
30
31         /**
32          * Called before scheduling starts on a block.
33          * @param env The environment.
34          * @param block The block which is to be scheduled.
35          * @return A per-block pointer that is additionally passed to select.
36          */
37         void *(*init_block)(void *env, ir_node *block);
38
39         /**
40          * The selection function.
41          * It picks one node out of the ready list to be scheduled next.
42          * The function does not have to delete the node from the ready set.
43          *
44          * @param env Some private information as returned by init_graph().
45          * @return block_env Some provate information as returned by init_block().
46          * @param sched_head The schedule so far.
47          * @param curr_time The current time step which the picked node
48          * will be assigned to.
49          * @param ready_list A set containing all ready nodes. Pick one of these
50          * nodes.
51          * @return The chosen node.
52          */
53         ir_node *(*select)(void *env, void *block_env,
54                         const struct list_head *sched_head,
55                         int curr_time, pset *ready_set);
56
57         /**
58          * Called after a block has been scheduled.
59          * @param env The environment.
60          * @param block_env The per block environemtn as returned by init_block().
61          * @param block The block that has been finished.
62          */
63         void (*finish_block)(void *env, void *block_env, ir_node *block);
64
65         /**
66          * Called after a whole graph has been scheduled.
67          * @param env The environment.
68          * @param irg The graph.
69          */
70         void (*finish_graph)(void *env, ir_graph *irg);
71 } list_sched_selector_t;
72
73
74 /**
75  * A trivial selector, that just selects the first ready node.
76  */
77 extern const list_sched_selector_t *trivial_selector;
78
79 /**
80  * List schedule a graph.
81  * Each block in the graph gets a list head to its link field being the
82  * head of the schedule. You can walk this list using the functions in
83  * list.h.
84  * @param irg The graph to schedule.
85  * @param sched_obst An obstack to allocate the lists on.
86  * @param map Maps each block to a list head giving the schedule.
87  * @param select_func A selection function.
88  */
89 void list_sched(ir_graph *irg, const list_sched_selector_t *select_func);
90
91
92
93 #endif