2 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Matt Thomas of 3am Software Foundry.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
31 #include <arm/vfpreg.h>
33 RCSID("$NetBSD: vfpsf.S,v 1.2 2013/06/23 06:19:55 matt Exp $")
36 * This file provides softfloat compatible routines which use VFP instructions
37 * to do the actual work. This should give near hard-float performance while
38 * being compatible with soft-float code.
40 * This file implements the single precision floating point routines.
44 #define __addsf3 __aeabi_fadd
45 #define __divsf3 __aeabi_fdiv
46 #define __mulsf3 __aeabi_fmul
47 #define __subsf3 __aeabi_fsub
48 #define __negsf2 __aeabi_fneg
49 #define __truncdfsf2 __aeabi_d2f
50 #define __fixsfsi __aeabi_f2iz
51 #define __fixunssfsi __aeabi_f2uiz
52 #define __floatsisf __aeabi_i2f
53 #define __floatunsisf __aeabi_ui2f
140 * Effect of a floating point comparision on the condition flags.
148 ENTRY(__aeabi_cfcmpeq)
151 vmrs APSR_nzcv, fpscr
155 ENTRY(__aeabi_cfcmple)
158 vmrs APSR_nzcv, fpscr
162 ENTRY(__aeabi_cfrcmple)
165 vmrs APSR_nzcv, fpscr
167 END(__aeabi_cfrcmple)
169 ENTRY(__aeabi_fcmpeq)
172 vmrs APSR_nzcv, fpscr
173 moveq r0, #1 /* (a == b) */
174 movne r0, #0 /* (a != b) or unordered */
178 ENTRY(__aeabi_fcmplt)
181 vmrs APSR_nzcv, fpscr
182 movlt r0, #1 /* (a < b) */
183 movcs r0, #0 /* (a >= b) or unordered */
187 ENTRY(__aeabi_fcmple)
190 vmrs APSR_nzcv, fpscr
191 movls r0, #1 /* (a <= b) */
192 movhi r0, #0 /* (a > b) or unordered */
196 ENTRY(__aeabi_fcmpge)
199 vmrs APSR_nzcv, fpscr
200 movge r0, #1 /* (a >= b) */
201 movlt r0, #0 /* (a < b) or unordered */
205 ENTRY(__aeabi_fcmpgt)
208 vmrs APSR_nzcv, fpscr
209 movgt r0, #1 /* (a > b) */
210 movle r0, #0 /* (a <= b) or unordered */
214 ENTRY(__aeabi_fcmpun)
217 vmrs APSR_nzcv, fpscr
218 movvs r0, #1 /* (isnan(a) || isnan(b)) */
219 movvc r0, #0 /* !isnan(a) && !isnan(b) */
224 /* N set if compare <= result */
225 /* Z set if compare = result */
226 /* C set if compare (=,>=,UNORD) result */
227 /* V set if compare UNORD result */
229 STRONG_ALIAS(__eqsf2, __nesf2)
233 vmrs APSR_nzcv, fpscr
234 moveq r0, #0 /* !(a == b) */
235 movne r0, #1 /* !(a == b) */
239 STRONG_ALIAS(__gesf2, __ltsf2)
243 vmrs APSR_nzcv, fpscr
244 mvnmi r0, #0 /* -(a < b) */
245 movpl r0, #0 /* -(a < b) */
249 STRONG_ALIAS(__gtsf2, __lesf2)
253 vmrs APSR_nzcv, fpscr
254 movgt r0, #1 /* (a > b) */
255 movle r0, #0 /* (a > b) */
262 vmrs APSR_nzcv, fpscr
263 movvs r0, #1 /* isnan(a) || isnan(b) */
264 movvc r0, #0 /* isnan(a) || isnan(b) */
267 #endif /* !__ARM_EABI__ */