authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-09-17 14:19:18+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-23 12:36:56-07:00
logc7c0517ac0a7aa54ac4f020555f3c13e71a51c43
tree332f7538cf8dc81a9540fee1060548062272cd0b
parent5141b4e05c08f394c4c0e76ea73f0547c9854288

spirv: emit OpNot for arithmetic not


1 files changed, 24 insertions(+), 6 deletions(-)

src/codegen/spirv.zig+24-6
...@@ -2403,13 +2403,31 @@ pub const DeclGen = struct {...@@ -2403,13 +2403,31 @@ pub const DeclGen = struct {
2403 if (self.liveness.isUnused(inst)) return null;2403 if (self.liveness.isUnused(inst)) return null;
2404 const ty_op = self.air.instructions.items(.data)[inst].ty_op;2404 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
2405 const operand_id = try self.resolve(ty_op.operand);2405 const operand_id = try self.resolve(ty_op.operand);
2406 const result_ty = self.typeOfIndex(inst);
2407 const result_ty_id = try self.resolveTypeId(result_ty);
2408 const info = try self.arithmeticTypeInfo(result_ty);
2409
2406 const result_id = self.spv.allocId();2410 const result_id = self.spv.allocId();
2407 const result_type_id = try self.resolveTypeId(Type.bool);2411 switch (info.class) {
2408 try self.func.body.emit(self.spv.gpa, .OpLogicalNot, .{2412 .bool => {
2409 .id_result_type = result_type_id,2413 try self.func.body.emit(self.spv.gpa, .OpLogicalNot, .{
2410 .id_result = result_id,2414 .id_result_type = result_ty_id,
2411 .operand = operand_id,2415 .id_result = result_id,
2412 });2416 .operand = operand_id,
2417 });
2418 },
2419 .float => unreachable,
2420 .composite_integer => unreachable, // TODO
2421 .strange_integer, .integer => {
2422 // Note: strange integer bits will be masked before operations that do not hold under modulo.
2423 try self.func.body.emit(self.spv.gpa, .OpNot, .{
2424 .id_result_type = result_ty_id,
2425 .id_result = result_id,
2426 .operand = operand_id,
2427 });
2428 },
2429 }
2430
2413 return result_id;2431 return result_id;
2414 }2432 }
24152433