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 Backend module interface.
23 * @author Matthias Braun
28 #include "firm_config.h"
32 #include "bemodule_t.h"
35 void be_init_sched(void);
36 void be_init_blocksched(void);
37 void be_init_spill(void);
38 void be_init_spilloptions(void);
39 void be_init_listsched(void);
40 void be_init_schedrss(void);
41 void be_init_chordal(void);
42 void be_init_chordal_main(void);
43 void be_init_copycoal(void);
44 void be_init_copyheur2(void);
45 void be_init_copyheur3(void);
46 void be_init_copyheur4(void);
47 void be_init_copyheur5(void);
48 void be_init_copystat(void);
49 void be_init_daemelspill(void);
50 void be_init_dbgout(void);
51 void be_init_arch_ia32(void);
52 void be_init_arch_ppc32(void);
53 void be_init_arch_mips(void);
54 void be_init_arch_arm(void);
55 void be_init_arch_sta(void);
56 void be_init_arch_TEMPLATE(void);
57 void be_init_ilpsched(void);
58 void be_init_copyilp(void);
59 void be_init_javacoal(void);
60 void be_init_peephole(void);
61 void be_init_ra(void);
62 void be_init_spillbelady(void);
63 void be_init_spillbelady2(void);
64 void be_init_spillbelady3(void);
65 void be_init_ssaconstr(void);
66 void be_init_stabs(void);
67 void be_init_ifg(void);
68 void be_init_irgmod(void);
69 void be_init_loopana(void);
70 void be_init_spillslots(void);
71 void be_init_live(void);
72 void be_init_state(void);
74 void be_quit_copystat(void);
77 * Driver for module initialization.
78 * Call your module initialization function here.
80 void be_init_modules(void)
82 static int run_once = 0;
95 be_init_spilloptions();
99 be_init_chordal_main();
104 // be_init_copyheur5();
108 be_init_spillbelady();
109 be_init_spillbelady2();
110 be_init_spillbelady3();
111 be_init_daemelspill();
118 be_init_arch_ppc32();
121 /* do NOT call be_init_arch_TEMPLATE() here, this is NOT a backend :-) */
126 #endif /* WITH_ILP */
131 #endif /* WITH_JVM */
135 #endif /* PLUGIN_IR_BE_STA */
138 void be_quit_modules(void)
143 //---------------------------------------------------------------------------
145 typedef struct module_opt_data_t {
147 be_module_list_entry_t * const *list_head;
151 * Searches in list for module option. If found, set option to given value and return true.
152 * Beware: return value of 0 means error.
154 static int set_opt_module(const char *name, lc_opt_type_t type, void *data,
157 module_opt_data_t *moddata = data;
161 const be_module_list_entry_t *module;
165 va_start(args, length);
166 opt = va_arg(args, const char*);
168 for (module = *(moddata->list_head); module != NULL; module = module->next) {
169 if (strcmp(module->name, opt) == 0) {
170 *(moddata->var) = module->data;
181 * Dump the names of all registered module options.
183 int dump_opt_module(char *buf, size_t buflen, const char *name,
184 lc_opt_type_t type, void *data, size_t length)
186 module_opt_data_t *moddata = data;
187 const be_module_list_entry_t *module;
192 for (module = *(moddata->list_head); module != NULL; module = module->next) {
193 if (module->data == *(moddata->var)) {
194 snprintf(buf, buflen, "%s", module->name);
199 snprintf(buf, buflen, "none");
204 * Dump the values of all register module options.
206 int dump_opt_module_vals(char *buf, size_t buflen, const char *name,
207 lc_opt_type_t type, void *data, size_t len)
209 module_opt_data_t *moddata = data;
211 const be_module_list_entry_t *module;
216 for (module = *(moddata->list_head); module != NULL; module = module->next) {
217 size_t len = strlen(module->name);
219 if (module != *(moddata->list_head)) {
220 p = strncat(p, ", ", buflen - 1);
224 p = strncat(p, module->name, buflen - 1);
236 * Add a new module to list.
238 void be_add_module_to_list(be_module_list_entry_t **list_head, const char *name,
241 be_module_list_entry_t *entry;
243 entry = xmalloc(sizeof(entry[0]));
245 entry->data = module;
246 entry->next = *list_head;
251 * Add an option for a module.
253 void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
254 const char *description,
255 be_module_list_entry_t * const * list_head,
258 module_opt_data_t *moddata;
260 moddata = xmalloc(sizeof(moddata[0]));
262 moddata->list_head = list_head;
264 lc_opt_add_opt(grp, name, description, lc_opt_type_enum,
265 moddata, sizeof(moddata[0]),
266 set_opt_module, dump_opt_module, dump_opt_module_vals,