3 * File name: ir/ir/irflag.h
4 * Purpose: Flags to control optimizations.
5 * Author: Christian Schaefer, Goetz Lindenmaier
9 * Copyright: (c) 1999-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
18 * @author Christian Schaefer
25 * A container type to load/restore all optimizations
27 typedef unsigned optimization_state_t;
30 * This function enables/disables optimizations globally.
32 * If optimize == 0 no optimizations are performed at all.
33 * Default: optimize == 1.
35 void set_optimize (int value);
36 int get_optimize(void);
38 /** Enables/Disables constant folding optimization.
40 * If opt_constant_folding == 1 perform
41 * - constant expression evaluation (2 + 5 ==> 7, 3 < 2 ==> false)
42 * - algebraic simplification (a * 0 ==> 0, a or a ==> a)
43 * - simplification of tests ( !(a < b) ==> (a >= b))
44 * - refining the memory representation
45 * - remove store after load
46 * Default: opt_constant_folding == 1.
48 void set_opt_constant_folding (int value);
50 /** Enables/Disables constant subexpression elimination.
52 * If opt_cse == 1 perform constant subexpression elimination.
53 * Default: opt_cse == 1.
55 void set_opt_cse (int value);
57 /** Enables/Disables global constant subexpression elimination.
59 * If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
60 * constant subexpression elimination for floating nodes. Intra
61 * procedure cse gets the graph into state "floating". It is necessary
62 * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
63 * right after a call to local_optimize with global cse turned on.
64 * Default: opt_global_cse == 0.
66 void set_opt_global_cse (int value);
68 /** Enables/Disables unreachable code elimination.
70 * If set, evaluate conditions of conditional branch and replace the
71 * branch with a Jmp/Bad Tuple.
73 * If opt_unreachable_code == 1 replace nodes (except Block,
74 * Phi and Tuple) with a Bad predecessor by the Bad node.
75 * Default: opt_unreachable_code == 1.
77 void set_opt_unreachable_code(int value);
79 /** Enables/Disables control flow optimizations.
81 * Performs Straightening, if simplifications and loop simplifications.
82 * Sets all separate control flow flags (control_flow_straightening,
83 * weak_simplification, strong_simplification and critical_edges).
85 void set_opt_control_flow(int value);
87 /** Enables/Disables Straightening. */
88 void set_opt_control_flow_straightening(int value);
90 /** Enables/Disables if simplifications in local optimizations. */
91 void set_opt_control_flow_weak_simplification(int value);
93 /** Enables/Disables strong if and loop simplification (in optimize_cf). */
94 void set_opt_control_flow_strong_simplification(int value);
96 /** Enables/Disables removal of critical control flow edges. */
97 void set_opt_critical_edges(int value);
99 /** Enables/Disables reassociation.
101 * If opt_reassociation == 1 reassociation is performed.
102 * Default: opt_reassociation == 1.
104 void set_opt_reassociation(int value);
106 /** Enables/Disables dead node elimination.
108 * If opt_dead_node_elimination == 1 deallocate all dead nodes
109 * by copying the firm graph.
110 * Default: opt_dead_node_elimination == 1. */
111 void set_opt_dead_node_elimination (int value);
113 /** Enables/Disables dead method elimination.
115 * If opt_dead_method_elimination == 1 methods never called are
117 * Default: opt_dead_method_elimination == 1. */
118 void set_opt_dead_method_elimination (int value);
119 void set_opt_dead_method_elimination_verbose (int value);
121 /** Enable/Disables inlining.
123 * If opt_inline == 1 the inlining transformation is performed.
125 void set_opt_inline (int value);
127 /** Enable/Disable optimization of dynamic method dispatch
129 * This flag enables/disables the optimization of dynamic method dispatch.
130 * If the flag is turned on Sel nodes can be replaced by Const nodes representing
131 * the address of a function.
133 void set_opt_dyn_meth_dispatch (int value);
135 /** Enable/Disable normalizations of the firm representation.
137 * This flag guards transformations that normalize the firm representation
138 * as removing Ids and Tuples, useless Phis, replacing SymConst(id) by
139 * Const(entity) and others.
140 * The transformations guarded by this flag are not guarded by flag
142 * Many algorithms operating on firm can not deal with constructs in
143 * the non-normalized representation.
145 * @@@ ATTENTION: not all such transformations are guarded by a flag.
147 void set_opt_normalize (int value);
149 /** Enable/Disable optimization of tail-recursion calls.
151 * This flag enables/disables the optimization tail-recursion call.
152 * If the flag is turned on tail-recursion calls are optimized into loops.
154 void set_opt_tail_recursion(int value);
156 /** Enable/Disable precise exception context. */
157 void set_opt_precise_exc_context(int value);
160 * Save the current optimization state.
162 void save_optimization_state(optimization_state_t *state);
165 * Restore the current optimization state.
167 void restore_optimization_state(const optimization_state_t *state);