3 * File name: ir/common/firm.h
4 * Purpose: Central firm header.
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
16 * Central FIRM header.
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
22 * This header is the central header of the library implementation of this
25 * The internal representation of a program in firm is separated into five
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.)
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).
56 /* The representations */
57 #include "firm_common.h" /* common type tags. */
58 #include "irprog.h" /* control flow and data of a program */
59 #include "irgraph.h" /* graphs */
60 #include "type.h" /* type representation */
61 #include "entity.h" /* entity representation */
62 #include "tv.h" /* target values */
63 #include "ident.h" /* source code identificators */
66 #include "ircons.h" /* construct ir */
67 #include "ircgcons.h" /* construct interprocedural graph */
70 #include "irflag.h" /* optimization flags */
71 #include "irgopt.h" /* optimize ir */
72 #include "reassoc.h" /* optimize ir by reassociation */
73 #include "ldstopt.h" /* optimize Load/Store */
74 #include "cfopt.h" /* optimize control flow */
75 #include "tailrec.h" /* optimize tail-recursion calls */
76 #include "ircgopt.h" /* Optimizations based on interprocedural graph */
77 #include "opt_osr.h" /* Operator Strength Reduction */
78 #include "strength_red.h" /* Old (and buggy) Strength reduction */
79 #include "loop_unrolling.h" /* Do loop unrolling */
80 #include "ifconv.h" /* if conversion */
81 #include "funccall.h" /* real function call optimization */
82 #include "return.h" /* Return node normalizations */
83 #include "scalar_replace.h" /* Scalar replacement */
84 #include "proc_cloning.h" /* procedure cloning */
85 #include "opt_confirms.h" /* Confirm based optimizations */
86 #include "gvn_pre.h" /* global value numbering and partial redundancy elimination */
87 #include "opt_frame.h" /* frame type optimization */
90 #include "lower_calls.h" /* lowering of different calls */
91 #include "lower_intrinsics.h" /* lowering of intrinsic calls */
94 #include "irouts.h" /* Graph reversal / out edges. */
95 #include "trouts.h" /* Graph reversal / out edges for types. */
96 #include "irdom.h" /* Dominator analysis */
97 #include "cgana.h" /* Analysis to construct interprocedural graph */
98 /* including some optimizations */
99 #include "irloop.h" /* loop and backedge analysis */
100 #include "callgraph.h" /* Callgraph construction */
101 #include "irconsconfirm.h" /* Confirm nodes */
102 #include "analyze_irg_args.h" /* Simple pointer parameter analysis */
103 #include "interval_analysis.h"
104 #include "field_temperature.h"
105 #include "execution_frequency.h"
108 #include "irgmod.h" /* Support to modify ir */
109 #include "irgwalk.h" /* Support to walk ir */
110 #include "typewalk.h" /* Support to walk type information */
111 #include "typegmod.h" /* Support to modify type graph */
112 #include "type_identify.h" /* Support for type identification */
113 #include "mangle.h" /* Support for mangling ident names. */
114 #include "tr_inheritance.h" /* Support to handle inheritance. */
116 #include "irarch.h" /* architecture dependent optimizations */
117 #include "archop.h" /* architecture dependent opcodes */
118 //#include "modeconv.h" /* architecture dependent mode conversion */
120 #include "firmstat.h" /* statistics */
122 #include "irreflect.h" /* reflection */
124 #include "seqnumbers.h" /* debug support */
127 /* @@@ temporarily for jni builder until preprocessor works.
128 Then it should be sufficient to include <file.h> instead
129 of firm.h as not all enums are needed in the implementation
132 #include "irprintf.h"
140 /* Macros that define the old function names we decided to rename.
141 Use for compatibility with old implementations. */
142 /*#include "old_fctnames.h"*/
145 * libFirm initialization parameters.
147 struct _firm_parameter_t {
149 * The size of this structure. init_firm() will only initialize
150 * this amount of data. This allows to add more fields to this structure
151 * without breaking compatibility to older source.
156 * Statistic options. If statistic function where enabled, these
157 * flags configure it, see enum firmstat_options_t.
159 unsigned enable_statistics;
162 * This function is called, whenever a local variable is
163 * used before definition. The function should insert a default value,
164 * and/or raise a compiler error/warning. Note that returning
165 * an Unknown is allowed here.
167 uninitialized_local_variable_func_t *initialize_local_func;
170 * The interface functions for the type identification module.
171 * If not set, the default implementation with compare_strict() and
172 * firm_hash_name() will be used.
174 type_identify_if_t *ti_if;
177 * The interface for the ident module.
178 * If not set, the default libFirm ident module (using hash sets).
183 * The architecture dependent opcode settings.
184 * If not set, no architecture dependent operations will be used.
186 const arch_ops_info *arch_op_settings;
189 * The default calling convention.
194 * The debug info that should be used for "builtin" objects.
196 dbg_info *builtin_dbg;
199 * Prefix for the command line options.
200 * example: if the option is -ffirm-opt-bla, then the prefix is "-f"
201 * @note Only active, if libfirm is compiled with libcore.
203 const char *arg_prefix;
206 * Number of arguments in the "command line".
207 * @note Only active, if libfirm is compiled with libcore.
212 * Array of arguments.
213 * @note Only active, if libfirm is compiled with libcore.
218 * Name of ini file which is initially read.
219 * @note Only active, if libfirm is compiled with libcore.
221 const char *ini_file;
224 typedef struct _firm_parameter_t firm_parameter_t;
226 #define libFirm_VERSION_MAJOR 1
227 #define libFirm_VERSION_MINOR 4
230 * The Firm version number.
232 typedef struct _firm_version_t {
238 * Initialize the firm library.
240 * Initializes the firm library. Allocates default data structures.
241 * Initializes configurable behavior of the library.
243 * @param params A structure containing the parameters of the libFirm.
245 * The parameter struct may be NULL. In that case, the original FIRM behavior
248 void init_firm(const firm_parameter_t *params);
251 * Frees all memory occupied by the firm library.
253 void free_firm(void);
256 * Returns the libFirm version number.
257 * If statically linked, always libFirm_VERSION_MAJOR, libFirm_VERSION_MINOR
259 void firm_get_version(firm_version_t *version);
265 #endif /* _FIRM_H_ */