authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-07-19 22:01:32+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-07-25 06:34:00+02:00
log6b4d4c70fd8b8696eb1220438b89f769a3c3a908
treee675c397482c996915f274d082c06f7395f95ea9
parent200b2e4ee108d388e0db2120aee38f83d1c7abdb
signaturelock-open Commit is signed but in an unrecognized format.

wasm: Only allow lowering C-ABI compatible types


2 files changed, 2 insertions(+), 23 deletions(-)

src/arch/wasm/abi.zig+1-19
...@@ -48,38 +48,20 @@ pub fn classifyType(ty: Type, target: Target) [2]Class {...@@ -48,38 +48,20 @@ pub fn classifyType(ty: Type, target: Target) [2]Class {
48 },48 },
49 .Bool => return direct,49 .Bool => return direct,
50 .Array => return memory,50 .Array => return memory,
51 // .ErrorUnion => {
52 // const has_tag = ty.errorUnionSet().hasRuntimeBitsIgnoreComptime();
53 // const has_pl = ty.errorUnionPayload().hasRuntimeBitsIgnoreComptime();
54 // if (!has_pl) return direct;
55 // if (!has_tag) {
56 // return classifyType(ty.errorUnionPayload(), target);
57 // }
58 // return memory;
59 // },
60 .Optional => {51 .Optional => {
61 std.debug.assert(ty.isPtrLikeOptional());52 std.debug.assert(ty.isPtrLikeOptional());
62 return direct;53 return direct;
63 // var buf: Type.Payload.ElemType = undefined;
64 // const pl_has_bits = ty.optionalChild(&buf).hasRuntimeBitsIgnoreComptime();
65 // if (!pl_has_bits) return direct;
66 // return memory;
67 },54 },
68 .Pointer => {55 .Pointer => {
69 // // Slices act like struct and will be passed by reference56 std.debug.assert(!ty.isSlice());
70 // if (ty.isSlice()) return memory;
71 return direct;57 return direct;
72 },58 },
73 .Union => {59 .Union => {
74 const layout = ty.unionGetLayout(target);60 const layout = ty.unionGetLayout(target);
75 std.debug.assert(layout.tag_size == 0);61 std.debug.assert(layout.tag_size == 0);
76 // if (layout.payload_size == 0 and layout.tag_size != 0) {
77 // return classifyType(ty.unionTagType().?, target);
78 // }
79 if (ty.unionFields().count() > 1) return memory;62 if (ty.unionFields().count() > 1) return memory;
80 return classifyType(ty.unionFields().values()[0].ty, target);63 return classifyType(ty.unionFields().values()[0].ty, target);
81 },64 },
82 // .AnyFrame, .Frame => return direct,
83 .ErrorUnion,65 .ErrorUnion,
84 .Frame,66 .Frame,
85 .AnyFrame,67 .AnyFrame,
src/codegen/llvm.zig+1-4
...@@ -9094,10 +9094,7 @@ fn firstParamSRet(fn_info: Type.Payload.Function.Data, target: std.Target) bool...@@ -9094,10 +9094,7 @@ fn firstParamSRet(fn_info: Type.Payload.Function.Data, target: std.Target) bool
9094 .windows => return x86_64_abi.classifyWindows(fn_info.return_type, target) == .memory,9094 .windows => return x86_64_abi.classifyWindows(fn_info.return_type, target) == .memory,
9095 else => return x86_64_abi.classifySystemV(fn_info.return_type, target)[0] == .memory,9095 else => return x86_64_abi.classifySystemV(fn_info.return_type, target)[0] == .memory,
9096 },9096 },
9097 .wasm32 => {9097 .wasm32 => return wasm_c_abi.classifyType(fn_info.return_type, target)[0] == .indirect,
9098 const classes = wasm_c_abi.classifyType(fn_info.return_type, target);
9099 return classes[0] == .indirect;
9100 },
9101 else => return false, // TODO investigate C ABI for other architectures9098 else => return false, // TODO investigate C ABI for other architectures
9102 },9099 },
9103 else => return false,9100 else => return false,