Changes API a little bit :-)
[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 struct _arch_isa_t;
18
19 /**
20  * A selector interface which is used by the list schedule framework.
21  * You can implement your own list scheduler by implementing these
22  * functions.
23  */
24 typedef struct _list_sched_selector_t {
25
26         /**
27          * Called before a graph is being scheduled.
28          * @param isa The isa.
29          * @param irg The graph.
30          * @return The environment pointer that is passed to all other
31          * functions in this struct.
32          */
33         void *(*init_graph)(const struct _arch_isa_t *isa, ir_graph *irg);
34
35         /**
36          * Called before scheduling starts on a block.
37          * @param env The environment.
38          * @param block The block which is to be scheduled.
39          * @return A per-block pointer that is additionally passed to select.
40          */
41         void *(*init_block)(void *env, ir_node *block);
42
43         /**
44          * The selection function.
45          * It picks one node out of the ready list to be scheduled next.
46          * The function does not have to delete the node from the ready set.
47          *
48          * @param env Some private information as returned by init_graph().
49          * @return block_env Some private information as returned by init_block().
50          * @param sched_head The schedule so far.
51          * @param curr_time The current time step which the picked node
52          * will be assigned to.
53          * @param ready_list A set containing all ready nodes. Pick one of these
54          * nodes.
55          * @return The chosen node.
56          */
57         ir_node *(*select)(void *env, void *block_env,
58                         const struct list_head *sched_head,
59                         int curr_time, pset *ready_set);
60
61         /**
62          * Called after a block has been scheduled.
63          * @param env The environment.
64          * @param block_env The per block environment as returned by init_block().
65          * @param block The block that has been finished.
66          */
67         void (*finish_block)(void *env, void *block_env, ir_node *block);
68
69         /**
70          * Called after a whole graph has been scheduled.
71          * @param env The environment.
72          * @param irg The graph.
73          */
74         void (*finish_graph)(void *env, ir_graph *irg);
75 } list_sched_selector_t;
76
77
78 /**
79  * A trivial selector, that just selects the first ready node.
80  */
81 extern const list_sched_selector_t *trivial_selector;
82
83 /**
84  * List schedule a graph.
85  * Each block in the graph gets a list head to its link field being the
86  * head of the schedule. You can walk this list using the functions in
87  * list.h.
88  * @param isa The isa which implements the scheduler.
89  * @param irg The graph to schedule.
90  */
91 void list_sched(const struct _arch_isa_t *isa, ir_graph *irg);
92
93 #endif