Skip to content

Commit f3f4dec

Browse files
committed
Add missing functions for f16 and f128
1 parent a991664 commit f3f4dec

File tree

8 files changed

+64
-6
lines changed

8 files changed

+64
-6
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ These builtins are needed to support 128-bit integers.
232232

233233
These builtins are needed to support `f16` and `f128`, which are in the process of being added to Rust.
234234

235-
- [ ] addtf3.c
236-
- [ ] comparetf2.c
237-
- [ ] divtf3.c
235+
- [x] addtf3.c
236+
- [x] comparetf2.c
237+
- [x] divtf3.c
238238
- [x] extenddftf2.c
239239
- [x] extendhfsf2.c
240240
- [x] extendhftf2.c
@@ -249,13 +249,13 @@ 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
256256
- [ ] ppc/floatditf.c
257257
- [ ] ppc/floatunditf.c
258-
- [ ] subtf3.c
258+
- [x] subtf3.c
259259
- [x] truncdfhf2.c
260260
- [x] truncsfhf2.c
261261
- [x] trunctfdf2.c

src/float/add.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ intrinsics! {
203203
add(a, b)
204204
}
205205

206+
pub extern "C" fn __addtf3(a: f128, b: f128) -> f128 {
207+
add(a, b)
208+
}
209+
206210
#[cfg(target_arch = "arm")]
207211
pub extern "C" fn __addsf3vfp(a: f32, b: f32) -> f32 {
208212
a + b

src/float/cmp.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,41 @@ intrinsics! {
170170
pub extern "C" fn __gtdf2(a: f64, b: f64) -> i32 {
171171
cmp(a, b).to_ge_abi()
172172
}
173+
174+
#[avr_skip]
175+
pub extern "C" fn __letf2(a: f128, b: f128) -> i32 {
176+
cmp(a, b).to_le_abi()
177+
}
178+
179+
#[avr_skip]
180+
pub extern "C" fn __getf2(a: f128, b: f128) -> i32 {
181+
cmp(a, b).to_ge_abi()
182+
}
183+
184+
#[avr_skip]
185+
pub extern "C" fn __unordtf2(a: f128, b: f128) -> i32 {
186+
unord(a, b) as i32
187+
}
188+
189+
#[avr_skip]
190+
pub extern "C" fn __eqtf2(a: f128, b: f128) -> i32 {
191+
cmp(a, b).to_le_abi()
192+
}
193+
194+
#[avr_skip]
195+
pub extern "C" fn __lttf2(a: f128, b: f128) -> i32 {
196+
cmp(a, b).to_le_abi()
197+
}
198+
199+
#[avr_skip]
200+
pub extern "C" fn __netf2(a: f128, b: f128) -> i32 {
201+
cmp(a, b).to_le_abi()
202+
}
203+
204+
#[avr_skip]
205+
pub extern "C" fn __gttf2(a: f128, b: f128) -> i32 {
206+
cmp(a, b).to_ge_abi()
207+
}
173208
}
174209

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

src/float/div.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,15 @@ intrinsics! {
914914
div64(a, b)
915915
}
916916

917+
// TODO: how should `HInt` be handled?
918+
pub extern "C" fn __divtf3(a: f128, b: f128) -> f128 {
919+
if cfg!(target_pointer_width = "64") {
920+
div32(a, b)
921+
} else {
922+
div64(a, b)
923+
}
924+
}
925+
917926
#[cfg(target_arch = "arm")]
918927
pub extern "C" fn __divsf3vfp(a: f32, b: f32) -> f32 {
919928
a / b

src/float/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(crate) trait Float:
5959
/// A mask for the significand
6060
const SIGNIFICAND_MASK: Self::Int;
6161

62-
// The implicit bit of the float format
62+
/// The implicit bit of the float format
6363
const IMPLICIT_BIT: Self::Int;
6464

6565
/// A mask for the exponent

src/float/mul.rs

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

202+
pub extern "C" fn __multf3(a: f128, b: f128) -> f128 {
203+
mul(a, b)
204+
}
205+
202206
#[cfg(target_arch = "arm")]
203207
pub extern "C" fn __mulsf3vfp(a: f32, b: f32) -> f32 {
204208
a * b

src/float/sub.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::float::add::__adddf3;
22
use crate::float::add::__addsf3;
3+
use crate::float::add::__addtf3;
34
use crate::float::Float;
45

56
intrinsics! {
@@ -15,6 +16,10 @@ intrinsics! {
1516
__adddf3(a, f64::from_repr(b.repr() ^ f64::SIGN_MASK))
1617
}
1718

19+
pub extern "C" fn __subtf3(a: f128, b: f128) -> f128 {
20+
__addtf3(a, f128::from_repr(b.repr() ^ f128::SIGN_MASK))
21+
}
22+
1823
#[cfg(target_arch = "arm")]
1924
pub extern "C" fn __subsf3vfp(a: f32, b: f32) -> f32 {
2025
a - b

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![cfg_attr(not(feature = "no-asm"), feature(asm))]
33
#![feature(abi_unadjusted)]
44
#![feature(asm_experimental_arch)]
5+
#![feature(c_unwind)]
56
#![cfg_attr(not(feature = "no-asm"), feature(global_asm))]
67
#![feature(cfg_target_has_atomic)]
78
#![feature(compiler_builtins)]

0 commit comments

Comments
 (0)