wasm: implement @frameAddress

This commit is contained in:
Luuk de Gram 2023-04-27 16:15:14 +02:00
parent 447a302990
commit eb77e3381f
No known key found for this signature in database
GPG Key ID: A8CFE58E4DC7D664

View File

@ -1242,7 +1242,7 @@ fn genFunc(func: *CodeGen) InnerError!void {
// check if we have to initialize and allocate anything into the stack frame.
// If so, create enough stack space and insert the instructions at the front of the list.
if (func.stack_size > 0) {
if (func.initial_stack_value != .none) {
var prologue = std.ArrayList(Mir.Inst).init(func.gpa);
defer prologue.deinit();
@ -1963,11 +1963,11 @@ fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
.tag_name => func.airTagName(inst),
.error_set_has_value => func.airErrorSetHasValue(inst),
.frame_addr => func.airFrameAddress(inst),
.mul_sat,
.mod,
.assembly,
.frame_addr,
.bit_reverse,
.is_err_ptr,
.is_non_err_ptr,
@ -6969,3 +6969,12 @@ fn airAtomicStore(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
return func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs });
}
fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
if (func.initial_stack_value == .none) {
try func.initializeStack();
}
try func.emitWValue(func.bottom_stack_value);
const result = try WValue.toLocal(.stack, func, Type.usize);
return func.finishAir(inst, result, &.{});
}