3 * File name: ir/ir/irgraph.c
4 * Purpose: Flags to control optimizations, inline implementation.
8 * Copyright: (c) 1998-2004 Universität Karlsruhe
9 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * Inline implementation of Optimization flags.
17 * @author Michael Beck
25 * current libFIRM optimizations
28 /** Common subexpression eliminations: Hash the nodes. */
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,
37 /** Evaluate operations. */
38 OPT_CONSTANT_FOLDING = 0x00000004,
40 /** Bad node propagation. */
41 OPT_UNREACHABLE_CODE = 0x00000008,
44 OPT_CONTROL_FLOW_STRAIGHTENING = 0x00000010,
47 OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION = 0x00000020,
50 OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION = 0x00000040,
53 OPT_CRITICAL_EDGES = 0x00000080,
55 /** Reclaim memory. */
56 OPT_DEAD_NODE_ELIMINATION = 0x00000100,
58 /** Reassociate nodes. */
59 OPT_REASSOCIATION = 0x00000200,
61 /** Do inlining transformation. */
62 OPT_INLINE = 0x00000400,
64 /** Remove dynamic method dispatch. */
65 OPT_DYN_METH_DISPATCH = 0x00000800,
67 /** Transformations that normalize the firm representation
68 * as removing Ids and Tuples, useless Phis, SymConst(id) -> Const(entity) ...
70 OPT_NORMALIZE = 0x00001000,
72 /** Remove tail-recursion. */
73 OPT_TAIL_RECURSION = 0x00002000,
75 /** Free never called methods */
76 OPT_DEAD_METHOD_ELIMINATION = 0x00004000,
78 /** precise exception context */
79 OPT_PRECISE_EXC_CONTEXT = 0x00008000,
81 /** EMPTY SLOT !!! TO BE ASSIGNED */
83 /** Do loop unrolling */
84 OPT_LOOP_UNROLLING = 0x00010000,
86 /** Do Strength reduction */
87 OPT_STRENGTH_RED = 0x00020000,
89 /** Optimize Loads and Stores */
90 OPT_REDUNDANT_LOADSTORE = 0x00040000,
92 /** Optimize Fragile OPs */
93 OPT_FRAGILE_OPS = 0x00080000,
96 OPT_IF_CONVERSION = 0x00100000,
98 /** Optimize real function calls. */
99 OPT_REAL_FUNC_CALL = 0x00200000,
101 /** Optimize cast nodes. */
102 OPT_CLASS_CASTS = 0x00400000,
103 OPT_SUPPRESS_DOWNCAST_OPT = 0x00800000,
105 /** Not really an optimization, removes Confirm nodes */
106 OPT_REMOVE_CONFIRM = 0x01000000,
108 /** Turn off all optimizations. */
109 OPT_OPTIMIZED = 0x40000000,
113 extern optimization_state_t libFIRM_opt;
114 extern optimization_state_t libFIRM_verb;
116 extern int firm_verbosity_level;
119 /** Returns constant folding optimization setting. */
120 static INLINE int _get_opt_cse(void)
122 return libFIRM_opt & OPT_CSE;
125 /** Returns constant subexpression elimination setting. */
126 static INLINE int get_opt_global_cse(void)
128 return libFIRM_opt & OPT_GLOBAL_CSE;
131 static INLINE int get_opt_loop_unrolling(void)
133 return libFIRM_opt & OPT_LOOP_UNROLLING;
136 /** Returns verbosity for loop unrolling. */
137 static INLINE int get_opt_loop_unrolling_verbose(void)
139 return libFIRM_verb & OPT_LOOP_UNROLLING;
142 static INLINE int get_opt_strength_red(void)
144 return libFIRM_opt & OPT_STRENGTH_RED;
147 /** Returns verbosity for strength reduction. */
148 static INLINE int get_opt_strength_red_verbose(void)
150 return libFIRM_verb & OPT_STRENGTH_RED;
153 /** Returns global constant subexpression elimination setting. */
154 static INLINE int get_opt_constant_folding(void)
156 return libFIRM_opt & OPT_CONSTANT_FOLDING;
159 /** Returns global constant subexpression elimination setting. */
160 static INLINE int get_opt_redundant_LoadStore(void)
162 return libFIRM_opt & OPT_REDUNDANT_LOADSTORE;
165 /** Returns unreachable code elimination setting. */
166 static INLINE int get_opt_unreachable_code(void)
168 return libFIRM_opt & OPT_UNREACHABLE_CODE;
171 /** Returns Straightening setting. */
172 static INLINE int get_opt_control_flow_straightening(void)
174 return libFIRM_opt & OPT_CONTROL_FLOW_STRAIGHTENING;
177 /** Returns if simplifications in local optimizations setting. */
178 static INLINE int get_opt_control_flow_weak_simplification(void)
180 return libFIRM_opt & OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION;
183 /** Returns strong if and loop simplification setting */
184 static INLINE int get_opt_control_flow_strong_simplification(void)
186 return libFIRM_opt & OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION;
189 /** Returns whether critical edges are removed */
190 static INLINE int get_opt_critical_edges(void)
192 return libFIRM_opt & OPT_CRITICAL_EDGES;
195 /** Returns reassociation setting. */
196 static INLINE int get_opt_reassociation(void)
198 return libFIRM_opt & OPT_REASSOCIATION;
201 /** Returns dead node elimination setting. */
202 static INLINE int get_opt_dead_node_elimination(void)
204 return libFIRM_opt & OPT_DEAD_NODE_ELIMINATION;
207 /** Returns dead method elimination setting. */
208 static INLINE int get_opt_dead_method_elimination(void)
210 return libFIRM_opt & OPT_DEAD_METHOD_ELIMINATION;
213 /** Returns dead method elimination setting. */
214 static INLINE int get_opt_dead_method_elimination_verbose(void)
216 return libFIRM_verb & OPT_DEAD_METHOD_ELIMINATION;
219 /** Returns global optimization setting */
220 static INLINE int get_opt_optimize(void)
222 return libFIRM_opt & OPT_OPTIMIZED;
225 static INLINE int _get_firm_verbosity (void) {
226 return firm_verbosity_level;
229 /** Returns inlining setting. */
230 static INLINE int get_opt_inline(void)
232 return libFIRM_opt & OPT_INLINE;
235 static INLINE int _get_opt_dyn_meth_dispatch(void)
237 return libFIRM_opt & OPT_DYN_METH_DISPATCH;
240 static INLINE int _get_opt_optimize_class_casts (void) {
241 return libFIRM_opt & OPT_CLASS_CASTS;
244 static INLINE int _get_opt_optimize_class_casts_verbose (void) {
245 return libFIRM_verb & OPT_CLASS_CASTS;
248 static INLINE int _get_opt_suppress_downcast_optimization (void) {
249 return libFIRM_opt & OPT_SUPPRESS_DOWNCAST_OPT;
252 static INLINE int get_opt_normalize(void)
254 return libFIRM_opt & OPT_NORMALIZE;
257 /** Returns tail-recursion setting. */
258 static INLINE int get_opt_tail_recursion(void)
260 return libFIRM_opt & OPT_TAIL_RECURSION;
263 /** Returns tail-recursion setting. */
264 static INLINE int get_opt_tail_recursion_verbose(void)
266 return libFIRM_verb & OPT_TAIL_RECURSION;
269 /** Returns precise exception context setting. */
270 static INLINE int get_opt_precise_exc_context(void)
272 return libFIRM_opt & OPT_PRECISE_EXC_CONTEXT;
275 /** Returns fragile ops setting. */
276 static INLINE int get_opt_fragile_ops(void)
278 return libFIRM_opt & OPT_FRAGILE_OPS;
281 /** Returns if conversion setting. */
282 static INLINE int get_opt_if_conversion(void)
284 return libFIRM_opt & OPT_IF_CONVERSION;
287 /** Returns real function call optimization setting. */
288 static INLINE int get_opt_real_func_call(void)
290 return libFIRM_opt & OPT_REAL_FUNC_CALL;
293 /** Returns Confirm removal setting. */
294 static INLINE int get_opt_remove_Confirm(void)
296 return libFIRM_opt & OPT_REMOVE_CONFIRM;
299 #define get_opt_cse() _get_opt_cse()
300 #define get_firm_verbosity() _get_firm_verbosity()
301 #define get_opt_dyn_meth_dispatch() _get_opt_dyn_meth_dispatch()
302 #define get_opt_optimize_class_casts() _get_opt_optimize_class_casts()
303 #define get_opt_optimize_class_casts_verbose() _get_opt_optimize_class_casts_verbose()
304 #define get_opt_suppress_downcast_optimization() _get_opt_suppress_downcast_optimization()
306 #endif /* _IRFLAG_T_H_ */