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 Flags to control optimizations.
23 * @author Michael Beck, Sebastian Hack
31 #include "firm_common.h"
35 /* DISABLE - don't do this optimization
36 ENABLE - lets see, if there is a better graph */
40 #define FLAG(name, value, def) (irf_##name & def) |
41 #define E_FLAG(name, value, def) FLAG(name, value, def)
42 #define I_FLAG(name, value, def) FLAG(name, value, def)
43 #define R_FLAG(name, value)
45 optimization_state_t libFIRM_opt =
46 #include "irflag_t.def"
54 /** The bitset of currently running phases. */
55 optimization_state_t libFIRM_running = 0;
57 /* verbose is always off on default */
58 optimization_state_t libFIRM_verb = 0;
60 /* silence warnings */
61 void set_opt_optimize(int value);
63 /* an external flag can be set and get from outside */
64 #define E_FLAG(name, value, def) \
65 void set_opt_##name(int flag) { \
66 if (flag) libFIRM_opt |= irf_##name; \
67 else libFIRM_opt &= ~irf_##name; \
69 int (get_opt_##name)(void) { \
70 return get_opt_##name##_(); \
73 /* an internal flag can only be set from outside */
74 #define I_FLAG(name, value, def) \
75 void set_opt_##name(int flag) { \
76 if (flag) libFIRM_opt |= irf_##name; \
77 else libFIRM_opt &= ~irf_##name; \
80 #define R_FLAG(name, value)
83 #include "irflag_t.def"
89 /* for compatibility reasons */
90 void set_optimize(int value)
92 set_opt_optimize(value);
95 int (get_optimize)(void)
97 return get_opt_optimize();
100 /* Save the current optimization state. */
101 void save_optimization_state(optimization_state_t *state)
103 *state = libFIRM_opt;
106 /* Restore the current optimization state. */
107 void restore_optimization_state(const optimization_state_t *state)
109 libFIRM_opt = *state;
112 /* Switches ALL optimizations off */
113 void all_optimizations_off(void)
119 /* only for debugging */
120 void firm_show_flags(FILE *f)
124 printf("Firm optimization state:\n");
125 #define E_FLAG(name, value, def) printf(" %-20s = %s\n", #name, get_opt_##name() ? "ON" : "OFF");
126 #define I_FLAG(name, value, def) printf(" %-20s = %s\n", #name, get_opt_##name() ? "ON" : "OFF");
127 #define R_FLAG(name, value) printf(" %-20s = %s\n", #name, is_##name##_running() ? "is running" : "not running");
128 #include "irflag_t.def"
136 static const lc_opt_table_entry_t firm_flags[] = {
137 #define I_FLAG(name, val, def) LC_OPT_ENT_BIT(#name, #name, &libFIRM_opt, (1 << val)),
138 #define E_FLAG(name, val, def) LC_OPT_ENT_BIT(#name, #name, &libFIRM_opt, (1 << val)),
139 #define R_FLAG(name, val)
140 #include "irflag_t.def"
147 void firm_init_flags(void)
149 lc_opt_entry_t *grp = lc_opt_get_grp(firm_opt_get_root(), "opt");
150 lc_opt_add_table(grp, firm_flags);
153 firm_verification_t opt_do_node_verification = FIRM_VERIFICATION_ON;
155 void do_node_verification(firm_verification_t mode)
157 opt_do_node_verification = mode;