Skip to content

Commit 13db8bf

Browse files
committed
Add support for sub*f3vfp and add*f3vfp
As done before for mul and div let's use extern "C" to generate `"aapcs"` or `"aapcs-vfp"` depending on target configuration.
1 parent 2d8f137 commit 13db8bf

File tree

5 files changed

+67
-8
lines changed

5 files changed

+67
-8
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ features = ["c"]
8585

8686
- [x] adddf3.c
8787
- [x] addsf3.c
88-
- [ ] arm/adddf3vfp.S
89-
- [ ] arm/addsf3vfp.S
88+
- [x] arm/adddf3vfp.S
89+
- [x] arm/addsf3vfp.S
9090
- [ ] arm/aeabi_dcmp.S
9191
- [ ] arm/aeabi_fcmp.S
9292
- [x] arm/aeabi_idivmod.S
@@ -127,8 +127,8 @@ features = ["c"]
127127
- [ ] arm/negsf2vfp.S
128128
- [ ] arm/nesf2vfp.S
129129
- [ ] arm/softfloat-alias.list
130-
- [ ] arm/subdf3vfp.S
131-
- [ ] arm/subsf3vfp.S
130+
- [x] arm/subdf3vfp.S
131+
- [x] arm/subsf3vfp.S
132132
- [ ] arm/truncdfsf2vfp.S
133133
- [ ] arm/udivmodsi4.S (generic version is done)
134134
- [ ] arm/udivsi3.S (generic version is done)

build.rs

-4
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,6 @@ mod c {
375375
if !llvm_target[0].starts_with("thumbv7em") {
376376
sources.extend(
377377
&[
378-
"arm/adddf3vfp.S",
379-
"arm/addsf3vfp.S",
380378
"arm/eqdf2vfp.S",
381379
"arm/eqsf2vfp.S",
382380
"arm/extendsfdf2vfp.S",
@@ -400,8 +398,6 @@ mod c {
400398
"arm/nesf2vfp.S",
401399
"arm/restore_vfp_d8_d15_regs.S",
402400
"arm/save_vfp_d8_d15_regs.S",
403-
"arm/subdf3vfp.S",
404-
"arm/subsf3vfp.S",
405401
],
406402
);
407403
}

src/float/add.rs

+10
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,14 @@ intrinsics! {
193193
pub extern "C" fn __adddf3(a: f64, b: f64) -> f64 {
194194
add(a, b)
195195
}
196+
197+
#[cfg(target_arch = "arm")]
198+
pub extern "C" fn __addsf3vfp(a: f32, b: f32) -> f32 {
199+
a + b
200+
}
201+
202+
#[cfg(target_arch = "arm")]
203+
pub extern "C" fn __adddf3vfp(a: f64, b: f64) -> f64 {
204+
a + b
205+
}
196206
}

src/float/sub.rs

+10
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ intrinsics! {
1010
pub extern "C" fn __subdf3(a: f64, b: f64) -> f64 {
1111
a + f64::from_repr(b.repr() ^ f64::SIGN_MASK)
1212
}
13+
14+
#[cfg(target_arch = "arm")]
15+
pub extern "C" fn __subsf3vfp(a: f32, b: f32) -> f32 {
16+
a - b
17+
}
18+
19+
#[cfg(target_arch = "arm")]
20+
pub extern "C" fn __subdf3vfp(a: f64, b: f64) -> f64 {
21+
a - b
22+
}
1323
}

testcrate/build.rs

+43
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ fn main() {
5151
},
5252
"compiler_builtins::float::add::__addsf3(a, b)");
5353

54+
if target_arch_arm {
55+
gen(|(a, b): (MyF64, MyF64)| {
56+
let c = a.0 + b.0;
57+
if a.0.is_nan() || b.0.is_nan() || c.is_nan() {
58+
None
59+
} else {
60+
Some(c)
61+
}
62+
},
63+
"compiler_builtins::float::add::__adddf3vfp(a, b)");
64+
gen(|(a, b): (LargeF32, LargeF32)| {
65+
let c = a.0 + b.0;
66+
if a.0.is_nan() || b.0.is_nan() || c.is_nan() {
67+
None
68+
} else {
69+
Some(c)
70+
}
71+
},
72+
"compiler_builtins::float::add::__addsf3vfp(a, b)");
73+
}
74+
75+
5476
// float/cmp.rs
5577
gen(|(a, b): (MyF64, MyF64)| {
5678
let (a, b) = (a.0, b.0);
@@ -301,6 +323,27 @@ fn main() {
301323
},
302324
"compiler_builtins::float::sub::__subsf3(a, b)");
303325

326+
if target_arch_arm {
327+
gen(|(a, b): (MyF64, MyF64)| {
328+
let c = a.0 - b.0;
329+
if a.0.is_nan() || b.0.is_nan() || c.is_nan() {
330+
None
331+
} else {
332+
Some(c)
333+
}
334+
},
335+
"compiler_builtins::float::sub::__subdf3vfp(a, b)");
336+
gen(|(a, b): (LargeF32, LargeF32)| {
337+
let c = a.0 - b.0;
338+
if a.0.is_nan() || b.0.is_nan() || c.is_nan() {
339+
None
340+
} else {
341+
Some(c)
342+
}
343+
},
344+
"compiler_builtins::float::sub::__subsf3vfp(a, b)");
345+
}
346+
304347
// float/mul.rs
305348
gen(|(a, b): (MyF64, MyF64)| {
306349
let c = a.0 * b.0;

0 commit comments

Comments
 (0)