diff --git a/lib/std/special/c_stage1.zig b/lib/std/special/c_stage1.zig index c905e8ecac..cd2d833c2d 100644 --- a/lib/std/special/c_stage1.zig +++ b/lib/std/special/c_stage1.zig @@ -5,6 +5,7 @@ const isNan = std.math.isNan; const native_arch = builtin.cpu.arch; const native_abi = builtin.abi; const native_os = builtin.os.tag; +const long_double_is_f128 = builtin.target.longDoubleIsF128(); const is_wasm = switch (native_arch) { .wasm32, .wasm64 => true, @@ -657,6 +658,9 @@ export fn ceil(x: f64) f64 { } export fn fmal(a: c_longdouble, b: c_longdouble, c: c_longdouble) c_longdouble { + if (!long_double_is_f128) { + @panic("TODO implement this"); + } return math.fma(c_longdouble, a, b, c); } diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 1b3e80ed12..8bd9e6e499 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -18,6 +18,8 @@ const strong_linkage = if (is_test) else std.builtin.GlobalLinkage.Strong; +const long_double_is_f128 = builtin.target.longDoubleIsF128(); + comptime { const __extenddftf2 = @import("compiler_rt/extendXfYf2.zig").__extenddftf2; @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage }); @@ -75,6 +77,15 @@ comptime { } if (!builtin.zig_is_stage2) { + if (!long_double_is_f128) { + // TODO implement these + //const __extendxftf2 = @import("compiler_rt/extendXfYf2.zig").__extendxftf2; + //@export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage }); + + //const __trunctfxf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfxf2; + //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage }); + } + switch (arch) { .i386, .x86_64, diff --git a/lib/std/special/compiler_rt/extendXfYf2.zig b/lib/std/special/compiler_rt/extendXfYf2.zig index 7afb6b1645..9a2580e9ec 100644 --- a/lib/std/special/compiler_rt/extendXfYf2.zig +++ b/lib/std/special/compiler_rt/extendXfYf2.zig @@ -22,6 +22,11 @@ pub fn __extendhftf2(a: u16) callconv(.C) f128 { return extendXfYf2(f128, f16, a); } +pub fn __extendxftf2(a: c_longdouble) callconv(.C) f128 { + _ = a; + @panic("TODO implement"); +} + pub fn __aeabi_h2f(arg: u16) callconv(.AAPCS) f32 { @setRuntimeSafety(false); return @call(.{ .modifier = .always_inline }, __extendhfsf2, .{arg}); diff --git a/lib/std/special/compiler_rt/truncXfYf2.zig b/lib/std/special/compiler_rt/truncXfYf2.zig index 1d0394197c..3cad52426e 100644 --- a/lib/std/special/compiler_rt/truncXfYf2.zig +++ b/lib/std/special/compiler_rt/truncXfYf2.zig @@ -20,6 +20,11 @@ pub fn __trunctfdf2(a: f128) callconv(.C) f64 { return @call(.{ .modifier = .always_inline }, truncXfYf2, .{ f64, f128, a }); } +pub fn __trunctfxf2(a: f128) callconv(.C) c_longdouble { + _ = a; + @panic("TODO implement"); +} + pub fn __truncdfsf2(a: f64) callconv(.C) f32 { return @call(.{ .modifier = .always_inline }, truncXfYf2, .{ f32, f64, a }); } diff --git a/lib/std/target.zig b/lib/std/target.zig index a5b998e29b..138f4cebe9 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -1712,6 +1712,13 @@ pub const Target = struct { else => ".X", }; } + + pub inline fn longDoubleIsF128(target: Target) bool { + return switch (target.cpu.arch) { + .riscv64, .aarch64, .aarch64_be, .aarch64_32, .s390x, .mips64, .mips64el => true, + else => false, + }; + } }; test {