authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-08-16 20:41:48+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-08-18 14:17:01+02:00
log63c25cc1cc4aef1ae5c7425496d99b30db2f44d7
tree4601f32c41590e381b2249e3a90739371c01cb91
parentdf507edffe6c1087b5f4786cb64ccaffd02b6848

wasm: fix callInstrinsic return value

Rather than storing it in a local and returning that, we now keep this on the stack as all internal functions expect it to be on the stack already and therefore were generating extra `local.set` instructions.

1 files changed, 2 insertions(+), 5 deletions(-)

src/arch/wasm/CodeGen.zig+2-5
......@@ -4106,7 +4106,6 @@ fn fpext(self: *Self, operand: WValue, given: Type, wanted: Type) InnerError!WVa
41064106 return f32_result;
41074107 }
41084108 if (wanted_bits == 64) {
4109 try self.emitWValue(f32_result);
41104109 try self.addTag(.f64_promote_f32);
41114110 return WValue{ .stack = {} };
41124111 }
......@@ -4628,7 +4627,6 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
46284627 Type.f32,
46294628 &.{ rhs_ext, lhs_ext, addend_ext },
46304629 );
4631 defer result.free(self);
46324630 return try (try self.fptrunc(result, Type.f32, ty)).toLocal(self, ty);
46334631 }
46344632
......@@ -5353,6 +5351,7 @@ fn airShlSat(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
53535351/// This function call assumes the C-ABI.
53545352/// Asserts arguments are not stack values when the return value is
53555353/// passed as the first parameter.
5354/// May leave the return value on the stack.
53565355fn callIntrinsic(
53575356 self: *Self,
53585357 name: []const u8,
......@@ -5398,8 +5397,6 @@ fn callIntrinsic(
53985397 } else if (want_sret_param) {
53995398 return sret;
54005399 } else {
5401 const result_local = try self.allocLocal(return_type);
5402 try self.addLabel(.local_set, result_local.local);
5403 return result_local;
5400 return WValue{ .stack = {} };
54045401 }
54055402}