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
31 #include "bemodule_t.h"
34 void be_init_abi(void);
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_sched_rand(void);
41 void be_init_sched_normal(void);
42 void be_init_sched_regpress(void);
43 void be_init_sched_trace(void);
44 void be_init_sched_trivial(void);
45 void be_init_chordal(void);
46 void be_init_pbqp_coloring(void);
47 void be_init_chordal_main(void);
48 void be_init_chordal_common(void);
49 void be_init_copyopt(void);
50 void be_init_copyheur(void);
51 void be_init_copyheur2(void);
52 void be_init_copyheur4(void);
53 void be_init_copyilp2(void);
54 void be_init_copynone(void);
55 void be_init_copystat(void);
56 void be_init_daemelspill(void);
57 void be_init_dbgout(void);
58 void be_init_arch_ia32(void);
59 void be_init_arch_arm(void);
60 void be_init_arch_amd64(void);
61 void be_init_arch_sta(void);
62 void be_init_arch_sparc(void);
63 void be_init_arch_TEMPLATE(void);
64 void be_init_copyilp(void);
65 void be_init_peephole(void);
66 void be_init_ra(void);
67 void be_init_spillbelady(void);
68 void be_init_ssaconstr(void);
69 void be_init_stabs(void);
70 void be_init_dwarf(void);
71 void be_init_pref_alloc(void);
72 void be_init_irgmod(void);
73 void be_init_loopana(void);
74 void be_init_spillslots(void);
75 void be_init_live(void);
76 void be_init_state(void);
77 void be_init_pbqp(void);
79 void be_quit_copystat(void);
80 void be_quit_pbqp(void);
83 * Driver for module initialization.
84 * Call your module initialization function here.
86 void be_init_modules(void)
88 static bool run_once = false;
100 be_init_blocksched();
102 be_init_spilloptions();
106 be_init_sched_normal();
107 be_init_sched_trace();
108 be_init_sched_regpress();
109 be_init_sched_rand();
110 be_init_sched_trivial();
112 be_init_chordal_main();
113 be_init_chordal_common();
120 be_init_pbqp_coloring();
125 be_init_spillbelady();
126 be_init_daemelspill();
128 be_init_pref_alloc();
135 be_init_arch_sparc();
136 be_init_arch_amd64();
137 be_init_arch_TEMPLATE();
143 #endif /* PLUGIN_IR_BE_STA */
150 void be_quit_modules(void)
158 //---------------------------------------------------------------------------
160 typedef struct module_opt_data_t {
162 be_module_list_entry_t * const *list_head;
166 * Searches in list for module option. If found, set option to given value and return true.
167 * Beware: return value of 0 means error.
169 static int set_opt_module(const char *name, lc_opt_type_t type, void *data,
172 module_opt_data_t *moddata = (module_opt_data_t*)data;
176 const be_module_list_entry_t *module;
180 va_start(args, length);
181 opt = va_arg(args, const char*);
183 for (module = *(moddata->list_head); module != NULL; module = module->next) {
184 if (strcmp(module->name, opt) == 0) {
185 *(moddata->var) = module->data;
196 * Dump the names of all registered module options.
198 static int dump_opt_module(char *buf, size_t buflen, const char *name,
199 lc_opt_type_t type, void *data, size_t length)
201 module_opt_data_t *moddata = (module_opt_data_t*)data;
202 const be_module_list_entry_t *module;
207 for (module = *(moddata->list_head); module != NULL; module = module->next) {
208 if (module->data == *(moddata->var)) {
209 snprintf(buf, buflen, "%s", module->name);
214 snprintf(buf, buflen, "none");
219 * Dump the values of all register module options.
221 static int dump_opt_module_vals(char *buf, size_t buflen, const char *name,
222 lc_opt_type_t type, void *data, size_t len)
224 module_opt_data_t *moddata = (module_opt_data_t*)data;
226 const be_module_list_entry_t *module;
231 for (module = *(moddata->list_head); module != NULL; module = module->next) {
232 size_t name_len = strlen(module->name);
234 if (module != *(moddata->list_head)) {
235 p = strncat(p, ", ", buflen - 1);
239 p = strncat(p, module->name, buflen - 1);
241 if (name_len >= buflen)
251 * Add a new module to list.
253 void be_add_module_to_list(be_module_list_entry_t **list_head, const char *name,
256 be_module_list_entry_t *entry = XMALLOC(be_module_list_entry_t);
258 entry->data = module;
259 entry->next = *list_head;
264 * Add an option for a module.
266 void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
267 const char *description,
268 be_module_list_entry_t * const * list_head,
271 module_opt_data_t *moddata = XMALLOC(module_opt_data_t);
273 moddata->list_head = list_head;
275 lc_opt_add_opt(grp, name, description, lc_opt_type_enum,
276 moddata, sizeof(moddata[0]),
277 set_opt_module, dump_opt_module, dump_opt_module_vals,