added missing include
[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 "firm_types.h"
11
12 #include "benodesets.h"
13 #include "bearch_t.h"
14
15 typedef struct _list_sched_selector_t list_sched_selector_t;
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 struct _list_sched_selector_t {
23
24         /**
25          * Called before a graph is being scheduled.
26          * @param arch_env The architecture environment.
27          * @param irg      The graph.
28          * @return         The environment pointer that is passed to all other functions in this struct.
29          */
30         void *(*init_graph)(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg);
31
32         /**
33          * Called before scheduling starts on a block.
34          * @param graph_env The environment.
35          * @param block The block which is to be scheduled.
36          * @return A per-block pointer that is additionally passed to select.
37          */
38         void *(*init_block)(void *graph_env, ir_node *block);
39
40         /**
41          * The selection function.
42          * It picks one node out of the ready list to be scheduled next.
43          * The function does not have to delete the node from the ready set.
44          *
45          * @return block_env Some private 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 *block_env, nodeset *ready_set);
54
55         /**
56          * This function decides, if a node should appear in a schedule.
57          * @param block_env The block environment.
58          * @param irn       The node.
59          * @return 1, if the node should be scheduled, 0 if not.
60          */
61         int (*to_appear_in_schedule)(void *block_env, const ir_node *irn);
62
63         /**
64          * Called after a block has been scheduled.
65          * @param env The environment.
66          * @param block_env The per block environment as returned by init_block().
67          */
68         void (*finish_block)(void *block_env);
69
70         /**
71          * Called after a whole graph has been scheduled.
72          * @param env The environment.
73          */
74         void (*finish_graph)(void *env);
75
76 };
77
78
79 /**
80  * A trivial selector, that just selects the first ready node.
81  */
82 extern const list_sched_selector_t *trivial_selector;
83
84 /**
85  * A selector that tries to minimize the register pressure.
86  * @note Not really operational yet.
87  */
88 extern const list_sched_selector_t *reg_pressure_selector;
89
90 /**
91  * List schedule a graph.
92  * Each block in the graph gets a list head to its link field being the
93  * head of the schedule. You can walk this list using the functions in
94  * list.h.
95  * @param arch_env The architecture environment.
96  * @param irg      The graph to schedule.
97  */
98 void list_sched(const arch_env_t *arch_env, ir_graph *irg);
99
100 #endif /* _FIRM_LIST_SCHED */