aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-01-20 04:38:49 +0200
committerGitHub <noreply@github.com>2023-01-20 04:38:49 +0200
commitfe6dcdba1407f00584725318404814571cdbd828 (patch)
tree4ca30c3db0fadcfa489ff9007a3ed8f773670c80 /src/codegen
parentd3599ec73cc07692c2579a8cf7151c918eea525f (diff)
parentc1bdf01533462aabb78321b554580fd378cdc59c (diff)
downloadzig-fe6dcdba1407f00584725318404814571cdbd828.tar.gz
zig-fe6dcdba1407f00584725318404814571cdbd828.zip
Merge pull request #14357 from kcbanner/llvm_byval_struct
llvm: implement Stdcall calling convention
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index abcb9b4060..3d31661b1e 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -10413,6 +10413,7 @@ fn firstParamSRet(fn_info: Type.Payload.Function.Data, target: std.Target) bool
.riscv32, .riscv64 => return riscv_c_abi.classifyType(fn_info.return_type, target) == .memory,
else => return false, // TODO investigate C ABI for other architectures
},
+ .Stdcall => return !isScalar(fn_info.return_type),
else => return false,
}
}
@@ -10568,6 +10569,13 @@ fn lowerFnRetTy(dg: *DeclGen, fn_info: Type.Payload.Function.Data) !*llvm.Type {
else => return dg.lowerType(fn_info.return_type),
}
},
+ .Stdcall => {
+ if (isScalar(fn_info.return_type)) {
+ return dg.lowerType(fn_info.return_type);
+ } else {
+ return dg.context.voidType();
+ }
+ },
else => return dg.lowerType(fn_info.return_type),
}
}
@@ -10798,6 +10806,17 @@ const ParamTypeIterator = struct {
},
}
},
+ .Stdcall => {
+ it.zig_index += 1;
+ it.llvm_index += 1;
+
+ if (isScalar(ty)) {
+ return .byval;
+ } else {
+ it.byval_attr = true;
+ return .byref;
+ }
+ },
else => {
it.zig_index += 1;
it.llvm_index += 1;