authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-04-27 16:15:14+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2023-05-19 20:18:58+02:00
logeb77e3381fac5f5bba2254cf5a7369aaea930e4e
tree8346a8f78d9cc5202922eb88af729a434939f72c
parent447a30299073ce88b7b26d18d060a345beac5276
signaturelock-open Commit is signed but in an unrecognized format.

wasm: implement `@frameAddress`


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

src/arch/wasm/CodeGen.zig+11-2
......@@ -1242,7 +1242,7 @@ fn genFunc(func: *CodeGen) InnerError!void {
12421242
12431243 // check if we have to initialize and allocate anything into the stack frame.
12441244 // If so, create enough stack space and insert the instructions at the front of the list.
1245 if (func.stack_size > 0) {
1245 if (func.initial_stack_value != .none) {
12461246 var prologue = std.ArrayList(Mir.Inst).init(func.gpa);
12471247 defer prologue.deinit();
12481248
......@@ -1963,11 +1963,11 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
19631963 .tag_name => func.airTagName(inst),
19641964
19651965 .error_set_has_value => func.airErrorSetHasValue(inst),
1966 .frame_addr => func.airFrameAddress(inst),
19661967
19671968 .mul_sat,
19681969 .mod,
19691970 .assembly,
1970 .frame_addr,
19711971 .bit_reverse,
19721972 .is_err_ptr,
19731973 .is_non_err_ptr,
......@@ -6969,3 +6969,12 @@ fn airAtomicStore(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
69696969
69706970 return func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
69716971}
6972
6973fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6974 if (func.initial_stack_value == .none) {
6975 try func.initializeStack();
6976 }
6977 try func.emitWValue(func.bottom_stack_value);
6978 const result = try WValue.toLocal(.stack, func, Type.usize);
6979 return func.finishAir(inst, result, &.{});
6980}