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.
This commit is contained in:
Andrew Kelley 2021-10-05 18:17:55 -07:00
parent 5518a0aff2
commit 01ad6c0b02
5 changed files with 32 additions and 0 deletions

View File

@ -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);
}

View File

@ -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,

View File

@ -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});

View File

@ -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 });
}

View File

@ -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 {