mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Reduce type info data size in IR
This commit is contained in:
+1
-1
@@ -1132,7 +1132,7 @@ __dynamic_map_delete :: proc(using h: __Map_Header, key: __Map_Key) {
|
|||||||
|
|
||||||
__dynamic_map_get_entry :: proc(using h: __Map_Header, index: int) -> ^__Map_Entry_Header {
|
__dynamic_map_get_entry :: proc(using h: __Map_Header, index: int) -> ^__Map_Entry_Header {
|
||||||
assert(0 <= index && index < m.entries.len);
|
assert(0 <= index && index < m.entries.len);
|
||||||
return cast(^__Map_Entry_Header)(cast(^byte)m.entries.data + index*entry_size);
|
return cast(^__Map_Entry_Header)(uintptr(m.entries.data) + uintptr(index*entry_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
__dynamic_map_erase :: proc(using h: __Map_Header, fr: __Map_Find_Result) {
|
__dynamic_map_erase :: proc(using h: __Map_Header, fr: __Map_Find_Result) {
|
||||||
|
|||||||
+4
-15
@@ -7628,22 +7628,12 @@ void ir_init_module(irModule *m, Checker *c) {
|
|||||||
{
|
{
|
||||||
// Add type info data
|
// Add type info data
|
||||||
{
|
{
|
||||||
isize max_index = -1;
|
isize max_type_info_count = m->info->type_info_types.count;
|
||||||
for_array(type_info_map_index, m->info->type_info_map.entries) {
|
|
||||||
auto *entry = &m->info->type_info_map.entries[type_info_map_index];
|
|
||||||
Type *t = cast(Type *)entry->key.ptr;
|
|
||||||
t = default_type(t);
|
|
||||||
isize entry_index = type_info_index(m->info, t);
|
|
||||||
if (max_index < entry_index) {
|
|
||||||
max_index = entry_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isize max_type_info_count = max_index+1;
|
|
||||||
|
|
||||||
String name = str_lit(IR_TYPE_INFO_DATA_NAME);
|
String name = str_lit(IR_TYPE_INFO_DATA_NAME);
|
||||||
Entity *e = make_entity_variable(m->allocator, nullptr, make_token_ident(name), make_type_array(m->allocator, t_type_info, max_type_info_count), false);
|
Entity *e = make_entity_variable(m->allocator, nullptr, make_token_ident(name), make_type_array(m->allocator, t_type_info, max_type_info_count), false);
|
||||||
irValue *g = ir_value_global(m->allocator, e, nullptr);
|
irValue *g = ir_value_global(m->allocator, e, nullptr);
|
||||||
g->Global.is_private = true;
|
g->Global.is_private = true;
|
||||||
ir_module_add_value(m, e, g);
|
ir_module_add_value(m, e, g);
|
||||||
map_set(&m->members, hash_string(name), g);
|
map_set(&m->members, hash_string(name), g);
|
||||||
ir_global_type_info_data = g;
|
ir_global_type_info_data = g;
|
||||||
@@ -7654,9 +7644,8 @@ void ir_init_module(irModule *m, Checker *c) {
|
|||||||
// NOTE(bill): Removes need for heap allocation by making it global memory
|
// NOTE(bill): Removes need for heap allocation by making it global memory
|
||||||
isize count = 0;
|
isize count = 0;
|
||||||
|
|
||||||
for_array(entry_index, m->info->type_info_map.entries) {
|
for_array(entry_index, m->info->type_info_types) {
|
||||||
auto *entry = &m->info->type_info_map.entries[entry_index];
|
Type *t = m->info->type_info_types[entry_index];
|
||||||
Type *t = cast(Type *)entry->key.ptr;
|
|
||||||
|
|
||||||
switch (t->kind) {
|
switch (t->kind) {
|
||||||
case Type_Union:
|
case Type_Union:
|
||||||
|
|||||||
Reference in New Issue
Block a user