4 #include "firm_config.h"
9 typedef struct _ilp_sched_selector_t ilp_sched_selector_t;
10 typedef struct _ilp_sched_selector_if_t ilp_sched_selector_if_t;
13 * A selector interface which is used by the ILP schedule framework.
14 * These functions provide the ILP scheduler with necessary information
15 * from the backend or they pass back information to the backend about
16 * the state of scheduling.
18 struct _ilp_sched_selector_if_t {
21 * This function is called before the scheduling of the irg.
22 * @param self The this pointer.
23 * @param irg The irg being scheduled.
24 * @return An irg scheduling environment.
26 void *(*init_irg_ilp_schedule)(const void *self, ir_graph *irg);
29 * This functions is called after an irg has been scheduled.
30 * @param self The this pointer.
31 * @param irg The irg which has been scheduled.
32 * @param irg_env The irg scheduling environment.
34 void (*finish_irg_ilp_schedule)(const void *self, ir_graph *irg, void *irg_env);
37 * This function is called before the scheduling of a block starts.
38 * @param self The this pointer.
39 * @param block The block being scheduled.
40 * @return A block scheduling environment.
42 void *(*init_block_ilp_schedule)(const void *self, ir_node *block);
45 * This functions is called after a block has been scheduled.
46 * @param self The this pointer.
47 * @param block The block which has been scheduled.
48 * @param block_env The block scheduling environment.
50 void (*finish_block_ilp_schedule)(const void *self, ir_node *block, void *block_env);
53 * Calculates the latency of node @p irn.
54 * @param self The this pointer.
55 * @param irn The node.
56 * @param block_env The block scheduling environment.
57 * @return The latency in cycles of node @p irn.
59 unsigned (*latency)(const void *self, ir_node *irn, void *block_env);
62 * This function is called after a certain node has been scheduled.
63 * @param self The this pointer.
64 * @param irn The node which has been scheduled.
65 * @param cycle The cycle at which the node is scheduled.
66 * @param block_env The block scheduling environment.
68 void (*node_scheduled)(const void *self, ir_node *irn, unsigned cycle, void *block_env);
72 * The actual ILP schedule selector.
74 struct _ilp_sched_selector_t {
75 ilp_sched_selector_if_t *impl;
81 #define BE_ILP_SCHED_CALL(func, self, obj, env) \
83 if ((self) && (self)->impl->func) \
84 (self)->impl->func((self), (obj), (env)); \
87 #define BE_ILP_SCHED_CALL2(func, self, obj, obj2, env) \
89 if ((self) && (self)->impl->func) \
90 (self)->impl->func((self), (obj), (obj2), (env)); \
93 #define BE_ILP_SCHED_CALL_ENVRET(func, self, obj, defret) \
94 ((self) && (self)->impl->func ? (self)->impl->func((self), (obj)) : (defret))
96 #define BE_ILP_SCHED_CALL_RET(func, self, obj, env, defret) \
97 ((self) && (self)->impl->func ? (self)->impl->func((self), (obj), (env)) : (defret))
100 * Convenience macros for all functions.
103 #define be_ilp_sched_init_irg_ilp_schedule(self, irg) \
104 BE_ILP_SCHED_CALL_ENVRET(init_irg_ilp_schedule, self, irg, NULL)
106 #define be_ilp_sched_finish_irg_ilp_schedule(self, irg, irg_env) \
107 BE_ILP_SCHED_CALL(finish_irg_ilp_schedule, self, irg, irg_env)
109 #define be_ilp_sched_init_block_ilp_schedule(self, block) \
110 BE_ILP_SCHED_CALL_ENVRET(init_block_ilp_schedule, self, block, NULL)
112 #define be_ilp_sched_finish_block_ilp_schedule(self, block, block_env) \
113 BE_ILP_SCHED_CALL(finish_block_ilp_schedule, self, block, block_env)
115 #define be_ilp_sched_latency(self, irn, block_env) \
116 BE_ILP_SCHED_CALL_RET(latency, self, irn, block_env, 0)
118 #define be_ilp_sched_node_scheduled(self, irn, cycle, block_env) \
119 BE_ILP_SCHED_CALL2(node_scheduled, self, irn, cycle, block_env)
122 * Perform ILP scheduling on given birg.
124 void be_ilp_sched(const be_irg_t *birg);
128 #include <libcore/lc_opts.h>
129 #include <libcore/lc_opts_enum.h>
132 * Register ILP scheduler options.
134 void ilpsched_register_options(lc_opt_entry_t *grp);
136 #endif /* WITH_LIBCORE */
138 #endif /* _BEILPSCHED_H_ */