7 #include <libfirm/firm_types.h>
15 extern struct obstack *type_obst;
33 /* note that the constant values represent the rank of the types as defined
36 ATOMIC_TYPE_INVALID = 0,
48 ATOMIC_TYPE_ULONGLONG,
51 ATOMIC_TYPE_LONG_DOUBLE,
53 #ifdef PROVIDE_COMPLEX
54 ATOMIC_TYPE_FLOAT_COMPLEX,
55 ATOMIC_TYPE_DOUBLE_COMPLEX,
56 ATOMIC_TYPE_LONG_DOUBLE_COMPLEX,
57 ATOMIC_TYPE_FLOAT_IMAGINARY,
58 ATOMIC_TYPE_DOUBLE_IMAGINARY,
59 ATOMIC_TYPE_LONG_DOUBLE_IMAGINARY,
65 TYPE_QUALIFIER_NONE = 0,
66 TYPE_QUALIFIER_CONST = 1 << 0,
67 TYPE_QUALIFIER_RESTRICT = 1 << 1,
68 TYPE_QUALIFIER_VOLATILE = 1 << 2,
71 typedef unsigned int type_qualifiers_t;
75 type_qualifiers_t qualifiers;
80 struct atomic_type_t {
82 atomic_type_kind_t akind;
85 struct builtin_type_t {
91 struct pointer_type_t {
104 struct function_parameter_t {
106 function_parameter_t *next;
109 struct function_type_t {
112 function_parameter_t *parameters;
113 unsigned variadic : 1;
114 unsigned unspecified_parameters : 1;
115 unsigned kr_style_parameters : 1;
118 struct compound_type_t {
120 /** the declaration of the compound type, its context field
121 * contains the compound entries. */
122 declaration_t *declaration;
127 /** the declaration of the enum type. You can find the enum entries by
128 * walking the declaration->next list until you don't find
129 * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
130 declaration_t *declaration;
133 struct typedef_type_t {
135 declaration_t *declaration;
136 type_t *resolved_type;
139 struct typeof_type_t {
141 expression_t *expression;
143 type_t *resolved_type;
146 struct bitfield_type_t {
155 atomic_type_t atomic;
156 builtin_type_t builtin;
157 pointer_type_t pointer;
159 function_type_t function;
160 compound_type_t compound;
162 typedef_type_t typedeft;
163 bitfield_type_t bitfield;
164 typeof_type_t typeoft;
167 type_t *make_atomic_type(atomic_type_kind_t type, type_qualifiers_t qualifiers);
168 type_t *make_pointer_type(type_t *points_to, type_qualifiers_t qualifiers);
170 type_t *duplicate_type(type_t *type);
172 static inline bool is_typeref(const type_t *type)
174 return type->kind == TYPE_TYPEDEF || type->kind == TYPE_TYPEOF;
177 static inline bool is_type_atomic(const type_t *type, atomic_type_kind_t atype)
179 assert(!is_typeref(type));
181 if(type->kind != TYPE_ATOMIC)
183 const atomic_type_t *atomic_type = &type->atomic;
185 return atomic_type->akind == atype;
188 static inline bool is_type_pointer(const type_t *type)
190 assert(!is_typeref(type));
191 return type->kind == TYPE_POINTER;
194 static inline bool is_type_array(const type_t *type)
196 assert(!is_typeref(type));
197 return type->kind == TYPE_ARRAY;
200 static inline bool is_type_function(const type_t *type)
202 assert(!is_typeref(type));
203 return type->kind == TYPE_FUNCTION;
206 static inline bool is_type_compound(const type_t *type)
208 assert(!is_typeref(type));
209 return type->kind == TYPE_COMPOUND_STRUCT
210 || type->kind == TYPE_COMPOUND_UNION;