Implement f128 multiplication

This commit is contained in:
Trevor Gross 2024-05-10 19:46:50 -05:00
parent 2755f457f8
commit 191c1b88cd
4 changed files with 29 additions and 6 deletions

View file

@ -249,7 +249,7 @@ These builtins are needed to support `f16` and `f128`, which are in the process
- [ ] floatsitf.c
- [ ] floatunditf.c
- [ ] floatunsitf.c
- [ ] multf3.c
- [x] multf3.c
- [ ] powitf2.c
- [ ] ppc/fixtfdi.c
- [ ] ppc/fixunstfdi.c

View file

@ -543,7 +543,6 @@ mod c {
("__floatsitf", "floatsitf.c"),
("__floatunditf", "floatunditf.c"),
("__floatunsitf", "floatunsitf.c"),
("__multf3", "multf3.c"),
("__divtf3", "divtf3.c"),
("__powitf2", "powitf2.c"),
("__fe_getround", "fp_mode.c"),
@ -562,26 +561,22 @@ mod c {
if target_arch == "mips64" {
sources.extend(&[
("__netf2", "comparetf2.c"),
("__multf3", "multf3.c"),
("__fixtfsi", "fixtfsi.c"),
("__floatsitf", "floatsitf.c"),
("__fixunstfsi", "fixunstfsi.c"),
("__floatunsitf", "floatunsitf.c"),
("__fe_getround", "fp_mode.c"),
("__divtf3", "divtf3.c"),
]);
}
if target_arch == "loongarch64" {
sources.extend(&[
("__netf2", "comparetf2.c"),
("__multf3", "multf3.c"),
("__fixtfsi", "fixtfsi.c"),
("__floatsitf", "floatsitf.c"),
("__fixunstfsi", "fixunstfsi.c"),
("__floatunsitf", "floatunsitf.c"),
("__fe_getround", "fp_mode.c"),
("__divtf3", "divtf3.c"),
]);
}

View file

@ -199,6 +199,17 @@ intrinsics! {
mul(a, b)
}
#[cfg(not(any(feature = "no-f16-f128", target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __multf3(a: f128, b: f128) -> f128 {
mul(a, b)
}
#[cfg(all(not(feature = "no-f16-f128"), any(target_arch = "powerpc", target_arch = "powerpc64")))]
pub extern "C" fn __mulkf3(a: f128, b: f128) -> f128 {
mul(a, b)
}
#[cfg(target_arch = "arm")]
pub extern "C" fn __mulsf3vfp(a: f32, b: f32) -> f32 {
a * b

View file

@ -1,4 +1,6 @@
#![allow(unused_macros)]
#![feature(f128)]
#![feature(f16)]
use testcrate::*;
@ -114,6 +116,21 @@ fn float_mul() {
f32, __mulsf3, Single, all();
f64, __muldf3, Double, all();
);
#[cfg(not(feature = "no-f16-f128"))]
{
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
use compiler_builtins::float::mul::__mulkf3 as __multf3;
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
use compiler_builtins::float::mul::__multf3;
float_mul!(
f128, __multf3, Quad,
// FIXME(llvm): there is a bug in LLVM rt.
// See <https://github.com/llvm/llvm-project/issues/91840>.
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
);
}
}
#[cfg(target_arch = "arm")]