| ... | @@ -1441,7 +1441,11 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { | ... | @@ -1441,7 +1441,11 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1441 | .subwrap => self.airWrapBinOp(inst, .sub), | 1441 | .subwrap => self.airWrapBinOp(inst, .sub), |
| 1442 | .mul => self.airBinOp(inst, .mul), | 1442 | .mul => self.airBinOp(inst, .mul), |
| 1443 | .mulwrap => self.airWrapBinOp(inst, .mul), | 1443 | .mulwrap => self.airWrapBinOp(inst, .mul), |
| 1444 | .div_trunc => self.airBinOp(inst, .div), | 1444 | .div_float, |
| | 1445 | .div_exact, |
| | 1446 | .div_trunc, |
| | 1447 | => self.airBinOp(inst, .div), |
| | 1448 | .div_floor => self.airDivFloor(inst), |
| 1445 | .bit_and => self.airBinOp(inst, .@"and"), | 1449 | .bit_and => self.airBinOp(inst, .@"and"), |
| 1446 | .bit_or => self.airBinOp(inst, .@"or"), | 1450 | .bit_or => self.airBinOp(inst, .@"or"), |
| 1447 | .bool_and => self.airBinOp(inst, .@"and"), | 1451 | .bool_and => self.airBinOp(inst, .@"and"), |
| ... | @@ -1583,9 +1587,6 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { | ... | @@ -1583,9 +1587,6 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1583 | .add_sat, | 1587 | .add_sat, |
| 1584 | .sub_sat, | 1588 | .sub_sat, |
| 1585 | .mul_sat, | 1589 | .mul_sat, |
| 1586 | .div_float, | | |
| 1587 | .div_floor, | | |
| 1588 | .div_exact, | | |
| 1589 | .mod, | 1590 | .mod, |
| 1590 | .assembly, | 1591 | .assembly, |
| 1591 | .shl_sat, | 1592 | .shl_sat, |
| ... | @@ -4757,3 +4758,30 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) InnerError!WValue { | ... | @@ -4757,3 +4758,30 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 4757 | else => return self.fail("TODO: @byteSwap for integers with bitsize {d}", .{int_info.bits}), | 4758 | else => return self.fail("TODO: @byteSwap for integers with bitsize {d}", .{int_info.bits}), |
| 4758 | } | 4759 | } |
| 4759 | } | 4760 | } |
| | 4761 | |
| | 4762 | fn airDivFloor(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| | 4763 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; |
| | 4764 | |
| | 4765 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; |
| | 4766 | const ty = self.air.typeOfIndex(inst); |
| | 4767 | const lhs = try self.resolveInst(bin_op.lhs); |
| | 4768 | const rhs = try self.resolveInst(bin_op.rhs); |
| | 4769 | |
| | 4770 | const div_result = try self.binOp(lhs, rhs, ty, .div); |
| | 4771 | if (ty.isUnsignedInt()) { |
| | 4772 | return div_result; |
| | 4773 | } else if (ty.isSignedInt()) { |
| | 4774 | return self.fail("TODO: `@divFloor` for signed integers", .{}); |
| | 4775 | } |
| | 4776 | |
| | 4777 | try self.emitWValue(div_result); |
| | 4778 | switch (ty.floatBits(self.target)) { |
| | 4779 | 32 => try self.addTag(.f32_floor), |
| | 4780 | 64 => try self.addTag(.f64_floor), |
| | 4781 | else => |bit_size| return self.fail("TODO: `@divFloor` for floats with bitsize: {d}", .{bit_size}), |
| | 4782 | } |
| | 4783 | |
| | 4784 | const result = try self.allocLocal(ty); |
| | 4785 | try self.addLabel(.local_set, result.local); |
| | 4786 | return result; |
| | 4787 | } |