2 * Primitive list scheduling.
4 * @author Sebastian Hack
7 #ifndef _FIRM_LIST_SCHED
8 #define _FIRM_LIST_SCHED
19 typedef struct _list_sched_selector_t list_sched_selector_t;
22 * A selector interface which is used by the list schedule framework.
23 * You can implement your own list scheduler by implementing these
26 struct _list_sched_selector_t {
29 * Called before a graph is being scheduled.
31 * @param irg The graph.
32 * @return The environment pointer that is passed to all other
33 * functions in this struct.
35 void *(*init_graph)(const list_sched_selector_t *vtab, const struct _arch_isa_t *isa, ir_graph *irg);
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.
43 void *(*init_block)(void *graph_env, ir_node *block);
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.
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
56 * @return The chosen node.
58 ir_node *(*select)(void *block_env, pset *ready_set);
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.
66 int (*to_appear_in_schedule)(void *block_env, const ir_node *irn);
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().
73 void (*finish_block)(void *block_env);
76 * Called after a whole graph has been scheduled.
77 * @param env The environment.
79 void (*finish_graph)(void *env);
84 * A default implementation of to_appear_in_schedule,
85 * as required in list_sched_selector_t.
87 extern be_default_to_appear_in_schedule(void *env, const ir_node *irn);
90 * A trivial selector, that just selects the first ready node.
92 extern const list_sched_selector_t *trivial_selector;
95 * A selector that tries to minimize the register pressure.
96 * @note Not really operational yet.
98 extern const list_sched_selector_t *reg_pressure_selector;
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
105 * @param isa The isa which implements the scheduler.
106 * @param irg The graph to schedule.
108 void list_sched(const struct _arch_isa_t *isa, ir_graph *irg);