2 * This file is part of cparser.
3 * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 #include <libfirm/firm_types.h>
31 ENTITY_COMPOUND_MEMBER,
43 typedef unsigned char entity_kind_t;
45 typedef enum namespace_tag_t {
51 typedef unsigned char entity_namespace_t;
53 typedef enum storage_class_tag_t {
57 STORAGE_CLASS_TYPEDEF,
59 STORAGE_CLASS_REGISTER,
60 } storage_class_tag_t;
61 typedef unsigned char storage_class_t;
63 typedef enum decl_modifier_t {
65 DM_DLLIMPORT = 1 << 0,
66 DM_DLLEXPORT = 1 << 1,
69 DM_MICROSOFT_INLINE = 1 << 4,
70 DM_FORCEINLINE = 1 << 5,
71 DM_SELECTANY = 1 << 6,
75 DM_NOINLINE = 1 << 10,
76 DM_RESTRICT = 1 << 11,
79 DM_TRANSPARENT_UNION = 1 << 14,
82 DM_CONSTRUCTOR = 1 << 17,
83 DM_DESTRUCTOR = 1 << 18,
87 DM_FASTCALL = 1 << 22,
89 DM_THISCALL = 1 << 24,
90 DM_DEPRECATED = 1 << 25,
91 DM_RETURNS_TWICE = 1 << 26,
94 typedef unsigned decl_modifiers_t;
97 * A scope containing entities.
101 entity_t *last_entity;
102 unsigned depth; /**< while parsing, the depth of this scope in the
107 * a named entity is something which can be referenced by its name
110 struct entity_base_t {
112 entity_namespace_t namespc;
114 source_position_t source_position;
115 scope_t *parent_scope; /**< The scope where this entity
118 /** next declaration in a scope */
120 /** next declaration with same symbol */
121 entity_t *symbol_next;
126 entity_t *alias; /* used for name mangling of anonymous types */
128 decl_modifiers_t modifiers;
133 bool irtype_complete : 1;
138 entity_t *alias; /* used for name mangling of anonymous types */
145 struct enum_value_t {
157 bool address_taken : 1;
158 statement_t *statement;
171 decl_modifiers_t modifiers;
176 struct declaration_t {
178 storage_class_t declared_storage_class;
179 storage_class_t storage_class;
180 decl_modifiers_t modifiers;
181 const char *deprecated_string; /**< MS deprecated string if any. */
182 bool used : 1; /**< Set if the declaration is used. */
183 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
190 struct compound_member_t {
192 unsigned char alignment;
194 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
198 il_size_t offset; /**< The offset of this member inside a compound. */
203 bool thread_local : 1; /**< GCC __thread */
204 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
206 unsigned char alignment;
207 symbol_t *get_property_sym; /**< MS get property. */
208 symbol_t *put_property_sym; /**< MS put property. */
210 initializer_t *initializer;
214 unsigned int value_number;
222 bool address_taken : 1;
227 unsigned int value_number;
233 * GNU builtin or MS intrinsic functions.
235 typedef enum builtin_kind_t {
236 bk_none = 0, /**< no builtin */
237 bk_gnu_builtin_alloca, /**< GNU __builtin_alloca */
238 bk_gnu_builtin_huge_val, /**< GNU __builtin_huge_val */
239 bk_gnu_builtin_inf, /**< GNU __builtin_inf */
240 bk_gnu_builtin_inff, /**< GNU __builtin_inff */
241 bk_gnu_builtin_infl, /**< GNU __builtin_infl */
242 bk_gnu_builtin_nan, /**< GNU __builtin_nan */
243 bk_gnu_builtin_nanf, /**< GNU __builtin_nanf */
244 bk_gnu_builtin_nanl, /**< GNU __builtin_nanl */
245 bk_gnu_builtin_va_end, /**< GNU __builtin_va_end */
246 bk_gnu_builtin_expect, /**< GNU __builtin_expect */
247 bk_gnu_builtin_return_address, /**< GNU __builtin_return_address */
248 bk_gnu_builtin_frame_address, /**< GNU __builtin_frame_address */
249 bk_gnu_builtin_ffs, /**< GNU __builtin_ffs */
250 bk_gnu_builtin_clz, /**< GNU __builtin_clz */
251 bk_gnu_builtin_ctz, /**< GNU __builtin_ctz */
252 bk_gnu_builtin_popcount, /**< GNU __builtin_popcount */
253 bk_gnu_builtin_parity, /**< GNU __builtin_parity */
254 bk_gnu_builtin_prefetch, /**< GNU __builtin_prefetch */
255 bk_gnu_builtin_trap, /**< GNU __builtin_trap */
257 bk_ms_rotl, /**< MS _rotl */
258 bk_ms_rotr, /**< MS _rotr */
259 bk_ms_rotl64, /**< MS _rotl64 */
260 bk_ms_rotr64, /**< MS _rotr64 */
261 bk_ms_byteswap_ushort, /**< MS _byteswap_ushort */
262 bk_ms_byteswap_ulong, /**< MS _byteswap_ulong */
263 bk_ms_byteswap_uint64, /**< MS _byteswap_uint64 */
265 bk_ms__debugbreak, /**< MS __debugbreak */
266 bk_ms_ReturnAddress, /**< MS _ReturnAddress */
267 bk_ms_AddressOfReturnAddress, /**< MS _AddressOfReturnAddress */
268 bk_ms__popcount, /**< MS __popcount */
269 bk_ms_enable, /**< MS _enable */
270 bk_ms_disable, /**< MS _disable */
271 bk_ms__inbyte, /**< MS __inbyte */
272 bk_ms__inword, /**< MS __inword */
273 bk_ms__indword, /**< MS __indword */
274 bk_ms__outbyte, /**< MS __outbyte */
275 bk_ms__outword, /**< MS __outword */
276 bk_ms__outdword, /**< MS __outdword */
277 bk_ms__ud2, /**< MS __ud2 */
278 bk_ms_BitScanForward, /**< MS _BitScanForward */
279 bk_ms_BitScanReverse, /**< MS _BitScanReverse */
280 bk_ms_InterlockedExchange, /**< MS _InterlockedExchange */
281 bk_ms_InterlockedExchange64, /**< MS _InterlockedExchange64 */
282 bk_ms__readeflags, /**< MS __readflags */
283 bk_ms__writeeflags, /**< MS __writeflags */
289 bool need_closure : 1; /**< Inner function needs closure. */
290 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
294 statement_t *statement;
298 ir_node *static_link; /**< if need_closure is set, the node representing
309 enum_value_t enum_value;
311 namespace_t namespacee;
313 declaration_t declaration;
315 parameter_t parameter;
317 compound_member_t compound_member;
320 static inline bool is_declaration(const entity_t *entity)
322 return entity->kind == ENTITY_FUNCTION || entity->kind == ENTITY_VARIABLE
323 || entity->kind == ENTITY_PARAMETER
324 || entity->kind == ENTITY_COMPOUND_MEMBER;
328 const char *get_entity_kind_name(entity_kind_t kind);