res->owner = owner;
res->name = name;
res->type = type;
+ res->allocation = dynamic_allocated;
+ res->visibility = local;
res->ld_name = NULL;
res->visit = 0;
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;
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);
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 */
res->type_op = type_op;
res->mode = mode;
res->name = name;
+ res->state = layout_undefined;
res->size = -1;
res->visit = 0;
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;
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 */
type *res;
res = new_type(type_primitive, mode, name);
res->size = get_mode_size(mode);
+ res->state = layout_fixed;
return res;
}
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. */
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. */
* 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 *