authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-01-21 22:48:31+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-02-04 19:09:33+01:00
log1d548aa2aab472f14013e67e29c6d898a7b31998
treef95034497764e5488ed29ed651cb73dbd0e06ff7
parent76d5696434095e39d9aaae92c1533b2d016c1a31
signaturebadge-check Signed by SSH key SHA256:ZS52FNyUv2WUXvO4njmVaFVO46RHojFuOrxRc4LuKzg

spirv: air splat


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

src/codegen/spirv.zig+15
......@@ -2195,6 +2195,7 @@ const DeclGen = struct {
21952195
21962196 .mul_add => try self.airMulAdd(inst),
21972197
2198 .splat => try self.airSplat(inst),
21982199 .reduce, .reduce_optimized => try self.airReduce(inst),
21992200 .shuffle => try self.airShuffle(inst),
22002201
......@@ -2603,6 +2604,7 @@ const DeclGen = struct {
26032604 // Idk why spir-v doesn't have a dedicated abs() instruction in the base
26042605 // instruction set. For now we're just going to negate and check to avoid
26052606 // importing the extinst.
2607 // TODO: Make this a call to compiler rt / ext inst
26062608 const neg_id = self.spv.allocId();
26072609 const args = .{
26082610 .id_result_type = self.typeId(operand_scalar_ty_ref),
......@@ -2877,6 +2879,19 @@ const DeclGen = struct {
28772879 return try wip.finalize();
28782880 }
28792881
2882 fn airSplat(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
2883 if (self.liveness.isUnused(inst)) return null;
2884 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
2885 const operand_id = try self.resolve(ty_op.operand);
2886 const result_ty = self.typeOfIndex(inst);
2887 var wip = try self.elementWise(result_ty);
2888 defer wip.deinit();
2889 for (wip.results) |*result_id| {
2890 result_id.* = operand_id;
2891 }
2892 return try wip.finalize();
2893 }
2894
28802895 fn airReduce(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
28812896 if (self.liveness.isUnused(inst)) return null;
28822897 const mod = self.module;
test/behavior/vector.zig-1
......@@ -326,7 +326,6 @@ test "vector @splat" {
326326 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
327327 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
328328 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
329 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
330329
331330 if (builtin.zig_backend == .stage2_llvm and
332331 builtin.os.tag == .macos)