2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief ILP based instruction scheduling.
23 * @author Christian Wuerdig
27 * An ILP scheduler based on
28 * "ILP-based Instruction Scheduling for IA-64"
29 * by Daniel Kaestner and Sebastian Winkel
30 * extended with register pressure constraints by Christian Wuerdig
32 #ifndef FIRM_BE_BEILPSCHED_H
33 #define FIRM_BE_BEILPSCHED_H
40 * A selector interface which is used by the ILP schedule framework.
41 * These functions provide the ILP scheduler with necessary information
42 * from the backend or they pass back information to the backend about
43 * the state of scheduling.
45 struct _ilp_sched_selector_if_t {
48 * This function is called before the scheduling of the irg.
49 * @param self The this pointer.
50 * @param irg The irg being scheduled.
51 * @return An irg scheduling environment.
53 void *(*init_irg_ilp_schedule)(const void *self, ir_graph *irg);
56 * This functions is called after an irg has been scheduled.
57 * @param self The this pointer.
58 * @param irg The irg which has been scheduled.
59 * @param irg_env The irg scheduling environment.
61 void (*finish_irg_ilp_schedule)(const void *self, ir_graph *irg, void *irg_env);
64 * This function is called before the scheduling of a block starts.
65 * @param self The this pointer.
66 * @param block The block being scheduled.
67 * @return A block scheduling environment.
69 void *(*init_block_ilp_schedule)(const void *self, ir_node *block);
72 * This functions is called after a block has been scheduled.
73 * @param self The this pointer.
74 * @param block The block which has been scheduled.
75 * @param block_env The block scheduling environment.
77 void (*finish_block_ilp_schedule)(const void *self, ir_node *block, void *block_env);
80 * Calculates the latency of node @p irn.
81 * @param self The this pointer.
82 * @param irn The node.
83 * @param block_env The block scheduling environment.
84 * @return The latency in cycles of node @p irn.
86 unsigned (*latency)(const void *self, ir_node *irn, void *block_env);
89 * This function is called after a certain node has been scheduled.
90 * @param self The this pointer.
91 * @param irn The node which has been scheduled.
92 * @param cycle The cycle at which the node is scheduled.
93 * @param block_env The block scheduling environment.
95 void (*node_scheduled)(const void *self, const ir_node *irn, unsigned cycle, void *block_env);
99 * The actual ILP schedule selector.
101 struct _ilp_sched_selector_t {
102 ilp_sched_selector_if_t *impl;
106 * Some helper macros.
108 #define BE_ILP_SCHED_CALL(func, self, obj, env) \
110 if ((self) && (self)->impl->func) \
111 (self)->impl->func((self), (obj), (env)); \
114 #define BE_ILP_SCHED_CALL2(func, self, obj, obj2, env) \
116 if ((self) && (self)->impl->func) \
117 (self)->impl->func((self), (obj), (obj2), (env)); \
120 #define BE_ILP_SCHED_CALL_ENVRET(func, self, obj, defret) \
121 ((self) && (self)->impl->func ? (self)->impl->func((self), (obj)) : (defret))
123 #define BE_ILP_SCHED_CALL_RET(func, self, obj, env, defret) \
124 ((self) && (self)->impl->func ? (self)->impl->func((self), (obj), (env)) : (defret))
127 * Convenience macros for all functions.
130 #define be_ilp_sched_init_irg_ilp_schedule(self, irg) \
131 BE_ILP_SCHED_CALL_ENVRET(init_irg_ilp_schedule, self, irg, NULL)
133 #define be_ilp_sched_finish_irg_ilp_schedule(self, irg, irg_env) \
134 BE_ILP_SCHED_CALL(finish_irg_ilp_schedule, self, irg, irg_env)
136 #define be_ilp_sched_init_block_ilp_schedule(self, block) \
137 BE_ILP_SCHED_CALL_ENVRET(init_block_ilp_schedule, self, block, NULL)
139 #define be_ilp_sched_finish_block_ilp_schedule(self, block, block_env) \
140 BE_ILP_SCHED_CALL(finish_block_ilp_schedule, self, block, block_env)
142 #define be_ilp_sched_latency(self, irn, block_env) \
143 BE_ILP_SCHED_CALL_RET(latency, self, irn, block_env, 0)
145 #define be_ilp_sched_node_scheduled(self, irn, cycle, block_env) \
146 BE_ILP_SCHED_CALL2(node_scheduled, self, irn, cycle, block_env)
149 * Perform ILP scheduling on given birg.
151 void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts);
153 #endif /* FIRM_BE_BEILPSCHED_H */