Skip to content

Commit 92b259c

Browse files
committed
Add __floatdisf and __floatundisf intrinsics
1 parent 0633d73 commit 92b259c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ features = ["c"]
150150
- [x] fixunssfdi.c
151151
- [x] fixunssfsi.c
152152
- [x] floatdidf.c
153-
- [ ] floatdisf.c
153+
- [x] floatdisf.c
154154
- [x] floatsidf.c
155155
- [x] floatsisf.c
156156
- [x] floatundidf.c
157-
- [ ] floatundisf.c
157+
- [x] floatundisf.c
158158
- [x] floatunsidf.c
159159
- [x] floatunsisf.c
160160
- [ ] i386/ashldi3.S

src/float/conv.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ intrinsics! {
8080
int_to_float!(i, i32, f64)
8181
}
8282

83+
#[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
84+
#[arm_aeabi_alias = __aeabi_l2f]
85+
pub extern "C" fn __floatdisf(i: i64) -> f32 {
86+
// On x86_64 LLVM will use native instructions for this conversion, we
87+
// can just do it directly
88+
if cfg!(target_arch = "x86_64") {
89+
i as f32
90+
} else {
91+
int_to_float!(i, i64, f32)
92+
}
93+
}
94+
8395
#[use_c_shim_if(all(target_arch = "x86", not(target_env = "msvc")))]
8496
#[arm_aeabi_alias = __aeabi_l2d]
8597
pub extern "C" fn __floatdidf(i: i64) -> f64 {
@@ -112,6 +124,14 @@ intrinsics! {
112124
int_to_float!(i, u32, f64)
113125
}
114126

127+
#[use_c_shim_if(all(not(target_env = "msvc"),
128+
any(target_arch = "x86",
129+
all(not(windows), target_arch = "x86_64"))))]
130+
#[arm_aeabi_alias = __aeabi_ul2f]
131+
pub extern "C" fn __floatundisf(i: u64) -> f32 {
132+
int_to_float!(i, u64, f32)
133+
}
134+
115135
#[use_c_shim_if(all(not(target_env = "msvc"),
116136
any(target_arch = "x86",
117137
all(not(windows), target_arch = "x86_64"))))]

0 commit comments

Comments
 (0)