13267d8adf4ace6eae059768ea72eca2a4abf652
[libfirm] / ir / tr / tpop.h
1
2 # ifndef _TYPEOP_H_
3 # define _TYPEOP_H_
4
5 #include "ident.h"
6
7 /****h* libfirm/tpop
8  *
9  * NAME
10  *  file tpop.h
11  * COPYRIGHT
12  *   (C) 2001 by Universitaet Karlsruhe
13  * AUTHORS
14  *   Goetz Lindenmaier
15  * NOTES
16  *  This module specifies the kinds of types available in firm.  They are
17  *  called type opcodes. These include classes, structs, methods, unions,
18  *  arrays, enumerations, pointers and primitive types.
19  *****
20  */
21
22 /****** tpop/typecode
23  *
24  * NAME
25  *   typecode -- an enum for the type kinds
26  * PURPOSE
27  *   For each type kind exists a typecode to identify it.
28  * SOURCE
29  */
30 typedef enum {
31   tpo_class,
32   tpo_struct,
33   tpo_method,
34   tpo_union,
35   tpo_array,
36   tpo_enumeration,
37   tpo_pointer,
38   tpo_primitive,
39   tpo_id
40 } tp_opcode;
41 /******/
42
43 /****s* tpop/tp_op
44  *
45  * NAME
46  *   tp_op  - a structure containing information about a kind of type.
47  * PURPOSE
48  *   A structure containing information about a kind of type.  So far
49  *   this is only the kind name, an enum for case-switching and some
50  *   internal values.
51  * SEE ALSO
52  *   get_tpop_name, get_tpop_code, get_tpop_ident
53  * SOURCE
54  */
55 typedef struct tp_op tp_op;
56 /******/
57
58
59 /****f* tpop/get_tpop_name
60  *
61  * NAME
62  *   get_tpop_name - Returns the string for the type opcode.
63  * SYNOPSIS
64  *   const char *get_tpop_name (tp_op *op)
65  * INPUTS
66  *   op - The type opcode to get the string from.
67  * RESULT
68  *   a string.  (@@@ Null terminated???)
69  ***
70  */
71 const char *get_tpop_name (tp_op *op);
72
73 /****f* tpop/get_tpop_code
74  *
75  * NAME
76  *   get_tpop_code - Returns an enum for the type opcode.
77  * SYNOPSIS
78  *   tp_opcode get_tpop_code (tp_op *op);
79  * INPUTS
80  *   op - The type opcode to get the enum from.
81  * RESULT
82  *   the enum.
83  ***
84  */
85 tp_opcode get_tpop_code (tp_op *op);
86
87 /****f* tpop/get_tpop_ident
88  *
89  * NAME
90  *   get_tpop_ident - Returns the ident for the type opcode.
91  * SYNOPSIS
92  *   ident *get_tpop_ident (tp_op *op);
93  * INPUTS
94  *   op - The type opcode to get the ident from.
95  * RESULT
96  *   The ident.
97  ***
98  */
99 ident *get_tpop_ident (tp_op *op);
100
101 /****d* tpop/type_class
102  *
103  * NAME
104  *   type_class  -
105  * PURPOSE
106  *   This type opcode marks that the corresponding type is a class type.
107  *   Consequently the type refers to supertypes, subtypes and entities.
108  *   Entities can be any fields, but also methods.
109  *   @@@ value class or not???
110  * NOTES
111  *   This struct is dynamically allocated but constant for the lifetime
112  *   of the library.
113  * SOURCE
114  */
115 extern tp_op *type_class;
116 /******/
117
118 /****d* tpop/type_struct
119  *
120  * NAME
121  *   type_struct
122  * PURPOSE
123  *   This type opcode marks that the corresponding type is a compound type
124  *   as a struct in C.  Consequently the type refers to a list of entities
125  *   which may not be methods (but pointers to methods).
126  * NOTES
127  *   This struct is dynamically allocated but constant for the lifetime
128  *   of the library.
129  * SOURCE
130  */
131 extern tp_op *type_struct;
132 /******/
133
134 /****d* tpop/type_method
135  *
136  * NAME
137  *   type_method
138  * PURPOSE
139  *   This type opcode marks that the corresponding type is a method type.
140  *   Consequently it refers to a list of arguments and results.
141  * NOTES
142  *   This struct is dynamically allocated but constant for the lifetime
143  *   of the library.
144  * SOURCE
145  */
146 extern tp_op *type_method;
147 /******/
148
149 /****d* tpop/type_union
150  *
151  * NAME
152  *   type_union
153  * PURPOSE
154  *   This type opcode marks that the corresponding type is a union type.
155  *   Consequently it refers to a list of unioned types.
156  * NOTES
157  *   This struct is dynamically allocated but constant for the lifetime
158  *   of the library.
159  * SOURCE
160  */
161 extern tp_op *type_union;
162 /******/
163
164 /****d* tpop/type_array
165  *
166  * NAME
167  *   type_array
168  * PURPOSE
169  *   This type opcode marks that the corresponding type is an array type.
170  *   Consequently it contains a list of dimensions (lower and upper bounds)
171  *   and an element type.
172  * NOTES
173  *   This struct is dynamically allocated but constant for the lifetime
174  *   of the library.
175  * SOURCE
176  */
177 extern tp_op *type_array;
178 /******/
179
180 /****d* tpop/type_enumeration
181  *
182  * NAME
183  *   type_enumeration
184  * PURPOSE
185  *   This type opcode marks that the corresponding type is an enumeration type.
186  *   Consequently it contains a list of idents for the enumeration identifiers
187  *   and a list of tarbet values that are the constants used to implement
188  *   the enumerators.
189  * NOTES
190  *   This struct is dynamically allocated but constant for the lifetime
191  *   of the library.
192  * SOURCE
193  */
194 extern tp_op *type_enumeration;
195 /******/
196
197 /****d* tpop/type_pointer
198  *
199  * NAME
200  *   type_pointer
201  * PURPOSE
202  *   This type opcode marks that the corresponding type is a pointer type.
203  *   It contains a reference to the type the pointer points to.
204  * NOTES
205  *   This struct is dynamically allocated but constant for the lifetime
206  *   of the library.
207  * SOURCE
208  */
209 extern tp_op *type_pointer;
210 /******/
211
212 /****d* tpop/type_primitive
213  *
214  * NAME
215  *   type_primitive
216  * PURPOSE
217  *   This type opcode marks that the corresponding type is a primitive type.
218  *   Primitive types are types that are directly mapped to target machine
219  *   modes.
220  * NOTES
221  *   This struct is dynamically allocated but constant for the lifetime
222  *   of the library.
223  * SOURCE
224  */
225 extern tp_op *type_primitive;
226 /******/
227
228 /****d* tpop/type_id
229  *
230  * NAME
231  *   type_id
232  * PURPOSE
233  *   This type opcode is an auxiliary opcode dedicated to support transformations
234  *   of the type structure.  If a type is changed to another type with another
235  *   opcode the new type will be allocated with new memory.  All nodes refereing
236  *   to the old type need to be changed to refer the new one.  This is simplified
237  *   by turning the old type into an id type that merely forwards to the new type
238  *   that now replaces the old one.
239  *   type_ids should never be visible out of the type module.  All access routines
240  *   should automatically check for type_id and eventually follow the forward in
241  *   type_id.  Two types are exchanged by a call to exchange_types.
242  *   If a type_id is visible externally report this as bug.  If it is assured that
243  *   this never happens this extern variable can be moved to type_t.h.
244  * NOTES
245  *   This struct is dynamically allocated but constant for the lifetime
246  *   of the library.
247  * SOURCE
248  */
249 extern tp_op *type_id;
250 /******/
251
252 # endif /*_TYPEOP_H_ */