3fd15637a58c7f48e71d379c86d4a7e0806ee2c6
[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 //  #include "old_fctnames.h"
73
74
75 /* The representations */
76 #include "firm_common.h"   /* common type tags. */
77 #include "irprog.h"        /* control flow and data of a program */
78 #include "type.h"          /* type representation */
79 #include "entity.h"        /* entity representation */
80 #include "tv.h"            /* target values */
81 #include "ident.h"         /* source code identificators */
82 /* Functionality */
83 #include "ircons.h"        /* construct ir */
84 #include "ircgcons.h"      /* construct interprocedural graph */
85
86 #include "irflag.h"        /* optimization flags */
87 #include "irgopt.h"        /* optimize ir */
88 #include "tailrec.h"       /* optimize tail-recursion calls */
89 #include "ircgopt.h"       /* Optimizations based on interprocedural graph */
90
91 #include "irouts.h"        /* Graph reversal / out edges. */
92 #include "irdom.h"         /* Dominator analysis */
93 #include "cgana.h"         /* Analysis to construct interprocedural graph */
94                            /* including some optimizations */
95 #include "irloop.h"        /* loop and backedge analysis */
96 #include "callgraph.h"     /* Callgraph construction */
97
98 #include "irgmod.h"        /* Support to modify ir */
99 #include "irgwalk.h"       /* Support to walk ir */
100 #include "typewalk.h"      /* Support to walk type information */
101 #include "typegmod.h"      /* Support to modify type graph */
102 #include "type_identify.h" /* Support for type identification */
103 #include "mangle.h"        /* Support for mangling ident names. */
104
105 #include "firmstat.h"      /* statistics */
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 "irvrfy.h"
113 #include "trvrfy.h"
114
115 /**
116  * libFirm initialization parameters.
117  */
118 struct _firm_parameter_t {
119   /**
120    * The size of this structure. init_firm() will only initialize
121    * this amount of data. This allows to add more fields to this structure
122    * without breaking compatibility to older source.
123    */
124   unsigned int size;
125
126   /**
127    * Statistic options. If statistic function where enabled, these
128    * flags configure it, see enum firmstat_options_t.
129    */
130   unsigned enable_statistics;
131
132   /**
133    * This function is called, whenever a local variable is
134    * used before definition.  The function should either insert a default value,
135    * or raise a compiler error/warning.
136    */
137   default_initialize_local_variable_func_t *initialize_local_func;
138
139   /**
140    * The compare function is used to identify equal types.  If not set
141    * it is initialized with the function compare_strict().
142    */
143   compare_types_func_t                     *compare_types_func;
144   /**
145    * The hash function is used to identify equal types.  It calculates a hash
146    * value of a type. Note, that the hash value for equal types must be identical.
147    * If not set it is initialized with the function hash_name().
148    */
149   hash_types_func_t                        *hash_types_func;
150
151 };
152
153
154 typedef struct _firm_parameter_t firm_parameter_t;
155
156
157
158 /**
159  * Initialize the firm library.
160  *
161  * Initializes the firm library.  Allocates default data structures.
162  * Initializes configurable behaviour of the library.
163  *
164  * @param param    This function is called, whenever a local variable is
165  * used before definition.  The function should either insert a default value,
166  * or raise a compiler error.
167  *
168  * The parameter func may be NULL. In that case, the original FIRM behavior
169  * is conserved.
170  *
171  * @see default_initialize_local_variable_func_t
172  */
173 void init_firm(const firm_parameter_t *params);
174
175 /**
176  * Frees all memory occupied by the firm library.
177  */
178 void free_firm(void);
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif /* _FIRM_H_ */