/*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#ifndef AEABI_VFP_H28#define AEABI_VFP_H2930#include <machine/acle-compat.h>3132/*33* ASM helper macros. These allow the functions to be changed depending on34* the endian-ness we are building for.35*/3637/* Allow the name of the function to be changed depending on the ABI */38#ifndef __ARM_PCS_VFP39#define AEABI_ENTRY(x) ENTRY(__aeabi_ ## x ## _vfp)40#define AEABI_END(x) END(__aeabi_ ## x ## _vfp)41#else42#define AEABI_ENTRY(x) \43ENTRY(__aeabi_ ## x) \44.symver __aeabi_##x, __aeabi_##x##@FBSDprivate_1.0;45#define AEABI_END(x) END(__aeabi_ ## x)46#endif4748/*49* These should be used when a function either takes, or returns a floating50* point falue. They will load the data from an ARM to a VFP register(s),51* or from a VFP to an ARM register52*/53#ifdef __ARM_BIG_ENDIAN54#define LOAD_DREG(vreg, reg0, reg1) vmov vreg, reg1, reg055#define UNLOAD_DREG(reg0, reg1, vreg) vmov reg1, reg0, vreg56#else57#define LOAD_DREG(vreg, reg0, reg1) vmov vreg, reg0, reg158#define UNLOAD_DREG(reg0, reg1, vreg) vmov reg0, reg1, vreg59#endif6061#define LOAD_SREGS(vreg0, vreg1, reg0, reg1) vmov vreg0, vreg1, reg0, reg162#define LOAD_SREG(vreg, reg) vmov vreg, reg63#define UNLOAD_SREG(reg, vreg) vmov reg, vreg6465/*66* C Helper macros67*/6869#if !defined(SOFTFLOAT_FOR_GCC)70/*71* Generate a function that will either call into the VFP implementation,72* or the soft float version for a given __aeabi_* helper. The function73* will take a single argument of the type given by in_type.74*/75#define AEABI_FUNC(name, in_type, soft_func) \76__aeabi_ ## name(in_type a) \77{ \78if (_libc_arm_fpu_present) \79return __aeabi_ ## name ## _vfp(a); \80else \81return soft_func (a); \82}8384/* As above, but takes two arguments of the same type */85#define AEABI_FUNC2(name, in_type, soft_func) \86__aeabi_ ## name(in_type a, in_type b) \87{ \88if (_libc_arm_fpu_present) \89return __aeabi_ ## name ## _vfp(a, b); \90else \91return soft_func (a, b); \92}9394/* As above, but with the soft float arguments reversed */95#define AEABI_FUNC2_REV(name, in_type, soft_func) \96__aeabi_ ## name(in_type a, in_type b) \97{ \98if (_libc_arm_fpu_present) \99return __aeabi_ ## name ## _vfp(a, b); \100else \101return soft_func (b, a); \102}103#else104/*105* Helper macros for when we are only able to use the softfloat106* version of these functions, i.e. on arm before armv6.107*/108#define AEABI_FUNC(name, in_type, soft_func) \109__aeabi_ ## name(in_type a) \110{ \111return soft_func (a); \112}113114/* As above, but takes two arguments of the same type */115#define AEABI_FUNC2(name, in_type, soft_func) \116__aeabi_ ## name(in_type a, in_type b) \117{ \118return soft_func (a, b); \119}120121/* As above, but with the soft float arguments reversed */122#define AEABI_FUNC2_REV(name, in_type, soft_func) \123__aeabi_ ## name(in_type a, in_type b) \124{ \125return soft_func (b, a); \126}127#endif128129#endif130131132133