mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-05 20:48:04 +00:00
Begin work on separating int and word sizes (i.e. size_of(int) might not equal size_of(uintptr))
This commit is contained in:
@@ -425,7 +425,7 @@ Raw_Map :: struct {
|
||||
// Map_Hash directly, though for consistency sake it's written as if it were
|
||||
// an array of Map_Cell(Map_Hash).
|
||||
data: uintptr, // 8-bytes on 64-bits, 4-bytes on 32-bits
|
||||
len: int, // 8-bytes on 64-bits, 4-bytes on 32-bits
|
||||
len: uintptr, // 8-bytes on 64-bits, 4-bytes on 32-bits
|
||||
allocator: Allocator, // 16-bytes on 64-bits, 8-bytes on 32-bits
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ map_cell_index_static :: #force_inline proc "contextless" (cells: [^]Map_Cell($T
|
||||
// len() for map
|
||||
@(require_results)
|
||||
map_len :: #force_inline proc "contextless" (m: Raw_Map) -> int {
|
||||
return m.len
|
||||
return int(m.len)
|
||||
}
|
||||
|
||||
// cap() for map
|
||||
@@ -207,8 +207,8 @@ map_load_factor :: #force_inline proc "contextless" (log2_capacity: uintptr) ->
|
||||
}
|
||||
|
||||
@(require_results)
|
||||
map_resize_threshold :: #force_inline proc "contextless" (m: Raw_Map) -> int {
|
||||
return int(map_load_factor(map_log2_cap(m)))
|
||||
map_resize_threshold :: #force_inline proc "contextless" (m: Raw_Map) -> uintptr {
|
||||
return map_load_factor(map_log2_cap(m))
|
||||
}
|
||||
|
||||
// The data stores the log2 capacity in the lower six bits. This is primarily
|
||||
|
||||
@@ -117,6 +117,7 @@ struct TargetMetrics {
|
||||
TargetOsKind os;
|
||||
TargetArchKind arch;
|
||||
isize word_size;
|
||||
isize int_size;
|
||||
isize max_align;
|
||||
isize max_simd_align;
|
||||
String target_triplet;
|
||||
@@ -238,6 +239,7 @@ struct BuildContext {
|
||||
|
||||
// In bytes
|
||||
i64 word_size; // Size of a pointer, must be >= 4
|
||||
i64 int_size; // Size of a int/uint, must be >= 4
|
||||
i64 max_align; // max alignment, must be >= 1 (and typically >= word_size)
|
||||
i64 max_simd_align; // max alignment, must be >= 1 (and typically >= word_size)
|
||||
|
||||
@@ -360,13 +362,13 @@ gb_internal isize MAX_ERROR_COLLECTOR_COUNT(void) {
|
||||
gb_global TargetMetrics target_windows_i386 = {
|
||||
TargetOs_windows,
|
||||
TargetArch_i386,
|
||||
4, 4, 8,
|
||||
4, 4, 4, 8,
|
||||
str_lit("i386-pc-windows-msvc"),
|
||||
};
|
||||
gb_global TargetMetrics target_windows_amd64 = {
|
||||
TargetOs_windows,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-pc-windows-msvc"),
|
||||
str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
};
|
||||
@@ -374,21 +376,21 @@ gb_global TargetMetrics target_windows_amd64 = {
|
||||
gb_global TargetMetrics target_linux_i386 = {
|
||||
TargetOs_linux,
|
||||
TargetArch_i386,
|
||||
4, 4, 8,
|
||||
4, 4, 4, 8,
|
||||
str_lit("i386-pc-linux-gnu"),
|
||||
|
||||
};
|
||||
gb_global TargetMetrics target_linux_amd64 = {
|
||||
TargetOs_linux,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-pc-linux-gnu"),
|
||||
str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
};
|
||||
gb_global TargetMetrics target_linux_arm64 = {
|
||||
TargetOs_linux,
|
||||
TargetArch_arm64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("aarch64-linux-elf"),
|
||||
str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"),
|
||||
};
|
||||
@@ -396,7 +398,7 @@ gb_global TargetMetrics target_linux_arm64 = {
|
||||
gb_global TargetMetrics target_linux_arm32 = {
|
||||
TargetOs_linux,
|
||||
TargetArch_arm32,
|
||||
4, 4, 8,
|
||||
4, 4, 4, 8,
|
||||
str_lit("arm-linux-gnu"),
|
||||
str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"),
|
||||
};
|
||||
@@ -404,7 +406,7 @@ gb_global TargetMetrics target_linux_arm32 = {
|
||||
gb_global TargetMetrics target_darwin_amd64 = {
|
||||
TargetOs_darwin,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-apple-darwin"),
|
||||
str_lit("e-m:o-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
};
|
||||
@@ -412,7 +414,7 @@ gb_global TargetMetrics target_darwin_amd64 = {
|
||||
gb_global TargetMetrics target_darwin_arm64 = {
|
||||
TargetOs_darwin,
|
||||
TargetArch_arm64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("arm64-apple-macosx11.0.0"),
|
||||
str_lit("e-m:o-i64:64-i128:128-n32:64-S128"),
|
||||
};
|
||||
@@ -420,14 +422,14 @@ gb_global TargetMetrics target_darwin_arm64 = {
|
||||
gb_global TargetMetrics target_freebsd_i386 = {
|
||||
TargetOs_freebsd,
|
||||
TargetArch_i386,
|
||||
4, 4, 8,
|
||||
4, 4, 4, 8,
|
||||
str_lit("i386-unknown-freebsd-elf"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_freebsd_amd64 = {
|
||||
TargetOs_freebsd,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-unknown-freebsd-elf"),
|
||||
str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
};
|
||||
@@ -435,7 +437,7 @@ gb_global TargetMetrics target_freebsd_amd64 = {
|
||||
gb_global TargetMetrics target_openbsd_amd64 = {
|
||||
TargetOs_openbsd,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-unknown-openbsd-elf"),
|
||||
str_lit("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
};
|
||||
@@ -443,7 +445,7 @@ gb_global TargetMetrics target_openbsd_amd64 = {
|
||||
gb_global TargetMetrics target_essence_amd64 = {
|
||||
TargetOs_essence,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-pc-none-elf"),
|
||||
};
|
||||
|
||||
@@ -451,7 +453,7 @@ gb_global TargetMetrics target_essence_amd64 = {
|
||||
gb_global TargetMetrics target_freestanding_wasm32 = {
|
||||
TargetOs_freestanding,
|
||||
TargetArch_wasm32,
|
||||
4, 8, 16,
|
||||
4, 4, 8, 16,
|
||||
str_lit("wasm32-freestanding-js"),
|
||||
str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"),
|
||||
};
|
||||
@@ -459,7 +461,7 @@ gb_global TargetMetrics target_freestanding_wasm32 = {
|
||||
gb_global TargetMetrics target_js_wasm32 = {
|
||||
TargetOs_js,
|
||||
TargetArch_wasm32,
|
||||
4, 8, 16,
|
||||
4, 4, 8, 16,
|
||||
str_lit("wasm32-js-js"),
|
||||
str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"),
|
||||
};
|
||||
@@ -467,7 +469,7 @@ gb_global TargetMetrics target_js_wasm32 = {
|
||||
gb_global TargetMetrics target_wasi_wasm32 = {
|
||||
TargetOs_wasi,
|
||||
TargetArch_wasm32,
|
||||
4, 8, 16,
|
||||
4, 4, 8, 16,
|
||||
str_lit("wasm32-wasi-js"),
|
||||
str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"),
|
||||
};
|
||||
@@ -476,7 +478,7 @@ gb_global TargetMetrics target_wasi_wasm32 = {
|
||||
gb_global TargetMetrics target_js_wasm64 = {
|
||||
TargetOs_js,
|
||||
TargetArch_wasm64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("wasm64-js-js"),
|
||||
str_lit(""),
|
||||
};
|
||||
@@ -484,7 +486,7 @@ gb_global TargetMetrics target_js_wasm64 = {
|
||||
gb_global TargetMetrics target_freestanding_amd64_sysv = {
|
||||
TargetOs_freestanding,
|
||||
TargetArch_amd64,
|
||||
8, 8, 16,
|
||||
8, 8, 8, 16,
|
||||
str_lit("x86_64-pc-none-gnu"),
|
||||
str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"),
|
||||
TargetABI_SysV,
|
||||
@@ -1164,15 +1166,23 @@ gb_internal void init_build_context(TargetMetrics *cross_target) {
|
||||
GB_ASSERT(metrics->os != TargetOs_Invalid);
|
||||
GB_ASSERT(metrics->arch != TargetArch_Invalid);
|
||||
GB_ASSERT(metrics->word_size > 1);
|
||||
GB_ASSERT(metrics->int_size > 1);
|
||||
GB_ASSERT(metrics->max_align > 1);
|
||||
GB_ASSERT(metrics->max_simd_align > 1);
|
||||
|
||||
GB_ASSERT(metrics->int_size >= metrics->word_size);
|
||||
if (metrics->int_size > metrics->word_size) {
|
||||
GB_ASSERT(metrics->int_size == 2*metrics->word_size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bc->metrics = *metrics;
|
||||
bc->ODIN_OS = target_os_names[metrics->os];
|
||||
bc->ODIN_ARCH = target_arch_names[metrics->arch];
|
||||
bc->endian_kind = target_endians[metrics->arch];
|
||||
bc->word_size = metrics->word_size;
|
||||
bc->int_size = metrics->int_size;
|
||||
bc->max_align = metrics->max_align;
|
||||
bc->max_simd_align = metrics->max_simd_align;
|
||||
bc->link_flags = str_lit(" ");
|
||||
|
||||
@@ -132,6 +132,7 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
|
||||
GB_ASSERT(type != t_invalid);
|
||||
|
||||
/* unsigned const word_size = cast(unsigned)build_context.word_size; */
|
||||
unsigned const int_bits = cast(unsigned)(8*build_context.int_size);
|
||||
unsigned const word_bits = cast(unsigned)(8*build_context.word_size);
|
||||
|
||||
switch (type->kind) {
|
||||
@@ -162,8 +163,8 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
|
||||
case Basic_f32: return lb_debug_type_basic_type(m, str_lit("f32"), 32, LLVMDWARFTypeEncoding_Float);
|
||||
case Basic_f64: return lb_debug_type_basic_type(m, str_lit("f64"), 64, LLVMDWARFTypeEncoding_Float);
|
||||
|
||||
case Basic_int: return lb_debug_type_basic_type(m, str_lit("int"), word_bits, LLVMDWARFTypeEncoding_Signed);
|
||||
case Basic_uint: return lb_debug_type_basic_type(m, str_lit("uint"), word_bits, LLVMDWARFTypeEncoding_Unsigned);
|
||||
case Basic_int: return lb_debug_type_basic_type(m, str_lit("int"), int_bits, LLVMDWARFTypeEncoding_Signed);
|
||||
case Basic_uint: return lb_debug_type_basic_type(m, str_lit("uint"), int_bits, LLVMDWARFTypeEncoding_Unsigned);
|
||||
case Basic_uintptr: return lb_debug_type_basic_type(m, str_lit("uintptr"), word_bits, LLVMDWARFTypeEncoding_Unsigned);
|
||||
|
||||
case Basic_typeid:
|
||||
@@ -257,8 +258,8 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
|
||||
{
|
||||
LLVMMetadataRef elements[2] = {};
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), t_u8_ptr, 0);
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, word_bits);
|
||||
return lb_debug_basic_struct(m, str_lit("string"), 2*word_bits, word_bits, elements, gb_count_of(elements));
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, int_bits);
|
||||
return lb_debug_basic_struct(m, str_lit("string"), 2*int_bits, int_bits, elements, gb_count_of(elements));
|
||||
}
|
||||
case Basic_cstring:
|
||||
{
|
||||
@@ -292,7 +293,7 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
|
||||
GB_PANIC("Type_Named should be handled in lb_debug_type separately");
|
||||
|
||||
case Type_SoaPointer:
|
||||
return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->SoaPointer.elem), word_bits, word_bits, 0, nullptr, 0);
|
||||
return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->SoaPointer.elem), int_bits, int_bits, 0, nullptr, 0);
|
||||
case Type_Pointer:
|
||||
return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->Pointer.elem), word_bits, word_bits, 0, nullptr, 0);
|
||||
case Type_MultiPointer:
|
||||
@@ -447,10 +448,11 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
|
||||
unsigned element_count = 0;
|
||||
LLVMMetadataRef elements[2] = {};
|
||||
Type *base_integer = type->RelativeSlice.base_integer;
|
||||
unsigned base_bits = cast(unsigned)(8*type_size_of(base_integer));
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data_offset"), base_integer, 0);
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), base_integer, 8*type_size_of(base_integer));
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), base_integer, base_bits);
|
||||
gbString name = type_to_string(type, temporary_allocator());
|
||||
return LLVMDIBuilderCreateStructType(m->debug_builder, nullptr, name, gb_string_length(name), nullptr, 0, 2*word_bits, word_bits, LLVMDIFlagZero, nullptr, elements, element_count, 0, nullptr, "", 0);
|
||||
return LLVMDIBuilderCreateStructType(m->debug_builder, nullptr, name, gb_string_length(name), nullptr, 0, 2*base_bits, base_bits, LLVMDIFlagZero, nullptr, elements, element_count, 0, nullptr, "", 0);
|
||||
}
|
||||
|
||||
case Type_Matrix: {
|
||||
@@ -618,6 +620,7 @@ gb_internal LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) {
|
||||
gb_internal void lb_debug_complete_types(lbModule *m) {
|
||||
/* unsigned const word_size = cast(unsigned)build_context.word_size; */
|
||||
unsigned const word_bits = cast(unsigned)(8*build_context.word_size);
|
||||
unsigned const int_bits = cast(unsigned)(8*build_context.int_size);
|
||||
|
||||
for_array(debug_incomplete_type_index, m->debug_incomplete_types) {
|
||||
TEMPORARY_ALLOCATOR_GUARD();
|
||||
@@ -691,27 +694,27 @@ gb_internal void lb_debug_complete_types(lbModule *m) {
|
||||
element_count = 2;
|
||||
elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count);
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->Slice.elem), 0*word_bits);
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->Slice.elem), 0*int_bits);
|
||||
#else
|
||||
// FIX HACK TODO(bill): For some reason this causes a crash in *nix systems due to the reference counting
|
||||
// of the debug type information
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*word_bits);
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*int_bits);
|
||||
#endif
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*word_bits);
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*int_bits);
|
||||
break;
|
||||
case Type_DynamicArray:
|
||||
element_count = 4;
|
||||
elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count);
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->DynamicArray.elem), 0*word_bits);
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->DynamicArray.elem), 0*int_bits);
|
||||
#else
|
||||
// FIX HACK TODO(bill): For some reason this causes a crash in *nix systems due to the reference counting
|
||||
// of the debug type information
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*word_bits);
|
||||
elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*int_bits);
|
||||
#endif
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*word_bits);
|
||||
elements[2] = lb_debug_struct_field(m, str_lit("cap"), t_int, 2*word_bits);
|
||||
elements[3] = lb_debug_struct_field(m, str_lit("allocator"), t_allocator, 3*word_bits);
|
||||
elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*int_bits);
|
||||
elements[2] = lb_debug_struct_field(m, str_lit("cap"), t_int, 2*int_bits);
|
||||
elements[3] = lb_debug_struct_field(m, str_lit("allocator"), t_allocator, 3*int_bits);
|
||||
break;
|
||||
|
||||
case Type_Map:
|
||||
@@ -737,7 +740,7 @@ gb_internal void lb_debug_complete_types(lbModule *m) {
|
||||
element_count = cast(unsigned)(bt->Struct.fields.count + element_offset);
|
||||
elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count);
|
||||
|
||||
isize field_size_bits = 8*type_size_of(bt) - element_offset*word_bits;
|
||||
isize field_size_bits = 8*type_size_of(bt) - element_offset*int_bits;
|
||||
|
||||
switch (bt->Struct.soa_kind) {
|
||||
case StructSoa_Slice:
|
||||
@@ -756,7 +759,7 @@ gb_internal void lb_debug_complete_types(lbModule *m) {
|
||||
".len", 4,
|
||||
file, 0,
|
||||
8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int),
|
||||
field_size_bits + 0*word_bits,
|
||||
field_size_bits + 0*int_bits,
|
||||
LLVMDIFlagZero, lb_debug_type(m, t_int)
|
||||
);
|
||||
elements[1] = LLVMDIBuilderCreateMemberType(
|
||||
@@ -764,7 +767,7 @@ gb_internal void lb_debug_complete_types(lbModule *m) {
|
||||
".cap", 4,
|
||||
file, 0,
|
||||
8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int),
|
||||
field_size_bits + 1*word_bits,
|
||||
field_size_bits + 1*int_bits,
|
||||
LLVMDIFlagZero, lb_debug_type(m, t_int)
|
||||
);
|
||||
elements[2] = LLVMDIBuilderCreateMemberType(
|
||||
@@ -772,7 +775,7 @@ gb_internal void lb_debug_complete_types(lbModule *m) {
|
||||
".allocator", 10,
|
||||
file, 0,
|
||||
8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int),
|
||||
field_size_bits + 2*word_bits,
|
||||
field_size_bits + 2*int_bits,
|
||||
LLVMDIFlagZero, lb_debug_type(m, t_allocator)
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -3410,12 +3410,15 @@ gb_internal i64 type_size_of(Type *t) {
|
||||
if (t->kind == Type_Basic) {
|
||||
GB_ASSERT_MSG(is_type_typed(t), "%s", type_to_string(t));
|
||||
switch (t->Basic.kind) {
|
||||
case Basic_string: size = 2*build_context.word_size; break;
|
||||
case Basic_string: size = 2*build_context.int_size; break;
|
||||
case Basic_cstring: size = build_context.word_size; break;
|
||||
case Basic_any: size = 2*build_context.word_size; break;
|
||||
case Basic_typeid: size = build_context.word_size; break;
|
||||
|
||||
case Basic_int: case Basic_uint: case Basic_uintptr: case Basic_rawptr:
|
||||
case Basic_int: case Basic_uint:
|
||||
size = build_context.int_size;
|
||||
break;
|
||||
case Basic_uintptr: case Basic_rawptr:
|
||||
size = build_context.word_size;
|
||||
break;
|
||||
default:
|
||||
@@ -3470,12 +3473,14 @@ gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
|
||||
case Type_Basic: {
|
||||
GB_ASSERT(is_type_typed(t));
|
||||
switch (t->Basic.kind) {
|
||||
case Basic_string: return build_context.word_size;
|
||||
case Basic_string: return build_context.int_size;
|
||||
case Basic_cstring: return build_context.word_size;
|
||||
case Basic_any: return build_context.word_size;
|
||||
case Basic_typeid: return build_context.word_size;
|
||||
|
||||
case Basic_int: case Basic_uint: case Basic_uintptr: case Basic_rawptr:
|
||||
case Basic_int: case Basic_uint:
|
||||
return build_context.int_size;
|
||||
case Basic_uintptr: case Basic_rawptr:
|
||||
return build_context.word_size;
|
||||
|
||||
case Basic_complex32: case Basic_complex64: case Basic_complex128:
|
||||
@@ -3509,10 +3514,10 @@ gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
|
||||
|
||||
case Type_DynamicArray:
|
||||
// data, count, capacity, allocator
|
||||
return build_context.word_size;
|
||||
return build_context.int_size;
|
||||
|
||||
case Type_Slice:
|
||||
return build_context.word_size;
|
||||
return build_context.int_size;
|
||||
|
||||
|
||||
case Type_Tuple: {
|
||||
@@ -3607,7 +3612,7 @@ gb_internal i64 type_align_of_internal(Type *t, TypePath *path) {
|
||||
return type_align_of_internal(t->RelativeSlice.base_integer, path);
|
||||
|
||||
case Type_SoaPointer:
|
||||
return build_context.word_size;
|
||||
return build_context.int_size;
|
||||
}
|
||||
|
||||
// NOTE(bill): Things that are bigger than build_context.word_size, are actually comprised of smaller types
|
||||
@@ -3692,12 +3697,14 @@ gb_internal i64 type_size_of_internal(Type *t, TypePath *path) {
|
||||
return size;
|
||||
}
|
||||
switch (kind) {
|
||||
case Basic_string: return 2*build_context.word_size;
|
||||
case Basic_string: return 2*build_context.int_size;
|
||||
case Basic_cstring: return build_context.word_size;
|
||||
case Basic_any: return 2*build_context.word_size;
|
||||
case Basic_typeid: return build_context.word_size;
|
||||
|
||||
case Basic_int: case Basic_uint: case Basic_uintptr: case Basic_rawptr:
|
||||
case Basic_int: case Basic_uint:
|
||||
return build_context.int_size;
|
||||
case Basic_uintptr: case Basic_rawptr:
|
||||
return build_context.word_size;
|
||||
}
|
||||
} break;
|
||||
@@ -3709,7 +3716,7 @@ gb_internal i64 type_size_of_internal(Type *t, TypePath *path) {
|
||||
return build_context.word_size;
|
||||
|
||||
case Type_SoaPointer:
|
||||
return build_context.word_size*2;
|
||||
return build_context.int_size*2;
|
||||
|
||||
case Type_Array: {
|
||||
i64 count, align, size, alignment;
|
||||
@@ -3742,11 +3749,11 @@ gb_internal i64 type_size_of_internal(Type *t, TypePath *path) {
|
||||
} break;
|
||||
|
||||
case Type_Slice: // ptr + len
|
||||
return 2 * build_context.word_size;
|
||||
return 2 * build_context.int_size;
|
||||
|
||||
case Type_DynamicArray:
|
||||
// data + len + cap + allocator(procedure+data)
|
||||
return (3 + 2)*build_context.word_size;
|
||||
return 3*build_context.int_size + 2*build_context.word_size;
|
||||
|
||||
case Type_Map:
|
||||
/*
|
||||
@@ -3902,8 +3909,8 @@ gb_internal i64 type_offset_of(Type *t, i32 index) {
|
||||
} else if (t->kind == Type_Basic) {
|
||||
if (t->Basic.kind == Basic_string) {
|
||||
switch (index) {
|
||||
case 0: return 0; // data
|
||||
case 1: return build_context.word_size; // len
|
||||
case 0: return 0; // data
|
||||
case 1: return build_context.int_size; // len
|
||||
}
|
||||
} else if (t->Basic.kind == Basic_any) {
|
||||
switch (index) {
|
||||
@@ -3913,16 +3920,16 @@ gb_internal i64 type_offset_of(Type *t, i32 index) {
|
||||
}
|
||||
} else if (t->kind == Type_Slice) {
|
||||
switch (index) {
|
||||
case 0: return 0; // data
|
||||
case 1: return 1*build_context.word_size; // len
|
||||
case 2: return 2*build_context.word_size; // cap
|
||||
case 0: return 0; // data
|
||||
case 1: return 1*build_context.int_size; // len
|
||||
case 2: return 2*build_context.int_size; // cap
|
||||
}
|
||||
} else if (t->kind == Type_DynamicArray) {
|
||||
switch (index) {
|
||||
case 0: return 0; // data
|
||||
case 1: return 1*build_context.word_size; // len
|
||||
case 2: return 2*build_context.word_size; // cap
|
||||
case 3: return 3*build_context.word_size; // allocator
|
||||
case 0: return 0; // data
|
||||
case 1: return 1*build_context.int_size; // len
|
||||
case 2: return 2*build_context.int_size; // cap
|
||||
case 3: return 3*build_context.int_size; // allocator
|
||||
}
|
||||
} else if (t->kind == Type_Union) {
|
||||
/* i64 s = */ type_size_of(t);
|
||||
|
||||
Reference in New Issue
Block a user