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 {...@@ -3218,31 +3218,31 @@ const DeclGen = struct {
3218 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;3218 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
3219 const operand_id = try self.resolve(ty_op.operand);3219 const operand_id = try self.resolve(ty_op.operand);
3220 const result_ty = self.typeOfIndex(inst);3220 const result_ty = self.typeOfIndex(inst);
3221 const result_ty_id = try self.resolveTypeId(result_ty);
3222 const info = try self.arithmeticTypeInfo(result_ty);3221 const info = try self.arithmeticTypeInfo(result_ty);
32233222
3224 const result_id = self.spv.allocId();3223 var wip = try self.elementWise(result_ty);
3225 switch (info.class) {3224 defer wip.deinit();
3226 .bool => {3225
3227 try self.func.body.emit(self.spv.gpa, .OpLogicalNot, .{3226 for (0..wip.results.len) |i| {
3228 .id_result_type = result_ty_id,3227 const args = .{
3229 .id_result = result_id,3228 .id_result_type = wip.scalar_ty_id,
3230 .operand = operand_id,3229 .id_result = wip.allocId(i),
3231 });3230 .operand = try wip.elementAt(result_ty, operand_id, i),
3232 },3231 };
3233 .float => unreachable,3232 switch (info.class) {
3234 .composite_integer => unreachable, // TODO3233 .bool => {
3235 .strange_integer, .integer => {3234 try self.func.body.emit(self.spv.gpa, .OpLogicalNot, args);
3236 // Note: strange integer bits will be masked before operations that do not hold under modulo.3235 },
3237 try self.func.body.emit(self.spv.gpa, .OpNot, .{3236 .float => unreachable,
3238 .id_result_type = result_ty_id,3237 .composite_integer => unreachable, // TODO
3239 .id_result = result_id,3238 .strange_integer, .integer => {
3240 .operand = operand_id,3239 // Note: strange integer bits will be masked before operations that do not hold under modulo.
3241 });3240 try self.func.body.emit(self.spv.gpa, .OpNot, args);
3242 },3241 },
3242 }
3243 }3243 }
32443244
3245 return result_id;3245 return try wip.finalize();
3246 }3246 }
32473247
3248 fn airArrayToSlice(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {3248 fn airArrayToSlice(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
...@@ -3305,7 +3305,6 @@ const DeclGen = struct {...@@ -3305,7 +3305,6 @@ const DeclGen = struct {
3305 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);3305 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);
33063306
3307 switch (result_ty.zigTypeTag(mod)) {3307 switch (result_ty.zigTypeTag(mod)) {
3308 .Vector => unreachable, // TODO
3309 .Struct => {3308 .Struct => {
3310 if (mod.typeToPackedStruct(result_ty)) |struct_type| {3309 if (mod.typeToPackedStruct(result_ty)) |struct_type| {
3311 _ = struct_type;3310 _ = struct_type;
...@@ -3353,7 +3352,7 @@ const DeclGen = struct {...@@ -3353,7 +3352,7 @@ const DeclGen = struct {
3353 constituents[0..index],3352 constituents[0..index],
3354 );3353 );
3355 },3354 },
3356 .Array => {3355 .Vector, .Array => {
3357 const array_info = result_ty.arrayInfo(mod);3356 const array_info = result_ty.arrayInfo(mod);
3358 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(mod));3357 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(mod));
3359 const elem_ids = try self.gpa.alloc(IdRef, n_elems);3358 const elem_ids = try self.gpa.alloc(IdRef, n_elems);
test/behavior/vector.zig-1
...@@ -628,7 +628,6 @@ test "vector bitwise not operator" {...@@ -628,7 +628,6 @@ test "vector bitwise not operator" {
628 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO628 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
629 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO629 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
630 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO630 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
631 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
632631
633 const S = struct {632 const S = struct {
634 fn doTheTestNot(comptime T: type, x: @Vector(4, T)) !void {633 fn doTheTestNot(comptime T: type, x: @Vector(4, T)) !void {