Skip to content

Commit cb04a07

Browse files
authored
Merge pull request #234 from ketsuban/master
Add __floatdisf and __floatundisf intrinsics
2 parents 2a2f6d9 + e3dda36 commit cb04a07

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ features = ["c"]
156156
- [x] fixunssfdi.c
157157
- [x] fixunssfsi.c
158158
- [x] floatdidf.c
159-
- [ ] floatdisf.c
159+
- [x] floatdisf.c
160160
- [x] floatsidf.c
161161
- [x] floatsisf.c
162162
- [x] floatundidf.c
163-
- [ ] floatundisf.c
163+
- [x] floatundisf.c
164164
- [x] floatunsidf.c
165165
- [x] floatunsisf.c
166166
- [ ] i386/ashldi3.S

build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ mod c {
174174
"divsc3.c",
175175
"divxc3.c",
176176
"extendhfsf2.c",
177-
"floatdisf.c",
178-
"floatundisf.c",
179177
"int_util.c",
180178
"muldc3.c",
181179
"mulsc3.c",

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)