7 #include <libfirm/firm_types.h>
15 struct obstack *type_obst;
31 /* note that the constant values represent the rank of the types as defined
34 ATOMIC_TYPE_INVALID = 0,
46 ATOMIC_TYPE_ULONGLONG,
49 ATOMIC_TYPE_LONG_DOUBLE,
51 #ifdef PROVIDE_COMPLEX
52 ATOMIC_TYPE_FLOAT_COMPLEX,
53 ATOMIC_TYPE_DOUBLE_COMPLEX,
54 ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
55 ATOMIC_TYPE_FLOAT_IMAGINARY,
56 ATOMIC_TYPE_DOUBLE_IMAGINARY,
57 ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY,
63 TYPE_QUALIFIER_NONE = 0,
64 TYPE_QUALIFIER_CONST = 1 << 0,
65 TYPE_QUALIFIER_RESTRICT = 1 << 1,
66 TYPE_QUALIFIER_VOLATILE = 1 << 2,
69 typedef unsigned int type_qualifiers_t;
73 type_qualifiers_t qualifiers;
78 struct atomic_type_t {
80 atomic_type_type_t atype;
83 struct builtin_type_t {
89 struct pointer_type_t {
102 struct function_parameter_t {
104 function_parameter_t *next;
107 struct function_type_t {
110 function_parameter_t *parameters;
111 unsigned variadic : 1;
112 unsigned unspecified_parameters : 1;
113 unsigned kr_style_parameters : 1;
116 struct compound_type_t {
118 /** the declaration of the compound type, its context field
119 * contains the compound entries. */
120 declaration_t *declaration;
125 /** the declaration of the enum type. You can find the enum entries by
126 * walking the declaration->next list until you don't find
127 * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
128 declaration_t *declaration;
131 struct typedef_type_t {
133 declaration_t *declaration;
134 type_t *resolved_type;
137 struct typeof_type_t {
139 expression_t *expression;
141 type_t *resolved_type;
147 atomic_type_t atomic;
148 builtin_type_t builtin;
149 pointer_type_t pointer;
151 function_type_t function;
152 compound_type_t compound;
154 typedef_type_t typedeft;
155 typeof_type_t typeoft;
158 type_t *make_atomic_type(atomic_type_type_t type, type_qualifiers_t qualifiers);
159 type_t *make_pointer_type(type_t *points_to, type_qualifiers_t qualifiers);
161 type_t *duplicate_type(type_t *type);
163 static inline bool is_typeref(const type_t *type)
165 return type->kind == TYPE_TYPEDEF || type->kind == TYPE_TYPEOF;
168 static inline bool is_type_atomic(const type_t *type, atomic_type_type_t atype)
170 assert(!is_typeref(type));
172 if(type->kind != TYPE_ATOMIC)
174 const atomic_type_t *atomic_type = &type->atomic;
176 return atomic_type->atype == atype;
179 static inline bool is_type_pointer(const type_t *type)
181 assert(!is_typeref(type));
182 return type->kind == TYPE_POINTER;
185 static inline bool is_type_array(const type_t *type)
187 assert(!is_typeref(type));
188 return type->kind == TYPE_ARRAY;
191 static inline bool is_type_function(const type_t *type)
193 assert(!is_typeref(type));
194 return type->kind == TYPE_FUNCTION;
197 static inline bool is_type_compound(const type_t *type)
199 assert(!is_typeref(type));
200 return type->kind == TYPE_COMPOUND_STRUCT
201 || type->kind == TYPE_COMPOUND_UNION;