* @see type.h tpop_t.h tpop.h
*/
-/** class attributes */
+/** Class flags. */
+enum class_flags {
+ cf_none = 0, /**< No flags. */
+ cf_final_class = 1, /**< Set if a class is an final class */
+ cf_interface_class = 2, /**< Set if a class is an "interface" */
+ cf_absctract_class = 4, /**< Set if a class is "abstract" */
+};
+
+/** Class type attributes. */
typedef struct {
- entity **members; /**< fields and methods of this class */
- ir_type **subtypes; /**< direct subtypes */
- ir_type **supertypes;/**< direct supertypes */
- peculiarity peculiarity; /**< peculiarity of this class */
- entity *type_info; /**< a entity representing this class, used for type info */
- unsigned vtable_size;/**< size of the vtable */
- unsigned final; /**< non-zero if this is a final class */
- int dfn; /**< number used for 'instanceof' operator */
+ ir_entity **members; /**< Array containing the fields and methods of this class. */
+ ir_type **subtypes; /**< Array containing the direct subtypes. */
+ ir_type **supertypes; /**< Array containing the direct supertypes */
+ ir_peculiarity peculiarity; /**< The peculiarity of this class. */
+ ir_entity *type_info; /**< An ir_entity representing this class, used for type info. */
+ int dfn; /**< A number that can be used for 'instanceof' operator. */
+ unsigned vtable_size; /**< The size of the vtable for this class. */
+ unsigned clss_flags; /**< Additional class flags. */
} cls_attr;
-/** struct attributes */
+/** Struct type attributes. */
typedef struct {
- entity **members; /**< Fields of this struct. No method entities allowed. */
+ ir_entity **members; /**< Fields of this struct. No method entities allowed. */
} stc_attr;
-/** A (type, entity) pair */
+/** A (type, ir_entity) pair. */
typedef struct {
ir_type *tp; /**< A type. */
- entity *ent; /**< An entity. */
+ ir_entity *ent; /**< An ir_entity. */
+ ident *param_name; /**< For debugging purposes: the name of the parameter */
} tp_ent_pair;
-/** method attributes */
+/** Method type attributes. */
typedef struct {
int n_params; /**< Number of parameters. */
- tp_ent_pair *param_type; /**< Array of parameter type/value entities pairs. */
+ tp_ent_pair *params; /**< Array of parameter type/value entities pairs. */
ir_type *value_params; /**< A type whose entities represent copied value arguments. */
int n_res; /**< Number of results. */
- tp_ent_pair *res_type; /**< Array of result type/value entity pairs. */
+ tp_ent_pair *res_type; /**< Array of result type/value ir_entity pairs. */
ir_type *value_ress; /**< A type whose entities represent copied value results. */
- variadicity variadicity; /**< variadicity of the method. */
- int first_variadic_param; /**< index of the first variadic parameter or -1 if non-variadic .*/
+ variadicity variadicity; /**< The variadicity of the method. */
+ int first_variadic_param; /**< The index of the first variadic parameter or -1 if non-variadic .*/
unsigned additional_properties; /**< Set of additional method properties. */
unsigned irg_calling_conv; /**< A set of calling convention flags. */
} mtd_attr;
-/** union attributes */
+/** Union type attributes. */
typedef struct {
- entity **members; /**< fields of this union. No method entities allowed. */
+ ir_entity **members; /**< Fields of this union. No method entities allowed. */
} uni_attr;
-/** array attributes */
+/** Array type attributes. */
typedef struct {
- int n_dimensions; /**< Number of array dimensions. */
+ int n_dimensions; /**< Number of array dimensions. */
ir_node **lower_bound; /**< Lower bounds of dimensions. Usually all 0. */
ir_node **upper_bound; /**< Upper bounds or dimensions. */
- int *order; /**< Ordering of dimensions. */
+ int *order; /**< Ordering of dimensions. */
ir_type *element_type; /**< The type of the array elements. */
- entity *element_ent; /**< Entity for the array elements, to be used for
- element selection with Sel. */
+ ir_entity *element_ent; /**< entity for the array elements, to be used for
+ element selection with a Sel node. */
} arr_attr;
-/** enum attributes */
+/** An enumerator constant. */
+struct ir_enum_const {
+ tarval *value; /**< The constants that represents this enumerator identifier. */
+ ident *nameid; /**< The name of the enumerator identifier. */
+ ir_type *owner; /**< owner type of this enumerator constant. */
+};
+
+/** Enum type attributes. */
typedef struct {
- int n_enums; /**< Number of enumerators. */
- tarval **enumer; /**< Contains all constants that represent a member
- of the enum -- enumerators. */
- ident **enum_nameid;/**< Contains the names of the enum fields as specified by
- the source program */
+ ir_enum_const *enumer; /**< Contains all enumerator constants that represent a member
+ of the enum -- enumerators. */
} enm_attr;
-/** pointer attributes */
+/** Pointer type attributes. */
typedef struct {
- ir_type *points_to; /**< The type of the entity the pointer points to. */
+ ir_type *points_to; /**< The type of the ir_entity the pointer points to. */
} ptr_attr;
/*
/** General type attributes. */
typedef union {
- cls_attr ca; /**< attributes of a class type */
- stc_attr sa; /**< attributes of a struct type */
- mtd_attr ma; /**< attributes of a method type */
- uni_attr ua; /**< attributes of an union type */
- arr_attr aa; /**< attributes of an array type */
- enm_attr ea; /**< attributes of an enumeration type */
- ptr_attr pa; /**< attributes of a pointer type */
+ cls_attr ca; /**< Attributes of a class type */
+ stc_attr sa; /**< Attributes of a struct type */
+ mtd_attr ma; /**< Attributes of a method type */
+ uni_attr ua; /**< Attributes of an union type */
+ arr_attr aa; /**< Attributes of an array type */
+ enm_attr ea; /**< Attributes of an enumeration type */
+ ptr_attr pa; /**< Attributes of a pointer type */
} tp_attr;
+/** Additional type flags. */
enum type_flags {
- tf_none = 0, /**< No flags. */
- tf_frame_type = 1, /**< Set if this is a frame type. */
- tf_lowered_type = 2, /**< Set if this is a lowered type. */
- tf_layout_fixed = 4 /**< set if the layout of a type is fixed */
+ tf_none = 0, /**< No flags. */
+ tf_frame_type = 1, /**< Set if this is a frame type. */
+ tf_value_param_type = 2, /**< Set if this is a value param type. */
+ tf_lowered_type = 4, /**< Set if this is a lowered type. */
+ tf_layout_fixed = 8, /**< Set if the layout of a type is fixed */
+ tf_global_type = 16, /**< Set only for the global type */
+ tf_tls_type = 32, /**< Set only for the tls type */
};
-/** the structure of a type */
+/** The structure of a type. */
struct ir_type {
firm_kind kind; /**< the firm kind, must be k_type */
const tp_op *type_op; /**< the type operation of the type */
ident *name; /**< The name of the type */
- visibility visibility; /**< Visibility of entities of this type. */
+ ir_visibility visibility;/**< Visibility of entities of this type. */
unsigned flags; /**< Type flags, a bitmask of enum type_flags. */
- int size; /**< Size of an entity of this type. This is determined
+ int size; /**< Size of an ir_entity of this type. This is determined
when fixing the layout of this class. Size must be
given in bits. */
- int align; /**< Alignment of an entity of this type. This should be
+ int align; /**< Alignment of an ir_entity of this type. This should be
set according to the source language needs. If not set it's
calculated automatically by get_type_alignment().
Alignment must be given in bits. */
/* ------------- fields for analyses ---------------*/
#ifdef DEBUG_libfirm
- long nr; /**< a unique node number for each node to make output
- readable. */
+ long nr; /**< An unique node number for each node to make output
+ readable. */
#endif
- tp_attr attr; /* type kind specific fields. This must be the last
- entry in this struct! Varying size! */
+ tp_attr attr; /**< Type kind specific fields. This must be the last
+ entry in this struct! Varying size! */
};
/**
return (ARR_LEN (clss->attr.ca.members));
}
-static INLINE entity *
+static INLINE ir_entity *
_get_class_member (const ir_type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < _get_class_n_members(clss));
}
static INLINE int
-_is_class_final (const ir_type *clss) {
+_is_class_final(const ir_type *clss) {
+ assert(clss && (clss->type_op == type_class));
+ return clss->attr.ca.clss_flags & cf_final_class;
+}
+
+static INLINE void
+_set_class_final(ir_type *clss, int final) {
+ assert(clss && (clss->type_op == type_class));
+ if (final)
+ clss->attr.ca.clss_flags |= cf_final_class;
+ else
+ clss->attr.ca.clss_flags &= ~cf_final_class;
+}
+
+static INLINE int
+_is_class_interface(const ir_type *clss) {
+ assert(clss && (clss->type_op == type_class));
+ return clss->attr.ca.clss_flags & cf_interface_class;
+}
+
+static INLINE void
+_set_class_interface(ir_type *clss, int final) {
+ assert(clss && (clss->type_op == type_class));
+ if (final)
+ clss->attr.ca.clss_flags |= cf_interface_class;
+ else
+ clss->attr.ca.clss_flags &= ~cf_interface_class;
+}
+
+static INLINE int
+_is_class_abstract(const ir_type *clss) {
assert(clss && (clss->type_op == type_class));
- return clss->attr.ca.final;
+ return clss->attr.ca.clss_flags & cf_absctract_class;
}
static INLINE void
-_set_class_final (ir_type *clss, int final) {
+_set_class_abstract(ir_type *clss, int final) {
assert(clss && (clss->type_op == type_class));
- clss->attr.ca.final = final;
+ if (final)
+ clss->attr.ca.clss_flags |= cf_absctract_class;
+ else
+ clss->attr.ca.clss_flags &= ~cf_absctract_class;
}
static INLINE int
#define get_class_vtable_size(clss) _get_class_vtable_size(clss)
#define set_class_vtable_size(clss, size) _set_class_vtable_size(clss, size)
#define is_class_final(clss) _is_class_final(clss)
-#define set_class_final(clss, final) _set_class_final(clss, final)
+#define set_class_final(clss, flag) _set_class_final(clss, flag)
+#define is_class_interface(clss) _is_class_interface(clss)
+#define set_class_interface(clss, flag) _set_class_interface(clss, flag)
+#define is_class_abstract(clss) _is_class_abstract(clss)
+#define set_class_abstract(clss, flag) _set_class_abstract(clss, flag)
#define is_Struct_type(strct) _is_struct_type(strct)
#define is_Method_type(method) _is_method_type(method)
#define is_Union_type(uni) _is_union_type(uni)