zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 1c02e58fc06aa3e429f963e600e126611df3626e (tree)
parent 21780899eb17a0cb795ff40e5fae6556c38ea13e
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 27 Sep 2023 11:23:28 -0700

Revert "compiler: don't use `@abs` builtin yet"

This reverts commit 21780899eb17a0cb795ff40e5fae6556c38ea13e.

After this commit, a version of the compiler which supports the new
`@abs` builtin is required.

Diffstat:
Msrc/Sema.zig | 2+-
Msrc/arch/x86_64/encoder.zig | 4++--
Msrc/value.zig | 12++++++------
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -37530,7 +37530,7 @@ fn float128IntPartToBigInt( float: f128, ) !std.math.big.int.Managed { const is_negative = std.math.signbit(float); - const floored = @floor(@fabs(float)); + const floored = @floor(@abs(float)); var rational = try std.math.big.Rational.init(arena); defer rational.q.deinit(); diff --git a/src/arch/x86_64/encoder.zig b/src/arch/x86_64/encoder.zig @@ -105,7 +105,7 @@ pub const Instruction = struct { try writer.print("{s} ptr [rip", .{@tagName(rip.ptr_size)}); if (rip.disp != 0) try writer.print(" {c} 0x{x}", .{ @as(u8, if (rip.disp < 0) '-' else '+'), - std.math.absCast(rip.disp), + @abs(rip.disp), }); try writer.writeByte(']'); }, @@ -140,7 +140,7 @@ pub const Instruction = struct { try writer.print(" {c} ", .{@as(u8, if (sib.disp < 0) '-' else '+')}) else if (sib.disp < 0) try writer.writeByte('-'); - try writer.print("0x{x}", .{std.math.absCast(sib.disp)}); + try writer.print("0x{x}", .{@abs(sib.disp)}); any = true; } diff --git a/src/value.zig b/src/value.zig @@ -1989,7 +1989,7 @@ pub const Value = struct { return 1; } - const w_value = @fabs(scalar); + const w_value = @abs(scalar); return @divFloor(@as(std.math.big.Limb, @intFromFloat(std.math.log2(w_value))), @typeInfo(std.math.big.Limb).Int.bits) + 1; } @@ -3741,11 +3741,11 @@ pub const Value = struct { .ComptimeFloat, .Float => { const target = mod.getTarget(); const storage: InternPool.Key.Float.Storage = switch (ty.floatBits(target)) { - 16 => .{ .f16 = @fabs(val.toFloat(f16, mod)) }, - 32 => .{ .f32 = @fabs(val.toFloat(f32, mod)) }, - 64 => .{ .f64 = @fabs(val.toFloat(f64, mod)) }, - 80 => .{ .f80 = @fabs(val.toFloat(f80, mod)) }, - 128 => .{ .f128 = @fabs(val.toFloat(f128, mod)) }, + 16 => .{ .f16 = @abs(val.toFloat(f16, mod)) }, + 32 => .{ .f32 = @abs(val.toFloat(f32, mod)) }, + 64 => .{ .f64 = @abs(val.toFloat(f64, mod)) }, + 80 => .{ .f80 = @abs(val.toFloat(f80, mod)) }, + 128 => .{ .f128 = @abs(val.toFloat(f128, mod)) }, else => unreachable, }; return (try mod.intern(.{ .float = .{