diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-06-24 22:21:43 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-27 01:21:32 -0700 |
| commit | ff37ccd298f0ab28a9d0e0ee1110dadc6db4df1e (patch) | |
| tree | 8b7b2ad4bc95f8cbbfd277fbfd7dfd30a7222b3a /src/arch/wasm/CodeGen.zig | |
| parent | dae516dbdffaf771e072679a76a6d48f3f0aa182 (diff) | |
| download | zig-ff37ccd298f0ab28a9d0e0ee1110dadc6db4df1e.tar.gz zig-ff37ccd298f0ab28a9d0e0ee1110dadc6db4df1e.zip | |
Air: store interned values in Air.Inst.Ref
Previously, interned values were represented as AIR instructions using
the `interned` tag. Now, the AIR ref directly encodes the InternPool
index. The encoding works as follows:
* If the ref matches one of the static values, it corresponds to the same InternPool index.
* Otherwise, if the MSB is 0, the ref corresponds to an InternPool index.
* Otherwise, if the MSB is 1, the ref corresponds to an AIR instruction index (after removing the MSB).
Note that since most static InternPool indices are low values (the
exceptions being `.none` and `.var_args_param_type`), the first rule is
almost a nop.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
| -rw-r--r-- | src/arch/wasm/CodeGen.zig | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 33d4a46741..ab6ded682e 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -854,9 +854,9 @@ const BigTomb = struct { lbt: Liveness.BigTomb, fn feed(bt: *BigTomb, op_ref: Air.Inst.Ref) void { - _ = Air.refToIndex(op_ref) orelse return; // constants do not have to be freed regardless const dies = bt.lbt.feed(); if (!dies) return; + // This will be a nop for interned constants. processDeath(bt.gen, op_ref); } @@ -882,8 +882,7 @@ fn iterateBigTomb(func: *CodeGen, inst: Air.Inst.Index, operand_count: usize) !B } fn processDeath(func: *CodeGen, ref: Air.Inst.Ref) void { - const inst = Air.refToIndex(ref) orelse return; - assert(func.air.instructions.items(.tag)[inst] != .interned); + if (Air.refToIndex(ref) == null) return; // Branches are currently only allowed to free locals allocated // within their own branch. // TODO: Upon branch consolidation free any locals if needed. @@ -1832,7 +1831,7 @@ fn buildPointerOffset(func: *CodeGen, ptr_value: WValue, offset: u64, action: en fn genInst(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { const air_tags = func.air.instructions.items(.tag); return switch (air_tags[inst]) { - .inferred_alloc, .inferred_alloc_comptime, .interned => unreachable, + .inferred_alloc, .inferred_alloc_comptime => unreachable, .add => func.airBinOp(inst, .add), .add_sat => func.airSatBinOp(inst, .add), |
