3 * File name: ir/ir/irflag.c
4 * Purpose: Flags to control optimizations.
5 * Author: Christian Schaefer, Goetz Lindenmaier
9 * Copyright: (c) 1999-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 #include "firm_common.h"
20 /* DISABLE - don't do this optimization
21 ENABLE - lets see, if there is a better graph */
25 #define FLAG(name, value, def) (irf_##name & def) |
26 #define E_FLAG(name, value, def) FLAG(name, value, def)
27 #define I_FLAG(name, value, def) FLAG(name, value, def)
29 optimization_state_t libFIRM_opt =
30 #include "irflag_t.def"
38 /* verbose is always off on default */
39 optimization_state_t libFIRM_verb = 0;
41 /** The Firm verbosity level */
42 int firm_verbosity_level;
44 /* an external flag can be set and get from outside */
45 #define E_FLAG(name, value, def) \
46 void set_opt_##name(int flag) { \
47 if (flag) libFIRM_opt |= irf_##name; \
48 else libFIRM_opt &= ~irf_##name; \
50 void set_opt_##name##_verbose(int flag) { \
51 if (flag) libFIRM_verb |= irf_##name; \
52 else libFIRM_verb &= ~irf_##name; \
54 int (get_opt_##name)(void) { \
55 return _get_opt_##name(); \
58 /* an internal flag can only be set from outside */
59 #define I_FLAG(name, value, def) \
60 void set_opt_##name(int flag) { \
61 if (flag) libFIRM_opt |= irf_##name; \
62 else libFIRM_opt &= ~irf_##name; \
64 void set_opt_##name##_verbose(int flag) { \
65 if (flag) libFIRM_verb |= irf_##name; \
66 else libFIRM_verb &= ~irf_##name; \
70 #include "irflag_t.def"
75 /* for compatibility reasons */
76 void set_optimize(int value) {
77 if (value) libFIRM_opt |= irf_optimize;
78 else libFIRM_opt &= ~irf_optimize;
81 int (get_optimize)(void) {
82 return get_opt_optimize();
85 void set_opt_control_flow(int value)
87 set_opt_control_flow_straightening(value);
88 set_opt_control_flow_weak_simplification(value);
89 set_opt_control_flow_strong_simplification(value);
90 set_opt_critical_edges(value);
93 void set_firm_verbosity (int value) {
94 firm_verbosity_level = value;
97 int (get_firm_verbosity) (void) {
98 return _get_firm_verbosity();
101 /* Save the current optimization state. */
102 void save_optimization_state(optimization_state_t *state)
104 *state = libFIRM_opt;
107 /* Restore the current optimization state. */
108 void restore_optimization_state(const optimization_state_t *state)
110 libFIRM_opt = *state;
114 void firm_show_flags(void) {
115 #define E_FLAG(name, value, def) printf(#name " = %s\n", get_opt_##name() ? "ON" : "OFF");
116 #define I_FLAG(name, value, def) printf(#name " = %s\n", get_opt_##name() ? "ON" : "OFF");
117 #include "irflag_t.def"