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