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,
62 TYPE_QUALIFIER_NONE = 0,
63 TYPE_QUALIFIER_CONST = 1 << 0,
64 TYPE_QUALIFIER_RESTRICT = 1 << 1,
65 TYPE_QUALIFIER_VOLATILE = 1 << 2,
68 typedef unsigned int type_qualifiers_t;
72 type_qualifiers_t qualifiers;
77 struct atomic_type_t {
79 atomic_type_type_t atype;
82 struct builtin_type_t {
88 struct pointer_type_t {
101 struct function_parameter_t {
103 function_parameter_t *next;
106 struct function_type_t {
109 function_parameter_t *parameters;
111 bool unspecified_parameters;
114 struct compound_type_t {
116 /** the declaration of the compound type, its context field
117 * contains the compound entries. */
118 declaration_t *declaration;
123 /** the declaration of the enum type. You can find the enum entries by
124 * walking the declaration->next list until you don't find
125 * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
126 declaration_t *declaration;
129 struct typedef_type_t {
131 declaration_t *declaration;
132 type_t *resolved_type;
135 struct typeof_type_t {
137 expression_t *expression;
139 type_t *resolved_type;
145 atomic_type_t atomic;
146 builtin_type_t builtin;
147 pointer_type_t pointer;
149 function_type_t function;
150 compound_type_t compound;
152 typedef_type_t typedeft;
153 typeof_type_t typeoft;
156 type_t *make_atomic_type(atomic_type_type_t type, type_qualifiers_t qualifiers);
157 type_t *make_pointer_type(type_t *points_to, type_qualifiers_t qualifiers);
159 type_t *duplicate_type(type_t *type);
161 static inline bool is_typeref(const type_t *type)
163 return type->type == TYPE_TYPEDEF || type->type == TYPE_TYPEOF;
166 static inline bool is_type_atomic(const type_t *type, atomic_type_type_t atype)
168 assert(!is_typeref(type));
170 if(type->type != TYPE_ATOMIC)
172 const atomic_type_t *atomic_type = &type->atomic;
174 return atomic_type->atype == atype;
177 static inline bool is_type_pointer(const type_t *type)
179 assert(!is_typeref(type));
180 return type->type == TYPE_POINTER;
183 static inline bool is_type_compound(const type_t *type)
185 assert(!is_typeref(type));
186 return type->type == TYPE_COMPOUND_STRUCT
187 || type->type == TYPE_COMPOUND_UNION;