diff options
| author | Andrea Piseri <andrea.piseri@gmail.com> | 2021-12-28 16:12:15 +0100 |
|---|---|---|
| committer | Andrea Piseri <andrea.piseri@gmail.com> | 2021-12-28 16:12:15 +0100 |
| commit | 822da9d12d4b1994b063d7ebf00cc2352ebf4884 (patch) | |
| tree | 866476a967ccfebf4d1f14b1180bb7165eee824c /src | |
| parent | 5d80e242244501a5eb256a72ed6ad5ca180bc49d (diff) | |
| parent | b0817d136b70d979453a5c47ca8132f7a33e5d2a (diff) | |
Merge branch 'master' into slice_scanner
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_abi.cpp | 15 | ||||
| -rw-r--r-- | src/main.cpp | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index c30f6531a..42f05bb27 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -965,6 +965,10 @@ namespace lbAbiArm64 { } return false; } + + unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef *base_type_, unsigned member_count_) { + return (member_count_ <= 4); + } lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef type, bool return_is_defined) { LLVMTypeRef homo_base_type = {}; @@ -975,7 +979,16 @@ namespace lbAbiArm64 { } else if (is_register(type)) { return non_struct(c, type); } else if (is_homogenous_aggregate(c, type, &homo_base_type, &homo_member_count)) { - return lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr); + if(is_homogenous_aggregate_small_enough(&homo_base_type, homo_member_count)) { + return lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr); + } else { + //TODO(Platin): do i need to create stuff that can handle the diffrent return type? + // else this needs a fix in llvm_backend_proc as we would need to cast it to the correct array type + + //LLVMTypeRef array_type = LLVMArrayType(homo_base_type, homo_member_count); + LLVMAttributeRef attr = lb_create_enum_attribute_with_type(c, "sret", type); + return lb_arg_type_indirect(type, attr); + } } else { i64 size = lb_sizeof(type); if (size <= 16) { diff --git a/src/main.cpp b/src/main.cpp index 7b4bc92ee..36b30112f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -439,13 +439,14 @@ i32 linker_stage(lbGenerator *gen) { // so use ld instead. // :UseLDForShared linker = "ld"; - link_settings = gb_string_appendc(link_settings, "-init '__$startup_runtime' "); // Shared libraries are .dylib on MacOS and .so on Linux. #if defined(GB_SYSTEM_OSX) output_ext = STR_LIT(".dylib"); + link_settings = gb_string_appendc(link_settings, "-init '___$startup_runtime' "); link_settings = gb_string_appendc(link_settings, "-dylib -dynamic "); #else output_ext = STR_LIT(".so"); + link_settings = gb_string_appendc(link_settings, "-init '__$startup_runtime' "); link_settings = gb_string_appendc(link_settings, "-shared "); #endif } else { |