From b173fa1b9a5643d0dff68d5f780351fa21f56630 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 30 Sep 2024 11:45:24 +0100 Subject: Fix LLVM 18 ABI for 128-bit integers (because LLVM broke things) --- src/llvm_abi.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/llvm_abi.cpp') diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 42086b09d..d0fe541da 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -531,6 +531,7 @@ namespace lbAbiAmd64SysV { RegClass_SSEInt16, RegClass_SSEInt32, RegClass_SSEInt64, + RegClass_SSEInt128, RegClass_SSEUp, RegClass_X87, RegClass_X87Up, @@ -616,6 +617,10 @@ namespace lbAbiAmd64SysV { } switch (kind) { case LLVMIntegerTypeKind: + if (LLVM_VERSION_MAJOR >= 18 && sz >= 16) { + return false; + } + return true; case LLVMHalfTypeKind: case LLVMFloatTypeKind: case LLVMDoubleTypeKind: -- cgit v1.2.3 From 4b6410e2253fb7c305c20ba1a55263cab4ec2c5a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 30 Sep 2024 12:32:55 +0100 Subject: ABI BREAKING for SysV: Change how multiple return values are handled to be separate like all other ABIs --- src/llvm_abi.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/llvm_abi.cpp') diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index d0fe541da..efc3e72c5 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -573,6 +573,15 @@ namespace lbAbiAmd64SysV { gb_internal Array classify(LLVMTypeRef t); gb_internal LLVMTypeRef llreg(LLVMContextRef c, Array const ®_classes, LLVMTypeRef type); + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { + if (!return_is_defined) { + return lb_arg_type_direct(LLVMVoidTypeInContext(c)); + } + LB_ABI_MODIFY_RETURN_IF_TUPLE_MACRO(); + + return amd64_type(c, return_type, Amd64TypeAttribute_StructRect, ft->calling_convention); + } + gb_internal LB_ABI_INFO(abi_info) { LLVMContextRef c = m->ctx; lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); @@ -583,12 +592,7 @@ namespace lbAbiAmd64SysV { for (unsigned i = 0; i < arg_count; i++) { ft->args[i] = amd64_type(c, arg_types[i], Amd64TypeAttribute_ByVal, calling_convention); } - - if (return_is_defined) { - ft->ret = amd64_type(c, return_type, Amd64TypeAttribute_StructRect, calling_convention); - } else { - ft->ret = lb_arg_type_direct(LLVMVoidTypeInContext(c)); - } + ft->ret = compute_return_type(ft, c, return_type, return_is_defined, return_is_tuple); return ft; } -- cgit v1.2.3 From c305c9dd04e4921e3094d052d17f5e519df24e40 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 4 Oct 2024 11:16:33 +0100 Subject: [ABI FIX] Fix 128-bit ABI issues --- src/llvm_abi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/llvm_abi.cpp') diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index efc3e72c5..0b2bb7956 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -622,9 +622,9 @@ namespace lbAbiAmd64SysV { switch (kind) { case LLVMIntegerTypeKind: if (LLVM_VERSION_MAJOR >= 18 && sz >= 16) { - return false; + return true; } - return true; + return false; case LLVMHalfTypeKind: case LLVMFloatTypeKind: case LLVMDoubleTypeKind: -- cgit v1.2.3