stuff
[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
79 /* Analyses */
80 #include "irouts.h"         /* Graph reversal / out edges. */
81 #include "irdom.h"          /* Dominator analysis */
82 #include "cgana.h"          /* Analysis to construct interprocedural graph */
83                             /* including some optimizations */
84 #include "irloop.h"         /* loop and backedge analysis */
85 #include "callgraph.h"      /* Callgraph construction */
86 #include "interval_analysis.h"
87 #include "field_temperature.h"
88 #include "execution_frequency.h"
89
90 /* Support */
91 #include "irgmod.h"         /* Support to modify ir */
92 #include "irgwalk.h"        /* Support to walk ir */
93 #include "typewalk.h"       /* Support to walk type information */
94 #include "typegmod.h"       /* Support to modify type graph */
95 #include "type_identify.h"  /* Support for type identification */
96 #include "mangle.h"         /* Support for mangling ident names. */
97 #include "tr_inheritance.h" /* Support to handle inheritance. */
98
99 #include "irarch.h"        /* architecture dependant optimizations */
100 //#include "modeconv.h"      /* architecture dependant mode conversion */
101
102 #include "firmstat.h"      /* statistics */
103
104 #include "irreflect.h"     /* reflection */
105
106
107 /* @@@ temporarily for jni builder until preprocessor works.
108    Then it should be sufficient to include <file.h> instead
109    of firm.h as not all enums are needed in the implementation
110    files. */
111 #include "irdump.h"
112 #include "irprintf.h"
113 #include "irvrfy.h"
114 #include "trvrfy.h"
115
116 #include "irarch.h"
117
118 #include "iredges.h"
119
120 /* Makros that define the old function names we decided to rename.
121    Use for compatibility with old implementations. */
122 /*#include "old_fctnames.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 either insert a default value,
144    * or raise a compiler error/warning.
145    */
146   uninitialized_local_variable_func_t *initialize_local_func;
147
148   /**
149    * The interface functions for the type identification module.
150    * If not set, the default implementation with compare_strict() and
151    * firm_hash_name() will be used.
152    */
153   type_identify_if_t *ti_if;
154
155   /**
156    * The interface for the ident module.
157    * If not set, the default libFirm ident module (using hash sets).
158    */
159   ident_if_t *id_if;
160
161         /**
162          * The factory function for the architecture dependent
163          * optimizations.
164          */
165
166 };
167
168
169 typedef struct _firm_parameter_t firm_parameter_t;
170
171
172
173 /**
174  * Initialize the firm library.
175  *
176  * Initializes the firm library.  Allocates default data structures.
177  * Initializes configurable behaviour of the library.
178  *
179  * @param param    This function is called, whenever a local variable is
180  * used before definition.  The function should either insert a default value,
181  * or raise a compiler error.
182  *
183  * The parameter func may be NULL. In that case, the original FIRM behavior
184  * is conserved.
185  *
186  * @see default_initialize_local_variable_func_t
187  */
188 void init_firm(const firm_parameter_t *params);
189
190 /**
191  * Frees all memory occupied by the firm library.
192  */
193 void free_firm(void);
194
195 #ifdef __cplusplus
196 }
197 #endif
198
199 #endif /* _FIRM_H_ */