use tv_t.h instead of tv.h
[libfirm] / ir / ir / irflag_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irgraph.c
4  * Purpose:     Flags to control optimizations, inline implementation.
5  * Author:      Michael Beck
6  * Created:
7  * CVS-ID:      $Id$
8  * Copyright:   (c) 1998-2004 Universität Karlsruhe
9  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
10  */
11
12 /**
13  * @file irflag_t.h
14  *
15  * Inline implementation of Optimization flags.
16  *
17  * @author Michael Beck
18  */
19 #ifndef _IRFLAG_T_H_
20 #define _IRFLAG_T_H_
21
22 #include "irflag.h"
23
24 /**
25  * current libFIRM optimizations
26  */
27 typedef enum {
28   /** Common subexpression eliminations: Hash the nodes. */
29   OPT_CSE                                = 0x00000001,
30
31   /** Don't use block predecessor for comparison.
32    *  Default must be zero as code placement must
33    *  be run right after a local optimize walk with
34    *  opt_global_cse on. */
35   OPT_GLOBAL_CSE                         = 0x00000002,
36
37   /** Evaluate operations. */
38   OPT_CONSTANT_FOLDING                   = 0x00000004,
39
40   /** Bad node propagation. */
41   OPT_UNREACHABLE_CODE                   = 0x00000008,
42
43   /** */
44   OPT_CONTROL_FLOW_STRAIGHTENING         = 0x00000010,
45
46   /** */
47   OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION   = 0x00000020,
48
49   /** */
50   OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION = 0x00000040,
51
52   /** */
53   OPT_CRITICAL_EDGES                     = 0x00000080,
54
55   /** Reclaim memory. */
56   OPT_DEAD_NODE_ELIMINATION              = 0x00000100,
57
58   /** Reassociate nodes. */
59   OPT_REASSOCIATION                      = 0x00000200,
60
61   /** Do inlining transformation. */
62   OPT_INLINE                             = 0x00000400,
63
64   /** Remove dynamic method dispatch. */
65   OPT_DYN_METH_DISPATCH                  = 0x00000800,
66
67   /** Transformations that normalize the firm representation
68    *  as removing Ids and Tuples, useless Phis, SymConst(id) -> Const(entity) ...
69    */
70   OPT_NORMALIZE                          = 0x00001000,
71
72   /** Remove tail-recursion. */
73   OPT_TAIL_RECURSION                     = 0x00002000,
74
75   /** Free never called methods */
76   OPT_DEAD_METHOD_ELIMINATION            = 0x00004000,
77
78   /** precise exception context */
79   OPT_PRECISE_EXC_CONTEXT                = 0x00008000,
80
81  /** EMPTY SLOT !!! TO BE ASSIGNED */
82
83   /** Do loop unrolling */
84   OPT_LOOP_UNROLLING                     = 0x00010000,
85
86   /** Do Strength reduction */
87   OPT_STRENGTH_RED                       = 0x00020000,
88
89   /** Optimize Loads and Stores */
90   OPT_REDUNDANT_LOADSTORE                = 0x00040000,
91
92   /** Optimize Fragile OPs */
93   OPT_FRAGILE_OPS                        = 0x00080000,
94
95   /** If conversion. */
96   OPT_IF_CONVERSION                      = 0x00100000,
97
98   /** Optimize real function calls. */
99   OPT_REAL_FUNC_CALL                     = 0x00200000,
100
101   /** Optimize cast nodes. */
102   OPT_CLASS_CASTS                        = 0x00400000,
103   OPT_SUPPRESS_DOWNCAST_OPT              = 0x00800000,
104
105   /** Turn off all optimizations. */
106   OPT_OPTIMIZED                          = 0x40000000,
107
108 } libfirm_opts_t;
109
110 extern optimization_state_t libFIRM_opt;
111 extern optimization_state_t libFIRM_verb;
112
113 extern int firm_verbosity_level;
114
115
116 /** Returns constant folding optimization setting. */
117 static INLINE int _get_opt_cse(void)
118 {
119   return libFIRM_opt & OPT_CSE;
120 }
121
122 /** Returns constant subexpression elimination setting. */
123 static INLINE int get_opt_global_cse(void)
124 {
125   return libFIRM_opt & OPT_GLOBAL_CSE;
126 }
127
128 static INLINE int get_opt_loop_unrolling(void)
129 {
130   return libFIRM_opt & OPT_LOOP_UNROLLING;
131 }
132
133 /** Returns verbosity for loop unrolling.   */
134 static INLINE int get_opt_loop_unrolling_verbose(void)
135 {
136   return libFIRM_verb & OPT_LOOP_UNROLLING;
137 }
138
139 static INLINE int get_opt_strength_red(void)
140 {
141   return libFIRM_opt & OPT_STRENGTH_RED;
142 }
143
144 /** Returns verbosity for strength reduction.   */
145 static INLINE int get_opt_strength_red_verbose(void)
146 {
147   return libFIRM_verb & OPT_STRENGTH_RED;
148 }
149
150 /** Returns global constant subexpression elimination setting. */
151 static INLINE int get_opt_constant_folding(void)
152 {
153   return libFIRM_opt & OPT_CONSTANT_FOLDING;
154 }
155
156 /** Returns global constant subexpression elimination setting. */
157 static INLINE int get_opt_redundant_LoadStore(void)
158 {
159   return libFIRM_opt & OPT_REDUNDANT_LOADSTORE;
160 }
161
162 /** Returns unreachable code elimination setting. */
163 static INLINE int get_opt_unreachable_code(void)
164 {
165   return libFIRM_opt & OPT_UNREACHABLE_CODE;
166 }
167
168 /** Returns Straightening setting. */
169 static INLINE int get_opt_control_flow_straightening(void)
170 {
171   return libFIRM_opt & OPT_CONTROL_FLOW_STRAIGHTENING;
172 }
173
174 /** Returns if simplifications in local optimizations setting. */
175 static INLINE int get_opt_control_flow_weak_simplification(void)
176 {
177   return libFIRM_opt & OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION;
178 }
179
180 /** Returns strong if and loop simplification setting */
181 static INLINE int get_opt_control_flow_strong_simplification(void)
182 {
183   return libFIRM_opt & OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION;
184 }
185
186 /** Returns whether critical edges are removed */
187 static INLINE int get_opt_critical_edges(void)
188 {
189   return libFIRM_opt & OPT_CRITICAL_EDGES;
190 }
191
192 /** Returns reassociation setting. */
193 static INLINE int get_opt_reassociation(void)
194 {
195   return libFIRM_opt & OPT_REASSOCIATION;
196 }
197
198 /** Returns dead node elimination setting. */
199 static INLINE int get_opt_dead_node_elimination(void)
200 {
201   return libFIRM_opt & OPT_DEAD_NODE_ELIMINATION;
202 }
203
204 /** Returns dead method elimination setting. */
205 static INLINE int get_opt_dead_method_elimination(void)
206 {
207   return libFIRM_opt & OPT_DEAD_METHOD_ELIMINATION;
208 }
209
210 /** Returns dead method elimination setting. */
211 static INLINE int get_opt_dead_method_elimination_verbose(void)
212 {
213   return libFIRM_verb & OPT_DEAD_METHOD_ELIMINATION;
214 }
215
216 /** Returns global optimization setting */
217 static INLINE int get_opt_optimize(void)
218 {
219   return libFIRM_opt & OPT_OPTIMIZED;
220 }
221
222 static INLINE int _get_firm_verbosity (void) {
223   return firm_verbosity_level;
224 }
225
226 /** Returns inlining setting. */
227 static INLINE int get_opt_inline(void)
228 {
229   return libFIRM_opt & OPT_INLINE;
230 }
231
232 static INLINE int _get_opt_dyn_meth_dispatch(void)
233 {
234   return libFIRM_opt & OPT_DYN_METH_DISPATCH;
235 }
236
237 static INLINE int _get_opt_optimize_class_casts (void) {
238   return libFIRM_opt & OPT_CLASS_CASTS;
239 }
240
241 static INLINE int _get_opt_optimize_class_casts_verbose (void) {
242   return libFIRM_verb & OPT_CLASS_CASTS;
243 }
244
245 static INLINE int _get_opt_suppress_downcast_optimization (void) {
246   return libFIRM_opt & OPT_SUPPRESS_DOWNCAST_OPT;
247 }
248
249 static INLINE int get_opt_normalize(void)
250 {
251   return libFIRM_opt & OPT_NORMALIZE;
252 }
253
254 /** Returns tail-recursion setting. */
255 static INLINE int get_opt_tail_recursion(void)
256 {
257   return libFIRM_opt & OPT_TAIL_RECURSION;
258 }
259
260 /** Returns tail-recursion setting. */
261 static INLINE int get_opt_tail_recursion_verbose(void)
262 {
263   return libFIRM_verb & OPT_TAIL_RECURSION;
264 }
265
266 /** Returns precise exception context setting. */
267 static INLINE int get_opt_precise_exc_context(void)
268 {
269   return libFIRM_opt & OPT_PRECISE_EXC_CONTEXT;
270 }
271
272 /** Returns fragile ops setting. */
273 static INLINE int get_opt_fragile_ops(void)
274 {
275   return libFIRM_opt & OPT_FRAGILE_OPS;
276 }
277
278 /** Returns if conversion setting. */
279 static INLINE int get_opt_if_conversion(void)
280 {
281   return libFIRM_opt & OPT_IF_CONVERSION;
282 }
283
284 /** Returns real function call optimization setting. */
285 static INLINE int get_opt_real_func_call(void)
286 {
287   return libFIRM_opt & OPT_REAL_FUNC_CALL;
288 }
289
290 #define get_opt_cse()                            _get_opt_cse()
291 #define get_firm_verbosity()                     _get_firm_verbosity()
292 #define get_opt_dyn_meth_dispatch()              _get_opt_dyn_meth_dispatch()
293 #define get_opt_optimize_class_casts()           _get_opt_optimize_class_casts()
294 #define get_opt_optimize_class_casts_verbose()   _get_opt_optimize_class_casts_verbose()
295 #define get_opt_suppress_downcast_optimization() _get_opt_suppress_downcast_optimization()
296
297 #endif /* _IRFLAG_T_H_ */