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