2 * Primitive list scheduling.
4 * @author Sebastian Hack
7 #ifndef _FIRM_LIST_SCHED
8 #define _FIRM_LIST_SCHED
10 #include "firm_types.h"
18 typedef struct _list_sched_selector_t list_sched_selector_t;
21 * A selector interface which is used by the list schedule framework.
22 * You can implement your own list scheduler by implementing these
25 struct _list_sched_selector_t {
28 * Called before a graph is being scheduled.
29 * @param arch_env The architecture environment.
30 * @param irg The graph.
31 * @return The environment pointer that is passed to all other functions in this struct.
33 void *(*init_graph)(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg);
36 * Called before scheduling starts on a block.
37 * @param graph_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.
41 void *(*init_block)(void *graph_env, ir_node *block);
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.
48 * @return block_env Some private information as returned by init_block().
49 * @param sched_head The schedule so far.
50 * @param curr_time The current time step which the picked node
51 * will be assigned to.
52 * @param ready_list A set containing all ready nodes. Pick one of these
54 * @return The chosen node.
56 ir_node *(*select)(void *block_env, pset *ready_set);
59 * This function decides, if a node should appear in a schedule.
60 * @param block_env The block environment.
61 * @param irn The node.
62 * @return 1, if the node should be scheduled, 0 if not.
64 int (*to_appear_in_schedule)(void *block_env, const ir_node *irn);
67 * Called after a block has been scheduled.
68 * @param env The environment.
69 * @param block_env The per block environment as returned by init_block().
71 void (*finish_block)(void *block_env);
74 * Called after a whole graph has been scheduled.
75 * @param env The environment.
77 void (*finish_graph)(void *env);
83 * A trivial selector, that just selects the first ready node.
85 extern const list_sched_selector_t *trivial_selector;
88 * A selector that tries to minimize the register pressure.
89 * @note Not really operational yet.
91 extern const list_sched_selector_t *reg_pressure_selector;
94 * List schedule a graph.
95 * Each block in the graph gets a list head to its link field being the
96 * head of the schedule. You can walk this list using the functions in
98 * @param arch_env The architecture environment.
99 * @param irg The graph to schedule.
101 void list_sched(const arch_env_t *arch_env, ir_graph *irg);
103 #endif /* _FIRM_LIST_SCHED */