Move to Raw_* types to raw.odin; Add size and align members to Type_Info

This commit is contained in:
Ginger Bill
2017-04-07 14:05:28 +01:00
parent 70f9cacdce
commit 83ebb24015
6 changed files with 66 additions and 109 deletions
+18 -43
View File
@@ -3,6 +3,7 @@
#import "os.odin"; #import "os.odin";
#import "fmt.odin"; #import "fmt.odin";
#import "utf8.odin"; #import "utf8.odin";
#import "raw.odin";
// IMPORTANT NOTE(bill): `type_info` & `type_info_val` cannot be used within a // IMPORTANT NOTE(bill): `type_info` & `type_info_val` cannot be used within a
// #shared_global_scope due to the internals of the compiler. // #shared_global_scope due to the internals of the compiler.
@@ -36,11 +37,14 @@ Type_Info_Record :: struct #ordered {
} }
Type_Info :: union { Type_Info :: union {
size: int,
align: int,
Named{name: string, base: ^Type_Info}, Named{name: string, base: ^Type_Info},
Integer{size: int, signed: bool}, Integer{signed: bool},
Float{size: int}, Float{},
Complex{size: int}, Complex{},
Quaternion{size: int}, Quaternion{},
String{}, String{},
Boolean{}, Boolean{},
Any{}, Any{},
@@ -60,7 +64,7 @@ Type_Info :: union {
}, },
Dynamic_Array{elem: ^Type_Info, elem_size: int}, Dynamic_Array{elem: ^Type_Info, elem_size: int},
Slice {elem: ^Type_Info, elem_size: int}, Slice {elem: ^Type_Info, elem_size: int},
Vector {elem: ^Type_Info, elem_size, count, align: int}, Vector {elem: ^Type_Info, elem_size, count: int},
Tuple {using record: Type_Info_Record}, // Only really used for procedures Tuple {using record: Type_Info_Record}, // Only really used for procedures
Struct {using record: Type_Info_Record}, Struct {using record: Type_Info_Record},
Raw_Union {using record: Type_Info_Record}, Raw_Union {using record: Type_Info_Record},
@@ -72,8 +76,6 @@ Type_Info :: union {
}, },
variant_names: []string, variant_names: []string,
variant_types: []^Type_Info, variant_types: []^Type_Info,
size: int,
align: int,
}, },
Enum{ Enum{
base: ^Type_Info, base: ^Type_Info,
@@ -419,37 +421,10 @@ __abs_quaternion256 :: proc(x: quaternion256) -> f64 #inline {
Raw_Any :: struct #ordered {
type_info: ^Type_Info,
data: rawptr,
}
Raw_String :: struct #ordered {
data: ^byte,
len: int,
};
Raw_Slice :: struct #ordered {
data: rawptr,
len: int,
cap: int,
};
Raw_Dynamic_Array :: struct #ordered {
data: rawptr,
len: int,
cap: int,
allocator: Allocator,
};
Raw_Dynamic_Map :: struct #ordered {
hashes: [dynamic]int,
entries: Raw_Dynamic_Array,
};
__dynamic_array_make :: proc(array_: rawptr, elem_size, elem_align: int, len, cap: int) { __dynamic_array_make :: proc(array_: rawptr, elem_size, elem_align: int, len, cap: int) {
array := cast(^Raw_Dynamic_Array)array_; array := cast(^raw.Dynamic_Array)array_;
__check_context(); __check_context();
array.allocator = context.allocator; array.allocator = context.allocator;
assert(array.allocator.procedure != nil); assert(array.allocator.procedure != nil);
@@ -461,7 +436,7 @@ __dynamic_array_make :: proc(array_: rawptr, elem_size, elem_align: int, len, ca
} }
__dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap: int) -> bool { __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap: int) -> bool {
array := cast(^Raw_Dynamic_Array)array_; array := cast(^raw.Dynamic_Array)array_;
if cap <= array.cap { if cap <= array.cap {
return true; return true;
@@ -490,7 +465,7 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap:
__dynamic_array_append :: proc(array_: rawptr, elem_size, elem_align: int, __dynamic_array_append :: proc(array_: rawptr, elem_size, elem_align: int,
items: rawptr, item_count: int) -> int { items: rawptr, item_count: int) -> int {
array := cast(^Raw_Dynamic_Array)array_; array := cast(^raw.Dynamic_Array)array_;
if item_count <= 0 || items == nil { if item_count <= 0 || items == nil {
return array.len; return array.len;
@@ -514,7 +489,7 @@ __dynamic_array_append :: proc(array_: rawptr, elem_size, elem_align: int,
} }
__dynamic_array_append_nothing :: proc(array_: rawptr, elem_size, elem_align: int) -> int { __dynamic_array_append_nothing :: proc(array_: rawptr, elem_size, elem_align: int) -> int {
array := cast(^Raw_Dynamic_Array)array_; array := cast(^raw.Dynamic_Array)array_;
ok := true; ok := true;
if array.cap <= array.len+1 { if array.cap <= array.len+1 {
@@ -534,7 +509,7 @@ __dynamic_array_append_nothing :: proc(array_: rawptr, elem_size, elem_align: in
__slice_append :: proc(slice_: rawptr, elem_size, elem_align: int, __slice_append :: proc(slice_: rawptr, elem_size, elem_align: int,
items: rawptr, item_count: int) -> int { items: rawptr, item_count: int) -> int {
slice := cast(^Raw_Slice)slice_; slice := cast(^raw.Slice)slice_;
if item_count <= 0 || items == nil { if item_count <= 0 || items == nil {
return slice.len; return slice.len;
@@ -587,7 +562,7 @@ __Map_Entry_Header :: struct #ordered {
} }
__Map_Header :: struct #ordered { __Map_Header :: struct #ordered {
m: ^Raw_Dynamic_Map, m: ^raw.Dynamic_Map,
is_key_string: bool, is_key_string: bool,
entry_size: int, entry_size: int,
entry_align: int, entry_align: int,
@@ -602,11 +577,11 @@ __dynamic_map_reserve :: proc(using header: __Map_Header, cap: int) -> bool {
__dynamic_map_rehash :: proc(using header: __Map_Header, new_count: int) { __dynamic_map_rehash :: proc(using header: __Map_Header, new_count: int) {
new_header := header; new_header := header;
nm: Raw_Dynamic_Map; nm: raw.Dynamic_Map;
new_header.m = ^nm; new_header.m = ^nm;
header_hashes := cast(^Raw_Dynamic_Array)^header.m.hashes; header_hashes := cast(^raw.Dynamic_Array)^header.m.hashes;
nm_hashes := cast(^Raw_Dynamic_Array)^nm.hashes; nm_hashes := cast(^raw.Dynamic_Array)^nm.hashes;
reserve(nm.hashes, new_count); reserve(nm.hashes, new_count);
+13 -11
View File
@@ -3,6 +3,7 @@
#import "utf8.odin"; #import "utf8.odin";
#import "types.odin"; #import "types.odin";
#import "strconv.odin"; #import "strconv.odin";
#import "raw.odin";
_BUFFER_SIZE :: 1<<12; _BUFFER_SIZE :: 1<<12;
@@ -106,19 +107,19 @@ write_type :: proc(buf: ^[]byte, ti: ^Type_Info) {
} }
case Float: case Float:
match info.size { match 8*info.size {
case 4: write_string(buf, "f32"); case 32: write_string(buf, "f32");
case 8: write_string(buf, "f64"); case 64: write_string(buf, "f64");
} }
case Complex: case Complex:
match info.size { match 8*info.size {
case 8: write_string(buf, "complex64"); case 64: write_string(buf, "complex64");
case 16: write_string(buf, "complex128"); case 128: write_string(buf, "complex128");
} }
case Quaternion: case Quaternion:
match info.size { match 8*info.size {
case 16: write_string(buf, "quaternion128"); case 128: write_string(buf, "quaternion128");
case 32: write_string(buf, "quaternion"); case 256: write_string(buf, "quaternion256");
} }
case String: write_string(buf, "string"); case String: write_string(buf, "string");
case Boolean: write_string(buf, "bool"); case Boolean: write_string(buf, "bool");
@@ -388,6 +389,7 @@ int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) {
arg.type_info = type_info_base(arg.type_info); arg.type_info = type_info_base(arg.type_info);
match i in arg { match i in arg {
case int: num = i; case int: num = i;
case uint: num = cast(int)i;
case i8: num = cast(int)i; case i8: num = cast(int)i;
case i16: num = cast(int)i; case i16: num = cast(int)i;
case i32: num = cast(int)i; case i32: num = cast(int)i;
@@ -779,7 +781,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
write_byte(fi.buf, '['); write_byte(fi.buf, '[');
defer write_byte(fi.buf, ']'); defer write_byte(fi.buf, ']');
array := cast(^Raw_Dynamic_Array)v.data; array := cast(^raw.Dynamic_Array)v.data;
for i in 0..array.len { for i in 0..array.len {
if i > 0 { if i > 0 {
write_string(fi.buf, ", "); write_string(fi.buf, ", ");
@@ -796,7 +798,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
write_string(fi.buf, "map["); write_string(fi.buf, "map[");
defer write_byte(fi.buf, ']'); defer write_byte(fi.buf, ']');
entries := ^(cast(^Raw_Dynamic_Map)v.data).entries; entries := ^(cast(^raw.Dynamic_Map)v.data).entries;
gs := union_cast(^Struct)type_info_base(info.generated_struct); gs := union_cast(^Struct)type_info_base(info.generated_struct);
ed := union_cast(^Dynamic_Array)type_info_base(gs.types[1]); ed := union_cast(^Dynamic_Array)type_info_base(gs.types[1]);
-6
View File
@@ -1229,12 +1229,6 @@ void init_preload(Checker *c) {
t_context_ptr = make_type_pointer(c->allocator, t_context); t_context_ptr = make_type_pointer(c->allocator, t_context);
} }
if (t_raw_dynamic_array == NULL) {
Entity *e = find_core_entity(c, str_lit("Raw_Dynamic_Array"));
t_raw_dynamic_array = e->type;
t_raw_dynamic_array = make_type_pointer(c->allocator, t_raw_dynamic_array);
}
if (t_map_key == NULL) { if (t_map_key == NULL) {
Entity *e = find_core_entity(c, str_lit("__Map_Key")); Entity *e = find_core_entity(c, str_lit("__Map_Key"));
t_map_key = e->type; t_map_key = e->type;
+34 -46
View File
@@ -7077,6 +7077,9 @@ void ir_gen_tree(irGen *s) {
irValue *tag = NULL; irValue *tag = NULL;
irValue *ti_ptr = ir_emit_array_epi(proc, ir_global_type_info_data, entry_index); irValue *ti_ptr = ir_emit_array_epi(proc, ir_global_type_info_data, entry_index);
ir_emit_store(proc, ir_emit_struct_ep(proc, ti_ptr, 0), ir_const_int(a, type_size_of(a, t)));
ir_emit_store(proc, ir_emit_struct_ep(proc, ti_ptr, 1), ir_const_int(a, type_align_of(a, t)));
switch (t->kind) { switch (t->kind) {
case Type_Named: { case Type_Named: {
@@ -7087,8 +7090,8 @@ void ir_gen_tree(irGen *s) {
irValue *name = ir_const_string(a, t->Named.type_name->token.string); irValue *name = ir_const_string(a, t->Named.type_name->token.string);
irValue *gtip = ir_get_type_info_ptr(proc, t->Named.base); irValue *gtip = ir_get_type_info_ptr(proc, t->Named.base);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), name); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), name);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 1), gtip); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), gtip);
} break; } break;
case Type_Basic: case Type_Basic:
@@ -7109,31 +7112,23 @@ void ir_gen_tree(irGen *s) {
case Basic_uint: { case Basic_uint: {
tag = ir_emit_conv(proc, ti_ptr, t_type_info_integer_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_integer_ptr);
bool is_unsigned = (t->Basic.flags & BasicFlag_Unsigned) != 0; bool is_unsigned = (t->Basic.flags & BasicFlag_Unsigned) != 0;
irValue *bits = ir_const_int(a, type_size_of(a, t));
irValue *is_signed = ir_const_bool(a, !is_unsigned); irValue *is_signed = ir_const_bool(a, !is_unsigned);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), bits); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), is_signed);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 1), is_signed);
} break; } break;
case Basic_f32: case Basic_f32:
case Basic_f64: { case Basic_f64: {
tag = ir_emit_conv(proc, ti_ptr, t_type_info_float_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_float_ptr);
irValue *bits = ir_const_int(a, type_size_of(a, t));
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), bits);
} break; } break;
case Basic_complex64: case Basic_complex64:
case Basic_complex128: { case Basic_complex128: {
tag = ir_emit_conv(proc, ti_ptr, t_type_info_complex_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_complex_ptr);
irValue *bits = ir_const_int(a, type_size_of(a, t));
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), bits);
} break; } break;
case Basic_quaternion128: case Basic_quaternion128:
case Basic_quaternion256: { case Basic_quaternion256: {
tag = ir_emit_conv(proc, ti_ptr, t_type_info_quaternion_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_quaternion_ptr);
irValue *bits = ir_const_int(a, type_size_of(a, t));
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), bits);
} break; } break;
case Basic_rawptr: case Basic_rawptr:
@@ -7154,19 +7149,19 @@ void ir_gen_tree(irGen *s) {
ir_emit_comment(proc, str_lit("Type_Info_Pointer")); ir_emit_comment(proc, str_lit("Type_Info_Pointer"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_pointer_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_pointer_ptr);
irValue *gep = ir_get_type_info_ptr(proc, t->Pointer.elem); irValue *gep = ir_get_type_info_ptr(proc, t->Pointer.elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), gep); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), gep);
} break; } break;
case Type_Array: { case Type_Array: {
ir_emit_comment(proc, str_lit("Type_Info_Array")); ir_emit_comment(proc, str_lit("Type_Info_Array"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_array_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_array_ptr);
irValue *gep = ir_get_type_info_ptr(proc, t->Array.elem); irValue *gep = ir_get_type_info_ptr(proc, t->Array.elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), gep); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), gep);
isize ez = type_size_of(a, t->Array.elem); isize ez = type_size_of(a, t->Array.elem);
irValue *elem_size = ir_emit_struct_ep(proc, tag, 1); irValue *elem_size = ir_emit_struct_ep(proc, tag, 3);
ir_emit_store(proc, elem_size, ir_const_int(a, ez)); ir_emit_store(proc, elem_size, ir_const_int(a, ez));
irValue *count = ir_emit_struct_ep(proc, tag, 2); irValue *count = ir_emit_struct_ep(proc, tag, 4);
ir_emit_store(proc, count, ir_const_int(a, t->Array.count)); ir_emit_store(proc, count, ir_const_int(a, t->Array.count));
} break; } break;
@@ -7174,42 +7169,41 @@ void ir_gen_tree(irGen *s) {
ir_emit_comment(proc, str_lit("Type_Info_DynamicArray")); ir_emit_comment(proc, str_lit("Type_Info_DynamicArray"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_dynamic_array_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_dynamic_array_ptr);
irValue *gep = ir_get_type_info_ptr(proc, t->DynamicArray.elem); irValue *gep = ir_get_type_info_ptr(proc, t->DynamicArray.elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), gep); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), gep);
isize ez = type_size_of(a, t->DynamicArray.elem); isize ez = type_size_of(a, t->DynamicArray.elem);
irValue *elem_size = ir_emit_struct_ep(proc, tag, 1); irValue *elem_size = ir_emit_struct_ep(proc, tag, 3);
ir_emit_store(proc, elem_size, ir_const_int(a, ez)); ir_emit_store(proc, elem_size, ir_const_int(a, ez));
} break; } break;
case Type_Slice: { case Type_Slice: {
ir_emit_comment(proc, str_lit("Type_Info_Slice")); ir_emit_comment(proc, str_lit("Type_Info_Slice"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_slice_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_slice_ptr);
irValue *gep = ir_get_type_info_ptr(proc, t->Slice.elem); irValue *gep = ir_get_type_info_ptr(proc, t->Slice.elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), gep); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), gep);
isize ez = type_size_of(a, t->Slice.elem); isize ez = type_size_of(a, t->Slice.elem);
irValue *elem_size = ir_emit_struct_ep(proc, tag, 1); irValue *elem_size = ir_emit_struct_ep(proc, tag, 3);
ir_emit_store(proc, elem_size, ir_const_int(a, ez)); ir_emit_store(proc, elem_size, ir_const_int(a, ez));
} break; } break;
case Type_Vector: { case Type_Vector: {
ir_emit_comment(proc, str_lit("Type_Info_Vector")); ir_emit_comment(proc, str_lit("Type_Info_Vector"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_vector_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_vector_ptr);
irValue *gep = ir_get_type_info_ptr(proc, t->Vector.elem); irValue *gep = ir_get_type_info_ptr(proc, t->Vector.elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), gep); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), gep);
isize ez = type_size_of(a, t->Vector.elem); isize ez = type_size_of(a, t->Vector.elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 1), ir_const_int(a, ez)); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), ir_const_int(a, ez));
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), ir_const_int(a, t->Vector.count)); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 4), ir_const_int(a, t->Vector.count));
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), ir_const_int(a, type_align_of(a, t)));
} break; } break;
case Type_Proc: { case Type_Proc: {
ir_emit_comment(proc, str_lit("Type_Info_Proc")); ir_emit_comment(proc, str_lit("Type_Info_Proc"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_procedure_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_procedure_ptr);
irValue *params = ir_emit_struct_ep(proc, tag, 0); irValue *params = ir_emit_struct_ep(proc, tag, 2);
irValue *results = ir_emit_struct_ep(proc, tag, 1); irValue *results = ir_emit_struct_ep(proc, tag, 3);
irValue *variadic = ir_emit_struct_ep(proc, tag, 2); irValue *variadic = ir_emit_struct_ep(proc, tag, 4);
irValue *convention = ir_emit_struct_ep(proc, tag, 3); irValue *convention = ir_emit_struct_ep(proc, tag, 5);
if (t->Proc.params != NULL) { if (t->Proc.params != NULL) {
ir_emit_store(proc, params, ir_get_type_info_ptr(proc, t->Proc.params)); ir_emit_store(proc, params, ir_get_type_info_ptr(proc, t->Proc.params));
@@ -7225,7 +7219,7 @@ void ir_gen_tree(irGen *s) {
case Type_Tuple: { case Type_Tuple: {
ir_emit_comment(proc, str_lit("Type_Info_Tuple")); ir_emit_comment(proc, str_lit("Type_Info_Tuple"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_tuple_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_tuple_ptr);
irValue *record = ir_emit_struct_ep(proc, tag, 0); irValue *record = ir_emit_struct_ep(proc, tag, 2);
{ {
irValue *align = ir_const_int(a, type_align_of(a, t)); irValue *align = ir_const_int(a, type_align_of(a, t));
@@ -7258,7 +7252,7 @@ void ir_gen_tree(irGen *s) {
case TypeRecord_Struct: { case TypeRecord_Struct: {
ir_emit_comment(proc, str_lit("Type_Info_Struct")); ir_emit_comment(proc, str_lit("Type_Info_Struct"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_struct_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_struct_ptr);
irValue *record = ir_emit_struct_ep(proc, tag, 0); irValue *record = ir_emit_struct_ep(proc, tag, 2);
{ {
irValue *size = ir_const_int(a, type_size_of(a, t)); irValue *size = ir_const_int(a, type_size_of(a, t));
@@ -7305,15 +7299,9 @@ void ir_gen_tree(irGen *s) {
case TypeRecord_Union: { case TypeRecord_Union: {
ir_emit_comment(proc, str_lit("Type_Info_Union")); ir_emit_comment(proc, str_lit("Type_Info_Union"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_union_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_union_ptr);
{
irValue *size = ir_const_int(a, type_size_of(a, t));
irValue *align = ir_const_int(a, type_align_of(a, t));
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), size);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 4), align);
}
{ {
irValue *common_fields = ir_emit_struct_ep(proc, tag, 0); irValue *common_fields = ir_emit_struct_ep(proc, tag, 2);
isize field_count = t->Record.field_count; isize field_count = t->Record.field_count;
irValue *memory_types = ir_type_info_member_types_offset(proc, field_count); irValue *memory_types = ir_type_info_member_types_offset(proc, field_count);
@@ -7348,8 +7336,8 @@ void ir_gen_tree(irGen *s) {
} }
{ {
irValue *variant_names = ir_emit_struct_ep(proc, tag, 1); irValue *variant_names = ir_emit_struct_ep(proc, tag, 3);
irValue *variant_types = ir_emit_struct_ep(proc, tag, 2); irValue *variant_types = ir_emit_struct_ep(proc, tag, 4);
isize variant_count = gb_max(0, t->Record.variant_count-1); isize variant_count = gb_max(0, t->Record.variant_count-1);
irValue *memory_names = ir_type_info_member_names_offset(proc, variant_count); irValue *memory_names = ir_type_info_member_names_offset(proc, variant_count);
@@ -7379,7 +7367,7 @@ void ir_gen_tree(irGen *s) {
case TypeRecord_RawUnion: { case TypeRecord_RawUnion: {
ir_emit_comment(proc, str_lit("Type_Info_RawUnion")); ir_emit_comment(proc, str_lit("Type_Info_RawUnion"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_raw_union_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_raw_union_ptr);
irValue *record = ir_emit_struct_ep(proc, tag, 0); irValue *record = ir_emit_struct_ep(proc, tag, 2);
{ {
irValue *size = ir_const_int(a, type_size_of(a, t)); irValue *size = ir_const_int(a, type_size_of(a, t));
@@ -7416,7 +7404,7 @@ void ir_gen_tree(irGen *s) {
{ {
GB_ASSERT(t->Record.enum_base_type != NULL); GB_ASSERT(t->Record.enum_base_type != NULL);
irValue *base = ir_type_info(proc, t->Record.enum_base_type); irValue *base = ir_type_info(proc, t->Record.enum_base_type);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), base); ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 2), base);
if (t->Record.field_count > 0) { if (t->Record.field_count > 0) {
Entity **fields = t->Record.fields; Entity **fields = t->Record.fields;
@@ -7450,13 +7438,13 @@ void ir_gen_tree(irGen *s) {
irValue *v_count = ir_const_int(a, count); irValue *v_count = ir_const_int(a, count);
irValue *names = ir_emit_struct_ep(proc, tag, 1); irValue *names = ir_emit_struct_ep(proc, tag, 3);
irValue *name_array_elem = ir_array_elem(proc, name_array); irValue *name_array_elem = ir_array_elem(proc, name_array);
ir_emit_store(proc, ir_emit_struct_ep(proc, names, 0), name_array_elem); ir_emit_store(proc, ir_emit_struct_ep(proc, names, 0), name_array_elem);
ir_emit_store(proc, ir_emit_struct_ep(proc, names, 1), v_count); ir_emit_store(proc, ir_emit_struct_ep(proc, names, 1), v_count);
irValue *values = ir_emit_struct_ep(proc, tag, 2); irValue *values = ir_emit_struct_ep(proc, tag, 4);
irValue *value_array_elem = ir_array_elem(proc, value_array); irValue *value_array_elem = ir_array_elem(proc, value_array);
ir_emit_store(proc, ir_emit_struct_ep(proc, values, 0), value_array_elem); ir_emit_store(proc, ir_emit_struct_ep(proc, values, 0), value_array_elem);
@@ -7470,10 +7458,10 @@ void ir_gen_tree(irGen *s) {
ir_emit_comment(proc, str_lit("Type_Info_Map")); ir_emit_comment(proc, str_lit("Type_Info_Map"));
tag = ir_emit_conv(proc, ti_ptr, t_type_info_map_ptr); tag = ir_emit_conv(proc, ti_ptr, t_type_info_map_ptr);
irValue *key = ir_emit_struct_ep(proc, tag, 0); irValue *key = ir_emit_struct_ep(proc, tag, 2);
irValue *value = ir_emit_struct_ep(proc, tag, 1); irValue *value = ir_emit_struct_ep(proc, tag, 3);
irValue *generated_struct = ir_emit_struct_ep(proc, tag, 2); irValue *generated_struct = ir_emit_struct_ep(proc, tag, 4);
irValue *count = ir_emit_struct_ep(proc, tag, 3); irValue *count = ir_emit_struct_ep(proc, tag, 5);
ir_emit_store(proc, key, ir_get_type_info_ptr(proc, t->Map.key)); ir_emit_store(proc, key, ir_get_type_info_ptr(proc, t->Map.key));
ir_emit_store(proc, value, ir_get_type_info_ptr(proc, t->Map.value)); ir_emit_store(proc, value, ir_get_type_info_ptr(proc, t->Map.value));
+1 -1
View File
@@ -643,7 +643,7 @@ void ir_print_value(irFileBuffer *f, irModule *m, irValue *value, Type *type_hin
ir_print_type(f, m, t_int); ir_print_type(f, m, t_int);
ir_fprintf(f, " 0, i32 0), "); ir_fprintf(f, " 0, i32 0), ");
ir_print_type(f, m, t_int); ir_print_type(f, m, t_int);
ir_fprintf(f, " %lld}", cs->count); ir_fprintf(f, " %lld, %lld}", cs->count, cs->count);
} }
} break; } break;
-2
View File
@@ -349,8 +349,6 @@ gb_global Type *t_allocator_ptr = NULL;
gb_global Type *t_context = NULL; gb_global Type *t_context = NULL;
gb_global Type *t_context_ptr = NULL; gb_global Type *t_context_ptr = NULL;
gb_global Type *t_raw_dynamic_array = NULL;
gb_global Type *t_raw_dynamic_array_ptr = NULL;
gb_global Type *t_map_key = NULL; gb_global Type *t_map_key = NULL;
gb_global Type *t_map_header = NULL; gb_global Type *t_map_header = NULL;