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