Skip to content

Commit b243393

Browse files
committed
Float/double comparison using VFP registers
Here We need `extern "C"` to generate `aapcs` or `aapcs-vfp` calls depending on target configuration. Doing this LLVM generate: 00005614 <nesf2vfp>: 5614: eeb40ae0 vcmpe.f32 s0, s1 5618: e3a00000 mov r0, #0 561c: eef1fa10 vmrs APSR_nzcv, fpscr 5620: 13000001 movwne r0, rust-lang#1 5624: e12fff1e bx lr That's exactly what We need.
1 parent 13db8bf commit b243393

File tree

4 files changed

+150
-16
lines changed

4 files changed

+150
-16
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ features = ["c"]
111111
- [ ] arm/floatsisfvfp.S
112112
- [ ] arm/floatunssidfvfp.S
113113
- [ ] arm/floatunssisfvfp.S
114-
- [ ] arm/gedf2vfp.S
115-
- [ ] arm/gesf2vfp.S
116-
- [ ] arm/gtdf2vfp.S
117-
- [ ] arm/gtsf2vfp.S
118-
- [ ] arm/ledf2vfp.S
119-
- [ ] arm/lesf2vfp.S
120-
- [ ] arm/ltdf2vfp.S
121-
- [ ] arm/ltsf2vfp.S
114+
- [x] arm/gedf2vfp.S
115+
- [x] arm/gesf2vfp.S
116+
- [x] arm/gtdf2vfp.S
117+
- [x] arm/gtsf2vfp.S
118+
- [x] arm/ledf2vfp.S
119+
- [x] arm/lesf2vfp.S
120+
- [x] arm/ltdf2vfp.S
121+
- [x] arm/ltsf2vfp.S
122122
- [ ] arm/modsi3.S (generic version is done)
123123
- [x] arm/muldf3vfp.S
124124
- [x] arm/mulsf3vfp.S

build.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,6 @@ mod c {
386386
"arm/floatsisfvfp.S",
387387
"arm/floatunssidfvfp.S",
388388
"arm/floatunssisfvfp.S",
389-
"arm/gedf2vfp.S",
390-
"arm/gesf2vfp.S",
391-
"arm/gtdf2vfp.S",
392-
"arm/gtsf2vfp.S",
393-
"arm/ledf2vfp.S",
394-
"arm/lesf2vfp.S",
395-
"arm/ltdf2vfp.S",
396-
"arm/ltsf2vfp.S",
397389
"arm/nedf2vfp.S",
398390
"arm/nesf2vfp.S",
399391
"arm/restore_vfp_d8_d15_regs.S",

src/float/cmp.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,44 @@ intrinsics! {
212212
pub extern "aapcs" fn __aeabi_dcmpgt(a: f64, b: f64) -> i32 {
213213
(__gtdf2(a, b) > 0) as i32
214214
}
215+
216+
pub extern "C" fn __gesf2vfp(a: f32, b: f32) -> i32 {
217+
(a >= b) as i32
218+
}
219+
220+
pub extern "C" fn __gedf2vfp(a: f64, b: f64) -> i32 {
221+
(a >= b) as i32
222+
}
223+
224+
pub extern "C" fn __gtdf2vfp(a: f32, b: f32) -> i32 {
225+
(a > b) as i32
226+
}
227+
228+
pub extern "C" fn __gtdd2vfp(a: f64, b: f64) -> i32 {
229+
(a > b) as i32
230+
}
231+
232+
pub extern "C" fn __lesf2vfp(a: f32, b: f32) -> i32 {
233+
(a <= b) as i32
234+
}
235+
236+
pub extern "C" fn __ledf2vfp(a: f64, b: f64) -> i32 {
237+
(a <= b) as i32
238+
}
239+
240+
pub extern "C" fn __ltdf2vfp(a: f32, b: f32) -> i32 {
241+
(a < b) as i32
242+
}
243+
244+
pub extern "C" fn __ltdd2vfp(a: f64, b: f64) -> i32 {
245+
(a < b) as i32
246+
}
247+
248+
pub extern "C" fn __nesf2vfp(a: f32, b: f32) -> i32 {
249+
(a != b) as i32
250+
}
251+
252+
pub extern "C" fn __nedf2vfp(a: f64, b: f64) -> i32 {
253+
(a != b) as i32
254+
}
215255
}

testcrate/build.rs

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,108 @@ fn main() {
235235
"compiler_builtins::float::cmp::__aeabi_dcmpgt(a, b)");
236236
}
237237

