85ff05033bae44e979bf3e655f4a08b9f4003b51
[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  This documentation no more  maintained since 2001!!!
17
18     Central FIRM header.
19
20     FIRM is a full graph based intermediate representation in SSA Form
21     with a novel concept to model side effects.  It allows fast, aggressive
22     optimizations.
23
24     This header is the central header of the library implementation of this
25     IR.
26
27     The internal representation of a program in firm is separated into five
28     different modules:
29      - Firm Graphs representing the code of a program. (Subdirectory ir.)
30        Firm Graphs are assembled out of several data structures:
31        irprog: represents a program.  Allows access to all types and all
32          FIRM graphs for procedures and other global things.
33        irgraph: represents a procedure.  Allows access to the code of the
34          procedure, the actual FIRM graph.
35        irnode: A node of a FIRM graph.  Nodes are typed with an opcode and a mode
36      and represent instructions in a program.
37        irop: The opcode of FIRM nodes.
38        irmode: The mode of FIRM nodes.  Most modes correspond to machine known
39          data types (int, float, pointer).
40      - Entities representing program known objects. (Subdirectory tr.)
41        All variables and procedures are entities.
42      - Types describing the type system for the program. (Subdirectory tr.)
43      - Target Values representing program known constants. (Subdirectory tv.)
44      - Identifiers representing any Strings used in the program. (Subdirectory ident.)
45
46      Further this library supplies functionality to build and optimize FIRM graphs
47      and further functionality needed in a compiler.  Finally there is more
48      generic functionality to support implementations using firm.  (Code generation,
49      further optimizations).
50
51      ircons: Interface to construct firm graphs, implements automatic Phi node
52        construction.
53      iropt: Optimizations applied to individual nodes.
54      irgopt: Optimizations for ir graphs.
55
56      irflag: Flags to direct the functionality.
57      common: dynamic typ check for all nodes,  configuration of the library,
58      debug:  ???
59
60      irgwalk: walker for ir graphs.
61      irvrfy:  verify the correctness of a firm node.
62 *
63 */
64
65 #ifndef _FIRM_H_
66 #define _FIRM_H_
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71
72 /* The representations */
73 #include "firm_common.h"   /* common type tags. */
74 #include "irprog.h"        /* control flow and data of a program */
75 #include "type.h"          /* type representation */
76 #include "entity.h"        /* entity representation */
77 #include "tv.h"            /* target values */
78 #include "ident.h"         /* source code identificators */
79 /* Functionality */
80 #include "ircons.h"        /* construct ir */
81 #include "ircgcons.h"      /* construct interprocedural graph */
82
83 #include "irflag.h"        /* optimization flags */
84 #include "irgopt.h"        /* optimize ir */
85 #include "reassoc.h"       /* optimize ir by reassociation */
86 #include "ldstopt.h"       /* optimize Load/Store */
87 #include "cfopt.h"         /* optimize control flow */
88 #include "tailrec.h"       /* optimize tail-recursion calls */
89 #include "ircgopt.h"       /* Optimizations based on interprocedural graph */
90 #include "strength_red.h"  /* Strength reduction */
91
92 #include "irouts.h"        /* Graph reversal / out edges. */
93 #include "irdom.h"         /* Dominator analysis */
94 #include "cgana.h"         /* Analysis to construct interprocedural graph */
95                            /* including some optimizations */
96 #include "irloop.h"        /* loop and backedge analysis */
97 #include "callgraph.h"     /* Callgraph construction */
98
99 #include "irgmod.h"        /* Support to modify ir */
100 #include "irgwalk.h"       /* Support to walk ir */
101 #include "typewalk.h"      /* Support to walk type information */
102 #include "typegmod.h"      /* Support to modify type graph */
103 #include "type_identify.h" /* Support for type identification */
104 #include "mangle.h"        /* Support for mangling ident names. */
105
106 #include "irarch.h"        /* architecture dependant optimizations */
107 //#include "modeconv.h"      /* architecture dependant mode conversion */
108
109 #include "firmstat.h"      /* statistics */
110
111 #include "irreflect.h"     /* reflection */
112
113
114 /* @@@ temporarily for jni builder until preprocessor works.
115    Then it should be sufficient to include <file.h> instead
116    of firm.h as not all enums are needed in the implementation
117    files. */
118 #include "irdump.h"
119 #include "irvrfy.h"
120 #include "trvrfy.h"
121
122 #include "irarch.h"
123
124 /* Makros that define the old function names we decided to rename.
125    Use for compatibility with old implementations. */
126 #include "old_fctnames.h"
127
128 /**
129  * libFirm initialization parameters.
130  */
131 struct _firm_parameter_t {
132   /**
133    * The size of this structure. init_firm() will only initialize
134    * this amount of data. This allows to add more fields to this structure
135    * without breaking compatibility to older source.
136    */
137   unsigned int size;
138
139   /**
140    * Statistic options. If statistic function where enabled, these
141    * flags configure it, see enum firmstat_options_t.
142    */
143   unsigned enable_statistics;
144
145   /**
146    * This function is called, whenever a local variable is
147    * used before definition.  The function should either insert a default value,
148    * or raise a compiler error/warning.
149    */
150   default_initialize_local_variable_func_t *initialize_local_func;
151
152   /**
153    * The interface functions for the type identification module.
154    * If not set, the default implementation with compare_strict() and
155    * hash_name() will be used.
156    */
157   type_identify_if_t *ti_if;
158
159   /**
160    * The interface for the ident module.
161    * If not set, the default libFirm ident module (using hash sets).
162    */
163   ident_if_t *id_if;
164
165         /**
166          * The factory function for the architecture dependent
167          * optimizations.
168          */
169
170 };
171
172
173 typedef struct _firm_parameter_t firm_parameter_t;
174
175
176
177 /**
178  * Initialize the firm library.
179  *
180  * Initializes the firm library.  Allocates default data structures.
181  * Initializes configurable behaviour of the library.
182  *
183  * @param param    This function is called, whenever a local variable is
184  * used before definition.  The function should either insert a default value,
185  * or raise a compiler error.
186  *
187  * The parameter func may be NULL. In that case, the original FIRM behavior
188  * is conserved.
189  *
190  * @see default_initialize_local_variable_func_t
191  */
192 void init_firm(const firm_parameter_t *params);
193
194 /**
195  * Frees all memory occupied by the firm library.
196  */
197 void free_firm(void);
198
199 #ifdef __cplusplus
200 }
201 #endif
202
203 #endif /* _FIRM_H_ */