mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Change type info table to be initializable constantly
[]Type_Info -> []^Type_Info
This commit is contained in:
@@ -280,7 +280,7 @@ Typeid_Kind :: enum u8 {
|
|||||||
|
|
||||||
// NOTE(bill): only the ones that are needed (not all types)
|
// NOTE(bill): only the ones that are needed (not all types)
|
||||||
// This will be set by the compiler
|
// This will be set by the compiler
|
||||||
type_table: []Type_Info
|
type_table: []^Type_Info
|
||||||
|
|
||||||
args__: []cstring
|
args__: []cstring
|
||||||
|
|
||||||
@@ -609,7 +609,7 @@ __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info #no_bounds_check
|
|||||||
if n < 0 || n >= len(type_table) {
|
if n < 0 || n >= len(type_table) {
|
||||||
n = 0
|
n = 0
|
||||||
}
|
}
|
||||||
return &type_table[n]
|
return type_table[n]
|
||||||
}
|
}
|
||||||
|
|
||||||
when !ODIN_NO_RTTI {
|
when !ODIN_NO_RTTI {
|
||||||
|
|||||||
+5
-14
@@ -1069,10 +1069,6 @@ gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) {
|
|||||||
// lb_add_attribute_to_proc(p->module, p->value, "norecurse");
|
// lb_add_attribute_to_proc(p->module, p->value, "norecurse");
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "nosync");
|
// lb_add_attribute_to_proc(p->module, p->value, "nosync");
|
||||||
// lb_add_attribute_to_proc(p->module, p->value, "willreturn");
|
// lb_add_attribute_to_proc(p->module, p->value, "willreturn");
|
||||||
if (!LB_USE_GIANT_PACKED_STRUCT) {
|
|
||||||
lb_add_attribute_to_proc(m, p->value, "optnone");
|
|
||||||
lb_add_attribute_to_proc(m, p->value, "noinline");
|
|
||||||
}
|
|
||||||
|
|
||||||
lb_begin_procedure_body(p);
|
lb_begin_procedure_body(p);
|
||||||
|
|
||||||
@@ -2691,17 +2687,19 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
|
|
||||||
{ // Add type info data
|
{ // Add type info data
|
||||||
isize max_type_info_count = info->minimum_dependency_type_info_set.count+1;
|
isize max_type_info_count = info->minimum_dependency_type_info_set.count+1;
|
||||||
Type *t = alloc_type_array(t_type_info, max_type_info_count);
|
Type *t = alloc_type_array(t_type_info_ptr, max_type_info_count);
|
||||||
|
|
||||||
// IMPORTANT NOTE(bill): As LLVM does not have a union type, an array of unions cannot be initialized
|
// IMPORTANT NOTE(bill): As LLVM does not have a union type, an array of unions cannot be initialized
|
||||||
// at compile time without cheating in some way. This means to emulate an array of unions is to use
|
// at compile time without cheating in some way. This means to emulate an array of unions is to use
|
||||||
// a giant packed struct of "corrected" data types.
|
// a giant packed struct of "corrected" data types.
|
||||||
|
|
||||||
LLVMTypeRef internal_llvm_type = lb_setup_type_info_data_internal_type(m, max_type_info_count);
|
LLVMTypeRef internal_llvm_type = lb_type(m, t);
|
||||||
|
|
||||||
LLVMValueRef g = LLVMAddGlobal(m->mod, internal_llvm_type, LB_TYPE_INFO_DATA_NAME);
|
LLVMValueRef g = LLVMAddGlobal(m->mod, internal_llvm_type, LB_TYPE_INFO_DATA_NAME);
|
||||||
LLVMSetInitializer(g, LLVMConstNull(internal_llvm_type));
|
LLVMSetInitializer(g, LLVMConstNull(internal_llvm_type));
|
||||||
LLVMSetLinkage(g, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage);
|
LLVMSetLinkage(g, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage);
|
||||||
|
LLVMSetUnnamedAddress(g, LLVMGlobalUnnamedAddr);
|
||||||
|
LLVMSetGlobalConstant(g, /*true*/false);
|
||||||
|
|
||||||
lbValue value = {};
|
lbValue value = {};
|
||||||
value.value = g;
|
value.value = g;
|
||||||
@@ -2710,11 +2708,6 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
lb_global_type_info_data_entity = alloc_entity_variable(nullptr, make_token_ident(LB_TYPE_INFO_DATA_NAME), t, EntityState_Resolved);
|
lb_global_type_info_data_entity = alloc_entity_variable(nullptr, make_token_ident(LB_TYPE_INFO_DATA_NAME), t, EntityState_Resolved);
|
||||||
lb_add_entity(m, lb_global_type_info_data_entity, value);
|
lb_add_entity(m, lb_global_type_info_data_entity, value);
|
||||||
|
|
||||||
if (LB_USE_GIANT_PACKED_STRUCT) {
|
|
||||||
LLVMSetLinkage(g, LLVMPrivateLinkage);
|
|
||||||
LLVMSetUnnamedAddress(g, LLVMGlobalUnnamedAddr);
|
|
||||||
LLVMSetGlobalConstant(g, /*true*/false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{ // Type info member buffer
|
{ // Type info member buffer
|
||||||
// NOTE(bill): Removes need for heap allocation by making it global memory
|
// NOTE(bill): Removes need for heap allocation by making it global memory
|
||||||
@@ -2750,9 +2743,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
|||||||
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
|
LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), name);
|
||||||
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
|
LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t)));
|
||||||
LLVMSetLinkage(g, LLVMInternalLinkage);
|
LLVMSetLinkage(g, LLVMInternalLinkage);
|
||||||
if (LB_USE_GIANT_PACKED_STRUCT) {
|
lb_make_global_private_const(g);
|
||||||
lb_make_global_private_const(g);
|
|
||||||
}
|
|
||||||
return lb_addr({g, alloc_type_pointer(t)});
|
return lb_addr({g, alloc_type_pointer(t)});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+85
-903
File diff suppressed because it is too large
Load Diff
@@ -365,6 +365,9 @@ enum Typeid_Kind : u8 {
|
|||||||
Typeid_Matrix,
|
Typeid_Matrix,
|
||||||
Typeid_SoaPointer,
|
Typeid_SoaPointer,
|
||||||
Typeid_Bit_Field,
|
Typeid_Bit_Field,
|
||||||
|
|
||||||
|
Typeid__COUNT
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// IMPORTANT NOTE(bill): This must match the same as the in core.odin
|
// IMPORTANT NOTE(bill): This must match the same as the in core.odin
|
||||||
|
|||||||
Reference in New Issue
Block a user