diff options
| author | gingerBill <bill@gingerbill.org> | 2023-04-20 11:55:18 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-04-20 11:55:18 +0100 |
| commit | cde442fa2cb8ebd2a2e305b75f677348c17bb768 (patch) | |
| tree | 8008f30ed2445b5a57f1353b48652470f5344011 /src/llvm_backend_utility.cpp | |
| parent | 84f966cb8fd450f52e6bfdea2bb3c0645e2a77e8 (diff) | |
Add internal padding to types where ptr size != int size
Diffstat (limited to 'src/llvm_backend_utility.cpp')
| -rw-r--r-- | src/llvm_backend_utility.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index ddae2243b..99deca5e9 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -929,7 +929,33 @@ gb_internal lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t) gb_internal i32 lb_convert_struct_index(lbModule *m, Type *t, i32 index) { if (t->kind == Type_Struct) { auto field_remapping = lb_get_struct_remapping(m, t); - index = field_remapping[index]; + return field_remapping[index]; + } else if (build_context.word_size != build_context.int_size) { + switch (t->kind) { + case Type_Slice: + GB_ASSERT(build_context.word_size*2 == build_context.int_size); + switch (index) { + case 0: return 0; // data + case 1: return 2; // len + } + break; + case Type_DynamicArray: + GB_ASSERT(build_context.word_size*2 == build_context.int_size); + switch (index) { + case 0: return 0; // data + case 1: return 2; // len + case 2: return 3; // cap + case 3: return 4; // allocator + } + break; + case Type_SoaPointer: + GB_ASSERT(build_context.word_size*2 == build_context.int_size); + switch (index) { + case 0: return 0; // data + case 1: return 2; // offset + } + break; + } } return index; } |