From d88be9755d1677cd1b1cfb3421769fb87cb15997 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Wed, 4 Jul 2001 07:00:08 +0000 Subject: [PATCH] Added support for lowering to entites, types. added support for visibilit of entities, allocation mode [r215] --- ir/tr/entity.c | 25 +++++++++++++++++++++++++ ir/tr/entity.h | 26 ++++++++++++++++++++++++++ ir/tr/entity_t.h | 4 ++++ ir/tr/type.c | 27 ++++++++++++++++++++++++--- ir/tr/type.h | 20 ++++++++++++++++++++ ir/tr/type_t.h | 4 +++- 6 files changed, 102 insertions(+), 4 deletions(-) diff --git a/ir/tr/entity.c b/ir/tr/entity.c index f54ee0664..001060282 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -39,6 +39,8 @@ new_entity (type *owner, ident *name, type *type) res->owner = owner; res->name = name; res->type = type; + res->allocation = dynamic_allocated; + res->visibility = local; res->ld_name = NULL; res->visit = 0; @@ -122,6 +124,29 @@ set_entity_type (entity *ent, type *type) { ent->type = type; } + +inline ent_allocation +get_entity_allocation (entity *ent) { + return ent->allocation; +} + +inline void +set_entity_allocation (entity *ent, ent_allocation al) { + ent->allocation = al; +} + + +inline ent_visibility +get_entity_visibility (entity *ent) { + return ent->visibility; +} + +inline void +set_entity_visibility (entity *ent, ent_visibility vis) { + if (vis != local) assert(ent->allocation == static_allocated); + ent->visibility = vis; +} + inline int get_entity_offset (entity *ent) { return ent->offset; diff --git a/ir/tr/entity.h b/ir/tr/entity.h index 4614c0897..1239ba3f7 100644 --- a/ir/tr/entity.h +++ b/ir/tr/entity.h @@ -97,6 +97,32 @@ inline void assert_legal_owner_of_ent(type *owner); type *get_entity_type (entity *ent); void set_entity_type (entity *ent, type *type); +typedef enum { + dynamic_allocated, /* The entity is allocated during runtime, either explicitly + by an Alloc node or implicitly as component of a compound + type. This is the default. */ + static_allocated /* The entity is allocated statically. We can use a + SymConst as address of the entity. */ +} ent_allocation; + +ent_allocation get_entity_allocation (entity *ent); +void set_entity_allocation (entity *ent, ent_allocation al); + +/* This enumeration flags the visibility of entities. This is necessary + for partial compilation. */ +typedef enum { + local, /* The entity is only visible locally. This is the default. */ + external_visible, /* The entity is visible to other external program parts, but + it is defined here. It may not be optimized away. The entity must + be static_allocated. */ + external_allocated /* The entity is defined and allocated externaly. This compilation + must not allocate memory for this entity. The entity must + be static_allocated. */ +} ent_visibility; + +ent_visibility get_entity_visibility (entity *ent); +void set_entity_visibility (entity *ent, ent_visibility vis); + int get_entity_offset (entity *ent); void set_entity_offset (entity *ent, int offset); diff --git a/ir/tr/entity_t.h b/ir/tr/entity_t.h index 9ec56598a..a605f6da6 100644 --- a/ir/tr/entity_t.h +++ b/ir/tr/entity_t.h @@ -47,6 +47,10 @@ struct entity { basic type of the language or a class itself */ type *owner; /* The class this entity belongs to. In case of local variables the method they are defined in. */ + ent_allocation allocation; /* Distinguishes static and dynamically allocated + entities. */ + ent_visibility visibility; /* Specifies visibility to external program + fragments */ int offset; /* Offset in byte for this entity. Fixed when layout of owner is determined. */ /* for methods */ diff --git a/ir/tr/type.c b/ir/tr/type.c index 4f527fae5..08b53f275 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -52,6 +52,7 @@ new_type(tp_op *type_op, ir_mode *mode, ident* name) { res->type_op = type_op; res->mode = mode; res->name = name; + res->state = layout_undefined; res->size = -1; res->visit = 0; @@ -102,16 +103,34 @@ int get_type_size(type *tp) { assert(tp); return tp->size; } -void set_type_size(type *tp, int size) { + +void +set_type_size(type *tp, int size) { assert(tp); /* For pointer and primitive size depends on the mode. */ - assert((tp->type_op != type_pointer) && (tp->type_op != type_primitive)); - tp->size = size; + if ((tp->type_op != type_pointer) && (tp->type_op != type_primitive)) + tp->size = size; } + +type_state +get_type_state(type *tp) { + assert(tp); + return tp->state; +} + +void +set_type_state(type *tp, type_state state) { + assert(tp); + /* For pointer and primitive always fixed. */ + if ((tp->type_op != type_pointer) && (tp->type_op != type_primitive)) + tp->state = state; +} + unsigned long get_type_visited(type *tp) { assert(tp); return tp->visit; } + void set_type_visited(type *tp, unsigned long num) { assert(tp); tp->visit = num; @@ -475,6 +494,7 @@ type *new_type_pointer (ident *name, type *points_to) { res = new_type(type_pointer, mode_p, name); res->attr.pa.points_to = points_to; res->size = get_mode_size(res->mode); + res->state = layout_fixed; return res; } /* manipulate fields of type_pointer */ @@ -503,6 +523,7 @@ type *new_type_primitive (ident *name, ir_mode *mode) { type *res; res = new_type(type_primitive, mode, name); res->size = get_mode_size(mode); + res->state = layout_fixed; return res; } diff --git a/ir/tr/type.h b/ir/tr/type.h index 2556de783..44a7f5008 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -105,8 +105,28 @@ void set_type_nameid(type *tp, ident* id); const char* get_type_name(type *tp); int get_type_size(type *tp); +/* For primitives and pointer types the size is always fixed. + This call is legal but has no effect. */ void set_type_size(type *tp, int size); +typedef enum { + layout_undefined, /* The layout of this type is not defined. + Address computation to access fields is not + possible, fields must be accessed by Sel nodes. + This is the default value except for pointer and + primitive types. */ + layout_fixed /* The layout is fixed, all component/member entities + have an offset assigned. Size of the type is known. + Arrays can be accessed by explicit address + computation. Default for pointer and primitive types. + */ +} type_state; + +type_state get_type_state(type *tp); +/* For primitives and pointer types the layout is always fixed. + This call is legal but has no effect. */ +void set_type_state(type *tp, type_state state); + unsigned long get_type_visited(type *tp); void set_type_visited(type *tp, unsigned long num); /* Sets visited field in type to type_visited. */ diff --git a/ir/tr/type_t.h b/ir/tr/type_t.h index 02d1f7d3f..151509a59 100644 --- a/ir/tr/type_t.h +++ b/ir/tr/type_t.h @@ -91,6 +91,8 @@ struct type { tp_op *type_op; ir_mode *mode; ident *name; + type_state state; /* Represents the types state: layout undefined or + fixed. */ int size; /* Size of an entity of this type. This is determined when fixing the layout of this class. Size must be given in bytes. */ @@ -111,7 +113,7 @@ struct type { * name - an ident for the name of this type. * RESULT * a new type of the given type. The remaining private attributes are not - * initalized. + * initalized. The type is in state layout_undefined. *** */ inline type * -- 2.20.1