Commit 0aec06e4 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

tr: Add and use new_type_segment().

In particular this ensures that the backend has segments for the PIC symbols and trampolines.
parent 00b25900
......@@ -403,9 +403,9 @@ static be_main_env_t *be_init_env(be_main_env_t *const env, char const *const co
{
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();
......
......@@ -79,20 +79,10 @@ static void complete_ir_prog(ir_prog *irp, const char *module_name)
#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. */
......
......@@ -1417,6 +1417,14 @@ void set_union_size(ir_type *tp, unsigned size)
}
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)
......
......@@ -174,7 +174,7 @@ typedef union {
} 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 */
......@@ -186,7 +186,7 @@ enum type_flags {
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)
/**
......@@ -575,4 +575,6 @@ static inline void _set_method_calling_convention(ir_type *method, unsigned cc_m
method->attr.ma.irg_calling_conv = cc_mask;
}
ir_type *new_type_segment(ident *name, type_flags flags);
#endif /* FIRM_TR_TYPE_T_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment