Add a wrapper macro for ir_nodehashmap_get(), which has the return type as additional...
[libfirm] / ir / tr / entity_t.h
index 3e7c44f..c17d9f7 100644 (file)
@@ -31,7 +31,6 @@
 #include "typerep.h"
 #include "type_t.h"
 #include "ident.h"
-#include "compound_path.h"
 
 typedef struct ir_initializer_base_t {
        ir_initializer_kind_t kind;
@@ -70,13 +69,6 @@ union ir_initializer_t {
        ir_initializer_tarval_t    tarval;
 };
 
-/** The attributes for compound entities. */
-typedef struct compound_ent_attr {
-       ir_node **values;     /**< constant values of compound entities. */
-       compound_graph_path **val_paths;
-                            /**< paths corresponding to constant values. */
-} compound_ent_attr;
-
 /** The attributes for methods. */
 typedef struct method_ent_attr {
        ir_graph *irg;                 /**< The corresponding irg if known.
@@ -98,9 +90,6 @@ typedef struct code_ent_attr {
 } code_ent_attr;
 
 typedef struct parameter_ent_attr {
-       /**< parameters might be compounds too */
-       compound_ent_attr  cmpd_attr;
-
        size_t   number; /**< corresponding parameter number */
        ir_mode *doubleword_low_mode;/**< entity is a lowered doubleword parameter,
                                                                so additional stores because of calling
@@ -111,6 +100,14 @@ typedef struct parameter_ent_attr {
                                    lowering...) */
 } parameter_ent_attr;
 
+typedef enum ir_entity_kind {
+       IR_ENTITY_NORMAL,
+       IR_ENTITY_METHOD,
+       IR_ENTITY_COMPOUND_MEMBER,
+       IR_ENTITY_PARAMETER,
+       IR_ENTITY_LABEL,
+       IR_ENTITY_UNKNOWN,
+} ir_entity_kind;
 
 /**
  * An abstract data type to represent program entities.
@@ -124,6 +121,7 @@ struct ir_entity {
        ir_type *type;           /**< The type of this entity */
        ir_type *owner;          /**< The compound type (e.g. class type) this
                                                              entity belongs to. */
+       unsigned entity_kind:3;  /**< entity kind */
        unsigned linkage:10;     /**< Specifies linkage type */
        unsigned volatility:1;   /**< Specifies volatility of entities content.*/
        unsigned aligned:1;      /**< Specifies alignment of entities content. */
@@ -139,7 +137,6 @@ struct ir_entity {
                                 /**< If the entity is a bit field, this is the
                                      offset of the start of the bit field
                                      within the byte specified by offset. */
-       unsigned is_parameter:1; /**< 1 if this represents a function parameter */
        int offset;              /**< Offset in bytes for this entity. Fixed
                                      when layout of owner is determined. */
        unsigned alignment;      /**< entity alignment in bytes */
@@ -161,8 +158,6 @@ struct ir_entity {
 #endif
 
        union {
-               /* ------------- fields for compound entities -------------- */
-               compound_ent_attr  cmpd_attr;
                /* ------------- fields for method entities ---------------- */
                method_ent_attr    mtd_attr;
                /* fields for code entities */
@@ -173,9 +168,22 @@ struct ir_entity {
 };
 
 /** Initialize the entity module. */
-void ir_init_entity(void);
+void ir_init_entity(ir_prog *irp);
 /** Cleanup entity module */
-void ir_finish_entity(void);
+void ir_finish_entity(ir_prog *irp);
+
+/**
+ * Creates an entity corresponding to the start address of a basic block
+ * (the basic block is marked with a label id).
+ */
+ir_entity *new_label_entity(ir_label_t label);
+
+/**
+ * Like new_label_entity() but with debug information.
+ */
+ir_entity *new_d_label_entity(ir_label_t label, dbg_info *dbgi);
+
+void set_entity_irg(ir_entity *ent, ir_graph *irg);
 
 /* ----------------------- inline functions ------------------------ */
 static inline int _is_entity(const void *thing)
@@ -233,12 +241,6 @@ static inline ir_type *_get_entity_type(const ir_entity *ent)
        return ent->type;
 }
 
-static inline void _set_entity_type(ir_entity *ent, ir_type *type)
-{
-       assert(ent && ent->kind == k_entity);
-       ent->type = type;
-}
-
 static inline ir_linkage _get_entity_linkage(const ir_entity *ent)
 {
        assert(ent && ent->kind == k_entity);
@@ -344,7 +346,7 @@ static inline void _set_entity_link(ir_entity *ent, void *l)
 static inline ir_graph *_get_entity_irg(const ir_entity *ent)
 {
        assert(ent && ent->kind == k_entity);
-       if (!is_Method_type(ent->type) || ent == unknown_entity) {
+       if (!is_Method_type(ent->type) || is_unknown_entity(ent)) {
                return NULL;
        }
 
@@ -381,12 +383,12 @@ static inline int _entity_not_visited(const ir_entity *ent)
 
 static inline int _is_parameter_entity(const ir_entity *entity)
 {
-       return entity->is_parameter;
+       return entity->entity_kind == IR_ENTITY_PARAMETER;
 }
 
 static inline size_t _get_entity_parameter_number(const ir_entity *entity)
 {
-       assert(entity->is_parameter);
+       assert(entity->entity_kind == IR_ENTITY_PARAMETER);
        return entity->attr.parameter.number;
 }
 
@@ -415,7 +417,6 @@ static inline void _set_entity_dbg_info(ir_entity *ent, dbg_info *db)
 #define set_entity_ld_ident(ent, ld_ident)       _set_entity_ld_ident(ent, ld_ident)
 #define get_entity_ld_name(ent)                  _get_entity_ld_name(ent)
 #define get_entity_type(ent)                     _get_entity_type(ent)
-#define set_entity_type(ent, type)               _set_entity_type(ent, type)
 #define get_entity_linkage(ent)                  _get_entity_linkage(ent)
 #define get_entity_volatility(ent)               _get_entity_volatility(ent)
 #define set_entity_volatility(ent, vol)          _set_entity_volatility(ent, vol)