| ... | ... | @@ -2440,10 +2440,15 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2440 | 2440 | .shr, .shr_exact => try cg.airShlShrBinOp(inst), |
| 2441 | 2441 | .shl, .shl_exact => try cg.airShlShrBinOp(inst), |
| 2442 | 2442 | |
| 2443 | | .mul => try cg.airMulDivBinOp(inst), |
| 2444 | | .mul_wrap => try cg.airMulDivBinOp(inst), |
| 2445 | | .rem => try cg.airMulDivBinOp(inst), |
| 2446 | | .mod => try cg.airMulDivBinOp(inst), |
| 2443 | .mul, |
| 2444 | .mul_wrap, |
| 2445 | .rem, |
| 2446 | .mod, |
| 2447 | .div_float, |
| 2448 | .div_trunc, |
| 2449 | .div_floor, |
| 2450 | .div_exact, |
| 2451 | => |air_tag| try cg.airMulDivBinOp(inst, air_tag), |
| 2447 | 2452 | |
| 2448 | 2453 | .add_sat => try cg.airAddSat(inst), |
| 2449 | 2454 | .sub_sat => try cg.airSubSat(inst), |
| ... | ... | @@ -2465,15 +2470,13 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2465 | 2470 | .ceil => try cg.airRound(inst, .{ .mode = .up, .precision = .inexact }), |
| 2466 | 2471 | .trunc_float => try cg.airRound(inst, .{ .mode = .zero, .precision = .inexact }), |
| 2467 | 2472 | .sqrt => try cg.airSqrt(inst), |
| 2468 | | .neg => try cg.airFloatSign(inst), |
| 2473 | .neg => |air_tag| try cg.airFloatSign(inst, air_tag), |
| 2469 | 2474 | |
| 2470 | 2475 | .add_with_overflow => try cg.airAddSubWithOverflow(inst), |
| 2471 | 2476 | .sub_with_overflow => try cg.airAddSubWithOverflow(inst), |
| 2472 | 2477 | .mul_with_overflow => try cg.airMulWithOverflow(inst), |
| 2473 | 2478 | .shl_with_overflow => try cg.airShlWithOverflow(inst), |
| 2474 | 2479 | |
| 2475 | | .div_float, .div_trunc, .div_floor, .div_exact => try cg.airMulDivBinOp(inst), |
| 2476 | | |
| 2477 | 2480 | .cmp_lt_errors_len => try cg.airCmpLtErrorsLen(inst), |
| 2478 | 2481 | |
| 2479 | 2482 | .bitcast => try cg.airBitCast(inst), |
| ... | ... | @@ -2528,19 +2531,19 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2528 | 2531 | .sub_safe, |
| 2529 | 2532 | .mul_safe, |
| 2530 | 2533 | => return cg.fail("TODO implement safety_checked_instructions", .{}), |
| 2531 | | .add_optimized, |
| 2532 | | .sub_optimized, |
| 2533 | | .mul_optimized, |
| 2534 | | .div_float_optimized, |
| 2535 | | .div_trunc_optimized, |
| 2536 | | .div_floor_optimized, |
| 2537 | | .div_exact_optimized, |
| 2538 | | .rem_optimized, |
| 2539 | | .mod_optimized, |
| 2540 | | .neg_optimized, |
| 2541 | | .reduce_optimized, |
| 2542 | | .int_from_float_optimized, |
| 2543 | | => return cg.fail("TODO implement optimized float mode", .{}), |
| 2534 | |
| 2535 | .add_optimized => try cg.airBinOp(inst, .add), |
| 2536 | .sub_optimized => try cg.airBinOp(inst, .sub), |
| 2537 | .mul_optimized => try cg.airBinOp(inst, .mul), |
| 2538 | .div_float_optimized => try cg.airMulDivBinOp(inst, .div_float), |
| 2539 | .div_trunc_optimized => try cg.airMulDivBinOp(inst, .div_trunc), |
| 2540 | .div_floor_optimized => try cg.airMulDivBinOp(inst, .div_floor), |
| 2541 | .div_exact_optimized => try cg.airMulDivBinOp(inst, .div_exact), |
| 2542 | .rem_optimized => try cg.airMulDivBinOp(inst, .rem), |
| 2543 | .mod_optimized => try cg.airMulDivBinOp(inst, .mod), |
| 2544 | .neg_optimized => try cg.airFloatSign(inst, .neg), |
| 2545 | .reduce_optimized => try cg.airReduce(inst), |
| 2546 | .int_from_float_optimized => try cg.airIntFromFloat(inst), |
| 2544 | 2547 | |
| 2545 | 2548 | .arg => try cg.airDbgArg(inst), |
| 2546 | 2549 | .ptr_add => |air_tag| if (use_old) try cg.airPtrArithmetic(inst, air_tag) else { |
| ... | ... | @@ -16257,12 +16260,11 @@ fn activeIntBits(self: *CodeGen, dst_air: Air.Inst.Ref) u16 { |
| 16257 | 16260 | return dst_info.bits; |
| 16258 | 16261 | } |
| 16259 | 16262 | |
| 16260 | | fn airMulDivBinOp(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 16263 | fn airMulDivBinOp(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 16261 | 16264 | const pt = self.pt; |
| 16262 | 16265 | const zcu = pt.zcu; |
| 16263 | 16266 | const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 16264 | 16267 | const result = result: { |
| 16265 | | const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)]; |
| 16266 | 16268 | const dst_ty = self.typeOfIndex(inst); |
| 16267 | 16269 | switch (dst_ty.zigTypeTag(zcu)) { |
| 16268 | 16270 | .float, .vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs), |
| ... | ... | @@ -19600,10 +19602,9 @@ fn airBitReverse(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 19600 | 19602 | return self.finishAir(inst, dst_mcv, .{ ty_op.operand, .none, .none }); |
| 19601 | 19603 | } |
| 19602 | 19604 | |
| 19603 | | fn floatSign(self: *CodeGen, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type) !void { |
| 19605 | fn floatSign(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag, operand: Air.Inst.Ref, ty: Type) !void { |
| 19604 | 19606 | const pt = self.pt; |
| 19605 | 19607 | const zcu = pt.zcu; |
| 19606 | | const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)]; |
| 19607 | 19608 | |
| 19608 | 19609 | const result = result: { |
| 19609 | 19610 | const scalar_bits = ty.scalarType(zcu).floatBits(self.target.*); |
| ... | ... | @@ -19728,10 +19729,10 @@ fn floatSign(self: *CodeGen, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Ty |
| 19728 | 19729 | return self.finishAir(inst, result, .{ operand, .none, .none }); |
| 19729 | 19730 | } |
| 19730 | 19731 | |
| 19731 | | fn airFloatSign(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 19732 | fn airFloatSign(self: *CodeGen, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void { |
| 19732 | 19733 | const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 19733 | 19734 | const ty = self.typeOf(un_op); |
| 19734 | | return self.floatSign(inst, un_op, ty); |
| 19735 | return self.floatSign(inst, tag, un_op, ty); |
| 19735 | 19736 | } |
| 19736 | 19737 | |
| 19737 | 19738 | const RoundMode = packed struct(u5) { |
| ... | ... | @@ -20014,7 +20015,7 @@ fn airAbs(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 20014 | 20015 | break :result dst_mcv; |
| 20015 | 20016 | }, |
| 20016 | 20017 | }, |
| 20017 | | .float => return self.floatSign(inst, ty_op.operand, ty), |
| 20018 | .float => return self.floatSign(inst, .abs, ty_op.operand, ty), |
| 20018 | 20019 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 20019 | 20020 | else => null, |
| 20020 | 20021 | .int => switch (ty.childType(zcu).intInfo(zcu).bits) { |
| ... | ... | @@ -20050,7 +20051,7 @@ fn airAbs(self: *CodeGen, inst: Air.Inst.Index) !void { |
| 20050 | 20051 | 5...8 => if (self.hasFeature(.avx2)) .{ .vp_d, .abs } else null, |
| 20051 | 20052 | }, |
| 20052 | 20053 | }, |
| 20053 | | .float => return self.floatSign(inst, ty_op.operand, ty), |
| 20054 | .float => return self.floatSign(inst, .abs, ty_op.operand, ty), |
| 20054 | 20055 | }, |
| 20055 | 20056 | }) orelse return self.fail("TODO implement airAbs for {}", .{ty.fmt(pt)}); |
| 20056 | 20057 | |
| ... | ... | @@ -22911,7 +22912,7 @@ fn genBinOp( |
| 22911 | 22912 | .mul => .{ .v_ss, .mul }, |
| 22912 | 22913 | .div_float, .div_trunc, .div_floor, .div_exact => .{ .v_ss, .div }, |
| 22913 | 22914 | .max => .{ .v_ss, .max }, |
| 22914 | | .min => .{ .v_ss, .max }, |
| 22915 | .min => .{ .v_ss, .min }, |
| 22915 | 22916 | else => unreachable, |
| 22916 | 22917 | }, |
| 22917 | 22918 | dst_reg, |