diff options
| author | Robin Voetter <robin@voetter.nl> | 2023-09-17 14:19:18 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-09-23 12:36:56 -0700 |
| commit | c7c0517ac0a7aa54ac4f020555f3c13e71a51c43 (patch) | |
| tree | 332f7538cf8dc81a9540fee1060548062272cd0b /src/codegen/spirv.zig | |
| parent | 5141b4e05c08f394c4c0e76ea73f0547c9854288 (diff) | |
| download | zig-c7c0517ac0a7aa54ac4f020555f3c13e71a51c43.tar.gz zig-c7c0517ac0a7aa54ac4f020555f3c13e71a51c43.zip | |
spirv: emit OpNot for arithmetic not
Diffstat (limited to 'src/codegen/spirv.zig')
| -rw-r--r-- | src/codegen/spirv.zig | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 572af60f3c..1e11970c51 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -2403,13 +2403,31 @@ pub const DeclGen = struct { if (self.liveness.isUnused(inst)) return null; const ty_op = self.air.instructions.items(.data)[inst].ty_op; const operand_id = try self.resolve(ty_op.operand); + const result_ty = self.typeOfIndex(inst); + const result_ty_id = try self.resolveTypeId(result_ty); + const info = try self.arithmeticTypeInfo(result_ty); + const result_id = self.spv.allocId(); - const result_type_id = try self.resolveTypeId(Type.bool); - try self.func.body.emit(self.spv.gpa, .OpLogicalNot, .{ - .id_result_type = result_type_id, - .id_result = result_id, - .operand = operand_id, - }); + switch (info.class) { + .bool => { + try self.func.body.emit(self.spv.gpa, .OpLogicalNot, .{ + .id_result_type = result_ty_id, + .id_result = result_id, + .operand = operand_id, + }); + }, + .float => unreachable, + .composite_integer => unreachable, // TODO + .strange_integer, .integer => { + // Note: strange integer bits will be masked before operations that do not hold under modulo. + try self.func.body.emit(self.spv.gpa, .OpNot, .{ + .id_result_type = result_ty_id, + .id_result = result_id, + .operand = operand_id, + }); + }, + } + return result_id; } |
