get_Call_n_params: use int for consistency
[libfirm] / include / libfirm / irflag.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Flags to control optimizations.
23  * @author  Christian Schaefer, Goetz Lindenmaier, Michael Beck
24  */
25 #ifndef FIRM_IR_IRFLAG_H
26 #define FIRM_IR_IRFLAG_H
27
28 #include "firm_types.h"
29 #include "begin.h"
30
31 /**
32  * @ingroup iroptimize
33  * @defgroup Optimization Flags
34  * Flags to customize the behavior of libfirm.
35  *
36  * There are the following groups of flags:
37  * -# Optimization flags.
38  *    -#  There is a flag, 'optimize' to turn on/off all optimizations.
39  *    -#  There are flags for each individual optimization.  Some flags turns
40  *        transformations in several algorithms on/off.
41  * -# Normalization flags.
42  *    These flags steer transformations of the ir that improve it, as removing
43  *    dump Phi nodes (one predecessor, all predecessors are equal ...), Ids, Tuples ...
44  * -# Verbosity flags.
45  *    -# Flags to steer the level of the information.
46  *    -# Flags to steer in which phase information should be dumped.
47  *@{
48  */
49
50 /**
51  * A container type to load/restore all optimizations
52  */
53 typedef unsigned optimization_state_t;
54
55 /**
56  * This function enables/disables optimizations globally.
57  *
58  * If optimize == 0 no optimizations are performed at all.
59  * Default: optimize == 1.
60  */
61 FIRM_API void set_optimize(int value);
62 /** Returns global optimizations flag.
63  * @see set_optimize() */
64 FIRM_API int get_optimize(void);
65
66 /** Enables/Disables constant folding optimization.
67  *
68  *  If opt_constant_folding == 1 perform
69  *  constant expression evaluation (2 + 5 ==> 7, 3 < 2 ==> false)
70  * Default: opt_constant_folding == 1.
71  */
72 FIRM_API void set_opt_constant_folding(int value);
73 /** returns 0 if constant_folding is disabled, !=0 otherwise */
74 FIRM_API int get_opt_constant_folding(void);
75
76 /** Enables/Disables algebraic simplifications.
77  *
78  *  If opt_algebraic_simplification == 1 perform
79  *  - algebraic simplification  (a * 0 ==> 0, a or a ==> a)
80  *  - simplification of tests   ( !(a < b) ==> (a >= b))
81  * Default: opt_algebraic_simplification == 1.
82  */
83 FIRM_API void set_opt_algebraic_simplification(int value);
84
85 /** Enables/Disables common subexpression elimination.
86  *
87  * If opt_cse == 1 perform common subexpression elimination.
88  * Default: opt_cse == 1.
89  */
90 FIRM_API void set_opt_cse(int value);
91
92 /** Returns constant folding optimization setting. */
93 FIRM_API int get_opt_cse(void);
94
95 /** Enables/Disables global constant subexpression elimination.
96  *
97  * If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
98  * constant subexpression elimination for floating nodes.  Intra
99  * procedure cse gets the graph into state "floating".  It is necessary
100  * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
101  * right after a call to local_optimize with global cse turned on.
102  * Default: opt_global_cse == 0.
103  */
104 FIRM_API void set_opt_global_cse(int value);
105
106 /** Restricts the behavior of cast optimization.
107  *
108  *  If set, downcast are not optimized if they might be
109  *  illegal as in (Super)(Sub) (new Super()).  Default:
110  *  0 == not suppressed.
111  */
112 FIRM_API void set_opt_suppress_downcast_optimization(int value);
113 /** Returns suppred_downcast flag.
114  * @see set_opt_suppress_downcast_optimization() */
115 FIRM_API int get_opt_suppress_downcast_optimization(void);
116
117 /**
118  * Enable/Disable Global Null Pointer Test Elimination.
119  *
120  * In languages where it is illegal to dereference NULL pointer, doing
121  * so makes the pointer "valid non-null", else the program will stop
122  * anyway by a fault.
123  *
124  * This flag should be set for C style languages.
125  */
126 FIRM_API void set_opt_global_null_ptr_elimination(int value);
127
128 /**
129  * Enable/Disable Automatic construction of Sync nodes during
130  * Firm construction.
131  *
132  * If this flags is set, sequential non-volatile Loads are automatically
133  * rearranged so that they can be executed in parallel by creating Sync nodes.
134  *
135  * This flag should be set for Java style languages.
136  */
137 FIRM_API void set_opt_auto_create_sync(int value);
138
139 /** Enable/Disable Alias analysis.
140  *
141  * If enabled, memory disambiguation by alias analysis is used.
142  */
143 FIRM_API void set_opt_alias_analysis(int value);
144
145 /** Enable/Disable closed world assumption.
146  *
147  * If enabled, optimizations expect to know the "whole world", i.e. no
148  * external types or callers exist.
149  * This enables some powerful optimizations.
150  */
151 FIRM_API void set_opt_closed_world(int value);
152
153 /**
154  * Save the current optimization state.
155  */
156 FIRM_API void save_optimization_state(optimization_state_t *state);
157
158 /**
159  * Restore the current optimization state.
160  */
161 FIRM_API void restore_optimization_state(const optimization_state_t *state);
162
163 /**
164  * Switches ALL optimizations off.
165  */
166 FIRM_API void all_optimizations_off(void);
167
168 /** @} */
169
170 /** @ingroup irverify
171  * @defgroup irverify_flags Flags
172  * Enable/Disable automatic correctness tests
173  * @{
174  */
175
176 /**
177  * Possible verification modes.
178  */
179 typedef enum firm_verification_t {
180   FIRM_VERIFICATION_OFF        = 0, /**< do not verify nodes at all */
181   FIRM_VERIFICATION_ON         = 1, /**< do node verification and assert on error in debug version */
182   FIRM_VERIFICATION_REPORT     = 2, /**< do node verification, but report to stderr only */
183   FIRM_VERIFICATION_ERROR_ONLY = 3  /**< do node verification, but NEVER do assert nor report */
184 } firm_verification_t;
185
186 /**
187  * Select verification of IR nodes and types.
188  *
189  * Per default the  verification is in mode NODE_VERIFICATION_ASSERT.
190  * Turn the verification off during development to check partial
191  * implementations.
192  */
193 FIRM_API void do_node_verification(firm_verification_t mode);
194
195 /** @} */
196
197 #include "end.h"
198
199 #endif