Path: blob/main/lib/libc/arm/aeabi/aeabi_vfp_float.S
39536 views
/*1* Copyright (C) 2013 Andrew Turner2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*25*/2627#include <machine/asm.h>28#include "aeabi_vfp.h"2930.fpu vfp31.syntax unified3233/* void __aeabi_cfcmpeq(float, float) */34AEABI_ENTRY(cfcmpeq)35LOAD_SREGS(s0, s1, r0, r1)36vcmp.f32 s0, s137vmrs APSR_nzcv, fpscr38RET39AEABI_END(cfcmpeq)4041/* void __aeabi_cfcmple(float, float) */42AEABI_ENTRY(cfcmple)43LOAD_SREGS(s0, s1, r0, r1)44vcmpe.f32 s0, s145vmrs APSR_nzcv, fpscr46RET47AEABI_END(cfcmple)4849/* void __aeabi_cfrcmple(float, float) */50AEABI_ENTRY(cfrcmple)51LOAD_SREGS(s0, s1, r0, r1)52vcmpe.f32 s1, s053vmrs APSR_nzcv, fpscr54RET55AEABI_END(cfrcmple)5657/* int __aeabi_fcmpeq(float, float) */58AEABI_ENTRY(fcmpeq)59LOAD_SREGS(s0, s1, r0, r1)60vcmp.f32 s0, s161vmrs APSR_nzcv, fpscr62ite ne63movne r0, #064moveq r0, #165RET66AEABI_END(fcmpeq)6768/* int __aeabi_fcmplt(float, float) */69AEABI_ENTRY(fcmplt)70LOAD_SREGS(s0, s1, r0, r1)71vcmp.f32 s0, s172vmrs APSR_nzcv, fpscr73ite cs74movcs r0, #075movcc r0, #176RET77AEABI_END(fcmplt)7879/* int __aeabi_fcmple(float, float) */80AEABI_ENTRY(fcmple)81LOAD_SREGS(s0, s1, r0, r1)82vcmp.f32 s0, s183vmrs APSR_nzcv, fpscr84ite hi85movhi r0, #086movls r0, #187RET88AEABI_END(fcmple)8990/* int __aeabi_fcmpge(float, float) */91AEABI_ENTRY(fcmpge)92LOAD_SREGS(s0, s1, r0, r1)93vcmp.f32 s0, s194vmrs APSR_nzcv, fpscr95ite lt96movlt r0, #097movge r0, #198RET99AEABI_END(fcmpge)100101/* int __aeabi_fcmpgt(float, float) */102AEABI_ENTRY(fcmpgt)103LOAD_SREGS(s0, s1, r0, r1)104vcmp.f32 s0, s1105vmrs APSR_nzcv, fpscr106ite le107movle r0, #0108movgt r0, #1109RET110AEABI_END(fcmpgt)111112/* int __aeabi_fcmpun(float, float) */113AEABI_ENTRY(fcmpun)114LOAD_SREGS(s0, s1, r0, r1)115vcmp.f32 s0, s1116vmrs APSR_nzcv, fpscr117ite vc118movvc r0, #0119movvs r0, #1120RET121AEABI_END(fcmpun)122123/* int __aeabi_f2iz(float) */124AEABI_ENTRY(f2iz)125LOAD_SREG(s0, r0)126#if 0127/*128* This should be the correct instruction, but binutils incorrectly129* encodes it as the version that used FPSCR to determine the rounding.130* When binutils is fixed we can use this again.131*/132vcvt.s32.f32 s0, s0133#else134ftosizs s0, s0135#endif136vmov r0, s0137RET138AEABI_END(f2iz)139140/* double __aeabi_f2d(float) */141AEABI_ENTRY(f2d)142LOAD_SREG(s0, r0)143vcvt.f64.f32 d0, s0144UNLOAD_DREG(r0, r1, d0)145RET146AEABI_END(f2d)147148/* float __aeabi_i2f(int) */149AEABI_ENTRY(i2f)150vmov s0, r0151vcvt.f32.s32 s0, s0152UNLOAD_SREG(r0, s0)153RET154AEABI_END(i2f)155156/* float __aeabi_fadd(float, float) */157AEABI_ENTRY(fadd)158LOAD_SREGS(s0, s1, r0, r1)159vadd.f32 s0, s0, s1160UNLOAD_SREG(r0, s0)161RET162AEABI_END(fadd)163164/* float __aeabi_fmul(float, float) */165AEABI_ENTRY(fdiv)166LOAD_SREGS(s0, s1, r0, r1)167vdiv.f32 s0, s0, s1168UNLOAD_SREG(r0, s0)169RET170AEABI_END(fdiv)171172/* float __aeabi_fmul(float, float) */173AEABI_ENTRY(fmul)174LOAD_SREGS(s0, s1, r0, r1)175vmul.f32 s0, s0, s1176UNLOAD_SREG(r0, s0)177RET178AEABI_END(fmul)179180/* float __aeabi_fsub(float, float) */181AEABI_ENTRY(fsub)182LOAD_SREGS(s0, s1, r0, r1)183vsub.f32 s0, s0, s1184UNLOAD_SREG(r0, s0)185RET186AEABI_END(fsub)187188.section .note.GNU-stack,"",%progbits189190191