In particular this ensures that the backend has segments for the PIC symbols and trampolines.
{
memset(env, 0, sizeof(*env));
env->ent_trampoline_map = pmap_create();
- env->pic_trampolines_type = new_type_class(NEW_ID("$PIC_TRAMPOLINE_TYPE"));
+ env->pic_trampolines_type = new_type_segment(NEW_ID("$PIC_TRAMPOLINE_TYPE"), tf_none);
env->ent_pic_symbol_map = pmap_create();
- env->pic_symbols_type = new_type_struct(NEW_ID("$PIC_SYMBOLS_TYPE"));
+ env->pic_symbols_type = new_type_segment(NEW_ID("$PIC_SYMBOLS_TYPE"), tf_none);
env->cup_name = compilation_unit_name;
env->arch_env = isa_if->begin_codegeneration();
#define IDENT(x) new_id_from_chars(x, sizeof(x) - 1)
irp->name = new_id_from_str(module_name);
- irp->segment_types[IR_SEGMENT_GLOBAL]
- = new_type_class(IDENT("GlobalType"));
- irp->segment_types[IR_SEGMENT_THREAD_LOCAL]
- = new_type_struct(IDENT("ThreadLocal"));
- irp->segment_types[IR_SEGMENT_CONSTRUCTORS]
- = new_type_class(IDENT("Constructors"));
- irp->segment_types[IR_SEGMENT_DESTRUCTORS]
- = new_type_class(IDENT("Destructors"));
-
- /* Set these flags for debugging. */
- irp->segment_types[IR_SEGMENT_GLOBAL]->flags |= tf_segment|tf_global_type;
- irp->segment_types[IR_SEGMENT_THREAD_LOCAL]->flags |= tf_segment|tf_tls_type;
- irp->segment_types[IR_SEGMENT_CONSTRUCTORS]->flags |= tf_segment|tf_constructors;
- irp->segment_types[IR_SEGMENT_DESTRUCTORS]->flags |= tf_segment|tf_destructors;
+ irp->segment_types[IR_SEGMENT_GLOBAL] = new_type_segment(IDENT("GlobalType"), tf_global_type);
+ irp->segment_types[IR_SEGMENT_THREAD_LOCAL] = new_type_segment(IDENT("ThreadLocal"), tf_tls_type);
+ irp->segment_types[IR_SEGMENT_CONSTRUCTORS] = new_type_segment(IDENT("Constructors"), tf_constructors);
+ irp->segment_types[IR_SEGMENT_DESTRUCTORS] = new_type_segment(IDENT("Destructors"), tf_destructors);
/* The global type is a class, but we cannot derive from it, so set
the final property to assist optimizations that checks for it. */
}
+ir_type *new_type_segment(ident *const name, type_flags const flags)
+{
+ ir_type *const seg = new_type_class(name);
+ seg->flags |= tf_segment | flags;
+ set_class_final(seg, true);
+ return seg;
+}
+
ir_type *new_d_type_array(size_t n_dimensions, ir_type *element_type,
type_dbg_info *db)
} tp_attr;
/** Additional type flags. */
-enum type_flags {
+typedef enum type_flags {
tf_none = 0, /**< No flags. */
tf_lowered_type = 1U << 0, /**< Set if this is a lowered type. */
tf_layout_fixed = 1U << 1, /**< Set if the layout of a type is fixed */
tf_constructors = 1U << 6, /**< Set only for the constructors segment type */
tf_destructors = 1U << 7, /**< Set only for the destructors segment type */
tf_variable_size = 1U << 8, /**< compound or array type may have variable size last element */
-};
+} type_flags;
ENUM_BITSET(type_flags)
/**
method->attr.ma.irg_calling_conv = cc_mask;
}
+ir_type *new_type_segment(ident *name, type_flags flags);
+
#endif /* FIRM_TR_TYPE_T_H */