69004ebc35c8db3e6230960331f4bf61c2e9dba1
[libfirm] / ir / ir / irflag.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irflag.c
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 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
17
18 #include "irflag.h"
19 #include "firm_common.h"
20
21
22 /* 0 - don't do this optimization
23    1 - lets see, if there is a better graph */
24 int optimized = 1;                  /* Turn off all optimizations. */
25
26 int opt_cse = 1;                    /* Hash the nodes. */
27 int opt_global_cse = 0;             /* Don't use block predecessor for comparison.
28                                        Default must be zero as code placement must
29                                        be run right after a local optimize walk with
30                                        opt_global_cse on. */
31 int opt_constant_folding = 1;       /* Evaluate operations. */
32 int opt_unreachable_code = 1;       /* Bad node propagation. */
33 int opt_control_flow_straightening = 1;           /*  */
34 int opt_control_flow_weak_simplification = 1;     /*  */
35 int opt_control_flow_strong_simplification = 1;   /*  */
36 int opt_critical_edges = 1;
37 int opt_dead_node_elimination = 1;  /* Reclaim memory. */
38 int opt_reassociation = 1;          /* Reassociate nodes. */
39 int opt_inline = 1;                 /* Do inlining transformation. */
40 int opt_dyn_meth_dispatch = 1;      /* Remove dynamic method dispatch. */
41
42 int opt_normalize = 1;              /* Transformations that normalize the firm representation
43                                        as removing Ids and Tuples, useless Phis, SymConst(id) ->
44                                        Const(entity) ... */
45
46 /* set the flags with set_flagname, get the flag with get_flagname */
47 INLINE void
48 set_opt_cse (int value)
49 {
50   opt_cse = value;
51 }
52
53 INLINE int
54 get_opt_cse (void)
55 {
56   return opt_cse;
57 }
58
59 void set_opt_global_cse (int value)
60 {
61   opt_global_cse = value;
62 }
63
64 int  get_opt_global_cse (void)
65 {
66   return opt_global_cse;
67 }
68
69 INLINE void
70 set_opt_constant_folding (int value)
71 {
72   opt_constant_folding=value;
73 }
74
75 INLINE int
76 get_opt_constant_folding (void)
77 {
78   return opt_constant_folding;
79 }
80
81 INLINE void
82 set_opt_unreachable_code(int value)
83 {
84   opt_unreachable_code = value;
85 }
86
87 INLINE int
88 get_opt_unreachable_code(void)
89 {
90   return opt_unreachable_code;
91 }
92
93 INLINE void set_opt_control_flow(int value) {
94   set_opt_control_flow_straightening(value);
95   set_opt_control_flow_weak_simplification(value);
96   set_opt_control_flow_strong_simplification(value);
97   set_opt_critical_edges(value);
98 }
99
100 /* Performs Straightening */
101 void set_opt_control_flow_straightening(int value) {
102   opt_control_flow_straightening = value;
103 }
104 int  get_opt_control_flow_straightening(void) {
105   return opt_control_flow_straightening;
106 }
107 /* Performs if simplifications in local optimizations. */
108 void set_opt_control_flow_weak_simplification(int value) {
109   opt_control_flow_weak_simplification = value;
110 }
111 int  get_opt_control_flow_weak_simplification(void) {
112   return opt_control_flow_weak_simplification;
113 }
114 /* Performs strong if and loop simplification (in optimize_cf). */
115 void set_opt_control_flow_strong_simplification(int value) {
116   opt_control_flow_strong_simplification = value;
117 }
118 int  get_opt_control_flow_strong_simplification(void) {
119   return opt_control_flow_strong_simplification;
120 }
121
122 void set_opt_critical_edges(int value) {
123   opt_critical_edges = value;
124 }
125 int  get_opt_critical_edges(void) {
126   return opt_critical_edges;
127 }
128
129
130 INLINE void
131 set_opt_reassociation(int value)
132 {
133   opt_reassociation = value;
134 }
135
136 INLINE int
137 get_opt_reassociation(void)
138 {
139   return opt_reassociation;
140 }
141
142 INLINE void
143 set_opt_dead_node_elimination (int value)
144 {
145   opt_dead_node_elimination = value;
146 }
147
148 INLINE int
149 get_opt_dead_node_elimination (void)
150 {
151   return opt_dead_node_elimination;
152 }
153
154 INLINE void
155 set_optimize (int value)
156 {
157   optimized = value;
158 }
159
160 INLINE int
161 get_optimize (void)
162 {
163   return optimized;
164 }
165
166
167 INLINE void set_opt_inline (int value) {
168   opt_inline = value;
169 }
170
171 INLINE int  get_opt_inline (void) {
172   return opt_inline;
173 }
174
175 /** Enable/Disable optimization of dynamic method dispatch
176  *
177  * This flag enables/disables the optimization of dynamic method dispatch.
178  * If the flag is turned on Sel nodes can be replaced by Const nodes representing
179  * the address of a function.
180  */
181 void set_opt_dyn_meth_dispatch (int value) {
182   opt_dyn_meth_dispatch = value;
183 }
184 int  get_opt_dyn_meth_dispatch (void) {
185   return opt_dyn_meth_dispatch;
186 }
187
188
189
190 INLINE void set_opt_normalize (int value) {
191   opt_normalize = value;
192 }
193
194 INLINE int  get_opt_normalize (void) {
195   return opt_normalize;
196 }