aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm/CodeGen.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-17 17:24:35 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-17 17:24:35 -0700
commit7233a3324aaa5b3995606f24b2b961149219986b (patch)
tree009a83fa10f489f0d6da4f77f07a4d0c8ca4e388 /src/arch/wasm/CodeGen.zig
parent76e103057ea6037d3bb3e44cd33880a9a91609fb (diff)
downloadzig-7233a3324aaa5b3995606f24b2b961149219986b.tar.gz
zig-7233a3324aaa5b3995606f24b2b961149219986b.zip
stage2: implement `@reduce`
Notably, Value.eql and Value.hash are improved to treat NaN as equal to itself, so that Type/Value can be hash map keys. Likewise float hashing normalizes the float value before computing the hash.
Diffstat (limited to 'src/arch/wasm/CodeGen.zig')
-rw-r--r--src/arch/wasm/CodeGen.zig13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index 33fb35163a..caddbbeaca 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -1263,6 +1263,7 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue {
.ret_load => self.airRetLoad(inst),
.splat => self.airSplat(inst),
.shuffle => self.airShuffle(inst),
+ .reduce => self.airReduce(inst),
.aggregate_init => self.airAggregateInit(inst),
.union_init => self.airUnionInit(inst),
.prefetch => self.airPrefetch(inst),
@@ -2988,7 +2989,6 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
const operand = try self.resolveInst(ty_op.operand);
- _ = ty_op;
_ = operand;
return self.fail("TODO: Implement wasm airSplat", .{});
}
@@ -2999,11 +2999,20 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
const ty_op = self.air.instructions.items(.data)[inst].ty_op;
const operand = try self.resolveInst(ty_op.operand);
- _ = ty_op;
_ = operand;
return self.fail("TODO: Implement wasm airShuffle", .{});
}
+fn airReduce(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
+ if (self.liveness.isUnused(inst)) return WValue{ .none = {} };
+
+ const reduce = self.air.instructions.items(.data)[inst].reduce;
+ const operand = try self.resolveInst(reduce.operand);
+
+ _ = operand;
+ return self.fail("TODO: Implement wasm airReduce", .{});
+}
+
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) InnerError!WValue {
if (self.liveness.isUnused(inst)) return WValue{ .none = {} };