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