Loads do not remove any nodes from the exec after sets. Also fix a 'node leak'.
[libfirm] / ir / tr / tpop.h
1 /*
2  * Copyright (C) 1995-2007 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   Opcode of types.
23  * @author  Goetz Lindenmaier, Michael Beck
24  * @version $Id$
25  * @summary
26  *
27  *  This module specifies the kinds of types available in firm.
28  *
29  *  They are called type opcodes. These include classes, structs, methods, unions,
30  *  arrays, enumerations, pointers and primitive types.
31  *  Special types with own opcodes are the id type, a type representing an unknown
32  *  type and a type used to specify that something has no type.
33  *
34  *  @see type.h
35  */
36 #ifndef FIRM_TR_TPOP_H
37 #define FIRM_TR_TPOP_H
38
39 #include "ident.h"
40
41 /**
42  *  An enum for the type kinds.
43  *  For each type kind exists a typecode to identify it.
44  */
45 typedef enum {
46         tpo_uninitialized = 0,   /* not a type opcode */
47         tpo_class,               /**< A class type. */
48         tpo_struct,              /**< A struct type. */
49         tpo_method,              /**< A method type. */
50         tpo_union,               /**< An union type. */
51         tpo_array,               /**< An array type. */
52         tpo_enumeration,         /**< An enumeration type. */
53         tpo_pointer,             /**< A pointer type. */
54         tpo_primitive,           /**< A primitive type. */
55         tpo_id,                  /**< Special Id tag used for type replacement. */
56         tpo_none,                /**< Special type for the None type. */
57         tpo_unknown,             /**< Special code for the Unknown type. */
58         tpo_max                  /* not a type opcode */
59 } tp_opcode;
60
61 /**
62  * A structure containing information about a kind of type.
63  * A structure containing information about a kind of type.  So far
64  * this is only the kind name, an enum for case-switching and some
65  * internal values.
66  *
67  * @see  get_tpop_name(), get_tpop_code(), get_tpop_ident()
68  */
69 typedef struct tp_op tp_op;
70
71
72 /**
73  * Returns the string for the type opcode.
74  *
75  * @param op  The type opcode to get the string from.
76  * @return a string.  (@todo Null terminated???)
77  */
78 const char *get_tpop_name (const tp_op *op);
79
80 /**
81  * Returns an enum for the type opcode.
82  *
83  * @param op   The type opcode to get the enum from.
84  * @return the enum.
85  */
86 tp_opcode get_tpop_code (const tp_op *op);
87
88 /**
89  * Returns the ident for the type opcode.
90  *
91  * @param op   The type opcode to get the ident from.
92  * @return The ident.
93  */
94 ident *get_tpop_ident (const tp_op *op);
95
96 /**
97  * This type opcode marks that the corresponding type is a class type.
98  *
99  * Consequently the type refers to supertypes, subtypes and entities.
100  * Entities can be any fields, but also methods.
101  * @@@ value class or not???
102  * This struct is dynamically allocated but constant for the lifetime
103  * of the library.
104  */
105 extern tp_op *type_class;
106 tp_op *get_tpop_class(void);
107
108 /**
109  * This type opcode marks that the corresponding type is a compound type
110  * as a struct in C.
111  *
112  * Consequently the type refers to a list of entities
113  * which may not be methods (but pointers to methods).
114  * This struct is dynamically allocated but constant for the lifetime
115  * of the library.
116  */
117 extern tp_op *type_struct;
118 tp_op *get_tpop_struct(void);
119
120 /**
121  * This type opcode marks that the corresponding type is a method type.
122  *
123  * Consequently it refers to a list of arguments and results.
124  * This struct is dynamically allocated but constant for the lifetime
125  * of the library.
126  */
127 extern tp_op *type_method;
128 tp_op *get_tpop_method(void);
129
130 /**
131  * This type opcode marks that the corresponding type is a union type.
132  *
133  * Consequently it refers to a list of unioned types.
134  * This struct is dynamically allocated but constant for the lifetime
135  * of the library.
136  */
137 extern tp_op *type_union;
138 tp_op *get_tpop_union(void);
139
140 /**
141  * This type opcode marks that the corresponding type is an array type.
142  *
143  * Consequently it contains a list of dimensions (lower and upper bounds)
144  * and an element type.
145  * This struct is dynamically allocated but constant for the lifetime
146  * of the library.
147  */
148 extern tp_op *type_array;
149 tp_op *get_tpop_array(void);
150
151 /**
152  * This type opcode marks that the corresponding type is an enumeration type.
153  *
154  * Consequently it contains a list of idents for the enumeration identifiers
155  * and a list of target values that are the constants used to implement
156  * the enumerators.
157  * This struct is dynamically allocated but constant for the lifetime
158  * of the library.
159  */
160 extern tp_op *type_enumeration;
161 tp_op *get_tpop_enumeration(void);
162
163 /**
164  * This type opcode marks that the corresponding type is a pointer type.
165  *
166  * It contains a reference to the type the pointer points to.
167  * This struct is dynamically allocated but constant for the lifetime
168  * of the library.
169  */
170 extern tp_op *type_pointer;
171 tp_op *get_tpop_pointer(void);
172
173 /**
174  * This type opcode marks that the corresponding type is a primitive type.
175  *
176  * Primitive types are types that are directly mapped to target machine
177  * modes.
178  * This struct is dynamically allocated but constant for the lifetime
179  * of the library.
180  */
181 extern tp_op *type_primitive;
182 tp_op *get_tpop_primitive(void);
183
184 /**
185  * This type opcode is an auxiliary opcode dedicated to support transformations
186  * of the type structure.
187  *
188  * If a type is changed to another type with another
189  * opcode the new type will be allocated with new memory.  All nodes refering
190  * to the old type need to be changed to refer to the new one.  This is simplified
191  * by turning the old type into an id type that merely forwards to the new type
192  * that now replaces the old one.
193  * type_ids should never be visible out of the type module.  All access routines
194  * should automatically check for type_id and eventually follow the forward in
195  * type_id.  Two types are exchanged by a call to exchange_types.
196  * If a type_id is visible externally report this as bug.  If it is assured that
197  * this never happens this extern variable can be moved to tpop_t.h.
198  * This struct is dynamically allocated but constant for the lifetime
199  * of the library.
200  */
201 extern tp_op *type_id;
202 tp_op *get_tpop_id(void);
203
204 /**
205  * This type opcode is an auxiliary opcode dedicated to support type analyses.
206  *
207  * Types with this opcode represents that there is no type.
208  * The type can be used to initialize fields of the type* that actually can not
209  * contain a type or that are initialized for an analysis. There exists exactly
210  * one type with this opcode.
211  */
212 extern tp_op *tpop_none;
213 tp_op *get_tpop_none(void);
214
215 /**
216  * This type opcode is an auxiliary opcode dedicated to support type analyses.
217  *
218  * Types with this opcode represents that there could be a type, but it is not
219  * known.  This type can be used to initialize fields before an analysis (not known
220  * yet) or to represent the top of a lattice (could not be determined).  There exists
221  * exactly one type with this opcode.
222  */
223 extern tp_op *tpop_unknown;
224 tp_op *get_tpop_unknown(void);
225
226 #endif /* FIRM_TR_TPOP_H */