moved beirg.h include from be.h to files which use it
[libfirm] / ir / be / beilpsched.h
1 #ifndef _BEILPSCHED_H_
2 #define _BEILPSCHED_H_
3
4 #include "firm_config.h"
5
6 #include "bemachine.h"
7 #include "beirg.h"
8
9 typedef struct _ilp_sched_selector_t ilp_sched_selector_t;
10
11 /**
12  * A selector interface which is used by the ILP schedule framework.
13  * These functions provide the ILP scheduler with necessary information
14  * from the backend or they pass back information to the backend about
15  * the state of scheduling.
16  */
17 struct _ilp_sched_selector_t {
18
19         /**
20          * This function is called before the scheduling of the irg.
21          * @param self    The this pointer.
22          * @param irg     The irg being scheduled.
23          * @return An irg scheduling environment.
24          */
25         void *(*init_irg_ilp_schedule)(const void *self, ir_graph *irg);
26
27         /**
28          * This functions is called after an irg has been scheduled.
29          * @param self    The this pointer.
30          * @param irg     The irg which has been scheduled.
31          * @param irg_env The irg scheduling environment.
32          */
33         void (*finish_irg_ilp_schedule)(const void *self, ir_graph *irg, void *irg_env);
34
35         /**
36          * This function is called before the scheduling of a block starts.
37          * @param self       The this pointer.
38          * @param block      The block being scheduled.
39          * @return A block scheduling environment.
40          */
41         void *(*init_block_ilp_schedule)(const void *self, ir_node *block);
42
43         /**
44          * This functions is called after a block has been scheduled.
45          * @param self      The this pointer.
46          * @param block     The block which has been scheduled.
47          * @param block_env The block scheduling environment.
48          */
49         void (*finish_block_ilp_schedule)(const void *self, ir_node *block, void *block_env);
50
51         /**
52          * Calculates the latency of node @p irn.
53          * @param self       The this pointer.
54          * @param irn        The node.
55          * @param block_env  The block scheduling environment.
56          * @return The latency in cycles of node @p irn.
57          */
58         unsigned (*latency)(const void *self, ir_node *irn, void *block_env);
59
60         /**
61          * This function is called after a certain node has been scheduled.
62          * @param self       The this pointer.
63          * @param irn        The node which has been scheduled.
64          * @param cycle      The cycle at which the node is scheduled.
65          * @param block_env  The block scheduling environment.
66          */
67         void (*node_scheduled)(const void *self, ir_node *irn, unsigned cycle, void *block_env);
68 };
69
70 #define BE_ILP_SCHED_CALL(func, self, obj, env) \
71         do {                                        \
72                 if ((self) && (self)->func)             \
73                         (self)->func((self), (obj), (env)); \
74         } while (0)
75
76 #define BE_ILP_SCHED_CALL2(func, self, obj, obj2, env)  \
77         do {                                                \
78                 if ((self) && (self)->func)                     \
79                         (self)->func((self), (obj), (obj2), (env)); \
80         } while (0)
81
82 #define BE_ILP_SCHED_CALL_ENVRET(func, self, obj, defret) \
83         ((self) && (self)->func ? (self)->func((self), (obj)) : (defret))
84
85 #define BE_ILP_SCHED_CALL_RET(func, self, obj, env, defret) \
86         ((self) && (self)->func ? (self)->func((self), (obj), (env)) : (defret))
87
88 /**
89  * Convenience macros for all functions.
90  */
91
92 #define be_ilp_sched_init_irg_ilp_schedule(self, irg) \
93         BE_ILP_SCHED_CALL_ENVRET(init_irg_ilp_schedule, self, irg, NULL)
94
95 #define be_ilp_sched_finish_irg_ilp_schedule(self, irg, irg_env) \
96         BE_ILP_SCHED_CALL(finish_irg_ilp_schedule, self, irg, irg_env)
97
98 #define be_ilp_sched_init_block_ilp_schedule(self, block) \
99         BE_ILP_SCHED_CALL_ENVRET(init_block_ilp_schedule, self, block, NULL)
100
101 #define be_ilp_sched_finish_block_ilp_schedule(self, block, block_env) \
102         BE_ILP_SCHED_CALL(finish_block_ilp_schedule, self, block, block_env)
103
104 #define be_ilp_sched_latency(self, irn, block_env) \
105         BE_ILP_SCHED_CALL_RET(latency, self, irn, block_env, 0)
106
107 #define be_ilp_sched_node_scheduled(self, irn, cycle, block_env) \
108         BE_ILP_SCHED_CALL2(node_scheduled, self, irn, cycle, block_env)
109
110 /**
111  * Perform ILP scheduling on given birg.
112  */
113 void be_ilp_sched(const be_irg_t *birg);
114
115 #ifdef WITH_LIBCORE
116
117 #include <libcore/lc_opts.h>
118 #include <libcore/lc_opts_enum.h>
119
120 /**
121  * Register ILP scheduler options.
122  */
123 void ilpsched_register_options(lc_opt_entry_t *grp);
124
125 #endif /* WITH_LIBCORE */
126
127 #endif /* _BEILPSCHED_H_ */