| ... | @@ -451,6 +451,8 @@ pub const DeclGen = struct { | ... | @@ -451,6 +451,8 @@ pub const DeclGen = struct { |
| 451 | .cmp_gte => try self.genBinOp(inst.castTag(.cmp_gte).?), | 451 | .cmp_gte => try self.genBinOp(inst.castTag(.cmp_gte).?), |
| 452 | .cmp_lt => try self.genBinOp(inst.castTag(.cmp_lt).?), | 452 | .cmp_lt => try self.genBinOp(inst.castTag(.cmp_lt).?), |
| 453 | .cmp_lte => try self.genBinOp(inst.castTag(.cmp_lte).?), | 453 | .cmp_lte => try self.genBinOp(inst.castTag(.cmp_lte).?), |
| | 454 | .bool_and => try self.genBinOp(inst.castTag(.bool_and).?), |
| | 455 | .bool_or => try self.genBinOp(inst.castTag(.bool_or).?), |
| 454 | .arg => self.genArg(), | 456 | .arg => self.genArg(), |
| 455 | // TODO: Breakpoints won't be supported in SPIR-V, but the compiler seems to insert them | 457 | // TODO: Breakpoints won't be supported in SPIR-V, but the compiler seems to insert them |
| 456 | // throughout the IR. | 458 | // throughout the IR. |
| ... | @@ -468,7 +470,7 @@ pub const DeclGen = struct { | ... | @@ -468,7 +470,7 @@ pub const DeclGen = struct { |
| 468 | const lhs_id = try self.resolve(inst.lhs); | 470 | const lhs_id = try self.resolve(inst.lhs); |
| 469 | const rhs_id = try self.resolve(inst.rhs); | 471 | const rhs_id = try self.resolve(inst.rhs); |
| 470 | | 472 | |
| 471 | const binop_result_id = self.spv.allocResultId(); | 473 | const result_id = self.spv.allocResultId(); |
| 472 | const result_type_id = try self.getOrGenType(inst.base.ty); | 474 | const result_type_id = try self.getOrGenType(inst.base.ty); |
| 473 | | 475 | |
| 474 | // TODO: Is the result the same as the argument types? | 476 | // TODO: Is the result the same as the argument types? |
| ... | @@ -516,16 +518,19 @@ pub const DeclGen = struct { | ... | @@ -516,16 +518,19 @@ pub const DeclGen = struct { |
| 516 | .cmp_gte => if (is_float) Opcode.OpFOrdGreaterThanEqual else if (is_signed) Opcode.OpSGreaterThanEqual else Opcode.OpUGreaterThanEqual, | 518 | .cmp_gte => if (is_float) Opcode.OpFOrdGreaterThanEqual else if (is_signed) Opcode.OpSGreaterThanEqual else Opcode.OpUGreaterThanEqual, |
| 517 | .cmp_lt => if (is_float) Opcode.OpFOrdLessThan else if (is_signed) Opcode.OpSLessThan else Opcode.OpULessThan, | 519 | .cmp_lt => if (is_float) Opcode.OpFOrdLessThan else if (is_signed) Opcode.OpSLessThan else Opcode.OpULessThan, |
| 518 | .cmp_lte => if (is_float) Opcode.OpFOrdLessThanEqual else if (is_signed) Opcode.OpSLessThanEqual else Opcode.OpULessThanEqual, | 520 | .cmp_lte => if (is_float) Opcode.OpFOrdLessThanEqual else if (is_signed) Opcode.OpSLessThanEqual else Opcode.OpULessThanEqual, |
| | 521 | // Bool -> bool operations. |
| | 522 | .bool_and => Opcode.OpLogicalAnd, |
| | 523 | .bool_or => Opcode.OpLogicalOr, |
| 519 | else => unreachable, | 524 | else => unreachable, |
| 520 | }; | 525 | }; |
| 521 | | 526 | |
| 522 | try writeInstruction(&self.spv.fn_decls, opcode, &[_]u32{ result_type_id, binop_result_id, lhs_id, rhs_id }); | 527 | try writeInstruction(&self.spv.fn_decls, opcode, &[_]u32{ result_type_id, result_id, lhs_id, rhs_id }); |
| 523 | | 528 | |
| 524 | // TODO: Trap on overflow? Probably going to be annoying. | 529 | // TODO: Trap on overflow? Probably going to be annoying. |
| 525 | // TODO: Look into NoSignedWrap/NoUnsignedWrap extensions. | 530 | // TODO: Look into NoSignedWrap/NoUnsignedWrap extensions. |
| 526 | | 531 | |
| 527 | if (info.class != .strange_integer) | 532 | if (info.class != .strange_integer) |
| 528 | return binop_result_id; | 533 | return result_id; |
| 529 | | 534 | |
| 530 | return self.fail(.{.node_offset = 0}, "TODO: SPIR-V backend: strange integer operation mask", .{}); | 535 | return self.fail(.{.node_offset = 0}, "TODO: SPIR-V backend: strange integer operation mask", .{}); |
| 531 | } | 536 | } |