irgraph: Put the obstack into ir_graph instead of delegating it.
[libfirm] / ir / ir / irflag_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Flags to control optimizations, inline implementation.
23  * @author   Michael Beck, Sebastian Hack
24  */
25 #ifndef FIRM_IR_IRFLAG_T_H
26 #define FIRM_IR_IRFLAG_T_H
27
28 #include "irflag.h"
29
30 /**
31  * libFIRM optimizations flags
32  */
33 typedef enum {
34 #define E_FLAG(name, value, def)    irf_##name = (1 << value),
35 #define I_FLAG(name, value, def)    irf_##name = (1 << value),
36 #define R_FLAG(name, value)
37
38 #include "irflag_t.def"
39         irf_last
40 #undef I_FLAG
41 #undef E_FLAG
42 #undef R_FLAG
43 } libfirm_opts_t;
44
45 /**
46  * libFIRM running flags
47  */
48 typedef enum {
49 #define E_FLAG(name, value, def)
50 #define I_FLAG(name, value, def)
51 #define R_FLAG(name, value)         ir_rf_##name = (1 << value),
52
53 #include "irflag_t.def"
54         ir_rf_last
55 #undef I_FLAG
56 #undef E_FLAG
57 #undef R_FLAG
58 } libfirm_running_t;
59
60 extern optimization_state_t libFIRM_opt, libFIRM_running, libFIRM_verb;
61 extern firm_verification_t opt_do_node_verification;
62
63 /** initialises the flags */
64 void firm_init_flags(void);
65
66 /* generate the getter functions for external access */
67 #define E_FLAG(name, value, def)                    \
68 static inline int get_opt_##name##_(void) {         \
69   return libFIRM_opt & irf_##name;                  \
70 }
71
72 /* generate the getter functions for internal access */
73 #define I_FLAG(name, value, def)                   \
74 static inline int get_opt_##name(void) {           \
75   return libFIRM_opt & irf_##name;                 \
76 }
77
78 /* generate getter and setter functions for running flags */
79 #define R_FLAG(name, value)                        \
80 static inline int is_##name##_running(void) {      \
81   return libFIRM_running & ir_rf_##name;           \
82 }                                                  \
83 static inline void set_##name##_running(int flag) {\
84   if (flag) libFIRM_running |= ir_rf_##name;       \
85   else      libFIRM_running &= ~ir_rf_##name;      \
86 }
87
88 #include "irflag_t.def"
89
90 #undef I_FLAG
91 #undef E_FLAG
92 #undef R_FLAG
93
94 static inline int get_optimize_(void)
95 {
96         return get_opt_optimize();
97 }
98
99 static inline firm_verification_t get_node_verification_mode(void)
100 {
101         return opt_do_node_verification;
102 }
103
104 #define get_optimize()                           get_optimize_()
105 #define get_opt_cse()                            get_opt_cse_()
106 #define get_opt_suppress_downcast_optimization() get_opt_suppress_downcast_optimization_()
107
108 #endif