verbosity flags
[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
82   /** EMPTY SLOT !!! TO BE ASSIGNED */
83
84   /** Do Strength reduction */
85   OPT_STRENGTH_RED                       = 0x00020000,
86
87   /** Optimize Loads and Stores */
88   OPT_REDUNDANT_LOADSTORE                = 0x00040000,
89
90   /** Turn off all optimizations. */
91   OPT_OPTIMIZED                          = 0x40000000,
92
93 } libfirm_opts_t;
94
95 extern optimization_state_t libFIRM_opt;
96 extern optimization_state_t libFIRM_verb;
97
98 extern int firm_verbosity_level;
99
100
101 /** Returns constant folding optimization setting. */
102 static INLINE int get_opt_cse(void)
103 {
104   return libFIRM_opt & OPT_CSE;
105 }
106
107 /** Returns constant subexpression elimination setting. */
108 static INLINE int get_opt_global_cse(void)
109 {
110   return libFIRM_opt & OPT_GLOBAL_CSE;
111 }
112
113 static INLINE int get_opt_strength_red(void)
114 {
115   return libFIRM_opt & OPT_STRENGTH_RED;
116 }
117
118 /** Returns verbosity for strength reduction.   */
119 static INLINE int get_opt_strength_red_verbosity(void)
120 {
121   return libFIRM_verb & OPT_STRENGTH_RED;
122 }
123
124 /** Returns global constant subexpression elimination setting. */
125 static INLINE int get_opt_constant_folding(void)
126 {
127   return libFIRM_opt & OPT_CONSTANT_FOLDING;
128 }
129
130 /** Returns global constant subexpression elimination setting. */
131 static INLINE int get_opt_redundant_LoadStore(void)
132 {
133   return libFIRM_opt & OPT_REDUNDANT_LOADSTORE;
134 }
135
136 /** Returns unreachable code elimination setting. */
137 static INLINE int get_opt_unreachable_code(void)
138 {
139   return libFIRM_opt & OPT_UNREACHABLE_CODE;
140 }
141
142 /** Returns Straightening setting. */
143 static INLINE int get_opt_control_flow_straightening(void)
144 {
145   return libFIRM_opt & OPT_CONTROL_FLOW_STRAIGHTENING;
146 }
147
148 /** Returns if simplifications in local optimizations setting. */
149 static INLINE int get_opt_control_flow_weak_simplification(void)
150 {
151   return libFIRM_opt & OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION;
152 }
153
154 /** Returns strong if and loop simplification setting */
155 static INLINE int get_opt_control_flow_strong_simplification(void)
156 {
157   return libFIRM_opt & OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION;
158 }
159
160 /** Returns whether critical edges are removed */
161 static INLINE int get_opt_critical_edges(void)
162 {
163   return libFIRM_opt & OPT_CRITICAL_EDGES;
164 }
165
166 /** Returns reassociation setting. */
167 static INLINE int get_opt_reassociation(void)
168 {
169   return libFIRM_opt & OPT_REASSOCIATION;
170 }
171
172 /** Returns dead node elimination setting. */
173 static INLINE int get_opt_dead_node_elimination(void)
174 {
175   return libFIRM_opt & OPT_DEAD_NODE_ELIMINATION;
176 }
177
178 /** Returns dead method elimination setting. */
179 static INLINE int get_opt_dead_method_elimination(void)
180 {
181   return libFIRM_opt & OPT_DEAD_METHOD_ELIMINATION;
182 }
183
184 /** Returns dead method elimination setting. */
185 static INLINE int get_opt_dead_method_elimination_verbose(void)
186 {
187   return libFIRM_verb & OPT_DEAD_METHOD_ELIMINATION;
188 }
189
190 /** Returns global optimization setting */
191 static INLINE int get_opt_optimize(void)
192 {
193   return libFIRM_opt & OPT_OPTIMIZED;
194 }
195
196 static INLINE int __get_firm_verbosity (void) {
197   return firm_verbosity_level;
198 }
199
200 /** Returns inlining setting. */
201 static INLINE int get_opt_inline(void)
202 {
203   return libFIRM_opt & OPT_INLINE;
204 }
205
206 static INLINE int get_opt_dyn_meth_dispatch(void)
207 {
208   return libFIRM_opt & OPT_DYN_METH_DISPATCH;
209 }
210
211 static INLINE int get_opt_normalize(void)
212 {
213   return libFIRM_opt & OPT_NORMALIZE;
214 }
215
216 /** Returns tail-recursion setting. */
217 static INLINE int get_opt_tail_recursion(void)
218 {
219   return libFIRM_opt & OPT_TAIL_RECURSION;
220 }
221
222 /** Returns precise exception context setting. */
223 static INLINE int get_opt_precise_exc_context(void)
224 {
225   return libFIRM_opt & OPT_PRECISE_EXC_CONTEXT;
226 }
227
228
229
230 #define get_firm_verbosity()  __get_firm_verbosity()
231
232 #endif /* _IRFLAG_T_H_ */