Skip to content

Commit 160ac7d

Browse files
committed
Compare float/double 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 cdb90c2 commit 160ac7d

File tree

3 files changed

+150
-8
lines changed

3 files changed

+150
-8
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

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 __ledf2vfp(a: f32, b: f32) -> i32 {
233+
(a <= b) as i32
234+
}
235+
236+
pub extern "C" fn __ledd2vfp(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
@@ -143,6 +143,108 @@ fn main() {
143143
},
144144
"compiler_builtins::float::cmp::__lesf2(a, b)");
145145

146+
if target_arch_arm {
147+
gen(|(a, b): (MyF32, MyF32)| {
148+
if a.0.is_nan() || b.0.is_nan() {
149+
None
150+
} else {
151+
let c = (a.0 != b.0) as i32;
152+
Some(c)
153+
}
154+
},
155+
"compiler_builtins::float::cmp::__nesf2vfp(a, b)");
156+
157+
gen(|(a, b): (MyF64, MyF64)| {
158+
if a.0.is_nan() || b.0.is_nan() {
159+
None
160+
} else {
161+
let c = (a.0 != b.0) as i32;
162+
Some(c)
163+
}
164+
},
165+
"compiler_builtins::float::cmp::__nedf2vfp(a, b)");
166+
167+
gen(|(a, b): (MyF32, MyF32)| {
168+
if a.0.is_nan() || b.0.is_nan() {
169+
None
170+
} else {
171+
let c = (a.0 < b.0) as i32;
172+
Some(c)
173+
}
174+
},
175+
"compiler_builtins::float::cmp::__ltdf2vfp(a, b)");
176+
177+
gen(|(a, b): (MyF64, MyF64)| {
178+
if a.0.is_nan() || b.0.is_nan() {
179+
None
180+
} else {
181+
let c = (a.0 < b.0) as i32;
182+
Some(c)
183+
}
184+
},
185+
"compiler_builtins::float::cmp::__ltdd2vfp(a, b)");
186+
187+
gen(|(a, b): (MyF32, MyF32)| {
188+
if a.0.is_nan() || b.0.is_nan() {
189+
None
190+
} else {
191+
let c = (a.0 <= b.0) as i32;
192+
Some(c)
193+
}
194+
},
195+
"compiler_builtins::float::cmp::__ledf2vfp(a, b)");
196+
197+
gen(|(a, b): (MyF64, MyF64)| {
198+
if a.0.is_nan() || b.0.is_nan() {
199+
None
200+
} else {
201+
let c = (a.0 <= b.0) as i32;
202+
Some(c)
203+
}
204+
},
205+
"compiler_builtins::float::cmp::__ledd2vfp(a, b)");
206+
207+
gen(|(a, b): (MyF32, MyF32)| {
208+
if a.0.is_nan() || b.0.is_nan() {
209+
None
210+
} else {
211+
let c = (a.0 > b.0) as i32;
212+
Some(c)
213+
}
214+
},
215+
"compiler_builtins::float::cmp::__gtdf2vfp(a, b)");
216+
217+
gen(|(a, b): (MyF64, MyF64)| {
218+
if a.0.is_nan() || b.0.is_nan() {
219+
None
220+
} else {
221+
let c = (a.0 > b.0) as i32;
222+
Some(c)
223+
}
224+
},
225+
"compiler_builtins::float::cmp::__gtdd2vfp(a, b)");
226+
227+
gen(|(a, b): (MyF32, MyF32)| {
228+
if a.0.is_nan() || b.0.is_nan() {
229+
None
230+
} else {
231+
let c = (a.0 >= b.0) as i32;
232+
Some(c)
233+
}
234+
},
235+
"compiler_builtins::float::cmp::__gesf2vfp(a, b)");
236+
237+
gen(|(a, b): (MyF64, MyF64)| {
238+
if a.0.is_nan() || b.0.is_nan() {
239+
None
240+
} else {
241+
let c = (a.0 >= b.0) as i32;
242+
Some(c)
243+
}
244+
},
245+
"compiler_builtins::float::cmp::__gedf2vfp(a, b)");
246+
}
247+
146248
// float/conv.rs
147249
gen(|a: MyF64| i64(a.0).ok(),
148250
"compiler_builtins::float::conv::__fixdfdi(a)");

0 commit comments

Comments
 (0)