authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-01-15 23:50:06+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2024-02-04 19:09:25+01:00
log15cf5f88c1bfb4b92285c515d294e1061d02672a
tree47e0bc1c1ede97a1cea3543eeb62d2b95e1b5047
parent403c6262bb4c9087f1d0138fc83fe4dd979864ad
signaturebadge-check Signed by SSH key SHA256:ZS52FNyUv2WUXvO4njmVaFVO46RHojFuOrxRc4LuKzg

spirv: vectors for air not


2 files changed, 22 insertions(+), 24 deletions(-)

src/codegen/spirv.zig+22-23
......@@ -3218,31 +3218,31 @@ const DeclGen = struct {
32183218 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
32193219 const operand_id = try self.resolve(ty_op.operand);
32203220 const result_ty = self.typeOfIndex(inst);
3221 const result_ty_id = try self.resolveTypeId(result_ty);
32223221 const info = try self.arithmeticTypeInfo(result_ty);
32233222
3224 const result_id = self.spv.allocId();
3225 switch (info.class) {
3226 .bool => {
3227 try self.func.body.emit(self.spv.gpa, .OpLogicalNot, .{
3228 .id_result_type = result_ty_id,
3229 .id_result = result_id,
3230 .operand = operand_id,
3231 });
3232 },
3233 .float => unreachable,
3234 .composite_integer => unreachable, // TODO
3235 .strange_integer, .integer => {
3236 // Note: strange integer bits will be masked before operations that do not hold under modulo.
3237 try self.func.body.emit(self.spv.gpa, .OpNot, .{
3238 .id_result_type = result_ty_id,
3239 .id_result = result_id,
3240 .operand = operand_id,
3241 });
3242 },
3223 var wip = try self.elementWise(result_ty);
3224 defer wip.deinit();
3225
3226 for (0..wip.results.len) |i| {
3227 const args = .{
3228 .id_result_type = wip.scalar_ty_id,
3229 .id_result = wip.allocId(i),
3230 .operand = try wip.elementAt(result_ty, operand_id, i),
3231 };
3232 switch (info.class) {
3233 .bool => {
3234 try self.func.body.emit(self.spv.gpa, .OpLogicalNot, args);
3235 },
3236 .float => unreachable,
3237 .composite_integer => unreachable, // TODO
3238 .strange_integer, .integer => {
3239 // Note: strange integer bits will be masked before operations that do not hold under modulo.
3240 try self.func.body.emit(self.spv.gpa, .OpNot, args);
3241 },
3242 }
32433243 }
32443244
3245 return result_id;
3245 return try wip.finalize();
32463246 }
32473247
32483248 fn airArrayToSlice(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
......@@ -3305,7 +3305,6 @@ const DeclGen = struct {
33053305 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);
33063306
33073307 switch (result_ty.zigTypeTag(mod)) {
3308 .Vector => unreachable, // TODO
33093308 .Struct => {
33103309 if (mod.typeToPackedStruct(result_ty)) |struct_type| {
33113310 _ = struct_type;
......@@ -3353,7 +3352,7 @@ const DeclGen = struct {
33533352 constituents[0..index],
33543353 );
33553354 },
3356 .Array => {
3355 .Vector, .Array => {
33573356 const array_info = result_ty.arrayInfo(mod);
33583357 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(mod));
33593358 const elem_ids = try self.gpa.alloc(IdRef, n_elems);
test/behavior/vector.zig-1
......@@ -628,7 +628,6 @@ test "vector bitwise not operator" {
628628 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
629629 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
630630 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
631 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
632631
633632 const S = struct {
634633 fn doTheTestNot(comptime T: type, x: @Vector(4, T)) !void {