Fixed 'inline' lossage --flo
[libfirm] / ir / ir / irflag_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irgraph.c
4  * Purpose:     Flags to control optimizations, inline implementation.
5  * Author:      Michael Beck
6  * Created:
7  * CVS-ID:      $Id$
8  * Copyright:   (c) 1998-2004 Universität Karlsruhe
9  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
10  */
11
12 /**
13  * @file irflag_t.h
14  *
15  * Inline implementation of Optimization flags.
16  *
17  * @author Michael Beck
18  */
19 #ifndef _IRFLAG_T_H_
20 #define _IRFLAG_T_H_
21
22 #include "irflag.h"
23
24 /**
25  * current libFIRM optimizations
26  */
27 typedef enum {
28   /** Common subexpression eliminations: Hash the nodes. */
29   OPT_CSE                                = 0x00000001,
30
31   /** Don't use block predecessor for comparison.
32    *  Default must be zero as code placement must
33    *  be run right after a local optimize walk with
34    *  opt_global_cse on. */
35   OPT_GLOBAL_CSE                         = 0x00000002,
36
37   /** Evaluate operations. */
38   OPT_CONSTANT_FOLDING                   = 0x00000004,
39
40   /** Bad node propagation. */
41   OPT_UNREACHABLE_CODE                   = 0x00000008,
42
43   /** */
44   OPT_CONTROL_FLOW_STRAIGHTENING         = 0x00000010,
45
46   /** */
47   OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION   = 0x00000020,
48
49   /** */
50   OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION = 0x00000040,
51
52   /** */
53   OPT_CRITICAL_EDGES                     = 0x00000080,
54
55   /** Reclaim memory. */
56   OPT_DEAD_NODE_ELIMINATION              = 0x00000100,
57
58   /** Reassociate nodes. */
59   OPT_REASSOCIATION                      = 0x00000200,
60
61   /** Do inlining transformation. */
62   OPT_INLINE                             = 0x00000400,
63
64   /** Remove dynamic method dispatch. */
65   OPT_DYN_METH_DISPATCH                  = 0x00000800,
66
67   /** Transformations that normalize the firm representation
68    *  as removing Ids and Tuples, useless Phis, SymConst(id) -> Const(entity) ...
69    */
70   OPT_NORMALIZE                          = 0x00001000,
71
72   /** Turn off all optimizations. */
73   OPT_OPTIMIZED                          = 0x40000000
74 } libfirm_opts_t;
75
76 extern optimization_state_t libFIRM_opt;
77
78 /* take care of the INLINE/USE_GCC_INLINE mess */
79
80 # ifndef INLINE
81 # ifdef USE_GCC_INLINE
82 # define INLINE __extension__ ((__inline__))
83 # else /* defined USE_GCC_INLINE */
84 # define INLINE
85 # endif /* define USE_GCC_INLINE */
86 # endif /* defined INLINE */
87
88
89 /** Returns constant folding optimization setting. */
90 INLINE int get_opt_cse(void)
91 # ifdef USE_GCC_INLINE
92 {
93   return libFIRM_opt & OPT_CSE;
94 }
95 # else /* defined USE_GCC_INLINE */
96 ;
97 # endif /* not defined USE_GCC_INLINE */
98
99 /** Returns constant subexpression elimination setting. */
100 INLINE int get_opt_global_cse(void)
101 # ifdef USE_GCC_INLINE
102 {
103   return libFIRM_opt & OPT_GLOBAL_CSE;
104 }
105 # else /* defined USE_GCC_INLINE */
106 ;
107 # endif /* not defined USE_GCC_INLINE */
108
109 /** Returns global constant subexpression elimination setting. */
110 INLINE int get_opt_constant_folding(void)
111 # ifdef USE_GCC_INLINE
112 {
113   return libFIRM_opt & OPT_CONSTANT_FOLDING;
114 }
115 # else /* defined USE_GCC_INLINE */
116 ;
117 # endif /* not defined USE_GCC_INLINE */
118
119 /** Returns unreachable code elimination setting. */
120 INLINE int get_opt_unreachable_code(void)
121 # ifdef USE_GCC_INLINE
122 {
123   return libFIRM_opt & OPT_UNREACHABLE_CODE;
124 }
125 # else /* defined USE_GCC_INLINE */
126 ;
127 # endif /* not defined USE_GCC_INLINE */
128
129 /** Returns Straightening setting. */
130 INLINE int get_opt_control_flow_straightening(void)
131 # ifdef USE_GCC_INLINE
132 {
133   return libFIRM_opt & OPT_CONTROL_FLOW_STRAIGHTENING;
134 }
135 # else /* defined USE_GCC_INLINE */
136 ;
137 # endif /* not defined USE_GCC_INLINE */
138
139 /** Returns if simplifications in local optimizations setting. */
140 INLINE int get_opt_control_flow_weak_simplification(void)
141 # ifdef USE_GCC_INLINE
142 {
143   return libFIRM_opt & OPT_CONTROL_FLOW_WEAK_SIMPLIFICATION;
144 }
145 # else /* defined USE_GCC_INLINE */
146 ;
147 # endif /* not defined USE_GCC_INLINE */
148
149 /** Returns strong if and loop simplification setting */
150 INLINE int get_opt_control_flow_strong_simplification(void)
151 # ifdef USE_GCC_INLINE
152 {
153   return libFIRM_opt & OPT_CONTROL_FLOW_STRONG_SIMPLIFICATION;
154 }
155 # else /* defined USE_GCC_INLINE */
156 ;
157 # endif /* not defined USE_GCC_INLINE */
158
159 /** Returns whether critical edges are removed */
160 INLINE int get_opt_critical_edges(void)
161 # ifdef USE_GCC_INLINE
162 {
163   return libFIRM_opt & OPT_CRITICAL_EDGES;
164 }
165 # else /* defined USE_GCC_INLINE */
166 ;
167 # endif /* not defined USE_GCC_INLINE */
168
169 /** Returns reassociation setting. */
170 INLINE int get_opt_reassociation(void)
171 # ifdef USE_GCC_INLINE
172 {
173   return libFIRM_opt & OPT_REASSOCIATION;
174 }
175 # else /* defined USE_GCC_INLINE */
176 ;
177 # endif /* not defined USE_GCC_INLINE */
178
179 /** Returns dead node elimination setting. */
180 INLINE int get_opt_dead_node_elimination(void)
181 # ifdef USE_GCC_INLINE
182 {
183   return libFIRM_opt & OPT_DEAD_NODE_ELIMINATION;
184 }
185 # else /* defined USE_GCC_INLINE */
186 ;
187 # endif /* not defined USE_GCC_INLINE */
188
189 /** Returns global optimization setting */
190 INLINE int get_opt_optimize(void)
191 # ifdef USE_GCC_INLINE
192 {
193   return libFIRM_opt & OPT_OPTIMIZED;
194 }
195 # else /* defined USE_GCC_INLINE */
196 ;
197 # endif /* not defined USE_GCC_INLINE */
198
199 /** Returns inlining setting. */
200 INLINE int get_opt_inline(void)
201 # ifdef USE_GCC_INLINE
202 {
203   return libFIRM_opt & OPT_INLINE;
204 }
205 # else /* defined USE_GCC_INLINE */
206 ;
207 # endif /* not defined USE_GCC_INLINE */
208
209 INLINE int get_opt_dyn_meth_dispatch(void)
210 # ifdef USE_GCC_INLINE
211 {
212   return libFIRM_opt & OPT_DYN_METH_DISPATCH;
213 }
214 # else /* defined USE_GCC_INLINE */
215 ;
216 # endif /* not defined USE_GCC_INLINE */
217
218 INLINE int get_opt_normalize(void)
219 # ifdef USE_GCC_INLINE
220 {
221   return libFIRM_opt & OPT_NORMALIZE;
222 }
223 # else /* defined USE_GCC_INLINE */
224 ;
225 # endif /* not defined USE_GCC_INLINE */
226
227 #endif /* _IRFLAG_T_H_ */