7 #include <libfirm/firm_types.h>
15 struct obstack *type_obst;
32 /* note that the constant values represent the rank of the types as defined
35 ATOMIC_TYPE_INVALID = 0,
47 ATOMIC_TYPE_ULONGLONG,
50 ATOMIC_TYPE_LONG_DOUBLE,
52 #ifdef PROVIDE_COMPLEX
53 ATOMIC_TYPE_FLOAT_COMPLEX,
54 ATOMIC_TYPE_DOUBLE_COMPLEX,
55 ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
56 ATOMIC_TYPE_FLOAT_IMAGINARY,
57 ATOMIC_TYPE_DOUBLE_IMAGINARY,
58 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;
112 bool unspecified_parameters;
115 struct compound_type_t {
117 /** the declaration of the compound type, its context field
118 * contains the compound entries. */
119 declaration_t *declaration;
124 /** the declaration of the enum type. You can find the enum entries by
125 * walking the declaration->next list until you don't find
126 * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
127 declaration_t *declaration;
130 struct typedef_type_t {
132 declaration_t *declaration;
133 type_t *resolved_type;
136 struct typeof_type_t {
138 expression_t *expression;
140 type_t *resolved_type;
146 atomic_type_t atomic;
147 builtin_type_t builtin;
148 pointer_type_t pointer;
150 function_type_t function;
151 compound_type_t compound;
153 typedef_type_t typedeft;
154 typeof_type_t typeoft;
157 type_t *make_atomic_type(atomic_type_type_t type, type_qualifiers_t qualifiers);
158 type_t *make_pointer_type(type_t *points_to, type_qualifiers_t qualifiers);
160 static inline bool is_typeref(const type_t *type)
162 return type->type == TYPE_TYPEDEF || type->type == TYPE_TYPEOF;
165 static inline bool is_type_atomic(const type_t *type, atomic_type_type_t atype)
167 assert(!is_typeref(type));
169 if(type->type != TYPE_ATOMIC)
171 const atomic_type_t *atomic_type = &type->atomic;
173 return atomic_type->atype == atype;
176 static inline bool is_type_pointer(const type_t *type)
178 assert(!is_typeref(type));
179 return type->type == TYPE_POINTER;
182 static inline bool is_type_compound(const type_t *type)
184 assert(!is_typeref(type));
185 return type->type == TYPE_COMPOUND_STRUCT
186 || type->type == TYPE_COMPOUND_UNION;