- Several warning fixes
[libfirm] / ir / tr / tpop.h
1 /**
2  *
3  * @file tpop.h
4  *
5  * Project:     libFIRM
6  * File name:   ir/tr/tpop.h
7  * Purpose:     Opcode of types.
8  * Author:      Goetz Lindenmaier
9  * Modified by:
10  * Created:
11  * Copyright:   (c) 2001-2003 Universität Karlsruhe
12  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
13  * CVS-ID:      $Id$
14  *
15  *  This module specifies the kinds of types available in firm.
16  *
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.
21  *
22  *  @see type.h
23  */
24
25 # ifndef _TYPEOP_H_
26 # define _TYPEOP_H_
27
28 #include "ident.h"
29
30 /**
31  *   An enum for the type kinds.
32  *   For each type kind exists a typecode to identify it.
33  */
34 typedef enum {
35   tpo_uninitialized = 0,   /* not a type opcode */
36   tpo_class,
37   tpo_struct,
38   tpo_method,
39   tpo_union,
40   tpo_array,
41   tpo_enumeration,
42   tpo_pointer,
43   tpo_primitive,
44   tpo_id,
45   tpo_none,
46   tpo_unknown,
47   tpo_max                  /* not a type opcode */
48 } tp_opcode;
49
50 /**
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
54  *   internal values.
55  *
56  * @see  get_tpop_name(), get_tpop_code(), get_tpop_ident()
57  */
58 typedef struct tp_op tp_op;
59
60
61 /**
62  *   Returns the string for the type opcode.
63  *
64  *   @param op  The type opcode to get the string from.
65  *   @return a string.  (@todo Null terminated???)
66  */
67 const char *get_tpop_name (const tp_op *op);
68
69 /**
70  *   Returns an enum for the type opcode.
71  *
72  *   @param op   The type opcode to get the enum from.
73  *   @return the enum.
74  */
75 tp_opcode get_tpop_code (const tp_op *op);
76
77 /**
78  *   Returns the ident for the type opcode.
79  *
80  *   @param op   The type opcode to get the ident from.
81  *   @return The ident.
82  */
83 ident *get_tpop_ident (const tp_op *op);
84
85 /**
86  *   This type opcode marks that the corresponding type is a class type.
87  *
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
92  *   of the library.
93  */
94 extern tp_op *type_class;
95 tp_op *get_tpop_class(void);
96
97 /**
98  *   This type opcode marks that the corresponding type is a compound type
99  *   as a struct in C.
100  *
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
104  *   of the library.
105  */
106 extern tp_op *type_struct;
107 tp_op *get_tpop_struct(void);
108
109 /**
110  *   This type opcode marks that the corresponding type is a method type.
111  *
112  *   Consequently it refers to a list of arguments and results.
113  *   This struct is dynamically allocated but constant for the lifetime
114  *   of the library.
115  */
116 extern tp_op *type_method;
117 tp_op *get_tpop_method(void);
118
119 /**
120  *   This type opcode marks that the corresponding type is a union type.
121  *
122  *   Consequently it refers to a list of unioned types.
123  *   This struct is dynamically allocated but constant for the lifetime
124  *   of the library.
125  */
126 extern tp_op *type_union;
127 tp_op *get_tpop_union(void);
128
129 /**
130  *   This type opcode marks that the corresponding type is an array type.
131  *
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
135  *   of the library.
136  */
137 extern tp_op *type_array;
138 tp_op *get_tpop_array(void);
139
140 /**
141  *   This type opcode marks that the corresponding type is an enumeration type.
142  *
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
145  *   the enumerators.
146  *   This struct is dynamically allocated but constant for the lifetime
147  *   of the library.
148  */
149 extern tp_op *type_enumeration;
150 tp_op *get_tpop_enumeration(void);
151
152 /**
153  *   This type opcode marks that the corresponding type is a pointer type.
154  *
155  *   It contains a reference to the type the pointer points to.
156  *   This struct is dynamically allocated but constant for the lifetime
157  *   of the library.
158  */
159 extern tp_op *type_pointer;
160 tp_op *get_tpop_pointer(void);
161
162 /**
163  *   This type opcode marks that the corresponding type is a primitive type.
164  *
165  *   Primitive types are types that are directly mapped to target machine
166  *   modes.
167  *   This struct is dynamically allocated but constant for the lifetime
168  *   of the library.
169  */
170 extern tp_op *type_primitive;
171 tp_op *get_tpop_primitive(void);
172
173 /**
174  *   This type opcode is an auxiliary opcode dedicated to support transformations
175  *   of the type structure.
176  *
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
188  *   of the library.
189  */
190 extern tp_op *type_id;
191 tp_op *get_tpop_id(void);
192
193 /**
194  *   This type opcode is an auxiliary opcode dedicated to support type analyses.
195  *
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.
200  */
201 extern tp_op *tpop_none;
202 tp_op *get_tpop_none(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 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.
211  */
212 extern tp_op *tpop_unknown;
213 tp_op *get_tpop_unknown(void);
214
215 # endif /*_TYPEOP_H_ */