238+
if target_arch_arm {
239+
gen(|(a, b): (LargeF32, LargeF32)| {
240+
if a.0.is_nan() || b.0.is_nan() {
241+
None
242+
} else {
243+
let c = (a.0 != b.0) as i32;
244+
Some(c)
245+
}
246+
},
247+
"compiler_builtins::float::cmp::__nesf2vfp(a, b)");
248+
249+
gen(|(a, b): (MyF64, MyF64)| {
250+
if a.0.is_nan() || b.0.is_nan() {
251+
None
252+
} else {
253+
let c = (a.0 != b.0) as i32;
254+
Some(c)
255+
}
256+
},
257+
"compiler_builtins::float::cmp::__nedf2vfp(a, b)");
258+
259+
gen(|(a, b): (LargeF32, LargeF32)| {
260+
if a.0.is_nan() || b.0.is_nan() {
261+
None
262+
} else {
263+
let c = (a.0 < b.0) as i32;
264+
Some(c)
265+
}
266+
},
267+
"compiler_builtins::float::cmp::__ltdf2vfp(a, b)");
268+
269+
gen(|(a, b): (MyF64, MyF64)| {
270+
if a.0.is_nan() || b.0.is_nan() {
271+
None
272+
} else {
273+
let c = (a.0 < b.0) as i32;
274+
Some(c)
275+
}
276+
},
277+
"compiler_builtins::float::cmp::__ltdd2vfp(a, b)");
278+
279+
gen(|(a, b): (LargeF32, LargeF32)| {
280+
if a.0.is_nan() || b.0.is_nan() {
281+
None
282+
} else {
283+
let c = (a.0 <= b.0) as i32;
284+
Some(c)
285+
}
286+
},
287+
"compiler_builtins::float::cmp::__lesf2vfp(a, b)");
288+
289+
gen(|(a, b): (MyF64, MyF64)| {
290+
if a.0.is_nan() || b.0.is_nan() {
291+
None
292+
} else {
293+
let c = (a.0 <= b.0) as i32;
294+
Some(c)
295+
}
296+
},
297+
"compiler_builtins::float::cmp::__ledf2vfp(a, b)");
298+
299+
gen(|(a, b): (LargeF32, LargeF32)| {
300+
if a.0.is_nan() || b.0.is_nan() {
301+
None
302+
} else {
303+
let c = (a.0 > b.0) as i32;
304+
Some(c)
305+
}
306+
},
307+
"compiler_builtins::float::cmp::__gtdf2vfp(a, b)");
308+
309+
gen(|(a, b): (MyF64, MyF64)| {
310+
if a.0.is_nan() || b.0.is_nan() {
311+
None
312+
} else {
313+
let c = (a.0 > b.0) as i32;
314+
Some(c)
315+
}
316+
},
317+
"compiler_builtins::float::cmp::__gtdd2vfp(a, b)");
318+
319+
gen(|(a, b): (LargeF32, LargeF32)| {
320+
if a.0.is_nan() || b.0.is_nan() {
321+
None
322+
} else {
323+
let c = (a.0 >= b.0) as i32;
324+
Some(c)
325+
}
326+
},
327+
"compiler_builtins::float::cmp::__gesf2vfp(a, b)");
328+
329+
gen(|(a, b): (MyF64, MyF64)| {
330+
if a.0.is_nan() || b.0.is_nan() {
331+
None
332+
} else {
333+
let c = (a.0 >= b.0) as i32;
334+
Some(c)
335+
}
336+
},
337+
"compiler_builtins::float::cmp::__gedf2vfp(a, b)");
338+
}
339+
238340
// float/conv.rs
239341
gen(|a: MyF64| i64(a.0).ok(),
240342
"compiler_builtins::float::conv::__fixdfdi(a)");

0 commit comments

Comments
 (0)