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
32 #include "bemodule_t.h"
35 void be_init_abi(void);
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_sched_rand(void);
42 void be_init_sched_normal(void);
43 void be_init_sched_regpress(void);
44 void be_init_sched_trace(void);
45 void be_init_sched_trivial(void);
46 void be_init_chordal(void);
47 void be_init_pbqp_coloring(void);
48 void be_init_chordal_main(void);
49 void be_init_chordal_common(void);
50 void be_init_copyopt(void);
51 void be_init_copyheur(void);
52 void be_init_copyheur2(void);
53 void be_init_copyheur4(void);
54 void be_init_copyilp2(void);
55 void be_init_copynone(void);
56 void be_init_copystat(void);
57 void be_init_daemelspill(void);
58 void be_init_dbgout(void);
59 void be_init_arch_ia32(void);
60 void be_init_arch_arm(void);
61 void be_init_arch_sparc(void);
62 void be_init_arch_amd64(void);
63 void be_init_arch_sta(void);
64 void be_init_arch_sparc(void);
65 void be_init_arch_TEMPLATE(void);
66 void be_init_copyilp(void);
67 void be_init_peephole(void);
68 void be_init_ra(void);
69 void be_init_spillbelady(void);
70 void be_init_ssaconstr(void);
71 void be_init_stabs(void);
72 void be_init_pref_alloc(void);
73 void be_init_irgmod(void);
74 void be_init_loopana(void);
75 void be_init_spillslots(void);
76 void be_init_live(void);
77 void be_init_state(void);
78 void be_init_pbqp(void);
80 void be_quit_copystat(void);
81 void be_quit_pbqp(void);
84 * Driver for module initialization.
85 * Call your module initialization function here.
87 void be_init_modules(void)
89 static bool run_once = false;
101 be_init_blocksched();
103 be_init_spilloptions();
107 be_init_sched_normal();
108 be_init_sched_trace();
109 be_init_sched_regpress();
110 be_init_sched_rand();
111 be_init_sched_trivial();
113 be_init_chordal_main();
114 be_init_chordal_common();
123 be_init_pbqp_coloring();
128 be_init_spillbelady();
129 be_init_daemelspill();
131 be_init_pref_alloc();
137 be_init_arch_sparc();
138 be_init_arch_amd64();
139 be_init_arch_TEMPLATE();
143 #endif /* WITH_ILP */
147 #endif /* PLUGIN_IR_BE_STA */
154 void be_quit_modules(void)
162 //---------------------------------------------------------------------------
164 typedef struct module_opt_data_t {
166 be_module_list_entry_t * const *list_head;
170 * Searches in list for module option. If found, set option to given value and return true.
171 * Beware: return value of 0 means error.
173 static int set_opt_module(const char *name, lc_opt_type_t type, void *data,
176 module_opt_data_t *moddata = (module_opt_data_t*)data;
180 const be_module_list_entry_t *module;
184 va_start(args, length);
185 opt = va_arg(args, const char*);
187 for (module = *(moddata->list_head); module != NULL; module = module->next) {
188 if (strcmp(module->name, opt) == 0) {
189 *(moddata->var) = module->data;
200 * Dump the names of all registered module options.
202 static int dump_opt_module(char *buf, size_t buflen, const char *name,
203 lc_opt_type_t type, void *data, size_t length)
205 module_opt_data_t *moddata = (module_opt_data_t*)data;
206 const be_module_list_entry_t *module;
211 for (module = *(moddata->list_head); module != NULL; module = module->next) {
212 if (module->data == *(moddata->var)) {
213 snprintf(buf, buflen, "%s", module->name);
218 snprintf(buf, buflen, "none");
223 * Dump the values of all register module options.
225 static int dump_opt_module_vals(char *buf, size_t buflen, const char *name,
226 lc_opt_type_t type, void *data, size_t len)
228 module_opt_data_t *moddata = (module_opt_data_t*)data;
230 const be_module_list_entry_t *module;
235 for (module = *(moddata->list_head); module != NULL; module = module->next) {
236 size_t len = strlen(module->name);
238 if (module != *(moddata->list_head)) {
239 p = strncat(p, ", ", buflen - 1);
243 p = strncat(p, module->name, buflen - 1);
255 * Add a new module to list.
257 void be_add_module_to_list(be_module_list_entry_t **list_head, const char *name,
260 be_module_list_entry_t *entry = XMALLOC(be_module_list_entry_t);
262 entry->data = module;
263 entry->next = *list_head;
268 * Add an option for a module.
270 void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
271 const char *description,
272 be_module_list_entry_t * const * list_head,
275 module_opt_data_t *moddata = XMALLOC(module_opt_data_t);
277 moddata->list_head = list_head;
279 lc_opt_add_opt(grp, name, description, lc_opt_type_enum,
280 moddata, sizeof(moddata[0]),
281 set_opt_module, dump_opt_module, dump_opt_module_vals,