firmjni fix
[libfirm] / ir / ir / irflag.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irflag.h
4  * Purpose:     Flags to control optimizations.
5  * Author:      Christian Schaefer, Goetz Lindenmaier
6  * Modified by: Michael Beck
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1999-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14  * @file irflag.h
15  *
16  * Flags to customize the behaviour of libfirm.
17  *
18  * @author Christian Schaefer
19  *
20  * There are the following groups of flags:
21  * 1. Optimization flags.
22  *    a)  There is a flag, 'optimize' to turn on/off all optimizations.
23  *    b)  There are flags for each individual optimization.  Some flags turns
24  *        transformations in several algorithms on/off.
25  * 2. Normalization flags.
26  *    These flags steer transformations of the ir that improve it, as removing
27  *    dump Phi nodes (one predecessor, all preds are equal ...), Ids, Tuples ...
28  * 3. Verbosity flags.
29  *    a) Flags to steer the level of the information.
30  *    b) Flags to steer in which phase information should be dumped.
31  *
32  */
33
34 #ifndef _IRFLAG_H_
35 #define _IRFLAG_H_
36
37 /**
38  * A container type to load/restore all optimizations
39  */
40 typedef unsigned optimization_state_t;
41
42 /**
43  * This function enables/disables optimizations globally.
44  *
45  * If optimize == 0 no optimizations are performed at all.
46  * Default: optimize == 1.
47  */
48 void set_optimize (int value);
49 int  get_optimize(void);
50
51 /** This function enables/disables output of information about phases and
52  *  controls the verbosity level.
53  *
54  *  0: no output at all.
55  *  1: very short output
56  *  >>1: very verbose output.
57  */
58 void set_firm_verbosity (int value);
59 int  get_firm_verbosity (void);
60
61 /** Enables/Disables constant folding optimization.
62  *
63  *  If opt_constant_folding == 1 perform
64  *  - constant expression evaluation (2 + 5 ==> 7, 3 < 2 ==> false)
65  *  - algebraic simplification  (a * 0 ==> 0, a or a ==> a)
66  *  - simplification of tests   ( !(a < b) ==> (a >= b))
67  *  - refining the memory representation
68  *  - remove store after load
69  * Default: opt_constant_folding == 1.
70  */
71 void set_opt_constant_folding (int value);
72
73 /** Enables/Disables removal of redundant Loads and Stores.
74  *
75  *  - Remove Store that overwrites a just stored value (WAW).
76  *  - Remove Store if it stores a value just loaded (WAR with the same value).
77  *  - Remove Load that loads a value just saved (RAW with the same value).
78  *  - remove Load that loads a value already loaded (RAR)
79  *  - replace Load of constant values with constants (RC)
80  */
81 void set_opt_redundant_LoadStore(int value);
82
83 /** Enables/Disables constant subexpression elimination.
84  *
85  * If opt_cse == 1 perform constant subexpression elimination.
86  * Default: opt_cse == 1.
87  */
88 void set_opt_cse (int value);
89
90 /** Returns constant folding optimization setting. */
91 int get_opt_cse(void);
92
93 /** Enables/Disables global constant subexpression elimination.
94  *
95  * If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
96  * constant subexpression elimination for floating nodes.  Intra
97  * procedure cse gets the graph into state "floating".  It is necessary
98  * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
99  * right after a call to local_optimize with global cse turned on.
100  * Default: opt_global_cse == 0.
101  */
102 void set_opt_global_cse (int value);
103
104 /** Enables/Disables strength reduction.
105  *
106  * If opt_strength_red == 1 perform strength reduction.
107  * See strenth_red.h.
108  *
109  * Default: opt_strength_red = 1;
110  */
111 void set_opt_strength_red (int value);
112
113 /** Enables/Disables output of information about strength reduction.
114  */
115 void set_opt_strength_red_verbose (int value);
116
117 /** Enables/Disables unreachable code elimination.
118  *
119  * If set, evaluate conditions of conditional branch and replace the
120  * branch with a Jmp/Bad Tuple.
121  *
122  * If opt_unreachable_code == 1 replace nodes (except Block,
123  * Phi and Tuple) with a Bad predecessor by the Bad node.
124  * Default: opt_unreachable_code == 1.
125  */
126 void set_opt_unreachable_code(int value);
127
128 /** Enables/Disables control flow optimizations.
129  *
130  * Performs Straightening, if simplifications and loop simplifications.
131  * Sets all separate control flow flags (control_flow_straightening,
132  * weak_simplification, strong_simplification and critical_edges).
133  */
134 void set_opt_control_flow(int value);
135
136 /** Enables/Disables Straightening. */
137 void set_opt_control_flow_straightening(int value);
138
139 /** Enables/Disables if simplifications in local optimizations. */
140 void set_opt_control_flow_weak_simplification(int value);
141
142 /** Enables/Disables strong if and loop simplification (in optimize_cf). */
143 void set_opt_control_flow_strong_simplification(int value);
144
145 /** Enables/Disables removal of critical control flow edges. */
146 void set_opt_critical_edges(int value);
147
148 /** Enables/Disables reassociation.
149  *
150  * If opt_reassociation == 1 reassociation is performed.
151  * Default: opt_reassociation == 1.
152  */
153 void set_opt_reassociation(int value);
154
155 /** Enables/Disables dead node elimination.
156  *
157  * If opt_dead_node_elimination == 1 deallocate all dead nodes
158  * by copying the firm graph.
159  * Default: opt_dead_node_elimination == 1. */
160 void set_opt_dead_node_elimination (int value);
161
162 /** Enables/Disables dead method elimination.
163  *
164  * If opt_dead_method_elimination == 1 methods never called are
165  * removed.
166  * Default: opt_dead_method_elimination == 1. */
167 void set_opt_dead_method_elimination (int value);
168 void set_opt_dead_method_elimination_verbose (int value);
169
170 /** Enable/Disables inlining.
171  *
172  * If opt_inline == 1 the inlining transformation is performed.
173  */
174 void set_opt_inline (int value);
175
176 /** Enable/Disable optimization of dynamic method dispatch
177  *
178  * This flag enables/disables the optimization of dynamic method dispatch.
179  * If the flag is turned on Sel nodes can be replaced by Const nodes representing
180  * the address of a function.
181  */
182 void set_opt_dyn_meth_dispatch (int value);
183
184 /** Enable/Disable optimization of tail-recursion calls.
185  *
186  * This flag enables/disables the optimization tail-recursion call.
187  * If the flag is turned on tail-recursion calls are optimized into loops.
188  */
189 void set_opt_tail_recursion(int value);
190 void set_opt_tail_recursion_verbose(int value);
191
192 void set_opt_fragile_ops(int value);
193
194
195 /** Enable/Disable normalizations of the firm representation.
196  *
197  *  This flag guards transformations that normalize the firm representation
198  *  as removing Ids and Tuples, useless Phis, replacing SymConst(id) by
199  *  Const(entity) and others.
200  *  The transformations guarded by this flag are not guarded by flag
201  *  "optimize".
202  *  Many algorithms operating on firm can not deal with constructs in
203  *  the non-normalized representation.
204  *  default: 1
205  *  @@@ ATTENTION: not all such transformations are guarded by a flag.
206  */
207 void set_opt_normalize (int value);
208
209
210 /** Enable/Disable precise exception context. */
211 void set_opt_precise_exc_context(int value);
212
213 /**
214  * Save the current optimization state.
215  */
216 void save_optimization_state(optimization_state_t *state);
217
218 /**
219  * Restore the current optimization state.
220  */
221 void restore_optimization_state(const optimization_state_t *state);
222
223 #endif