24ccba58557ab177be556b01c51f35b322b2a0a8
[libfirm] / ir / common / firm.h
1 /*
2  * Copyright (C) 1995-2007 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     Central firm header.
23  * @author    Martin Trapp, Christian Schaefer, Goetz Lindenmaier
24  * @version   $Id$
25  * @summary
26  *  Central FIRM header.
27  *
28  *  FIRM is a full graph based intermediate representation in SSA Form
29  *  with a novel concept to model side effects.  It allows fast, aggressive
30  *  optimizations.
31  *
32  *  This header is the central header of the library implementation of this
33  *  IR.
34  *
35  *  The internal representation of a program in firm is separated into five
36  *  different modules:
37  *   - Firm Graphs representing the code of a program. (Subdirectory ir.)
38  *     Firm Graphs are assembled out of several data structures:
39  *     irprog: represents a program.  Allows access to all types and all
40  *       FIRM graphs for procedures and other global things.
41  *     irgraph: represents a procedure.  Allows access to the code of the
42  *       procedure, the actual FIRM graph.
43  *     irnode: A node of a FIRM graph.  Nodes are typed with an opcode and a mode
44  *   and represent instructions in a program.
45  *     irop: The opcode of FIRM nodes.
46  *     irmode: The mode of FIRM nodes.  Most modes correspond to machine known
47  *       data types (int, float, pointer).
48  *   - Entities representing program known objects. (Subdirectory tr.)
49  *     All variables and procedures are entities.
50  *   - Types describing the type system for the program. (Subdirectory tr.)
51  *   - Target Values representing program known constants. (Subdirectory tv.)
52  *   - Identifiers representing any Strings used in the program. (Subdirectory ident.)
53  *
54  *   Further this library supplies functionality to build and optimize FIRM graphs
55  *   and further functionality needed in a compiler.  Finally there is more
56  *   generic functionality to support implementations using firm.  (Code generation,
57  *   further optimizations).
58  */
59 #ifndef FIRM_COMMON_FIRM_H
60 #define FIRM_COMMON_FIRM_H
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 /* The representations */
67 #include "firm_common.h"   /* common type tags. */
68 #include "irprog.h"        /* control flow and data of a program */
69 #include "irgraph.h"       /* graphs */
70 #include "type.h"          /* type representation */
71 #include "entity.h"        /* entity representation */
72 #include "tv.h"            /* target values */
73 #include "ident.h"         /* source code identificators */
74
75 /* Functionality */
76 #include "ircons.h"        /* construct ir */
77 #include "ircgcons.h"      /* construct interprocedural graph */
78
79 /* Optimizations */
80 #include "irflag.h"         /* optimization flags */
81 #include "irgopt.h"         /* optimize ir */
82 #include "reassoc.h"        /* optimize ir by reassociation */
83 #include "ldstopt.h"        /* optimize Load/Store */
84 #include "cfopt.h"          /* optimize control flow */
85 #include "tailrec.h"        /* optimize tail-recursion calls */
86 #include "ircgopt.h"        /* Optimizations based on interprocedural graph */
87 #include "opt_osr.h"        /* Operator Strength Reduction */
88 #include "strength_red.h"   /* Old (and buggy) Strength reduction */
89 #include "loop_unrolling.h" /* Do loop unrolling */
90 #include "ifconv.h"         /* if conversion */
91 #include "funccall.h"       /* real function call optimization */
92 #include "return.h"         /* Return node normalizations */
93 #include "scalar_replace.h" /* Scalar replacement */
94 #include "proc_cloning.h"   /* procedure cloning */
95 #include "opt_confirms.h"   /* Confirm based optimizations */
96 #include "gvn_pre.h"        /* global value numbering and partial redundancy elimination */
97 #include "opt_frame.h"      /* frame type optimization */
98 #include "tropt.h"          /* optimize the type representation */
99 #include "condeval.h"       /* control flow optimization by conditional evaluation */
100
101 /* Lowering */
102 #include "lower_calls.h"      /* lowering of different calls */
103 #include "lower_intrinsics.h" /* lowering of intrinsic calls */
104 #include "lower_dw.h"         /* double word types lowering */
105 #include "lower_hl.h"
106
107 /* Analyses */
108 #include "irouts.h"           /* Graph reversal / out edges. */
109 #include "trouts.h"           /* Graph reversal / out edges for types. */
110 #include "irdom.h"            /* Dominator analysis */
111 #include "cgana.h"            /* Analysis to construct interprocedural graph */
112                               /* including some optimizations */
113 #include "irloop.h"           /* loop and backedge analysis */
114 #include "callgraph.h"        /* Callgraph construction */
115 #include "irconsconfirm.h"    /* Confirm nodes */
116 #include "analyze_irg_args.h" /* Simple pointer parameter analysis */
117 #include "irtypeinfo.h"       /* type information for nodes */
118 #include "irmemory.h"         /* memory disambiguation */
119 #include "interval_analysis.h"
120 #include "field_temperature.h"
121 #include "execution_frequency.h"
122
123 /* Support */
124 #include "irgmod.h"         /* Support to modify ir */
125 #include "irgwalk.h"        /* Support to walk ir */
126 #include "typewalk.h"       /* Support to walk type information */
127 #include "typegmod.h"       /* Support to modify type graph */
128 #include "type_identify.h"  /* Support for type identification */
129 #include "mangle.h"         /* Support for mangling ident names. */
130 #include "tr_inheritance.h" /* Support to handle inheritance. */
131
132 #include "irarch.h"        /* architecture dependent optimizations */
133 #include "archop.h"        /* architecture dependent opcodes */
134 //#include "modeconv.h"      /* architecture dependent mode conversion */
135
136 #include "firmstat.h"      /* statistics */
137
138 #include "irreflect.h"     /* reflection */
139
140 #include "seqnumbers.h"    /* debug support */
141 #include "firm_ycomp.h"    /* ycomp debugging support */
142
143
144 /* @@@ temporarily for jni builder until preprocessor works.
145    Then it should be sufficient to include <file.h> instead
146    of firm.h as not all enums are needed in the implementation
147    files. */
148 #include "irdump.h"
149 #include "irprintf.h"
150 #include "irvrfy.h"
151 #include "trvrfy.h"
152
153 #include "irarch.h"
154
155 #include "iredges.h"
156
157 /* Macros that define the old function names we decided to rename.
158    Use for compatibility with old implementations. */
159 /*#include "old_fctnames.h"*/
160
161 /**
162  * libFirm initialization parameters.
163  */
164 struct _firm_parameter_t {
165   /**
166    * The size of this structure. init_firm() will only initialize
167    * this amount of data. This allows to add more fields to this structure
168    * without breaking compatibility to older source.
169    */
170   unsigned int size;
171
172   /**
173    * Statistic options. If statistic function where enabled, these
174    * flags configure it, see enum firmstat_options_t.
175    */
176   unsigned enable_statistics;
177
178   /**
179    * This function is called, whenever a local variable is
180    * used before definition. The function should insert a default value,
181    * and/or raise a compiler error/warning. Note that returning
182    * an Unknown is allowed here.
183    */
184   uninitialized_local_variable_func_t *initialize_local_func;
185
186   /**
187    * The interface functions for the type identification module.
188    * If not set, the default implementation with compare_strict() and
189    * firm_hash_name() will be used.
190    */
191   type_identify_if_t *ti_if;
192
193   /**
194    * The interface for the ident module.
195    * If not set, the default libFirm ident module (using hash sets).
196    */
197   ident_if_t *id_if;
198
199   /**
200    * The architecture dependent opcode settings.
201    * If not set, no architecture dependent operations will be used.
202    */
203   const arch_ops_info *arch_op_settings;
204
205   /**
206    * The default calling convention.
207    */
208   unsigned cc_mask;
209
210   /**
211    * The debug info that should be used for "builtin" objects.
212    */
213   dbg_info *builtin_dbg;
214 };
215
216 typedef struct _firm_parameter_t firm_parameter_t;
217
218 #define libFirm_VERSION_MAJOR 1
219 #define libFirm_VERSION_MINOR 4
220
221 /**
222  * The Firm version number.
223  */
224 typedef struct _firm_version_t {
225   unsigned major;
226   unsigned minor;
227 } firm_version_t;
228
229 /**
230  * Initialize the firm library.
231  *
232  * Initializes the firm library.  Allocates default data structures.
233  * Initializes configurable behavior of the library.
234  *
235  * @param params   A structure containing the parameters of the libFirm.
236  *
237  * The parameter struct may be NULL. In that case, the original FIRM behavior
238  * is conserved.
239  */
240 void init_firm(const firm_parameter_t *params);
241
242 /**
243  * Frees all memory occupied by the firm library.
244  */
245 void free_firm(void);
246
247 /**
248  * Returns the libFirm version number.
249  * If statically linked, always libFirm_VERSION_MAJOR, libFirm_VERSION_MINOR
250  */
251 void firm_get_version(firm_version_t *version);
252
253 #ifdef WITH_LIBCORE
254 /**
255  * Read initializations arguments from the .init file.
256  */
257 void firm_init_options(const char *arg_prefix, int argc, const char **argv);
258 #endif
259
260 #ifdef __cplusplus
261 }
262 #endif
263
264 #endif