X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Ftype.h;h=464944c67aca95961fbf5b0bb5b2caaadd803202;hb=217c4f3a0ffc115825dbebb2270ab1d20c246e97;hp=ce5e1ed16ba35aa92e1fbbfe30d779fa385c03c7;hpb=1e1e5373de456d6ef02d2b397767ebbf881f1a80;p=libfirm diff --git a/ir/tr/type.h b/ir/tr/type.h index ce5e1ed16..464944c67 100644 --- a/ir/tr/type.h +++ b/ir/tr/type.h @@ -149,6 +149,73 @@ ident* get_type_ident(const type *tp); void set_type_ident(type *tp, ident* id); const char* get_type_name(const type *tp); +/** This enumeration flags the visibility of entities and types. + * + * This is necessary for partial compilation. + * We rely on the ordering of the flags. + */ +typedef enum { + visibility_local, /**< The entity is only visible locally. This is the default for + entities. + The type is only visible locally. All instances are allocated + locally, and no pointer to entities of this type are passed + out of this compilation unit. */ + visibility_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. + For types: entities of this type can be accessed externaly. No + instances of this type are allocated externally. */ + visibility_external_allocated /**< The entity is defined and allocated externally. This compilation + must not allocate memory for this entity. The entity must + be static_allocated. This can also be an external defined + method. + For types: entities of this type are allocated and accessed from + external code. Default for types. */ +} visibility; + +/** The visibility of a type. + * + * The visibility of a type indicates, whether entities of this type + * are accessed or allocated in external code. + * + * An entity of a type is allocated in external code, if the external + * code declares a variable of this type, or dynamically allocates + * an entity of this type. If the external code declares a (compound) + * type, that contains entities of this type, the visibility also + * must be external_allocated. + * + * The visibility must be higher than that of all entities, if the + * type is a compound. Here it is questionable, what happens with + * static entities. If these are accessed external by direct reference, + * (a static call to a method, that is also in the dispatch table) + * it should not affect the visibility of the type. + * + * + * @@@ Do we need a visibility for types? + * I change the layout of types radically when doing type splitting. + * I need to know, which fields of classes are accessed in the rts, + * e.g., [_length. I may not move [_length to the split part. + * The layout though, is a property of the type. + * + * One could also think of changing the mode of a type ... + * + * But, we could also output macros to access the fields, e.g., + * ACCESS_[_length (X) X->length // conventional + * ACCESS_[_length (X) X->_split_ref->length // with type splitting + * + * For now I implement this function, that returns the visibility + * based on the visibility of the entities of a compound ... + * + * This function returns visibility_external_visible if one or more + * entities of a compound type have visibility_external_visible. + * Entities of types are never visibility_external_allocated (right?). + * Else returns visibility_local. + */ +visibility get_type_visibility (const type *tp); +void set_type_visibility (type *tp, visibility v); + + + /** The state of the type layout. */ typedef enum { layout_undefined, /**< The layout of this type is not defined. @@ -432,6 +499,12 @@ int get_class_n_subtypes (const type *clss); /** Gets the subtype at position pos, 0 <= pos < n_subtype. */ type *get_class_subtype (type *clss, int pos); +/** Returns the index to access subclass as subtype of class. + * + * If subclass is no direct subtype of class returns -1. + */ +int get_class_subtype_index(type *clss, const type *subclass); + /** Sets the subtype at position pos, 0 <= pos < n_subtype. * * Does not set the corresponding supertype relation for subtype: this might @@ -451,7 +524,10 @@ void add_class_supertype (type *clss, type *supertype); /** Returns the number of supertypes */ int get_class_n_supertypes (const type *clss); -/** Returns the index of an supertype in a type. */ +/** Returns the index to access superclass as supertype of class. + * + * If superclass is no direct supertype of class returns -1. + */ int get_class_supertype_index(type *clss, type *super_clss); /** Gets the supertype at position pos, 0 <= pos < n_supertype. */