2 * Primitive list scheduling.
4 * @author Sebastian Hack
7 #ifndef _FIRM_LIST_SCHED
8 #define _FIRM_LIST_SCHED
18 * A selector interface which is used by the list schedule framework.
19 * You can implement your own list scheduler by implementing these
22 typedef struct _list_sched_selector_t {
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.
29 void *(*init_graph)(ir_graph *irg);
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.
37 void *(*init_block)(void *env, ir_node *block);
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.
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
51 * @return The chosen node.
53 ir_node *(*select)(void *env, void *block_env,
54 const struct list_head *sched_head,
55 int curr_time, pset *ready_set);
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.
63 void (*finish_block)(void *env, void *block_env, ir_node *block);
66 * Called after a whole graph has been scheduled.
67 * @param env The environment.
68 * @param irg The graph.
70 void (*finish_graph)(void *env, ir_graph *irg);
71 } list_sched_selector_t;
75 * A trivial selector, that just selects the first ready node.
77 extern const list_sched_selector_t *trivial_selector;
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
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.
89 void list_sched(ir_graph *irg, const list_sched_selector_t *select_func);