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