aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/wasm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-19 22:39:46 -0400
committerGitHub <noreply@github.com>2021-10-19 22:39:46 -0400
commit4a76523b92bcf0e9b48438cb22f49e67e0ab3fa1 (patch)
treed8a05453ecd23c9e1dbbc912731958e3b84c9c7a /src/codegen/wasm.zig
parent372e9709ad2f4af24461f0fa601754a469091c2b (diff)
parentc1508c98f479497c2b2586ea944be9f3ddae28fc (diff)
downloadzig-4a76523b92bcf0e9b48438cb22f49e67e0ab3fa1.tar.gz
zig-4a76523b92bcf0e9b48438cb22f49e67e0ab3fa1.zip
Merge pull request #9984 from Snektron/field-elem-access
Field elem access
Diffstat (limited to 'src/codegen/wasm.zig')
-rw-r--r--src/codegen/wasm.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig
index 6902553257..f0d9e43439 100644
--- a/src/codegen/wasm.zig
+++ b/src/codegen/wasm.zig
@@ -866,6 +866,7 @@ pub const Context = struct {
.struct_field_ptr_index_1 => self.airStructFieldPtrIndex(inst, 1),
.struct_field_ptr_index_2 => self.airStructFieldPtrIndex(inst, 2),
.struct_field_ptr_index_3 => self.airStructFieldPtrIndex(inst, 3),
+ .struct_field_val => self.airStructFieldVal(inst),
.switch_br => self.airSwitchBr(inst),
.unreach => self.airUnreachable(inst),
.wrap_optional => self.airWrapOptional(inst),
@@ -1456,6 +1457,15 @@ pub const Context = struct {
return WValue{ .local = struct_ptr.multi_value.index + index };
}
+ fn airStructFieldVal(self: *Context, inst: Air.Inst.Index) InnerError!WValue {
+ if (self.liveness.isUnused(inst)) return WValue.none;
+
+ const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
+ const extra = self.air.extraData(Air.StructField, ty_pl.payload).data;
+ const struct_multivalue = self.resolveInst(extra.struct_operand).multi_value;
+ return WValue{ .local = struct_multivalue.index + extra.field_index };
+ }
+
fn airSwitchBr(self: *Context, inst: Air.Inst.Index) InnerError!WValue {
// result type is always 'noreturn'
const blocktype = wasm.block_empty;