6 * File name: ir/tr/tpop.h
7 * Purpose: Opcode of types.
8 * Author: Goetz Lindenmaier
11 * Copyright: (c) 2001-2003 Universität Karlsruhe
12 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * This module specifies the kinds of types available in firm.
17 * They are called type opcodes. These include classes, structs, methods, unions,
18 * arrays, enumerations, pointers and primitive types.
19 * Special types with own opcodes are the id type, a type representing an unknown
20 * type and a type used to specify that something has no type.
31 * An enum for the type kinds.
32 * For each type kind exists a typecode to identify it.
35 tpo_uninitialized = 0, /* not a type opcode */
47 tpo_max /* not a type opcode */
51 * A structure containing information about a kind of type.
52 * A structure containing information about a kind of type. So far
53 * this is only the kind name, an enum for case-switching and some
56 * @see get_tpop_name(), get_tpop_code(), get_tpop_ident()
58 typedef struct tp_op tp_op;
62 * Returns the string for the type opcode.
64 * @param op The type opcode to get the string from.
65 * @return a string. (@todo Null terminated???)
67 const char *get_tpop_name (const tp_op *op);
70 * Returns an enum for the type opcode.
72 * @param op The type opcode to get the enum from.
75 tp_opcode get_tpop_code (const tp_op *op);
78 * Returns the ident for the type opcode.
80 * @param op The type opcode to get the ident from.
83 ident *get_tpop_ident (const tp_op *op);
86 * This type opcode marks that the corresponding type is a class type.
88 * Consequently the type refers to supertypes, subtypes and entities.
89 * Entities can be any fields, but also methods.
90 * @@@ value class or not???
91 * This struct is dynamically allocated but constant for the lifetime
94 extern tp_op *type_class;
95 tp_op *get_tpop_class(void);
98 * This type opcode marks that the corresponding type is a compound type
101 * Consequently the type refers to a list of entities
102 * which may not be methods (but pointers to methods).
103 * This struct is dynamically allocated but constant for the lifetime
106 extern tp_op *type_struct;
107 tp_op *get_tpop_struct(void);
110 * This type opcode marks that the corresponding type is a method type.
112 * Consequently it refers to a list of arguments and results.
113 * This struct is dynamically allocated but constant for the lifetime
116 extern tp_op *type_method;
117 tp_op *get_tpop_method(void);
120 * This type opcode marks that the corresponding type is a union type.
122 * Consequently it refers to a list of unioned types.
123 * This struct is dynamically allocated but constant for the lifetime
126 extern tp_op *type_union;
127 tp_op *get_tpop_union(void);
130 * This type opcode marks that the corresponding type is an array type.
132 * Consequently it contains a list of dimensions (lower and upper bounds)
133 * and an element type.
134 * This struct is dynamically allocated but constant for the lifetime
137 extern tp_op *type_array;
138 tp_op *get_tpop_array(void);
141 * This type opcode marks that the corresponding type is an enumeration type.
143 * Consequently it contains a list of idents for the enumeration identifiers
144 * and a list of target values that are the constants used to implement
146 * This struct is dynamically allocated but constant for the lifetime
149 extern tp_op *type_enumeration;
150 tp_op *get_tpop_enumeration(void);
153 * This type opcode marks that the corresponding type is a pointer type.
155 * It contains a reference to the type the pointer points to.
156 * This struct is dynamically allocated but constant for the lifetime
159 extern tp_op *type_pointer;
160 tp_op *get_tpop_pointer(void);
163 * This type opcode marks that the corresponding type is a primitive type.
165 * Primitive types are types that are directly mapped to target machine
167 * This struct is dynamically allocated but constant for the lifetime
170 extern tp_op *type_primitive;
171 tp_op *get_tpop_primitive(void);
174 * This type opcode is an auxiliary opcode dedicated to support transformations
175 * of the type structure.
177 * If a type is changed to another type with another
178 * opcode the new type will be allocated with new memory. All nodes refering
179 * to the old type need to be changed to refer to the new one. This is simplified
180 * by turning the old type into an id type that merely forwards to the new type
181 * that now replaces the old one.
182 * type_ids should never be visible out of the type module. All access routines
183 * should automatically check for type_id and eventually follow the forward in
184 * type_id. Two types are exchanged by a call to exchange_types.
185 * If a type_id is visible externally report this as bug. If it is assured that
186 * this never happens this extern variable can be moved to tpop_t.h.
187 * This struct is dynamically allocated but constant for the lifetime
190 extern tp_op *type_id;
191 tp_op *get_tpop_id(void);
194 * This type opcode is an auxiliary opcode dedicated to support type analyses.
196 * Types with this opcode represents that there is no type.
197 * The type can be used to initialize fields of the type* that actually can not
198 * contain a type or that are initialized for an analysis. There exists exactly
199 * one type with this opcode.
201 extern tp_op *tpop_none;
202 tp_op *get_tpop_none(void);
205 * This type opcode is an auxiliary opcode dedicated to support type analyses.
207 * Types with this opcode represents that there could be a type, but it is not
208 * known. This type can be used to initialize fields before an analysis (not known
209 * yet) or to represent the top of a lattice (could not be determined). There exists
210 * exactly one type with this opcode.
212 extern tp_op *tpop_unknown;
213 tp_op *get_tpop_unknown(void);
215 # endif /*_TYPEOP_H_ */