mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
x86_64: implement @rem for floats
This commit is contained in:
parent
3bf9a8feb5
commit
35c9b717f7
@ -6831,12 +6831,12 @@ fn genBinOp(
|
||||
const rhs_ty = self.typeOf(rhs_air);
|
||||
const abi_size: u32 = @intCast(lhs_ty.abiSize(mod));
|
||||
|
||||
if (lhs_ty.isRuntimeFloat() and switch (lhs_ty.floatBits(self.target.*)) {
|
||||
if (lhs_ty.isRuntimeFloat() and (air_tag == .rem or switch (lhs_ty.floatBits(self.target.*)) {
|
||||
16 => !self.hasFeature(.f16c),
|
||||
32, 64 => false,
|
||||
80, 128 => true,
|
||||
else => unreachable,
|
||||
}) {
|
||||
})) {
|
||||
var callee: ["__add?f3".len]u8 = undefined;
|
||||
const result = try self.genCall(.{ .lib = .{
|
||||
.return_type = lhs_ty.toIntern(),
|
||||
@ -6852,9 +6852,14 @@ fn genBinOp(
|
||||
@tagName(air_tag)[0..3],
|
||||
floatCompilerRtAbiName(lhs_ty.floatBits(self.target.*)),
|
||||
}),
|
||||
.min, .max => std.fmt.bufPrint(&callee, "{s}f{s}{s}", .{
|
||||
.rem, .min, .max => std.fmt.bufPrint(&callee, "{s}f{s}{s}", .{
|
||||
floatLibcAbiPrefix(lhs_ty),
|
||||
@tagName(air_tag),
|
||||
switch (air_tag) {
|
||||
.rem => "mod",
|
||||
.min => "min",
|
||||
.max => "max",
|
||||
else => unreachable,
|
||||
},
|
||||
floatLibcAbiSuffix(lhs_ty),
|
||||
}),
|
||||
else => return self.fail("TODO implement genBinOp for {s} {}", .{
|
||||
|
||||
@ -1332,6 +1332,7 @@ test "remainder division" {
|
||||
try comptime remdiv(f80);
|
||||
try comptime remdiv(f128);
|
||||
try remdiv(f16);
|
||||
try remdiv(f32);
|
||||
try remdiv(f64);
|
||||
try remdiv(f80);
|
||||
try remdiv(f128);
|
||||
@ -1356,7 +1357,7 @@ test "float remainder division using @rem" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf) return error.SkipZigTest;
|
||||
|
||||
try comptime frem(f16);
|
||||
try comptime frem(f32);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user