| ... | ... | @@ -1309,6 +1309,7 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1309 | 1309 | .xor => self.airBinOp(inst, .xor), |
| 1310 | 1310 | .max => self.airMaxMin(inst, .max), |
| 1311 | 1311 | .min => self.airMaxMin(inst, .min), |
| 1312 | .mul_add => self.airMulAdd(inst), |
| 1312 | 1313 | |
| 1313 | 1314 | .add_with_overflow => self.airBinOpOverflow(inst, .add), |
| 1314 | 1315 | .sub_with_overflow => self.airBinOpOverflow(inst, .sub), |
| ... | ... | @@ -1468,7 +1469,6 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { |
| 1468 | 1469 | .atomic_store_seq_cst, |
| 1469 | 1470 | .atomic_rmw, |
| 1470 | 1471 | .tag_name, |
| 1471 | | .mul_add, |
| 1472 | 1472 | => |tag| return self.fail("TODO: Implement wasm inst: {s}", .{@tagName(tag)}), |
| 1473 | 1473 | }; |
| 1474 | 1474 | } |
| ... | ... | @@ -1721,8 +1721,7 @@ fn load(self: *Self, operand: WValue, ty: Type, offset: u32) InnerError!WValue { |
| 1721 | 1721 | else |
| 1722 | 1722 | .signed; |
| 1723 | 1723 | |
| 1724 | | // TODO: Revisit below to determine if optional zero-sized pointers should still have abi-size 4. |
| 1725 | | const abi_size = if (ty.isPtrLikeOptional()) @as(u8, 4) else @intCast(u8, ty.abiSize(self.target)); |
| 1724 | const abi_size = @intCast(u8, ty.abiSize(self.target)); |
| 1726 | 1725 | |
| 1727 | 1726 | const opcode = buildOpcode(.{ |
| 1728 | 1727 | .valtype1 = typeToValtype(ty, self.target), |
| ... | ... | @@ -3912,3 +3911,24 @@ fn airMaxMin(self: *Self, inst: Air.Inst.Index, op: enum { max, min }) InnerErro |
| 3912 | 3911 | |
| 3913 | 3912 | return result; |
| 3914 | 3913 | } |
| 3914 | |
| 3915 | fn airMulAdd(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 3916 | if (self.liveness.isUnused(inst)) return WValue{ .none = {} }; |
| 3917 | const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
| 3918 | const bin_op = self.air.extraData(Air.Bin, pl_op.payload).data; |
| 3919 | const ty = self.air.typeOfIndex(inst); |
| 3920 | if (ty.zigTypeTag() == .Vector) { |
| 3921 | return self.fail("TODO: `@mulAdd` for vectors", .{}); |
| 3922 | } |
| 3923 | |
| 3924 | if (ty.floatBits(self.target) == 16) { |
| 3925 | return self.fail("TODO: `@mulAdd` for f16", .{}); |
| 3926 | } |
| 3927 | |
| 3928 | const addend = try self.resolveInst(pl_op.operand); |
| 3929 | const lhs = try self.resolveInst(bin_op.lhs); |
| 3930 | const rhs = try self.resolveInst(bin_op.rhs); |
| 3931 | |
| 3932 | const mul_result = try self.binOp(lhs, rhs, ty, .mul); |
| 3933 | return self.binOp(mul_result, addend, ty, .add); |
| 3934 | } |