2 * Primitive list scheduling.
4 * @author Sebastian Hack
7 #ifndef _FIRM_LIST_SCHED
8 #define _FIRM_LIST_SCHED
10 #include "firm_types.h"
12 #include "benodesets.h"
15 typedef struct _list_sched_selector_t list_sched_selector_t;
18 * A selector interface which is used by the list schedule framework.
19 * You can implement your own list scheduler by implementing these
22 struct _list_sched_selector_t {
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.
30 void *(*init_graph)(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg);
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.
38 void *(*init_block)(void *graph_env, ir_node *block);
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.
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
51 * @return The chosen node.
53 ir_node *(*select)(void *block_env, nodeset *ready_set);
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.
61 int (*to_appear_in_schedule)(void *block_env, const ir_node *irn);
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().
68 void (*finish_block)(void *block_env);
71 * Called after a whole graph has been scheduled.
72 * @param env The environment.
74 void (*finish_graph)(void *env);
80 * A trivial selector, that just selects the first ready node.
82 extern const list_sched_selector_t *trivial_selector;
85 * A selector that tries to minimize the register pressure.
86 * @note Not really operational yet.
88 extern const list_sched_selector_t *reg_pressure_selector;
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
95 * @param arch_env The architecture environment.
96 * @param irg The graph to schedule.
98 void list_sched(const arch_env_t *arch_env, ir_graph *irg);
100 #endif /* _FIRM_LIST_SCHED */