-#define X(s) s, sizeof(s)-1
- irp->name = new_id_from_chars(X(INITAL_PROG_NAME));
-
- irp->glob_type = new_type_class(new_id_from_chars(X(GLOBAL_TYPE_NAME)));
- irp->tls_type = new_type_struct(new_id_from_chars(X(TLS_TYPE_NAME)));
- /* Remove these types from type list. Must be treated differently than
- other types. */
- remove_irp_type(irp->glob_type);
- remove_irp_type(irp->tls_type);
-
- /* set these flags for debugging */
- irp->glob_type->flags |= tf_global_type;
- irp->tls_type->flags |= tf_tls_type;
-
- irp->const_code_irg = new_const_code_irg();
-
- irp->phase_state = phase_building;
- irp->outs_state = outs_none;
- irp->ip_outedges = NULL;
- irp->trouts_state = outs_none;
- irp->class_cast_state = ir_class_casts_transitive;
-
- return irp;
-}
-
-/* initializes ir_prog. Constructs only the basic lists */
+ int i;
+#define IDENT(s) new_id_from_chars(s, sizeof(s)-1)
+
+ irp->name = IDENT(INITAL_PROG_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_struct(IDENT("Constructors"));
+ irp->segment_types[IR_SEGMENT_DESTRUCTORS]
+ = new_type_struct(IDENT("Destructors"));
+ /* Remove these types from type list. Must be treated differently than
+ other types. */
+ for (i = 0; i < IR_SEGMENT_COUNT; ++i) {
+ remove_irp_type(irp->segment_types[i]);
+ }
+
+ /* Set these flags for debugging. */
+ irp->segment_types[IR_SEGMENT_GLOBAL]->flags |= tf_global_type;
+ irp->segment_types[IR_SEGMENT_THREAD_LOCAL]->flags |= tf_tls_type;
+
+ /* The global type is a class, but we cannot derive from it, so set
+ the final property to assist optimizations that checks for it. */
+ set_class_final(irp->segment_types[IR_SEGMENT_GLOBAL], 1);
+
+ irp->const_code_irg = new_const_code_irg();
+
+ irp->phase_state = phase_building;
+ irp->outs_state = outs_none;
+ irp->ip_outedges = NULL;
+ irp->trouts_state = outs_none;
+ irp->class_cast_state = ir_class_casts_transitive;
+ irp->globals_adr_taken_state = ir_address_taken_not_computed;
+
+ return irp;
+#undef IDENT
+}
+
+/* initializes ir_prog. Constructs only the basic lists. */