Skip to content

Commit c99f5b6

Browse files
committed
Implement f128 multiplication
1 parent 2b3edd7 commit c99f5b6

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ These builtins are needed to support `f16` and `f128`, which are in the process
249249
- [ ] floatsitf.c
250250
- [ ] floatunditf.c
251251
- [ ] floatunsitf.c
252-
- [ ] multf3.c
252+
- [x] multf3.c
253253
- [ ] powitf2.c
254254
- [ ] ppc/fixtfdi.c
255255
- [ ] ppc/fixunstfdi.c

build.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ mod c {
543543
("__floatsitf", "floatsitf.c"),
544544
("__floatunditf", "floatunditf.c"),
545545
("__floatunsitf", "floatunsitf.c"),
546-
("__multf3", "multf3.c"),
547546
("__divtf3", "divtf3.c"),
548547
("__powitf2", "powitf2.c"),
549548
("__fe_getround", "fp_mode.c"),
@@ -562,26 +561,22 @@ mod c {
562561
if target_arch == "mips64" {
563562
sources.extend(&[
564563
("__netf2", "comparetf2.c"),
565-
("__multf3", "multf3.c"),
566564
("__fixtfsi", "fixtfsi.c"),
567565
("__floatsitf", "floatsitf.c"),
568566
("__fixunstfsi", "fixunstfsi.c"),
569567
("__floatunsitf", "floatunsitf.c"),
570568
("__fe_getround", "fp_mode.c"),
571-
("__divtf3", "divtf3.c"),
572569
]);
573570
}
574571

575572
if target_arch == "loongarch64" {
576573
sources.extend(&[
577574
("__netf2", "comparetf2.c"),
578-
("__multf3", "multf3.c"),
579575
("__fixtfsi", "fixtfsi.c"),
580576
("__floatsitf", "floatsitf.c"),
581577
("__fixunstfsi", "fixunstfsi.c"),
582578
("__floatunsitf", "floatunsitf.c"),
583579
("__fe_getround", "fp_mode.c"),
584-
("__divtf3", "divtf3.c"),
585580
]);
586581
}
587582

src/float/mul.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ intrinsics! {
199199
mul(a, b)
200200
}
201201

202+
#[cfg(not(any(feature = "no-f16-f128", target_arch = "powerpc", target_arch = "powerpc64")))]
203+
pub extern "C" fn __multf3(a: f128, b: f128) -> f128 {
204+
mul(a, b)
205+
}
206+
207+
208+
#[cfg(all(not(feature = "no-f16-f128"), any(target_arch = "powerpc", target_arch = "powerpc64")))]
209+
pub extern "C" fn __mulkf3(a: f128, b: f128) -> f128 {
210+
mul(a, b)
211+
}
212+
202213
#[cfg(target_arch = "arm")]
203214
pub extern "C" fn __mulsf3vfp(a: f32, b: f32) -> f32 {
204215
a * b

testcrate/tests/mul.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(unused_macros)]
2+
#![feature(f128)]
3+
#![feature(f16)]
24

35
use testcrate::*;
46

@@ -114,6 +116,21 @@ fn float_mul() {
114116
f32, __mulsf3, Single, all();
115117
f64, __muldf3, Double, all();
116118
);
119+
120+
#[cfg(not(feature = "no-f16-f128"))]
121+
{
122+
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
123+
use compiler_builtins::float::mul::__mulkf3 as __multf3;
124+
#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))]
125+
use compiler_builtins::float::mul::__multf3;
126+
127+
float_mul!(
128+
f128, __multf3, Quad,
129+
// FIXME(llvm): there is a bug in LLVM rt.
130+
// See <https://github.com/llvm/llvm-project/issues/91840>.
131+
not(any(feature = "no-sys-f128", all(target_arch = "aarch64", target_os = "linux")));
132+
);
133+
}
117134
}
118135

119136
#[cfg(target_arch = "arm")]

0 commit comments

Comments
 (0)