From 20c028dc2eefd23898ecff42a8fdf9e1eef7c90b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 8 Sep 2005 12:06:32 +0000 Subject: [PATCH] added additional graph properties, these can be set in the entity for external allocated entities. fixed some typos added more comments [r6602] --- ir/tr/entity.c | 102 ++++++++++++++++++++++++++++------------------- ir/tr/entity.h | 33 +++++++++++---- ir/tr/entity_t.h | 102 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 159 insertions(+), 78 deletions(-) diff --git a/ir/tr/entity.c b/ir/tr/entity.c index aefab8d3c..cdf598096 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -44,28 +44,11 @@ /** general **/ /*******************************************************************/ -entity *unknown_entity = NULL; entity *get_unknown_entity(void) { return unknown_entity; } -#define UNKNOWN_ENTITY_NAME "unknown_entity" +entity *unknown_entity = NULL; -static INLINE entity * -new_rd_entity (dbg_info *db, type *owner, ident *name, type *type); - -void -init_entity (void) -{ - symconst_symbol sym; - - assert(firm_unknown_type && "Call init_type before init_entity!"); - assert(!unknown_entity && "Call init_entity only once!"); - unknown_entity = new_rd_entity(NULL, firm_unknown_type, new_id_from_str(UNKNOWN_ENTITY_NAME), firm_unknown_type); - set_entity_visibility(unknown_entity, visibility_external_allocated); - set_entity_ld_ident(unknown_entity, get_entity_ident(unknown_entity)); - - sym.entity_p = unknown_entity; - current_ir_graph = get_const_code_irg(); - unknown_entity->value = new_SymConst(sym, symconst_addr_ent); -} +entity *get_unknown_entity(void) { return unknown_entity; } +#define UNKNOWN_ENTITY_NAME "unknown_entity" /*-----------------------------------------------------------------*/ /* ENTITY */ @@ -91,7 +74,14 @@ static INLINE void insert_entity_in_owner (entity *ent) { } /** - * creates a new entity + * Creates a new entity. This entity is NOT inserted in the owner type. + * + * @param db debug info for this entity + * @param owner the owner type of the new entity + * @param name the name of the new entity + * @param type the type of the new entity + * + * @return the new created entity */ static INLINE entity * new_rd_entity (dbg_info *db, type *owner, ident *name, type *type) @@ -103,10 +93,12 @@ new_rd_entity (dbg_info *db, type *owner, ident *name, type *type) res = xmalloc(sizeof(*res)); memset(res, 0, sizeof(*res)); - res->kind = k_entity; - res->owner = owner; - res->name = name; - res->type = type; + + res->kind = k_entity; + res->name = name; + res->ld_name = NULL; + res->owner = owner; + res->type = type; if (get_type_tpop(type) == type_method) res->allocation = allocation_static; @@ -114,25 +106,30 @@ new_rd_entity (dbg_info *db, type *owner, ident *name, type *type) res->allocation = allocation_automatic; res->visibility = visibility_local; - res->offset = -1; + if (is_Method_type(type)) { symconst_symbol sym; sym.entity_p = res; res->variability = variability_constant; - rem = current_ir_graph; + rem = current_ir_graph; current_ir_graph = get_const_code_irg(); - res->value = new_SymConst(sym, symconst_addr_ent); + res->value = new_SymConst(sym, symconst_addr_ent); current_ir_graph = rem; - } else { + res->irg_add_properties = 0; + } + else { res->variability = variability_uninitialized; - res->value = NULL; - res->values = NULL; - res->val_paths = NULL; + res->value = NULL; + res->values = NULL; + res->val_paths = NULL; } - res->peculiarity = peculiarity_existent; + res->volatility = volatility_non_volatile; res->stickyness = stickyness_unsticky; - res->ld_name = NULL; + res->offset = -1; + res->link = NULL; + res->peculiarity = peculiarity_existent; + if (is_Class_type(owner)) { res->overwrites = NEW_ARR_F(entity *, 0); res->overwrittenby = NEW_ARR_F(entity *, 0); @@ -142,8 +139,6 @@ new_rd_entity (dbg_info *db, type *owner, ident *name, type *type) } res->irg = NULL; - //res->accesses = NULL; - #ifdef DEBUG_libfirm res->nr = get_irp_new_node_nr(); #endif /* DEBUG_libfirm */ @@ -187,10 +182,10 @@ static void free_entity_attrs(entity *ent) { if (ent->val_paths) { if (is_compound_entity(ent)) for (i = 0; i < get_compound_ent_n_values(ent); i++) - if (ent->val_paths[i]) ; - /* free_compound_graph_path(ent->val_paths[i]) ; * @@@ warum nich? */ - /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */ - /* DEL_ARR_F(ent->val_paths); */ + if (ent->val_paths[i]) ; + /* free_compound_graph_path(ent->val_paths[i]) ; * @@@ warum nich? */ + /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */ + /* DEL_ARR_F(ent->val_paths); */ } ent->val_paths = NULL; ent->values = NULL; @@ -1299,3 +1294,30 @@ int (entity_visited)(entity *ent) { int (entity_not_visited)(entity *ent) { return _entity_not_visited(ent); } + +unsigned (get_entity_additional_properties)(const entity *ent) { + return _get_entity_additional_properties(ent); +} + +void (set_entity_additional_properties)(entity *ent, unsigned property_mask) { + _set_entity_additional_properties(ent, property_mask); +} + +void (set_entity_additional_property)(entity *ent, unsigned flag) { + _set_entity_additional_property(ent, (irg_additional_property)flag); +} + +void init_entity(void) +{ + symconst_symbol sym; + + assert(firm_unknown_type && "Call init_type before init_entity!"); + assert(!unknown_entity && "Call init_entity only once!"); + unknown_entity = new_rd_entity(NULL, firm_unknown_type, new_id_from_str(UNKNOWN_ENTITY_NAME), firm_unknown_type); + set_entity_visibility(unknown_entity, visibility_external_allocated); + set_entity_ld_ident(unknown_entity, get_entity_ident(unknown_entity)); + + sym.entity_p = unknown_entity; + current_ir_graph = get_const_code_irg(); + unknown_entity->value = new_SymConst(sym, symconst_addr_ent); +} diff --git a/ir/tr/entity.h b/ir/tr/entity.h index 819ec8de2..0c2c1e83d 100644 --- a/ir/tr/entity.h +++ b/ir/tr/entity.h @@ -52,6 +52,13 @@ * The ir_graph constructor automatically sets this field. * If (type != method_type) access of this field will cause * an assertion. +* - unsigned irg_add_properties: +* If (type == method_type) this mirrors the additional flags +* of the corresponding irg if set or is an own set for +* this entity. This construction allows to specify these +* flags even if no graph is available. +* If (type != method_type) access of this field will cause +* an assertion. */ # ifndef _ENTITY_H_ @@ -60,6 +67,7 @@ # include "ident.h" # include "type.h" # include "dbginfo.h" +# include "irgraph.h" # include "tr_inheritance.h" @@ -82,7 +90,7 @@ typedef struct ir_graph ir_graph; /** * - * An abstract data type to represent program entites. + * An abstract data type to represent program entities. * * @param owner A compound type this entity is a part of. * @param type The type of this entity. @@ -93,7 +101,7 @@ typedef struct ir_graph ir_graph; * @param visibility A flag indicating the visibility of this entity (values: local, * external_visible, external_allocated) * @param variability A flag indicating the variability of this entity (values: - * uninitialized, initalized, part_constant, constant) + * uninitialized, initialized, part_constant, constant) * @param volatility @@@ * @param offset The offset of the entity within the compound object in bits. Only set * if the owner in the state "layout_fixed". @@ -250,7 +258,7 @@ const char *get_visibility_name(visibility vis); /** This enumeration flags the variability of entities. */ typedef enum { - variability_uninitialized, /**< The content of the entity is completely unknown. */ + variability_uninitialized, /**< The content of the entity is completely unknown. Default. */ variability_initialized, /**< After allocation the entity is initialized with the value given somewhere in the entity. */ variability_part_constant, /**< For entities of compound types. @@ -270,7 +278,7 @@ const char *get_variability_name(ent_variability var); /** This enumeration flags the volatility of entities. */ typedef enum { - volatility_non_volatile, /**< The entity is not volatile */ + volatility_non_volatile, /**< The entity is not volatile. Default. */ volatility_is_volatile /**< The entity is volatile */ } ent_volatility; @@ -287,9 +295,9 @@ const char *get_volatility_name(ent_volatility var); typedef enum { stickyness_unsticky, /**< The entity can be removed from the program, unless contraindicated - by other attributes */ + by other attributes. Default. */ stickyness_sticky /**< The entity must remain in the - program in any case */ + program in any case. */ } ent_stickyness; /** Get the entity's stickyness */ @@ -538,6 +546,15 @@ 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); + +/** 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); + /** * @page unknown_entity * @@ -557,6 +574,7 @@ int entity_not_visited(entity *ent); * ld_name = "unknown_entity" * owner = unknown_type * type = unknown_type + * allocation = allocation_automatic * visibility = visibility_external_allocated * offset = -1 * variability = variability_uninitialized @@ -575,7 +593,8 @@ int entity_not_visited(entity *ent); */ /* A variable that contains the only unknown entity. */ extern entity *unknown_entity; -/* Returns the unknown entity */ + +/** Returns the unknown entity */ entity *get_unknown_entity(void); # endif /* _ENTITY_H_ */ diff --git a/ir/tr/entity_t.h b/ir/tr/entity_t.h index ac0326e3b..160671c04 100644 --- a/ir/tr/entity_t.h +++ b/ir/tr/entity_t.h @@ -109,6 +109,8 @@ struct entity { ir_graph *irg; /**< If (type == method_type) this is the corresponding irg. The ir_graph constructor automatically sets this field. Yes, it must be here. */ + unsigned irg_add_properties; /**< If (type == method_type) this is a set of additional. + graph flags if the irg of an entity is not known. */ /* ------------- fields for analyses ---------------*/ @@ -323,36 +325,74 @@ _entity_not_visited(entity *ent) { return _get_entity_visited(ent) < firm_type_visited; } -#define is_entity(thing) _is_entity(thing) -#define get_entity_name(ent) _get_entity_name(ent) -#define get_entity_ident(ent) _get_entity_ident(ent) -#define get_entity_owner(ent) _get_entity_owner(ent) -#define get_entity_ld_ident(ent) _get_entity_ld_ident(ent) -#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_allocation(ent) _get_entity_allocation(ent) -#define set_entity_allocation(ent, al) _set_entity_allocation(ent, al) -#define get_entity_visibility(ent) _get_entity_visibility(ent) -#define get_entity_variability(ent) _get_entity_variability(ent) -#define get_entity_volatility(ent) _get_entity_volatility(ent) -#define set_entity_volatility(ent, vol) _set_entity_volatility(ent, vol) -#define get_entity_peculiarity(ent) _get_entity_peculiarity(ent) -#define set_entity_peculiarity(ent, pec) _set_entity_peculiarity(ent, pec) -#define get_entity_stickyness(ent) _get_entity_stickyness(ent) -#define set_entity_stickyness(ent, stickyness) _set_entity_stickyness(ent, stickyness) -#define get_entity_offset_bits(ent) _get_entity_offset_bits(ent) -#define get_entity_offset_bytes(ent) _get_entity_offset_bytes(ent) -#define set_entity_offset_bits(ent, offset) _set_entity_offset_bits(ent, offset) -#define set_entity_offset_bytes(ent, offset) _set_entity_offset_bytes(ent, offset) -#define get_entity_link(ent) _get_entity_link(ent) -#define set_entity_link(ent, l) _set_entity_link(ent, l) -#define get_entity_irg(ent) _get_entity_irg(ent) -#define get_entity_visited(ent) _get_entity_visited(ent) -#define set_entity_visited(ent, num) _set_entity_visited(ent, num) -#define mark_entity_visited(ent) _mark_entity_visited(ent) -#define entity_visited(ent) _entity_visited(ent) -#define entity_not_visited(ent) _entity_not_visited(ent) +static INLINE unsigned +_get_entity_additional_properties(const entity *ent) { + ir_graph *irg; + assert(ent && ent->kind == k_entity); + assert(ent == unknown_entity || is_Method_type(ent->type)); + irg = _get_entity_irg(ent); + return irg ? + get_irg_additional_properties(irg) : + ent->irg_add_properties; +} + +static INLINE void +_set_entity_additional_properties(entity *ent, unsigned mask) { + ir_graph *irg; + assert(ent && ent->kind == k_entity); + assert(ent == unknown_entity || is_Method_type(ent->type)); + irg = _get_entity_irg(ent); + if (irg) + set_irg_additional_properties(irg, mask); + else + ent->irg_add_properties = mask; +} + +static INLINE void +_set_entity_additional_property(entity *ent, irg_additional_property flag) { + ir_graph *irg; + assert(ent && ent->kind == k_entity); + assert(ent == unknown_entity || is_Method_type(ent->type)); + irg = _get_entity_irg(ent); + if (irg) + set_irg_additional_property(irg, flag); + else + ent->irg_add_properties |= flag; +} + +#define is_entity(thing) _is_entity(thing) +#define get_entity_name(ent) _get_entity_name(ent) +#define get_entity_ident(ent) _get_entity_ident(ent) +#define get_entity_owner(ent) _get_entity_owner(ent) +#define get_entity_ld_ident(ent) _get_entity_ld_ident(ent) +#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_allocation(ent) _get_entity_allocation(ent) +#define set_entity_allocation(ent, al) _set_entity_allocation(ent, al) +#define get_entity_visibility(ent) _get_entity_visibility(ent) +#define get_entity_variability(ent) _get_entity_variability(ent) +#define get_entity_volatility(ent) _get_entity_volatility(ent) +#define set_entity_volatility(ent, vol) _set_entity_volatility(ent, vol) +#define get_entity_peculiarity(ent) _get_entity_peculiarity(ent) +#define set_entity_peculiarity(ent, pec) _set_entity_peculiarity(ent, pec) +#define get_entity_stickyness(ent) _get_entity_stickyness(ent) +#define set_entity_stickyness(ent, stickyness) _set_entity_stickyness(ent, stickyness) +#define get_entity_offset_bits(ent) _get_entity_offset_bits(ent) +#define get_entity_offset_bytes(ent) _get_entity_offset_bytes(ent) +#define set_entity_offset_bits(ent, offset) _set_entity_offset_bits(ent, offset) +#define set_entity_offset_bytes(ent, offset) _set_entity_offset_bytes(ent, offset) +#define get_entity_link(ent) _get_entity_link(ent) +#define set_entity_link(ent, l) _set_entity_link(ent, l) +#define get_entity_irg(ent) _get_entity_irg(ent) +#define get_entity_visited(ent) _get_entity_visited(ent) +#define set_entity_visited(ent, num) _set_entity_visited(ent, num) +#define mark_entity_visited(ent) _mark_entity_visited(ent) +#define entity_visited(ent) _entity_visited(ent) +#define entity_not_visited(ent) _entity_not_visited(ent) +#define get_entity_additional_properties(ent) _get_entity_additional_properties(ent) +#define set_entity_additional_properties(ent, m) _set_entity_additional_properties(ent, m) +#define set_entity_additional_property(ent, f) _set_entity_additional_property(ent, f) # endif /* _ENTITY_T_H_ */ -- 2.20.1