authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-05 18:17:55-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-05 18:19:31-07:00
log01ad6c0b020193a6c5c82e13296a12e847f78d05
treeaaa1c6c428a0e0578efa1dce73c336cd682a4734
parent5518a0aff2ab023e9021b74a0a14eb9fcfc094cc

freestanding libc: don't rely on compiler_rt symbols we don't have yet

Previous commit made fmal depend on __extendxftf2 and __trunctfxf2 but we don't have implementations of those yet.

5 files changed, 32 insertions(+), 0 deletions(-)

lib/std/special/c_stage1.zig+4
......@@ -5,6 +5,7 @@ const isNan = std.math.isNan;
55const native_arch = builtin.cpu.arch;
66const native_abi = builtin.abi;
77const native_os = builtin.os.tag;
8const long_double_is_f128 = builtin.target.longDoubleIsF128();
89
910const is_wasm = switch (native_arch) {
1011 .wasm32, .wasm64 => true,
......@@ -657,6 +658,9 @@ export fn ceil(x: f64) f64 {
657658}
658659
659660export fn fmal(a: c_longdouble, b: c_longdouble, c: c_longdouble) c_longdouble {
661 if (!long_double_is_f128) {
662 @panic("TODO implement this");
663 }
660664 return math.fma(c_longdouble, a, b, c);
661665}
662666
lib/std/special/compiler_rt.zig+11
......@@ -18,6 +18,8 @@ const strong_linkage = if (is_test)
1818else
1919 std.builtin.GlobalLinkage.Strong;
2020
21const long_double_is_f128 = builtin.target.longDoubleIsF128();
22
2123comptime {
2224 const __extenddftf2 = @import("compiler_rt/extendXfYf2.zig").__extenddftf2;
2325 @export(__extenddftf2, .{ .name = "__extenddftf2", .linkage = linkage });
......@@ -75,6 +77,15 @@ comptime {
7577 }
7678
7779 if (!builtin.zig_is_stage2) {
80 if (!long_double_is_f128) {
81 // TODO implement these
82 //const __extendxftf2 = @import("compiler_rt/extendXfYf2.zig").__extendxftf2;
83 //@export(__extendxftf2, .{ .name = "__extendxftf2", .linkage = linkage });
84
85 //const __trunctfxf2 = @import("compiler_rt/truncXfYf2.zig").__trunctfxf2;
86 //@export(__trunctfxf2, .{ .name = "__trunctfxf2", .linkage = linkage });
87 }
88
7889 switch (arch) {
7990 .i386,
8091 .x86_64,
lib/std/special/compiler_rt/extendXfYf2.zig+5
......@@ -22,6 +22,11 @@ pub fn __extendhftf2(a: u16) callconv(.C) f128 {
2222 return extendXfYf2(f128, f16, a);
2323}
2424
25pub fn __extendxftf2(a: c_longdouble) callconv(.C) f128 {
26 _ = a;
27 @panic("TODO implement");
28}
29
2530pub fn __aeabi_h2f(arg: u16) callconv(.AAPCS) f32 {
2631 @setRuntimeSafety(false);
2732 return @call(.{ .modifier = .always_inline }, __extendhfsf2, .{arg});
lib/std/special/compiler_rt/truncXfYf2.zig+5
......@@ -20,6 +20,11 @@ pub fn __trunctfdf2(a: f128) callconv(.C) f64 {
2020 return @call(.{ .modifier = .always_inline }, truncXfYf2, .{ f64, f128, a });
2121}
2222
23pub fn __trunctfxf2(a: f128) callconv(.C) c_longdouble {
24 _ = a;
25 @panic("TODO implement");
26}
27
2328pub fn __truncdfsf2(a: f64) callconv(.C) f32 {
2429 return @call(.{ .modifier = .always_inline }, truncXfYf2, .{ f32, f64, a });
2530}
lib/std/target.zig+7
......@@ -1712,6 +1712,13 @@ pub const Target = struct {
17121712 else => ".X",
17131713 };
17141714 }
1715
1716 pub inline fn longDoubleIsF128(target: Target) bool {
1717 return switch (target.cpu.arch) {
1718 .riscv64, .aarch64, .aarch64_be, .aarch64_32, .s390x, .mips64, .mips64el => true,
1719 else => false,
1720 };
1721 }
17151722};
17161723
17171724test {