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"
16 typedef struct _list_sched_selector_t list_sched_selector_t;
19 * A selector interface which is used by the list schedule framework.
20 * You can implement your own list scheduler by implementing these
23 struct _list_sched_selector_t {
26 * Called before a graph is being scheduled.
27 * @param arch_env The architecture environment.
28 * @param irg The graph.
29 * @return The environment pointer that is passed to all other functions in this struct.
31 void *(*init_graph)(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg);
34 * Called before scheduling starts on a block.
35 * @param graph_env The environment.
36 * @param block The block which is to be scheduled.
37 * @return A per-block pointer that is additionally passed to select.
39 void *(*init_block)(void *graph_env, ir_node *block);
42 * The selection function.
43 * It picks one node out of the ready list to be scheduled next.
44 * The function does not have to delete the node from the ready set.
46 * @param block_env Some private information as returned by init_block().
47 * @param sched_head The schedule so far.
48 * @param ready_set A set containing all ready nodes. Pick one of these nodes.
49 * @param live_set A set containing all nodes currently alive.
50 * @return The chosen node.
52 ir_node *(*select)(void *block_env, nodeset *ready_set, nodeset *live_set);
55 * This function decides, if a node should appear in a schedule.
56 * @param block_env The block environment.
57 * @param irn The node.
58 * @return 1, if the node should be scheduled, 0 if not.
60 int (*to_appear_in_schedule)(void *block_env, const ir_node *irn);
63 * This function gets executed after a node finally has been made ready.
64 * @param block_env The block environment.
65 * @param irn The node made ready.
66 * @param pred The previously scheduled node.
68 void (*node_ready)(void *block_env, ir_node *irn, ir_node *pred);
71 * This function gets executed after a node finally has been selected.
72 * @param block_env The block environment.
73 * @param irn The selected node.
75 void (*node_selected)(void *block_env, ir_node *irn);
78 * Returns the execution time of node irn.
80 unsigned (*exectime)(void *block_env, const ir_node *irn);
83 * Calculates the latency of executing cycle curr_cycle of node curr in cycle pred_cycle
86 * @param block_env The block environment.
87 * @param pred The previous node.
88 * @param pred_cycle The previous node execution cycle.
89 * @param curr The current node.
90 * @param curr_cycle The current node execution cycle.
92 unsigned (*latency)(void *block_env, const ir_node *pred, int pred_cycle, const ir_node *curr, int curr_cycle);
95 * Called after a block has been scheduled.
96 * @param env The environment.
97 * @param block_env The per block environment as returned by init_block().
99 void (*finish_block)(void *block_env);
102 * Called after a whole graph has been scheduled.
103 * @param env The environment.
105 void (*finish_graph)(void *env);
111 * A trivial selector, that just selects the first ready node.
113 extern const list_sched_selector_t *trivial_selector;
116 * A selector that tries to minimize the register pressure.
117 * @note Not really operational yet.
119 extern const list_sched_selector_t *reg_pressure_selector;
122 * A selector based on trace scheduling as introduced by Muchnik[TM]
124 extern const list_sched_selector_t *muchnik_selector;
127 * A selector based on trace scheduling as introduced by Muchnik[TM]
128 * but using the mueller heuristic selector.
130 extern const list_sched_selector_t *heuristic_selector;
133 * List schedule a graph.
134 * Each block in the graph gets a list head to its link field being the
135 * head of the schedule. You can walk this list using the functions in
138 * @param birg The backend irg.
139 * @param enable_mris Flag indicating if mris preparation should be done
141 void list_sched(const be_irg_t *birg, be_options_t *be_opts);
143 #endif /* _FIRM_LIST_SCHED */