- add block Phi list resource
[libfirm] / include / libfirm / firm.h
1 /*
2  * Copyright (C) 1995-2008 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 "typerep.h"       /* type representation */
71 #include "tv.h"            /* target values */
72 #include "ident.h"         /* source code identificators */
73
74 /* Functionality */
75 #include "ircons.h"        /* construct ir */
76 #include "ircgcons.h"      /* construct interprocedural graph */
77
78 /* Optimizations */
79 #include "irflag.h"         /* optimization flags */
80 #include "irgopt.h"         /* optimize ir */
81 #include "iroptimize.h"     /* optimize ir by reassociation */
82 #include "ircgopt.h"        /* Optimizations based on interprocedural graph */
83
84 /* Lowering */
85 #include "lowering.h"         /* lowering of different calls parameters, intrinsic calls, double word types, high-level constructs */
86
87 /* Analyses */
88 #include "irouts.h"           /* Graph reversal / out edges. */
89 #include "trouts.h"           /* Graph reversal / out edges for types. */
90 #include "irdom.h"            /* Dominator analysis */
91 #include "cgana.h"            /* Analysis to construct interprocedural graph */
92                               /* including some optimizations */
93 #include "irloop.h"           /* loop and backedge analysis */
94 #include "callgraph.h"        /* Callgraph construction */
95 #include "irconsconfirm.h"    /* Confirm nodes */
96 #include "analyze_irg_args.h" /* Simple pointer parameter analysis */
97 #include "irtypeinfo.h"       /* type information for nodes */
98 #include "irmemory.h"         /* memory disambiguation */
99 #include "interval_analysis.h"
100 #include "field_temperature.h"
101 #include "execution_frequency.h"
102
103 /* Support */
104 #include "irgmod.h"         /* Support to modify ir */
105 #include "irgwalk.h"        /* Support to walk ir */
106
107 #include "irarch.h"        /* architecture dependent optimizations */
108 #include "archop.h"        /* architecture dependent opcodes */
109
110 #include "firmstat.h"      /* statistics */
111
112 #include "dbginfo.h"       /* debug support */
113 #include "seqnumbers.h"    /* debug support */
114 #include "firm_ycomp.h"    /* ycomp debugging support */
115
116 #include "irdump.h"
117 #include "irprintf.h"
118 #include "irvrfy.h"
119
120 #include "irarch.h"
121
122 #include "iredges.h"
123
124 /**
125  * libFirm initialization parameters.
126  */
127 struct _firm_parameter_t {
128   /**
129    * The size of this structure. init_firm() will only initialize
130    * this amount of data. This allows to add more fields to this structure
131    * without breaking compatibility to older source.
132    */
133   unsigned int size;
134
135   /**
136    * Statistic options. If statistic function where enabled, these
137    * flags configure it, see enum firmstat_options_t.
138    */
139   unsigned enable_statistics;
140
141   /**
142    * This function is called, whenever a local variable is
143    * used before definition. The function should insert a default value,
144    * and/or raise a compiler error/warning. Note that returning
145    * an Unknown is allowed here.
146    */
147   uninitialized_local_variable_func_t *initialize_local_func;
148
149   /**
150    * The interface functions for the type identification module.
151    * If not set, the default implementation with compare_strict() and
152    * firm_hash_name() will be used.
153    */
154   type_identify_if_t *ti_if;
155
156   /**
157    * The interface for the ident module.
158    * If not set, the default libFirm ident module (using hash sets).
159    */
160   ident_if_t *id_if;
161
162   /**
163    * The architecture dependent opcode settings.
164    * If not set, no architecture dependent operations will be used.
165    */
166   const arch_ops_info *arch_op_settings;
167
168   /**
169    * The default calling convention.
170    */
171   unsigned cc_mask;
172
173   /**
174    * The debug info that should be used for "builtin" objects.
175    */
176   dbg_info *builtin_dbg;
177 };
178
179 typedef struct _firm_parameter_t firm_parameter_t;
180
181 /* Set a version number if it has not been set in environment */
182 #ifndef libfirm_VERSION_MAJOR
183 #define libfirm_VERSION_MAJOR 1
184 #endif
185
186 #ifndef libfirm_VERSION_MINOR
187 #define libfirm_VERSION_MINOR 4
188 #endif
189
190 /**
191  * The Firm version number.
192  */
193 typedef struct _firm_version_t {
194   unsigned major;
195   unsigned minor;
196   const char *revision;
197   const char *build;
198 } firm_version_t;
199
200 /**
201  * Initialize the firm library.
202  *
203  * Initializes the firm library.  Allocates default data structures.
204  * Initializes configurable behavior of the library.
205  *
206  * @param params   A structure containing the parameters of the libFirm.
207  *
208  * The parameter struct may be NULL. In that case, the original FIRM behavior
209  * is conserved.
210  */
211 void init_firm(const firm_parameter_t *params);
212
213 /**
214  * Frees all memory occupied by the firm library.
215  */
216 void free_firm(void);
217
218 /**
219  * Returns the libFirm version number.
220  * If statically linked, always libFirm_VERSION_MAJOR, libFirm_VERSION_MINOR
221  */
222 void firm_get_version(firm_version_t *version);
223
224 /**
225  * Read initializations arguments from the .init file.
226  */
227 void firm_init_options(const char *arg_prefix, int argc, const char **argv);
228
229 #ifdef __cplusplus
230 }
231 #endif
232
233 #endif