no need for firm_config.h anymore
[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  * @version  $Id$
25  */
26 #ifndef FIRM_IR_IRFLAG_T_H
27 #define FIRM_IR_IRFLAG_T_H
28
29 #include "irflag.h"
30
31 /**
32  * libFIRM optimizations flags
33  */
34 typedef enum {
35 #define E_FLAG(name, value, def)    irf_##name = (1 << value),
36 #define I_FLAG(name, value, def)    irf_##name = (1 << value),
37 #define R_FLAG(name, value)
38
39 #include "irflag_t.def"
40         irf_last
41 #undef I_FLAG
42 #undef E_FLAG
43 #undef R_FLAG
44 } libfirm_opts_t;
45
46 /**
47  * libFIRM running flags
48  */
49 typedef enum {
50 #define E_FLAG(name, value, def)
51 #define I_FLAG(name, value, def)
52 #define R_FLAG(name, value)         ir_rf_##name = (1 << value),
53
54 #include "irflag_t.def"
55         ir_rf_last
56 #undef I_FLAG
57 #undef E_FLAG
58 #undef R_FLAG
59 } libfirm_running_t;
60
61 extern optimization_state_t libFIRM_opt, libFIRM_running, libFIRM_verb;
62 extern firm_verification_t opt_do_node_verification;
63
64 /** initialises the flags */
65 void firm_init_flags(void);
66
67 /* generate the getter functions for external access */
68 #define E_FLAG(name, value, def)                    \
69 static INLINE int _get_opt_##name(void) {           \
70   return libFIRM_opt & irf_##name;                  \
71 }
72
73 /* generate the getter functions for internal access */
74 #define I_FLAG(name, value, def)                   \
75 static INLINE int get_opt_##name(void) {           \
76   return libFIRM_opt & irf_##name;                 \
77 }
78
79 /* generate getter and setter functions for running flags */
80 #define R_FLAG(name, value)                        \
81 static INLINE int is_##name##_running(void) {      \
82   return libFIRM_running & ir_rf_##name;           \
83 }                                                  \
84 static INLINE void set_##name##_running(int flag) {\
85   if (flag) libFIRM_running |= ir_rf_##name;       \
86   else      libFIRM_running &= ~ir_rf_##name;      \
87 }
88
89 #include "irflag_t.def"
90
91 #undef I_FLAG
92 #undef E_FLAG
93 #undef R_FLAG
94
95 static INLINE int _get_optimize(void) {
96         return get_opt_optimize();
97 }
98
99 static INLINE firm_verification_t
100 get_node_verification_mode(void) {
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_dyn_meth_dispatch()              _get_opt_dyn_meth_dispatch()
107 #define get_opt_optimize_class_casts()           _get_opt_optimize_class_casts()
108 #define get_opt_suppress_downcast_optimization() _get_opt_suppress_downcast_optimization()
109
110 extern void firm_init_flags(void);
111
112 #endif