2 * Copyright (C) 1995-2007 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 Backend module interface.
23 * @author Matthias Braun
29 #endif /* HAVE_CONFIG_H */
33 #include "bemodule_t.h"
36 void be_init_sched(void);
37 void be_init_blocksched(void);
38 void be_init_spill(void);
39 void be_init_spilloptions(void);
40 void be_init_listsched(void);
41 void be_init_schedrss(void);
42 void be_init_chordal(void);
43 void be_init_chordal_main(void);
44 void be_init_copycoal(void);
45 void be_init_copyheur2(void);
46 void be_init_copyheur3(void);
47 void be_init_copyheur4(void);
48 void be_init_copystat(void);
49 void be_init_daemelspill(void);
50 void be_init_arch_ia32(void);
51 void be_init_arch_ppc32(void);
52 void be_init_arch_mips(void);
53 void be_init_arch_arm(void);
54 void be_init_arch_sta(void);
55 void be_init_arch_TEMPLATE(void);
56 void be_init_ilpsched(void);
57 void be_init_copyilp(void);
58 void be_init_javacoal(void);
59 void be_init_ra(void);
60 void be_init_spillbelady(void);
61 void be_init_spillbelady2(void);
62 void be_init_spillmorgan(void);
63 void be_init_spillremat(void);
64 void be_init_ssaconstr(void);
65 void be_init_ifg(void);
66 void be_init_irgmod(void);
67 void be_init_loopana(void);
68 void be_init_spillslots(void);
69 void be_init_live(void);
70 void be_init_state(void);
72 void be_quit_copystat(void);
75 * Driver for module initialization.
76 * Call your module initialization function here.
78 void be_init_modules(void)
80 static int run_once = 0;
93 be_init_spilloptions();
96 be_init_chordal_main();
103 be_init_spillbelady();
104 be_init_spillbelady2();
105 be_init_spillmorgan();
106 be_init_daemelspill();
112 be_init_arch_ppc32();
115 /* do NOT call be_init_arch_TEMPLATE() here, this is NOT a backend :-) */
120 be_init_spillremat();
121 #endif /* WITH_ILP */
126 #endif /* WITH_JVM */
130 #endif /* PLUGIN_IR_BE_STA */
133 void be_quit_modules(void)
138 //---------------------------------------------------------------------------
140 typedef struct module_opt_data_t {
142 be_module_list_entry_t * const *list_head;
146 * Searches in list for module option. If found, set option to given value and return true.
147 * Beware: return value of 0 means error.
149 static int set_opt_module(const char *name, lc_opt_type_t type, void *data,
152 module_opt_data_t *moddata = data;
156 const be_module_list_entry_t *module;
160 va_start(args, length);
161 opt = va_arg(args, const char*);
163 for (module = *(moddata->list_head); module != NULL; module = module->next) {
164 if (strcmp(module->name, opt) == 0) {
165 *(moddata->var) = module->data;
176 * Dump the names of all registered module options.
178 int dump_opt_module(char *buf, size_t buflen, const char *name,
179 lc_opt_type_t type, void *data, size_t length)
181 module_opt_data_t *moddata = data;
182 const be_module_list_entry_t *module;
187 for (module = *(moddata->list_head); module != NULL; module = module->next) {
188 if (module->data == *(moddata->var)) {
189 snprintf(buf, buflen, "%s", module->name);
194 snprintf(buf, buflen, "none");
199 * Dump the values of all register module options.
201 int dump_opt_module_vals(char *buf, size_t buflen, const char *name,
202 lc_opt_type_t type, void *data, size_t len)
204 module_opt_data_t *moddata = data;
206 const be_module_list_entry_t *module;
211 for (module = *(moddata->list_head); module != NULL; module = module->next) {
212 size_t len = strlen(module->name);
214 if (module != *(moddata->list_head)) {
215 p = strncat(p, ", ", buflen - 1);
219 p = strncat(p, module->name, buflen - 1);
231 * Add a new module to list.
233 void be_add_module_to_list(be_module_list_entry_t **list_head, const char *name,
236 be_module_list_entry_t *entry;
238 entry = xmalloc(sizeof(entry[0]));
240 entry->data = module;
241 entry->next = *list_head;
246 * Add an option for a module.
248 void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
249 const char *description,
250 be_module_list_entry_t * const * list_head,
253 module_opt_data_t *moddata;
255 moddata = xmalloc(sizeof(moddata[0]));
257 moddata->list_head = list_head;
259 lc_opt_add_opt(grp, name, description, lc_opt_type_enum,
260 moddata, sizeof(moddata[0]),
261 set_opt_module, dump_opt_module, dump_opt_module_vals,