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