From 97e544bba9e3a0dacb3a7542952ea9f1b903667e Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Tue, 9 Nov 2004 17:35:38 +0000 Subject: [PATCH] comments, removed unused fields added unknown entity [r4338] --- ir/tr/entity.c | 38 +++++++++++++++++++++++++++++--------- ir/tr/entity.h | 21 +++++++++++++++++++++ ir/tr/entity_t.h | 4 +++- ir/tr/type.h | 2 +- ir/tr/type_t.h | 2 -- ir/tr/typewalk.h | 5 +++-- 6 files changed, 57 insertions(+), 15 deletions(-) diff --git a/ir/tr/entity.c b/ir/tr/entity.c index b64f8849c..c20618bcb 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -36,16 +36,25 @@ /** general **/ /*******************************************************************/ +entity *unknown_entity = NULL; entity *get_unknown_entity(void) { return unknown_entity; } +#define UNKNOWN_ENTITY_NAME "unknown_entity" + +static INLINE entity * +new_rd_entity (dbg_info *db, type *owner, ident *name, type *type); + void init_entity (void) { + assert(unknown_type && "Call init_type before init_entity!"); + new_rd_entity(NULL, unknown_type, new_id_from_str(UNKNOWN_ENTITY_NAME), unknown_type); } + /*-----------------------------------------------------------------*/ /* ENTITY */ /*-----------------------------------------------------------------*/ -static void insert_entity_in_owner (entity *ent) { +static INLINE void insert_entity_in_owner (entity *ent) { type *owner = ent->owner; switch (get_type_tpop_code(owner)) { case tpo_class: { @@ -64,8 +73,8 @@ static void insert_entity_in_owner (entity *ent) { } } -entity * -new_entity (type *owner, ident *name, type *type) +static INLINE entity * +new_rd_entity (dbg_info *db, type *owner, ident *name, type *type) { entity *res; ir_graph *rem; @@ -73,8 +82,8 @@ new_entity (type *owner, ident *name, type *type) assert(!id_contains_char(name, ' ') && "entity name should not contain spaces"); res = (entity *) xmalloc (sizeof (entity)); + memset(res, 0, sizeof(res)); res->kind = k_entity; - assert_legal_owner_of_ent(owner); res->owner = owner; res->name = name; res->type = type; @@ -113,7 +122,7 @@ new_entity (type *owner, ident *name, type *type) } res->irg = NULL; - res->accesses = NULL; + //res->accesses = NULL; #ifdef DEBUG_libfirm res->nr = get_irp_new_node_nr(); @@ -121,18 +130,29 @@ new_entity (type *owner, ident *name, type *type) #endif /* DEBUG_libfirm */ res->visit = 0; + set_entity_dbg_info(res, db); - /* Remember entity in it's owner. */ - insert_entity_in_owner (res); return res; } + entity * new_d_entity (type *owner, ident *name, type *type, dbg_info *db) { - entity *res = new_entity(owner, name, type); - set_entity_dbg_info(res, db); + assert_legal_owner_of_ent(owner); + entity *res = new_rd_entity(db, owner, name, type); + /* Remember entity in it's owner. */ + insert_entity_in_owner (res); + return res; } +entity * +new_entity (type *owner, ident *name, type *type) { + return new_d_entity(owner, name, type, NULL); +} + + + + static void free_entity_attrs(entity *ent) { int i; if (get_type_tpop(get_entity_owner(ent)) == type_class) { diff --git a/ir/tr/entity.h b/ir/tr/entity.h index d5fab7e22..216aca99d 100644 --- a/ir/tr/entity.h +++ b/ir/tr/entity.h @@ -529,5 +529,26 @@ bool entity_not_visited(entity *ent); * dynamic type are given. */ entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent); +/** + * @page unknown_entity + * + * This entity is an auxiliary entity dedicated to support analyses. + * + * The unknown entity represents that there could be an entity, but it is not + * known. This entity can be used to initialize fields before an analysis (not known + * yet) or to represent the top of a lattice (could not be determined). There exists + * exactly one entity unknown. This entity has as owner and as type the unknown type. It is + * allocated when initializing the entity module. + * + * The following values are set: + * mode: mode_ANY + * name: "type_unknown" + * state: layout_fixed + * size: 0 + */ +/* A variable that contains the only unknown entity. */ +extern entity *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 5343c4a28..cf52d889d 100644 --- a/ir/tr/entity_t.h +++ b/ir/tr/entity_t.h @@ -109,7 +109,6 @@ struct entity { /* ------------- fields for analyses ---------------*/ - ir_node **accesses; /**< accessing nodes: loads, stores. */ #ifdef DEBUG_libfirm int nr; /**< a unique node number for each node to make output @@ -118,6 +117,8 @@ struct entity { # endif /* DEBUG_libfirm */ }; + + /* ----------------------- inline functions ------------------------ */ static INLINE int __is_entity(const void *thing) { @@ -225,6 +226,7 @@ __set_entity_peculiarity(entity *ent, peculiarity pec) { assert(ent && ent->kind == k_entity); /* @@@ why peculiarity only for methods? */ assert(is_method_type(ent->type)); + ent->peculiarity = pec; } diff --git a/ir/tr/type.h b/ir/tr/type.h index 4bc92a6cd..3a170aa54 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -904,7 +904,7 @@ type *get_none_type(void); */ /* A variable that contains the only unknown type. */ extern type *unknown_type; -/* Returns the none type */ +/* Returns the unknown type */ type *get_unknown_type(void); diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h index ae1286359..c66e15c82 100644 --- a/ir/tr/type_t.h +++ b/ir/tr/type_t.h @@ -131,8 +131,6 @@ struct type { struct dbg_info* dbi; /**< A pointer to information for debug support. */ /* ------------- fields for analyses ---------------*/ - ir_node **allocations; /**< array of all Alloc nodes with this type - @@@ Should not be in here, hash table! */ #ifdef DEBUG_libfirm int nr; /**< a unique node number for each node to make output diff --git a/ir/tr/typewalk.h b/ir/tr/typewalk.h index 66d0e159b..cbdef1381 100644 --- a/ir/tr/typewalk.h +++ b/ir/tr/typewalk.h @@ -99,7 +99,7 @@ void class_walk_super2sub(class_walk_func *pre, void *env); /** - * the entity walk function + * the entity walk function. A function type for entity walkers. * * @param ent points to the visited entity * @param env free environment pointer @@ -111,9 +111,10 @@ typedef void entity_walk_func(entity *ent, void *env); * * @param tp the type * @param doit the entity walker function - * @param env environment, wil be passed to the walker function + * @param env environment, will be passed to the walker function */ void walk_types_entities(type *tp, entity_walk_func *doit, void *env); + #endif /* _TYPEWALK_H_ */ -- 2.20.1