Fixed pinned info
[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:
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  * Optimization flags.
17  *
18  * @author Christian Schaefer
19  */
20
21 #ifndef _IRFLAG_H_
22 #define _IRFLAG_H_
23
24 /**
25  * A container type to load/restore all optimizations
26  */
27 typedef unsigned optimization_state_t;
28
29 /**
30  * This function enables/disables optimizations globally.
31  *
32  * If optimize == 0 no optimizations are performed at all.
33  * Default: optimize == 1.
34  */
35 void set_optimize (int value);
36 int get_optimize(void);
37
38 /** Enables/Disables constant folding optimization.
39  *
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.
47  */
48 void set_opt_constant_folding (int value);
49
50 /** Enables/Disables removal of redundant Loads and Stores.
51  *
52  *  - Remove Store that overwrites a just stored value (WAW).
53  *  - Remove Store if it stores a value just loaded (WAR with the same value).
54  *  - Remove Load that loads a value just saved (RAW with the same value).
55  */
56 void set_opt_redundant_LoadStore(int value);
57
58 /** Enables/Disables constant subexpression elimination.
59  *
60  * If opt_cse == 1 perform constant subexpression elimination.
61  * Default: opt_cse == 1.
62  */
63 void set_opt_cse (int value);
64
65 /** Enables/Disables global constant subexpression elimination.
66  *
67  * If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
68  * constant subexpression elimination for floating nodes.  Intra
69  * procedure cse gets the graph into state "floating".  It is necessary
70  * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
71  * right after a call to local_optimize with global cse turned on.
72  * Default: opt_global_cse == 0.
73  */
74 void set_opt_global_cse (int value);
75
76 /** Enables/Disables strength reduction.
77  *
78  * If opt_strength_red == 1 perform strength reduction.
79  * See strenth_red.h.
80  *
81  * Default: opt_strength_red = 1;
82  */
83 void set_opt_strength_red (int value);
84
85 /** Enables/Disables unreachable code elimination.
86  *
87  * If set, evaluate conditions of conditional branch and replace the
88  * branch with a Jmp/Bad Tuple.
89  *
90  * If opt_unreachable_code == 1 replace nodes (except Block,
91  * Phi and Tuple) with a Bad predecessor by the Bad node.
92  * Default: opt_unreachable_code == 1.
93  */
94 void set_opt_unreachable_code(int value);
95
96 /** Enables/Disables control flow optimizations.
97  *
98  * Performs Straightening, if simplifications and loop simplifications.
99  * Sets all separate control flow flags (control_flow_straightening,
100  * weak_simplification, strong_simplification and critical_edges).
101  */
102 void set_opt_control_flow(int value);
103
104 /** Enables/Disables Straightening. */
105 void set_opt_control_flow_straightening(int value);
106
107 /** Enables/Disables if simplifications in local optimizations. */
108 void set_opt_control_flow_weak_simplification(int value);
109
110 /** Enables/Disables strong if and loop simplification (in optimize_cf). */
111 void set_opt_control_flow_strong_simplification(int value);
112
113 /** Enables/Disables removal of critical control flow edges. */
114 void set_opt_critical_edges(int value);
115
116 /** Enables/Disables reassociation.
117  *
118  * If opt_reassociation == 1 reassociation is performed.
119  * Default: opt_reassociation == 1.
120  */
121 void set_opt_reassociation(int value);
122
123 /** Enables/Disables dead node elimination.
124  *
125  * If opt_dead_node_elimination == 1 deallocate all dead nodes
126  * by copying the firm graph.
127  * Default: opt_dead_node_elimination == 1. */
128 void set_opt_dead_node_elimination (int value);
129
130 /** Enables/Disables dead method elimination.
131  *
132  * If opt_dead_method_elimination == 1 methods never called are
133  * removed.
134  * Default: opt_dead_method_elimination == 1. */
135 void set_opt_dead_method_elimination (int value);
136 void set_opt_dead_method_elimination_verbose (int value);
137
138 /** Enable/Disables inlining.
139  *
140  * If opt_inline == 1 the inlining transformation is performed.
141  */
142 void set_opt_inline (int value);
143
144 /** Enable/Disable optimization of dynamic method dispatch
145  *
146  * This flag enables/disables the optimization of dynamic method dispatch.
147  * If the flag is turned on Sel nodes can be replaced by Const nodes representing
148  * the address of a function.
149  */
150 void set_opt_dyn_meth_dispatch (int value);
151
152 /** Enable/Disable optimization of tail-recursion calls.
153  *
154  * This flag enables/disables the optimization tail-recursion call.
155  * If the flag is turned on tail-recursion calls are optimized into loops.
156  */
157 void set_opt_tail_recursion(int value);
158
159
160 /** Enable/Disable normalizations of the firm representation.
161  *
162  *  This flag guards transformations that normalize the firm representation
163  *  as removing Ids and Tuples, useless Phis, replacing SymConst(id) by
164  *  Const(entity) and others.
165  *  The transformations guarded by this flag are not guarded by flag
166  *  "optimize".
167  *  Many algorithms operating on firm can not deal with constructs in
168  *  the non-normalized representation.
169  *  default: 1
170  *  @@@ ATTENTION: not all such transformations are guarded by a flag.
171  */
172 void set_opt_normalize (int value);
173
174
175 /** Enable/Disable precise exception context. */
176 void set_opt_precise_exc_context(int value);
177
178 /**
179  * Save the current optimization state.
180  */
181 void save_optimization_state(optimization_state_t *state);
182
183 /**
184  * Restore the current optimization state.
185  */
186 void restore_optimization_state(const optimization_state_t *state);
187
188 #endif