Commit 3ed0b9b7 authored by Michael Beck's avatar Michael Beck
Browse files

get_entity_repr_class() added, needed to get a class from a type info entity

mtp_property_runtime added

[r8283]
parent 93ec9eb4
......@@ -116,6 +116,7 @@ new_rd_entity(dbg_info *db, ir_type *owner, ident *name, ir_type *type)
res->compiler_gen = 0;
res->offset = -1;
res->link = NULL;
res->repr_class = NULL;
if (is_Method_type(type)) {
symconst_symbol sym;
......@@ -163,20 +164,20 @@ new_rd_entity(dbg_info *db, ir_type *owner, ident *name, ir_type *type)
}
entity *
new_d_entity (ir_type *owner, ident *name, ir_type *type, dbg_info *db) {
new_d_entity(ir_type *owner, ident *name, ir_type *type, dbg_info *db) {
entity *res;
assert_legal_owner_of_ent(owner);
assert(is_compound_type(owner));
res = new_rd_entity(db, owner, name, type);
/* Remember entity in it's owner. */
insert_entity_in_owner (res);
insert_entity_in_owner(res);
hook_new_entity(res);
return res;
}
entity *
new_entity (ir_type *owner, ident *name, ir_type *type) {
new_entity(ir_type *owner, ident *name, ir_type *type) {
return new_d_entity(owner, name, type, NULL);
}
......@@ -220,14 +221,14 @@ static void free_entity_attrs(entity *ent) {
}
entity *
copy_entity_own (entity *old, ir_type *new_owner) {
copy_entity_own(entity *old, ir_type *new_owner) {
entity *newe;
assert(old && old->kind == k_entity);
assert_legal_owner_of_ent(new_owner);
assert(is_entity(old));
assert(is_compound_type(new_owner));
if (old->owner == new_owner) return old;
newe = xmalloc(sizeof(*newe));
memcpy (newe, old, sizeof(*newe));
memcpy(newe, old, sizeof(*newe));
newe->owner = new_owner;
if (is_Class_type(new_owner)) {
newe->overwrites = NEW_ARR_F(entity *, 0);
......@@ -237,13 +238,13 @@ copy_entity_own (entity *old, ir_type *new_owner) {
newe->nr = get_irp_new_node_nr();
#endif
insert_entity_in_owner (newe);
insert_entity_in_owner(newe);
return newe;
}
entity *
copy_entity_name (entity *old, ident *new_name) {
copy_entity_name(entity *old, ident *new_name) {
entity *newe;
assert(old && old->kind == k_entity);
......@@ -306,21 +307,12 @@ ir_type *
}
void
set_entity_owner (entity *ent, ir_type *owner) {
assert(ent && ent->kind == k_entity);
assert_legal_owner_of_ent(owner);
set_entity_owner(entity *ent, ir_type *owner) {
assert(is_entity(ent));
assert(is_compound_type(owner));
ent->owner = owner;
}
void /* should this go into type.c? */
assert_legal_owner_of_ent(ir_type *owner) {
assert(get_type_tpop_code(owner) == tpo_class ||
get_type_tpop_code(owner) == tpo_union ||
get_type_tpop_code(owner) == tpo_struct ||
get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity
-- to select fields! */
}
ident *
(get_entity_ld_ident)(entity *ent) {
return _get_entity_ld_ident(ent);
......@@ -1311,15 +1303,15 @@ int
}
int is_atomic_entity(entity *ent) {
ir_type *t = get_entity_type(ent);
tp_op *op = get_type_tpop(t);
ir_type *t = get_entity_type(ent);
const tp_op *op = get_type_tpop(t);
return (op == type_primitive || op == type_pointer ||
op == type_enumeration || op == type_method);
}
int is_compound_entity(entity *ent) {
ir_type *t = get_entity_type(ent);
tp_op *op = get_type_tpop(t);
ir_type *t = get_entity_type(ent);
const tp_op *op = get_type_tpop(t);
return (op == type_class || op == type_struct ||
op == type_array || op == type_union);
}
......@@ -1417,6 +1409,12 @@ void set_entity_additional_property(entity *ent, mtp_additional_property flag)
}
}
/* Returns the class type that this type info entity represents or NULL
if ent is no type info entity. */
ir_type *(get_entity_repr_class)(const entity *ent) {
return _get_entity_repr_class(ent);
}
/* Initialize entity module. */
void firm_init_entity(void)
{
......
......@@ -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 (ir_type *owner, ident *name, ir_type *tp);
entity *new_entity(ir_type *owner, ident *name, ir_type *tp);
/**
* Creates a new entity.
......@@ -138,7 +138,7 @@ entity *new_entity (ir_type *owner, ident *name, ir_type *tp);
* value is a pointer to the method.
* Visibility is local, offset -1, and it is not volatile.
*/
entity *new_d_entity (ir_type *owner, ident *name, ir_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 (ir_type *owner, ident *name, ir_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, ir_type *new_owner);
entity *copy_entity_own(entity *old, ir_type *new_owner);
/**
* Copies the entity if the new_name is different from the
......@@ -162,7 +162,7 @@ entity *copy_entity_own (entity *old, ir_type *new_owner);
* The mangled name ld_name is set to NULL.
* Overwrites relation is copied from old.
*/
entity *copy_entity_name (entity *old, ident *new_name);
entity *copy_entity_name(entity *old, ident *new_name);
/**
* Frees the entity.
......@@ -170,16 +170,16 @@ entity *copy_entity_name (entity *old, ident *new_name);
* The owner will still contain the pointer to this
* entity, as well as all other references!
*/
void free_entity (entity *ent);
void free_entity(entity *ent);
/** Returns the name of an entity. */
const char *get_entity_name (const entity *ent);
const char *get_entity_name(const entity *ent);
/** Returns the ident of an entity. */
ident *get_entity_ident (const entity *ent);
ident *get_entity_ident(const entity *ent);
/** Sets the ident of the entity. */
void set_entity_ident (entity *ent, ident *id);
void set_entity_ident(entity *ent, ident *id);
/** Returns the mangled name of the entity.
*
......@@ -187,29 +187,26 @@ void set_entity_ident (entity *ent, ident *id);
* Else it generates a name with mangle_entity()
* and remembers this new name internally.
*/
ident *get_entity_ld_ident (entity *ent);
ident *get_entity_ld_ident(entity *ent);
/** Sets the mangled name of the entity. */
void set_entity_ld_ident (entity *ent, ident *ld_ident);
void set_entity_ld_ident(entity *ent, ident *ld_ident);
/** Returns the mangled name of the entity as a string. */
const char *get_entity_ld_name (entity *ent);
const char *get_entity_ld_name(entity *ent);
/** Returns the owner of the entity. */
ir_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, ir_type *owner);
/** Asserts if the type owner is either a compound type or an array */
void assert_legal_owner_of_ent(ir_type *owner);
void set_entity_owner(entity *ent, ir_type *owner);
/** Returns the type of an entity. */
ir_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, ir_type *tp);
void set_entity_type(entity *ent, ir_type *tp);
/** The allocation type. */
typedef enum {
......@@ -564,6 +561,10 @@ void set_entity_additional_properties(entity *ent, unsigned property_mask);
/** Sets one additional graph property. */
void set_entity_additional_property(entity *ent, mtp_additional_property flag);
/** Returns the class type that this type info entity represents or NULL
if ent is no type info entity. */
ir_type *get_entity_repr_class(const entity *ent);
/**
* @page unknown_entity
*
......
......@@ -3,10 +3,10 @@
* File name: ir/tr/entity_t.h
* Purpose: Representation of all program known entities -- private header.
* 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.
*/
......@@ -59,13 +59,13 @@ struct compound_graph_path {
access path. */
};
/** attributes for atomic entities */
/** The attributes for atomic entities. */
typedef struct atomic_ent_attr {
ir_node *value; /**< value if entity is not of variability uninitialized.
Only for atomic entities. */
} atomic_ent_attr;
/** attributes for compound entities */
/** The attributes for compound entities. */
typedef struct compound_ent_attr {
ir_node **values; /**< constant values of compound entities. Only available if
variability not uninitialized. Must be set for variability constant. */
......@@ -73,10 +73,10 @@ typedef struct compound_ent_attr {
variability not uninitialized. Must be set for variability constant. */
} compound_ent_attr;
/** a reserved value for "not yet set" */
/** A reserved value for "not yet set". */
#define VTABLE_NUM_NOT_SET ((unsigned)(-1))
/** attributes for methods */
/** The attributes for methods. */
typedef struct method_ent_attr {
ir_graph *irg; /**< The corresponding irg if known.
The ir_graph constructor automatically sets this field. */
......@@ -93,7 +93,7 @@ typedef struct method_ent_attr {
} method_ent_attr;
/** the type of an entity */
/** The type of an entity. */
struct entity {
firm_kind kind; /**< The dynamic type tag for entity. */
ident *name; /**< The name of this entity. */
......@@ -120,6 +120,7 @@ struct entity {
unsigned long visit; /**< visited counter for walks of the type information. */
struct dbg_info *dbi; /**< A pointer to information for debug support. */
void *link; /**< To store some intermediate information. */
ir_type *repr_class; /**< If this entity represents a class info, the associated class. */
/* ------------- fields for entities owned by a class type ---------------*/
......@@ -144,7 +145,7 @@ struct entity {
# endif /* DEBUG_libfirm */
};
/** Initialize entity module. */
/** Initialize the entity module. */
void firm_init_entity(void);
......@@ -357,6 +358,12 @@ _entity_not_visited(entity *ent) {
return _get_entity_visited(ent) < firm_type_visited;
}
static INLINE ir_type *
_get_entity_repr_class(const entity *ent) {
assert(ent && ent->kind == k_entity);
return ent->repr_class;
}
#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)
......@@ -389,5 +396,7 @@ _entity_not_visited(entity *ent) {
#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_repr_class(ent) _get_entity_repr_class(ent)
#endif /* _FIRM_TR_ENTITY_T_H_ */
......@@ -55,21 +55,22 @@
# include <stdlib.h>
#endif
# include <stddef.h>
#include <stddef.h>
# include "type_t.h"
#include "type_t.h"
# include "xmalloc.h"
# include "irprog_t.h"
# include "ircons.h"
# include "tpop_t.h"
# include "typegmod.h"
# include "mangle.h"
# include "tv_t.h"
# include "irhooks.h"
# include "irtools.h"
#include "xmalloc.h"
#include "irprog_t.h"
#include "ircons.h"
#include "tpop_t.h"
#include "typegmod.h"
#include "mangle.h"
#include "tv_t.h"
#include "irhooks.h"
#include "irtools.h"
#include "entity_t.h"
# include "array.h"
#include "array.h"
/*-----------------------------------------------------------------*/
/** TYPE **/
......@@ -953,6 +954,8 @@ entity *get_class_type_info(const ir_type *clss) {
}
void set_class_type_info(ir_type *clss, entity *ent) {
clss->attr.ca.type_info = ent;
if (ent)
ent->repr_class = clss;
}
const char *get_peculiarity_name(ir_peculiarity p) {
......
......@@ -857,6 +857,7 @@ typedef enum {
GCC: __attribute__((malloc)). */
mtp_property_intrinsic = 0x00000040, /**< This method is intrinsic. It is expected that
a lowering phase will remove all calls to it. */
mtp_property_runtime = 0x00000080, /**< This method represents a runtime routine. */
mtp_property_inherited = (1<<31) /**< Internal. Used only in irg's, means property is
inherited from type. */
} mtp_additional_property;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment