aboutsummaryrefslogtreecommitdiff
path: root/src/link/Wasm.zig
diff options
context:
space:
mode:
authorPavel Verigo <paul.verigo@gmail.com>2025-04-27 15:36:24 +0200
committerAndrew Kelley <andrew@ziglang.org>2025-05-01 18:10:36 -0400
commita843be44a0cd88d152116a11ba75d059bbb01073 (patch)
tree8f424e9ac8029a632d9ed43e5df7e944465040ce /src/link/Wasm.zig
parentad9cb401124e4b2d59e49bed2736aad7813e4f1d (diff)
downloadzig-a843be44a0cd88d152116a11ba75d059bbb01073.tar.gz
zig-a843be44a0cd88d152116a11ba75d059bbb01073.zip
wasm-c-abi: llvm fix struct handling + reorganize
I changed to `wasm/abi.zig`, this design is certainly better than the previous one. Still there is some conflict of interest between llvm and self-hosted backend, better design will appear when abi tests will be tested with self-hosted. Resolves: #23304 Resolves: #23305
Diffstat (limited to 'src/link/Wasm.zig')
-rw-r--r--src/link/Wasm.zig33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 603be663ff..5f107823a4 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -4627,10 +4627,13 @@ fn convertZcuFnType(
try params_buffer.append(gpa, .i32); // memory address is always a 32-bit handle
} else if (return_type.hasRuntimeBitsIgnoreComptime(zcu)) {
if (cc == .wasm_mvp) {
- const res_classes = abi.classifyType(return_type, zcu);
- assert(res_classes[0] == .direct and res_classes[1] == .none);
- const scalar_type = abi.scalarType(return_type, zcu);
- try returns_buffer.append(gpa, CodeGen.typeToValtype(scalar_type, zcu, target));
+ switch (abi.classifyType(return_type, zcu)) {
+ .direct => |scalar_ty| {
+ assert(!abi.lowerAsDoubleI64(scalar_ty, zcu));
+ try returns_buffer.append(gpa, CodeGen.typeToValtype(scalar_ty, zcu, target));
+ },
+ .indirect => unreachable,
+ }
} else {
try returns_buffer.append(gpa, CodeGen.typeToValtype(return_type, zcu, target));
}
@@ -4645,18 +4648,16 @@ fn convertZcuFnType(
switch (cc) {
.wasm_mvp => {
- const param_classes = abi.classifyType(param_type, zcu);
- if (param_classes[1] == .none) {
- if (param_classes[0] == .direct) {
- const scalar_type = abi.scalarType(param_type, zcu);
- try params_buffer.append(gpa, CodeGen.typeToValtype(scalar_type, zcu, target));
- } else {
- try params_buffer.append(gpa, CodeGen.typeToValtype(param_type, zcu, target));
- }
- } else {
- // i128/f128
- try params_buffer.append(gpa, .i64);
- try params_buffer.append(gpa, .i64);
+ switch (abi.classifyType(param_type, zcu)) {
+ .direct => |scalar_ty| {
+ if (!abi.lowerAsDoubleI64(scalar_ty, zcu)) {
+ try params_buffer.append(gpa, CodeGen.typeToValtype(scalar_ty, zcu, target));
+ } else {
+ try params_buffer.append(gpa, .i64);
+ try params_buffer.append(gpa, .i64);
+ }
+ },
+ .indirect => try params_buffer.append(gpa, CodeGen.typeToValtype(param_type, zcu, target)),
}
},
else => try params_buffer.append(gpa, CodeGen.typeToValtype(param_type, zcu, target)),