doxygen comment added
[libfirm] / ir / tr / entity.h
index c7fcecc..a3cc430 100644 (file)
@@ -3,10 +3,10 @@
  * File name:   ir/tr/entity.h
  * Purpose:     Representation of all program known entities.
  * Author:      Martin Trapp, Christian Schaefer
- * Modified by: Goetz Lindenmaier
+ * Modified by: Goetz Lindenmaier, Michael Beck
  * Created:
  * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universität Karlsruhe
+ * Copyright:   (c) 1998-2006 Universität Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 
@@ -42,9 +42,9 @@
  * - ident *ld_name: Unique name of this entity, i.e., the mangled
  *                   name.  E.g., for a class `A' with field `a' this
  *                   is the ident for `A_a'.
- * - type *type:     The type of this entity, e.g., a method type, a
+ * - ir_type *type:  The type of this entity, e.g., a method type, a
  *                   basic type of the language or a class itself.
- * - type *owner:    The class this entity belongs to.  In case of local
+ * - ir_type *owner: The class this entity belongs to.  In case of local
  *                  variables the method they are defined in.
  * - int offset:     Offset in bits for this entity.  Fixed when layout
  *                  of owner is determined.
@@ -60,8 +60,8 @@
  *                   If (type != method_type) access of this field will cause
  *                   an assertion.
  */
-#ifndef _ENTITY_H_
-#define _ENTITY_H_
+#ifndef _FIRM_TR_ENTITY_H_
+#define _FIRM_TR_ENTITY_H_
 
 #include "firm_types.h"
 #include "dbginfo.h"
@@ -127,7 +127,7 @@ typedef struct entity entity;
  * value is a pointer to the method.
  * Visibility is local, offset -1, and it is not volatile.
  */
-entity     *new_entity (type *owner, ident *name, type *tp);
+entity     *new_entity (ir_type *owner, ident *name, ir_type *tp);
 
 /**
  * Creates a new entity.
@@ -138,7 +138,7 @@ entity     *new_entity (type *owner, ident *name, type *tp);
  * value is a pointer to the method.
  * Visibility is local, offset -1, and it is not volatile.
  */
-entity     *new_d_entity (type *owner, ident *name, type *tp, dbg_info *db);
+entity     *new_d_entity (ir_type *owner, ident *name, ir_type *tp, dbg_info *db);
 
 /**
  * Copies the entity if the new_owner is different from the
@@ -152,7 +152,7 @@ entity     *new_d_entity (type *owner, ident *name, type *tp, dbg_info *db);
  *       itself and not to the origin.  Right now we have to change
  *       the peculiarity and then set a new atomic value by hand.
  */
-entity     *copy_entity_own (entity *old, type *new_owner);
+entity     *copy_entity_own (entity *old, ir_type *new_owner);
 
 /**
  * Copies the entity if the new_name is different from the
@@ -178,6 +178,9 @@ const char *get_entity_name     (const entity *ent);
 /** Returns the ident of an entity. */
 ident      *get_entity_ident    (const entity *ent);
 
+/** Sets the ident of the entity. */
+void        set_entity_ident (entity *ent, ident *id);
+
 /** Returns the mangled name of the entity.
  *
  * If the mangled name is set it returns the existing name.
@@ -193,20 +196,20 @@ void        set_entity_ld_ident (entity *ent, ident *ld_ident);
 const char *get_entity_ld_name (entity *ent);
 
 /** Returns the owner of the entity. */
-type       *get_entity_owner (entity *ent);
+ir_type    *get_entity_owner (entity *ent);
 
 /** Sets the owner field in entity to owner.  Don't forget to add
    ent to owner!! */
-void        set_entity_owner (entity *ent, type *owner);
+void        set_entity_owner (entity *ent, ir_type *owner);
 
 /** Asserts if the type owner is either a compound type or an array */
-void assert_legal_owner_of_ent(type *owner);
+void assert_legal_owner_of_ent(ir_type *owner);
 
 /** Returns the type of an entity. */
-type     *get_entity_type (entity *ent);
+ir_type  *get_entity_type (entity *ent);
 
 /** Sets the type of an entity. */
-void      set_entity_type (entity *ent, type *tp);
+void      set_entity_type (entity *ent, ir_type *tp);
 
 /** The allocation type. */
 typedef enum {
@@ -219,7 +222,7 @@ typedef enum {
   allocation_dynamic,   /**< The entity is allocated during runtime, explicitly
                  by an Alloc node. */
   allocation_static     /**< The entity is allocated statically.  We can use a
-                             Const as address of the entity. */
+                             Const as address of the entity.  This is the default for methods. */
 } ent_allocation;
 
 /** Returns the allocation type of an entity. */
@@ -316,15 +319,18 @@ void    set_entity_link(entity *ent, void *l);
 ir_graph *get_entity_irg(const entity *ent);
 void      set_entity_irg(entity *ent, ir_graph *irg);
 
+/** Gets the entity vtable number. */
+unsigned get_entity_vtable_number(entity *ent);
+
+/** Sets the entity vtable number. */
+void     set_entity_vtable_number(entity *ent, unsigned vtable_number);
+
 /** Return the peculiarity of an entity. */
 peculiarity get_entity_peculiarity (const entity *ent);
 
 /** Sets the peculiarity of an entity. */
 void        set_entity_peculiarity (entity *ent, peculiarity pec);
 
-/** Return the name of the peculiarity. */
-const char *get_peculiarity_name(peculiarity var);
-
 /* -- Representation of constant values of entities -- */
 /** Returns true if the the node is representable as code on
  *  const_code_irg. */
@@ -354,7 +360,7 @@ typedef struct compound_graph_path compound_graph_path;
 #endif /* _COMPOUND_GRAPH_PATH_TYPEDEF_ */
 
 /** Creates a new compound graph path. */
-compound_graph_path *new_compound_graph_path(type *tp, int length);
+compound_graph_path *new_compound_graph_path(ir_type *tp, int length);
 
 /** Returns non-zero if an object is a compound graph path */
 int     is_compound_graph_path(void *thing);
@@ -371,7 +377,7 @@ int     get_compound_graph_path_array_index(compound_graph_path *gr, int pos);
 void    set_compound_graph_path_array_index(compound_graph_path *gr, int pos, int index);
 
 /** Checks whether the path up to pos is correct. If the path contains a NULL,
- *  assumes the path is not complete and returns 'true'. */
+ *  assumes the path is not complete and returns non-zero. */
 int is_proper_compound_graph_path(compound_graph_path *gr, int pos);
 
 /* A value of a compound entity is a pair of a value and the description of the
@@ -503,16 +509,20 @@ int is_atomic_entity(entity *ent);
 /** Returns true if the type of the entity is a class, structure,
    array or union type. */
 int is_compound_entity(entity *ent);
+/** Returns true if the type of the entity is a Method type. */
+int is_method_entity(entity *ent);
 
 /** Returns non-zero if ent1 and ent2 have are equal except for their owner.
    Two entities are equal if
     - they have the same type (the same C-struct)
     - ...?
 */
-bool equal_entity(entity *ent1, entity *ent2);
+int equal_entity(entity *ent1, entity *ent2);
 
 /** Outputs a unique number for this entity if libfirm is compiled for
-   debugging, (configure with --enable-debug) else returns 0. */
+ *  debugging, (configure with --enable-debug) else returns the address
+ *  of the type cast to long.
+ */
 long get_entity_nr(entity *ent);
 
 /** Returns the entities visited count. */
@@ -530,20 +540,20 @@ int        entity_visited(entity *ent);
 /** Returns true if this entity was not visited. */
 int        entity_not_visited(entity *ent);
 
-/** Returns the mask of the additional graph properties. */
-unsigned get_entity_additional_properties(const entity *ent);
+/**
+ * Returns the mask of the additional entity properties.
+ * The properties are automatically inherited from the irg if available
+ * or from the method type if they were not set using
+ * set_entity_additional_properties() or
+ * set_entity_additional_property().
+ */
+unsigned get_entity_additional_properties(entity *ent);
 
 /** Sets the mask of the additional graph properties. */
 void set_entity_additional_properties(entity *ent, unsigned property_mask);
 
 /** Sets one additional graph property. */
-void set_entity_additional_property(entity *ent, unsigned flag);
-
-/** Returns the calling convention of an entities graph. */
-unsigned get_entity_calling_convention(const entity *ent);
-
-/** Sets the calling convention of an entities graph. */
-void set_entity_calling_convention(entity *ent, unsigned cc_mask);
+void set_entity_additional_property(entity *ent, mtp_additional_property flag);
 
 /**
  * @page unknown_entity
@@ -579,7 +589,6 @@ void set_entity_calling_convention(entity *ent, unsigned cc_mask);
  *    overwrittenby = NULL
  *    irg           = NULL
  *    link          = NULL
- *
  */
 /* A variable that contains the only unknown entity. */
 extern entity *unknown_entity;
@@ -587,7 +596,6 @@ extern entity *unknown_entity;
 /** Returns the unknown entity */
 entity *get_unknown_entity(void);
 
-/** Encodes how a pointer parameter is accessed. */
 /** Encodes how a pointer parameter is accessed. */
 typedef enum acc_bits {
   ptr_access_none  = 0,                      /**< no access */
@@ -598,4 +606,8 @@ typedef enum acc_bits {
   ptr_access_all   = ptr_access_rw|ptr_access_store     /**< all possible access */
 } ptr_access_kind;
 
-#endif /* _ENTITY_H_ */
+#define IS_READ(a)     ((a) & ptr_access_read)
+#define IS_WRITTEN(a)  ((a) & ptr_access_write)
+#define IS_STORED(a)   ((a) & ptr_access_store)
+
+#endif /* _FIRM_TR_ENTITY_H_ */