allow specification of names for in parameters in spec file
[libfirm] / ir / tr / entity.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /*
21  * Project:     libFIRM
22  * File name:   ir/tr/entity.h
23  * Purpose:     Representation of all program known entities.
24  * Author:      Martin Trapp, Christian Schaefer
25  * Modified by: Goetz Lindenmaier, Michael Beck
26  * Created:
27  * CVS-ID:      $Id$
28  * Copyright:   (c) 1998-2006 Universität Karlsruhe
29  */
30
31 /**
32  * @file    entity.h
33  * @brief   Representation of all program known entities.
34  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
35  * @version $Id$
36  * @summary
37  *
38  * An entity is the representation of program known objects in Firm.
39  * The primary concept of entities is to represent members of complex
40  * types, i.e., fields and methods of classes.  As not all programming
41  * language model all variables and methods as members of some class,
42  * the concept of entities is extended to cover also local and global
43  * variables, and arbitrary procedures.
44  *
45  * An entity always specifies the type of the object it represents and
46  * the type of the object it is a part of, the owner of the entity.
47  * Originally this is the type of the class of which the entity is a
48  * member.
49  * The owner of local variables is the procedure they are defined in.
50  * The owner of global variables and procedures visible in the whole
51  * program is a universally defined class type "GlobalType".  The owner
52  * of procedures defined in the scope of an other procedure is the
53  * enclosing procedure.
54  *
55  * @link ir_entity
56  */
57 #ifndef FIRM_TR_ENTITY_H
58 #define FIRM_TR_ENTITY_H
59
60 #include "firm_types.h"
61 #include "dbginfo.h"
62
63 #include "tr_inheritance.h"
64
65 /*-----------------------------------------------------------------*/
66 /* ENTITY                                                          */
67 /*-----------------------------------------------------------------*/
68
69 /**
70  * @page ir_entity  Representation of an program entity.
71  *
72  * The type ir_entity is an abstract data type to represent program entities.
73  * If contains the following attributes:
74  *
75  *   - owner:      A compound type this entity is a part of.
76  *   - type:       The type of this entity.
77  *   - name:       The string that represents this entity in the source program.
78  *   - allocation: A flag saying whether the entity is dynamically or statically
79  *                 allocated (values: dynamic_allocated,  static_allocated,
80  *                 automatic_allocated).
81  *   - visibility: A flag indicating the visibility of this entity (values: local,
82  *                 external_visible,  external_allocated)
83  *   - variability: A flag indicating the variability of this entity (values:
84  *                  uninitialized, initialized, part_constant, constant)
85  *   - volatility: @@@
86  *   - offset:     The offset of the entity within the compound object in bytes.  Only set
87  *                 if the owner in the state "layout_fixed".
88  *   - offset_bits_remainder:   The offset bit remainder of a bitfield entity (in a compound)
89  *                 in bits.  Only set if the owner in the state "layout_fixed".
90  *   - overwrites: A list of entities overwritten by this entity.  This list is only
91  *                 existent if the owner of this entity is a class.  The members in
92  *                 this list must be entities of super classes.
93  *   - overwrittenby: A list of entities that overwrite this entity.  This list is only
94  *                 existent if the owner of this entity is a class.  The members in
95  *                 this list must be entities of sub classes.
96  *   - link:       A void* to associate some additional information with the entity.
97  *   - irg:        If the entity is a method this is the ir graph that represents the
98  *                 code of the method.
99  *   - peculiarity: The peculiarity of the entity.  If the entity is a method this
100  *                 indicates whether the entity represents
101  *                 a real method or whether it only exists to describe an interface.
102  *                 In that case there nowhere exists code for this entity and this entity
103  *                 is never dynamically used in the code.
104  *                 Values: description, existent.  Default: existent.
105  *   - visited:    visited flag.  Master flag is type_visited.
106  *
107  * These fields can only be accessed via access functions.
108  *
109  * @see  ir_type
110  */
111
112 /* to resolve recursion between entity.h and type.h */
113 /** the type of an entity */
114 #ifndef _ENTITY_TYPEDEF_
115 #define _ENTITY_TYPEDEF_
116 typedef struct ir_entity ir_entity, entity;
117 #endif
118
119 /**
120  * Creates a new entity.
121  *
122  * Automatically inserts the entity as a member of owner.
123  * Entity is automatic_allocated and uninitialized except if the type
124  * is type_method, then it is static_allocated and constant.  The constant
125  * value is a pointer to the method.
126  * Visibility is local, offset -1, and it is not volatile.
127  */
128 ir_entity     *new_entity(ir_type *owner, ident *name, ir_type *tp);
129
130 /**
131  * Creates a new entity.
132  *
133  * Automatically inserts the entity as a member of owner.
134  * The entity is automatic allocated and uninitialized except if the type
135  * is type_method, then it is static allocated and constant.  The constant
136  * value is a pointer to the method.
137  * Visibility is local, offset -1, and it is not volatile.
138  */
139 ir_entity     *new_d_entity(ir_type *owner, ident *name, ir_type *tp, dbg_info *db);
140
141 /**
142  * Copies the entity if the new_owner is different from the
143  * owner of the old entity,  else returns the old entity.
144  *
145  * Automatically inserts the new entity as a member of owner.
146  * Resets the overwrites/overwritten_by fields.
147  * Keeps the old atomic value.
148  *   @@@ Maybe we should change this.  If peculiarity of a method
149  *       is existent, we should add a new SymConst that points to
150  *       itself and not to the origin.  Right now we have to change
151  *       the peculiarity and then set a new atomic value by hand.
152  */
153 ir_entity     *copy_entity_own(ir_entity *old, ir_type *new_owner);
154
155 /**
156  * Copies the entity if the new_name is different from the
157  * name of the old entity, else returns the old entity.
158  *
159  * Automatically inserts the new entity as a member of owner.
160  * The mangled name ld_name is set to NULL.
161  * Overwrites relation is copied from old.
162  */
163 ir_entity     *copy_entity_name(ir_entity *old, ident *new_name);
164
165 /**
166  * Frees the entity.
167  *
168  * The owner will still contain the pointer to this
169  * entity, as well as all other references!
170  */
171 void        free_entity(ir_entity *ent);
172
173 /** Returns the name of an entity. */
174 const char *get_entity_name(const ir_entity *ent);
175
176 /** Returns the ident of an entity. */
177 ident      *get_entity_ident(const ir_entity *ent);
178
179 /** Sets the ident of the entity. */
180 void        set_entity_ident(ir_entity *ent, ident *id);
181
182 /** Returns the mangled name of the entity.
183  *
184  * If the mangled name is set it returns the existing name.
185  * Else it generates a name with mangle_entity()
186  * and remembers this new name internally.
187  */
188 ident      *get_entity_ld_ident(ir_entity *ent);
189
190 /** Sets the mangled name of the entity. */
191 void        set_entity_ld_ident(ir_entity *ent, ident *ld_ident);
192
193 /** Returns the mangled name of the entity as a string. */
194 const char *get_entity_ld_name(ir_entity *ent);
195
196 /** Returns the owner of the entity. */
197 ir_type    *get_entity_owner(ir_entity *ent);
198
199 /** Sets the owner field in entity to owner.  Don't forget to add
200    ent to owner!! */
201 void        set_entity_owner(ir_entity *ent, ir_type *owner);
202
203 /** Returns the type of an entity. */
204 ir_type  *get_entity_type(ir_entity *ent);
205
206 /** Sets the type of an entity. */
207 void      set_entity_type(ir_entity *ent, ir_type *tp);
208
209 /** The allocation type. */
210 typedef enum {
211   allocation_automatic, /**< The entity is allocated during runtime, implicitly
212                              as component of a compound type.   This is the default. */
213   allocation_parameter, /**< The entity is a parameter.  It is also automatic allocated.
214                              We distinguish the allocation of parameters from the allocation
215                              of local variables as their placement depends on the calling
216                              conventions. */
217   allocation_dynamic,   /**< The entity is allocated during runtime, explicitly
218                              by an Alloc node. */
219   allocation_static     /**< The entity is allocated statically.  We can use a
220                              Const as address of the entity.  This is the default for methods. */
221 } ir_allocation;
222
223 /** Returns the allocation type of an entity. */
224 ir_allocation get_entity_allocation(const ir_entity *ent);
225
226 /** Sets the allocation type of an entity. */
227 void           set_entity_allocation(ir_entity *ent, ir_allocation al);
228
229 /** Return the name of the allocation type. */
230 const char *get_allocation_name(ir_allocation vis);
231
232 /** Returns the visibility of an entity. */
233 ir_visibility get_entity_visibility(const ir_entity *ent);
234
235 /** Sets the visibility of an entity. */
236 void       set_entity_visibility(ir_entity *ent, ir_visibility vis);
237
238 /** Return the name of the visibility */
239 const char *get_visibility_name(ir_visibility vis);
240
241 /** This enumeration flags the variability of entities. */
242 typedef enum {
243   variability_uninitialized,    /**< The content of the entity is completely unknown. Default. */
244   variability_initialized,      /**< After allocation the entity is initialized with the
245                                      value given somewhere in the entity. */
246   variability_part_constant,    /**< For entities of compound types.
247                                      The members of the entity are mixed constant,
248                                      initialized or uninitialized. */
249   variability_constant          /**< The entity is constant. */
250 } ir_variability;
251
252 /** Returns the variability of an entity. */
253 ir_variability get_entity_variability(const ir_entity *ent);
254
255 /** Sets the variability of an entity. */
256 void           set_entity_variability(ir_entity *ent, ir_variability var);
257
258 /** Return the name of the variability. */
259 const char *get_variability_name(ir_variability var);
260
261 /** This enumeration flags the volatility of entities. */
262 typedef enum {
263   volatility_non_volatile,    /**< The entity is not volatile. Default. */
264   volatility_is_volatile      /**< The entity is volatile */
265 } ir_volatility;
266
267 /** Returns the volatility of an entity. */
268 ir_volatility get_entity_volatility(const ir_entity *ent);
269
270 /** Sets the volatility of an entity. */
271 void          set_entity_volatility(ir_entity *ent, ir_volatility vol);
272
273 /** Return the name of the volatility. */
274 const char *get_volatility_name(ir_volatility var);
275
276 /** This enumeration flags the stickyness of an entity. */
277 typedef enum {
278   stickyness_unsticky,          /**< The entity can be removed from
279                                    the program, unless contraindicated
280                                    by other attributes. Default. */
281   stickyness_sticky             /**< The entity must remain in the
282                                    program in any case. */
283 } ir_stickyness;
284
285 /** Get the entity's stickyness. */
286 ir_stickyness get_entity_stickyness(const ir_entity *ent);
287
288 /** Set the entity's stickyness. */
289 void          set_entity_stickyness(ir_entity *ent, ir_stickyness stickyness);
290
291 /** Returns the offset of an entity (in a compound) in bytes. Only set if layout = fixed. */
292 int       get_entity_offset(const ir_entity *ent);
293
294 /** Sets the offset of an entity (in a compound) in bytes. */
295 void      set_entity_offset(ir_entity *ent, int offset);
296
297 /** Returns the offset bit remainder of a bitfield entity (in a compound) in bits. Only set if layout = fixed. */
298 unsigned char get_entity_offset_bits_remainder(const ir_entity *ent);
299
300 /** Sets the offset bit remainder of a bitfield entity (in a compound) in bits. */
301 void      set_entity_offset_bits_remainder(ir_entity *ent, unsigned char offset);
302
303 /** Returns the stored intermediate information. */
304 void *get_entity_link(const ir_entity *ent);
305
306 /** Stores new intermediate information. */
307 void set_entity_link(ir_entity *ent, void *l);
308
309 /* -- Fields of method entities -- */
310 /** The entity knows the corresponding irg if the entity is a method.
311    This allows to get from a Call to the called irg.
312    Only entities of peculiarity "existent" can have a corresponding irg,
313    else the field is fixed to NULL.  (Get returns NULL, set asserts.) */
314 ir_graph *get_entity_irg(const ir_entity *ent);
315 void      set_entity_irg(ir_entity *ent, ir_graph *irg);
316
317 /** Gets the entity vtable number. */
318 unsigned get_entity_vtable_number(const ir_entity *ent);
319
320 /** Sets the entity vtable number. */
321 void     set_entity_vtable_number(ir_entity *ent, unsigned vtable_number);
322
323 /** Return the peculiarity of an entity. */
324 ir_peculiarity get_entity_peculiarity(const ir_entity *ent);
325
326 /** Sets the peculiarity of an entity. */
327 void           set_entity_peculiarity(ir_entity *ent, ir_peculiarity pec);
328
329 /** Checks if an entity cannot be overridden anymore. */
330 int is_entity_final(const ir_entity *ent);
331
332 /** Sets/resets the final flag of an entity. */
333 void set_entity_final(ir_entity *ent, int final);
334
335 /** Checks if an entity is compiler generated. */
336 int is_entity_compiler_generated(const ir_entity *ent);
337
338 /** Sets/resets the compiler generated flag. */
339 void set_entity_compiler_generated(ir_entity *ent, int flag);
340
341 /**
342  * The state of the address_taken flag.
343  */
344 typedef enum {
345         ir_address_not_taken     = 0,  /**< The address is NOT taken. */
346         ir_address_taken_unknown = 1,  /**< The state of the address taken flag is unknown. */
347         ir_address_taken         = 2   /**< The address IS taken. */
348 } ir_address_taken_state;
349
350 /** Return the state of the address taken flag of an entity. */
351 ir_address_taken_state get_entity_address_taken(const ir_entity *ent);
352
353 /** Sets/resets the state of the address taken flag of an entity. */
354 void set_entity_address_taken(ir_entity *ent, ir_address_taken_state flag);
355
356 /** Return the name of the address_taken state. */
357 const char *get_address_taken_state_name(ir_address_taken_state state);
358
359 /* -- Representation of constant values of entities -- */
360 /**
361  * Returns true if the the node is representable as code on
362  * const_code_irg.
363  *
364  * @deprecated This function is not used by libFirm and stays here
365  *             only as a helper for the old Jack frontend.
366  */
367 int      is_irn_const_expression(ir_node *n);
368
369 /**
370  * Copies a Firm subgraph that complies to the restrictions for
371  * constant expressions to current_block in current_ir_graph.
372  *
373  * @param dbg  debug info for all newly created nodes
374  * @param n    the node
375  *
376  * Set current_ir_graph to get_const_code_irg() to generate a constant
377  * expression.
378  */
379 ir_node *copy_const_value(dbg_info *dbg, ir_node *n);
380
381 /* Set has no effect for existent entities of type method. */
382 ir_node *get_atomic_ent_value(ir_entity *ent);
383 void     set_atomic_ent_value(ir_entity *ent, ir_node *val);
384
385 /**
386  * The following type describes a path to a leave in the compound graph.
387  * Node 0 in the path must be an entity of type tp given in the constructor.  If
388  * the type of this element is compound, the path node 1 is an element of the type
389  * of node 0 an so forth, until an entity of atomic type is reached.
390  */
391 #ifndef _COMPOUND_GRAPH_PATH_TYPEDEF_
392 #define _COMPOUND_GRAPH_PATH_TYPEDEF_
393 typedef struct compound_graph_path compound_graph_path;
394 #endif /* _COMPOUND_GRAPH_PATH_TYPEDEF_ */
395
396 /** Creates a new compound graph path. */
397 compound_graph_path *new_compound_graph_path(ir_type *tp, int length);
398
399 /** Returns non-zero if an object is a compound graph path */
400 int     is_compound_graph_path(const void *thing);
401
402 /** Frees a graph path object */
403 void    free_compound_graph_path (compound_graph_path *gr);
404
405 /** Returns the length of a graph path */
406 int     get_compound_graph_path_length(const compound_graph_path *gr);
407
408 ir_entity *get_compound_graph_path_node(const compound_graph_path *gr, int pos);
409 void    set_compound_graph_path_node(compound_graph_path *gr, int pos, ir_entity *node);
410 int     get_compound_graph_path_array_index(const compound_graph_path *gr, int pos);
411 void    set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
412
413 /** Checks whether the path up to pos is correct. If the path contains a NULL,
414  *  assumes the path is not complete and returns non-zero. */
415 int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
416
417 /* A value of a compound entity is a pair of a value and the description of the
418    corresponding access path to the member of the compound.  */
419 void     add_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path);
420 void     set_compound_ent_value_w_path(ir_entity *ent, ir_node *val, compound_graph_path *path, int pos);
421 /** Returns the number of constant values needed to initialize the entity.
422  *
423  *  Asserts if the entity has variability_uninitialized.
424  * */
425 int      get_compound_ent_n_values(ir_entity *ent);
426 /** Returns a constant value given the position. */
427 ir_node *get_compound_ent_value(ir_entity *ent, int pos);
428 /** Returns the access path for value at position pos. */
429 compound_graph_path *get_compound_ent_value_path(ir_entity *ent, int pos);
430 /** Returns a constant value given the access path.
431  *  The path must contain array indices for all array element entities. */
432 ir_node *get_compound_ent_value_by_path(ir_entity *ent, compound_graph_path *path);
433
434 /** Removes all constant entries where the path ends at value_ent. Does not
435    free the memory of the paths.  (The same path might be used for several
436    constant entities. */
437 void     remove_compound_ent_value(ir_entity *ent, ir_entity *value_ent);
438
439 /* Some languages support only trivial access paths, i.e., the member is a
440    direct, atomic member of the constant entities type. In this case the
441    corresponding entity can be accessed directly.  The following functions
442    allow direct access. */
443
444 /** Generates a Path with length 1.
445     Beware: Has a bad runtime for array elements (O(|array|) and should be
446     avoided there. Use add_compound_ent_value_w_path() instead and create
447     the path manually. */
448 void     add_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member);
449
450 /** Returns the last member in the path */
451 ir_entity  *get_compound_ent_value_member(ir_entity *ent, int pos);
452
453 /** Sets the path at pos 0 */
454 void     set_compound_ent_value(ir_entity *ent, ir_node *val, ir_entity *member, int pos);
455
456 /** Initializes the entity ent which must be of a one dimensional
457    array type with the values given in the values array.
458    The array must have a lower and an upper bound.  Keeps the
459    order of values. Does not test whether the number of values
460    fits into the given array size.  Does not test whether the
461    values have the proper mode for the array. */
462 void set_array_entity_values(ir_entity *ent, tarval **values, int num_vals);
463
464 /**
465  * Return the offset in bits from the last byte address.
466  *
467  * This requires that the layout of all concerned types is fixed.
468  *
469  * @param ent Any entity of compound type with at least pos initialization values.
470  * @param pos The position of the value for which the offset is requested.
471  */
472 int get_compound_ent_value_offset_bit_remainder(ir_entity *ent, int pos);
473
474 /** Return the overall offset of value at position pos in bytes.
475  *
476  * This requires that the layout of all concerned types is fixed.
477  * Asserts if bit offset is not byte aligned.
478  *
479  * @param ent Any entity of compound type with at least pos initialization values.
480  * @param pos The position of the value for which the offset is requested.
481  */
482 int  get_compound_ent_value_offset_bytes(ir_entity *ent, int pos);
483
484 /* --- Fields of entities with a class type as owner --- */
485 /* Overwrites is a field that specifies that an access to the overwritten
486    entity in the supertype must use this entity.  It's a list as with
487    multiple inheritance several entities can be overwritten.  This field
488    is mostly useful for method entities.
489    If a Sel node selects an entity that is overwritten by other entities it
490    must return a pointer to the entity of the dynamic type of the pointer
491    that is passed to it.  Lowering of the Sel node must assure this.
492    Overwrittenby is the inverse of overwrites.  Both add routines add
493    both relations, they only differ in the order of arguments. */
494 void    add_entity_overwrites   (ir_entity *ent, ir_entity *overwritten);
495 int     get_entity_n_overwrites (ir_entity *ent);
496 int     get_entity_overwrites_index(ir_entity *ent, ir_entity *overwritten);
497 ir_entity *get_entity_overwrites   (ir_entity *ent, int pos);
498 void    set_entity_overwrites   (ir_entity *ent, int pos, ir_entity *overwritten);
499 void    remove_entity_overwrites(ir_entity *ent, ir_entity *overwritten);
500
501 void    add_entity_overwrittenby   (ir_entity *ent, ir_entity *overwrites);
502 int     get_entity_n_overwrittenby (ir_entity *ent);
503 int     get_entity_overwrittenby_index(ir_entity *ent, ir_entity *overwrites);
504 ir_entity *get_entity_overwrittenby   (ir_entity *ent, int pos);
505 void    set_entity_overwrittenby   (ir_entity *ent, int pos, ir_entity *overwrites);
506 void    remove_entity_overwrittenby(ir_entity *ent, ir_entity *overwrites);
507
508 /**
509  *   Checks whether a pointer points to an entity.
510  *
511  *   @param thing     an arbitrary pointer
512  *
513  *   @return
514  *       true if the thing is an entity, else false
515  */
516 int is_entity (const void *thing);
517
518 /** Returns true if the type of the entity is a primitive, pointer
519  * enumeration or method type.
520  *
521  * @Note This is a different classification than from is_primitive_type().
522  */
523 int is_atomic_entity(ir_entity *ent);
524 /** Returns true if the type of the entity is a class, structure,
525    array or union type. */
526 int is_compound_entity(ir_entity *ent);
527 /** Returns true if the type of the entity is a Method type. */
528 int is_method_entity(ir_entity *ent);
529
530 /** Returns non-zero if ent1 and ent2 have are equal except for their owner.
531    Two entities are equal if
532     - they have the same type (the same C-struct)
533     - ...?
534 */
535 int equal_entity(ir_entity *ent1, ir_entity *ent2);
536
537 /** Outputs a unique number for this entity if libfirm is compiled for
538  *  debugging, (configure with --enable-debug) else returns the address
539  *  of the type cast to long.
540  */
541 long get_entity_nr(const ir_entity *ent);
542
543 /** Returns the entities visited count. */
544 unsigned long get_entity_visited(ir_entity *ent);
545
546 /** Sets the entities visited count. */
547 void        set_entity_visited(ir_entity *ent, unsigned long num);
548
549 /** Sets visited field in entity to entity_visited. */
550 void        mark_entity_visited(ir_entity *ent);
551
552 /** Returns true if this entity was visited. */
553 int        entity_visited(ir_entity *ent);
554
555 /** Returns true if this entity was not visited. */
556 int        entity_not_visited(ir_entity *ent);
557
558 /**
559  * Returns the mask of the additional entity properties.
560  * The properties are automatically inherited from the irg if available
561  * or from the method type if they were not set using
562  * set_entity_additional_properties() or
563  * set_entity_additional_property().
564  */
565 unsigned get_entity_additional_properties(ir_entity *ent);
566
567 /** Sets the mask of the additional graph properties. */
568 void set_entity_additional_properties(ir_entity *ent, unsigned property_mask);
569
570 /** Sets one additional graph property. */
571 void set_entity_additional_property(ir_entity *ent, mtp_additional_property flag);
572
573 /** Returns the class type that this type info entity represents or NULL
574     if ent is no type info entity. */
575 ir_type *get_entity_repr_class(const ir_entity *ent);
576
577 /**
578  * @page unknown_entity  The Unknown entity
579  *
580  *  This entity is an auxiliary entity dedicated to support analyses.
581  *
582  *  The unknown entity represents that there could be an entity, but it is not
583  *  known.  This entity can be used to initialize fields before an analysis (not known
584  *  yet) or to represent the top of a lattice (could not be determined).  There exists
585  *  exactly one entity unknown. This entity has as owner and as type the unknown type. It is
586  *  allocated when initializing the entity module.
587  *
588  *  The entity can take the role of any entity, also methods.  It returns default
589  *  values in these cases.
590  *
591  *  The following values are set:
592  *
593  * - name          = "unknown_entity"
594  * - ld_name       = "unknown_entity"
595  * - owner         = unknown_type
596  * - type          = unknown_type
597  * - allocation    = allocation_automatic
598  * - visibility    = visibility_external_allocated
599  * - offset        = -1
600  * - variability   = variability_uninitialized
601  * - value         = SymConst(unknown_entity)
602  * - values        = NULL
603  * - val_paths     = NULL
604  * - peculiarity   = peculiarity_existent
605  * - volatility    = volatility_non_volatile
606  * - stickyness    = stickyness_unsticky
607  * - ld_name       = NULL
608  * - overwrites    = NULL
609  * - overwrittenby = NULL
610  * - irg           = NULL
611  * - link          = NULL
612  */
613 /* A variable that contains the only unknown entity. */
614 extern ir_entity *unknown_entity;
615
616 /** Returns the @link unknown_entity unknown entity @endlink. */
617 ir_entity *get_unknown_entity(void);
618
619 /** Encodes how a pointer parameter is accessed. */
620 typedef enum acc_bits {
621   ptr_access_none  = 0,                                 /**< no access */
622   ptr_access_read  = 1,                                 /**< read access */
623   ptr_access_write = 2,                                 /**< write access */
624   ptr_access_rw    = ptr_access_read|ptr_access_write,  /**< read AND write access */
625   ptr_access_store = 4,                                 /**< the pointer is stored */
626   ptr_access_all   = ptr_access_rw|ptr_access_store     /**< all possible access */
627 } ptr_access_kind;
628
629 #define IS_READ(a)     ((a) & ptr_access_read)
630 #define IS_WRITTEN(a)  ((a) & ptr_access_write)
631 #define IS_STORED(a)   ((a) & ptr_access_store)
632
633 /**
634  * Supported image sections.
635  * Currently only methods can be placed in different sections.
636  */
637 typedef enum {
638   section_text,           /**< The code segment. This is the default for methods. */
639   section_constructors    /**< The constructor section. */
640 } ir_img_section;
641
642 /** Returns the section of a method. */
643 ir_img_section get_method_img_section(const ir_entity *method);
644
645 /** Sets the section of a method. */
646 void set_method_img_section(ir_entity *method, ir_img_section section);
647
648 #endif /* FIRM_TR_ENTITY_H */