some fixes for xml dumper / still buggy.
[libfirm] / ir / tr / tpop.h
1 /* (C) 2001 by Universitaet Karlsruhe */
2
3 /* $Id$ */
4
5 # ifndef _TYPEOP_H_
6 # define _TYPEOP_H_
7
8 #include "ident.h"
9
10 /**
11  *  @file tpop.h
12  *
13  *  This module specifies the kinds of types available in firm.
14  *
15  *  @author  Goetz Lindenmaier
16  *
17  *  They are called type opcodes. These include classes, structs, methods, unions,
18  *  arrays, enumerations, pointers and primitive types.
19  */
20
21 /**
22  *   an enum for the type kinds.
23  *   For each type kind exists a typecode to identify it.
24  */
25 typedef enum {
26   tpo_class,
27   tpo_struct,
28   tpo_method,
29   tpo_union,
30   tpo_array,
31   tpo_enumeration,
32   tpo_pointer,
33   tpo_primitive,
34   tpo_id
35 } tp_opcode;
36
37 /**
38  *   A structure containing information about a kind of type.
39  *   A structure containing information about a kind of type.  So far
40  *   this is only the kind name, an enum for case-switching and some
41  *   internal values.
42  *
43  * @see  get_tpop_name(), get_tpop_code(), get_tpop_ident()
44  */
45 typedef struct tp_op tp_op;
46
47
48 /**
49  *   Returns the string for the type opcode.
50  *
51  *   @param op  The type opcode to get the string from.
52  *   @return a string.  (@todo Null terminated???)
53  */
54 const char *get_tpop_name (tp_op *op);
55
56 /**
57  *   Returns an enum for the type opcode.
58  *
59  *   @param op   The type opcode to get the enum from.
60  *   @return the enum.
61  */
62 tp_opcode get_tpop_code (tp_op *op);
63
64 /**
65  *   Returns the ident for the type opcode.
66  *
67  *   @param op   The type opcode to get the ident from.
68  *   @return The ident.
69  */
70 ident *get_tpop_ident (tp_op *op);
71
72 /**
73  *   This type opcode marks that the corresponding type is a class type.
74  *
75  *   Consequently the type refers to supertypes, subtypes and entities.
76  *   Entities can be any fields, but also methods.
77  *   @@@ value class or not???
78  *   This struct is dynamically allocated but constant for the lifetime
79  *   of the library.
80  */
81 extern tp_op *type_class;
82 tp_op *get_type_class(void);
83
84 /**
85  *   This type opcode marks that the corresponding type is a compound type
86  *   as a struct in C.
87  *
88  *   Consequently the type refers to a list of entities
89  *   which may not be methods (but pointers to methods).
90  *   This struct is dynamically allocated but constant for the lifetime
91  *   of the library.
92  */
93 extern tp_op *type_struct;
94 tp_op *get_type_struct(void);
95
96 /**
97  *   This type opcode marks that the corresponding type is a method type.
98  *
99  *   Consequently it refers to a list of arguments and results.
100  *   This struct is dynamically allocated but constant for the lifetime
101  *   of the library.
102  */
103 extern tp_op *type_method;
104 tp_op *get_type_method(void);
105
106 /**
107  *   This type opcode marks that the corresponding type is a union type.
108  *
109  *   Consequently it refers to a list of unioned types.
110  *   This struct is dynamically allocated but constant for the lifetime
111  *   of the library.
112  */
113 extern tp_op *type_union;
114 tp_op *get_type_union(void);
115
116 /**
117  *   This type opcode marks that the corresponding type is an array type.
118  *
119  *   Consequently it contains a list of dimensions (lower and upper bounds)
120  *   and an element type.
121  *   This struct is dynamically allocated but constant for the lifetime
122  *   of the library.
123  */
124 extern tp_op *type_array;
125 tp_op *get_type_array(void);
126
127 /**
128  *   This type opcode marks that the corresponding type is an enumeration type.
129  *
130  *   Consequently it contains a list of idents for the enumeration identifiers
131  *   and a list of tarbet values that are the constants used to implement
132  *   the enumerators.
133  *   This struct is dynamically allocated but constant for the lifetime
134  *   of the library.
135  */
136 extern tp_op *type_enumeration;
137 tp_op *get_type_enumeration(void);
138
139 /**
140  *   This type opcode marks that the corresponding type is a pointer type.
141  *
142  *   It contains a reference to the type the pointer points to.
143  *   This struct is dynamically allocated but constant for the lifetime
144  *   of the library.
145  */
146 extern tp_op *type_pointer;
147 tp_op *get_type_pointer(void);
148
149 /**
150  *   This type opcode marks that the corresponding type is a primitive type.
151  *
152  *   Primitive types are types that are directly mapped to target machine
153  *   modes.
154  *   This struct is dynamically allocated but constant for the lifetime
155  *   of the library.
156  */
157 extern tp_op *type_primitive;
158 tp_op *get_type_primitive(void);
159
160 /**
161  *   This type opcode is an auxiliary opcode dedicated to support transformations
162  *   of the type structure.
163  *
164  *   If a type is changed to another type with another
165  *   opcode the new type will be allocated with new memory.  All nodes refering
166  *   to the old type need to be changed to refer the new one.  This is simplified
167  *   by turning the old type into an id type that merely forwards to the new type
168  *   that now replaces the old one.
169  *   type_ids should never be visible out of the type module.  All access routines
170  *   should automatically check for type_id and eventually follow the forward in
171  *   type_id.  Two types are exchanged by a call to exchange_types.
172  *   If a type_id is visible externally report this as bug.  If it is assured that
173  *   this never happens this extern variable can be moved to tpop_t.h.
174  *   This struct is dynamically allocated but constant for the lifetime
175  *   of the library.
176  */
177 extern tp_op *type_id;
178 tp_op *get_type_id(void);
179
180 # endif /*_TYPEOP_H_ */