aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-10-24 19:13:21 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-10-24 19:13:21 -0400
commitf8bd1cd3b11802d3566d287167d79d3cfc3ef41d (patch)
tree076226342d7d97280d02d364f8cc7311b3d98d86 /src/analyze.cpp
parent32c89531b1475ce8e3b8efdf7a07745da7bc854a (diff)
downloadzig-f8bd1cd3b11802d3566d287167d79d3cfc3ef41d.tar.gz
zig-f8bd1cd3b11802d3566d287167d79d3cfc3ef41d.zip
implement partial C ABI support for aarch64
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index e2df290df6..73ad719627 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -919,14 +919,13 @@ bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) {
if (type_is_c_abi_int(g, fn_type_id->return_type)) {
return false;
}
- if (g->zig_target->arch == ZigLLVM_x86) {
- X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type);
- return abi_class == X64CABIClass_MEMORY;
- } else if (g->zig_target->arch == ZigLLVM_x86_64) {
+ if (g->zig_target->arch == ZigLLVM_x86 ||
+ g->zig_target->arch == ZigLLVM_x86_64 ||
+ target_is_arm(g->zig_target) ||
+ target_is_riscv(g->zig_target))
+ {
X64CABIClass abi_class = type_c_abi_x86_64_class(g, fn_type_id->return_type);
- return abi_class == X64CABIClass_MEMORY;
- } else if (target_is_arm(g->zig_target) || target_is_riscv(g->zig_target)) {
- return type_size(g, fn_type_id->return_type) > 16;
+ return abi_class == X64CABIClass_MEMORY || abi_class == X64CABIClass_MEMORY_nobyval;
} else if (g->zig_target->arch == ZigLLVM_mipsel) {
return false;
}
@@ -7509,6 +7508,11 @@ X64CABIClass type_c_abi_x86_64_class(CodeGen *g, ZigType *ty) {
if (g->zig_target->os == OsWindows || g->zig_target->os == OsUefi) {
return type_windows_abi_x86_64_class(g, ty, ty_size);
+ } else if (g->zig_target->arch == ZigLLVM_aarch64 ||
+ g->zig_target->arch == ZigLLVM_aarch64_be)
+ {
+ X64CABIClass result = type_system_V_abi_x86_64_class(g, ty, ty_size);
+ return (result == X64CABIClass_MEMORY) ? X64CABIClass_MEMORY_nobyval : result;
} else {
return type_system_V_abi_x86_64_class(g, ty, ty_size);
}