aeabi_double.c revision 273471
1245655Sandrew/* 2245655Sandrew * Copyright (C) 2012 Andrew Turner 3245655Sandrew * All rights reserved. 4245655Sandrew * 5245655Sandrew * Redistribution and use in source and binary forms, with or without 6245655Sandrew * modification, are permitted provided that the following conditions 7245655Sandrew * are met: 8245655Sandrew * 1. Redistributions of source code must retain the above copyright 9245655Sandrew * notice, this list of conditions and the following disclaimer. 10245655Sandrew * 2. Redistributions in binary form must reproduce the above copyright 11245655Sandrew * notice, this list of conditions and the following disclaimer in the 12245655Sandrew * documentation and/or other materials provided with the distribution. 13245655Sandrew * 14245655Sandrew * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15245655Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16245655Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17245655Sandrew * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18245655Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19245655Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20245655Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21245655Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22245655Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23245655Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24245655Sandrew * SUCH DAMAGE. 25245655Sandrew * 26245655Sandrew */ 27245655Sandrew 28245655Sandrew#include <sys/cdefs.h> 29245655Sandrew__FBSDID("$FreeBSD: stable/10/lib/libc/arm/aeabi/aeabi_double.c 273471 2014-10-22 13:50:38Z andrew $"); 30245655Sandrew 31245655Sandrew#include "softfloat-for-gcc.h" 32245655Sandrew#include "milieu.h" 33245655Sandrew#include "softfloat.h" 34245655Sandrew 35266314Sian#include "aeabi_vfp.h" 36245655Sandrew 37266314Sianextern int _libc_arm_fpu_present; 38245655Sandrew 39266314Sianflag __unorddf2(float64, float64); 40245655Sandrew 41266314Sian/* These are written in asm and are only called from this file */ 42266314Sianint __aeabi_dcmpeq_vfp(float64, float64); 43266314Sianint __aeabi_dcmplt_vfp(float64, float64); 44266314Sianint __aeabi_dcmple_vfp(float64, float64); 45266314Sianint __aeabi_dcmpgt_vfp(float64, float64); 46266314Sianint __aeabi_dcmpge_vfp(float64, float64); 47266314Sianint __aeabi_dcmpun_vfp(float64, float64); 48266314Sianint __aeabi_d2iz_vfp(float64); 49266314Sianfloat32 __aeabi_d2f_vfp(float64); 50266314Sianfloat64 __aeabi_i2d_vfp(int); 51266314Sianfloat64 __aeabi_dadd_vfp(float64, float64); 52266314Sianfloat64 __aeabi_ddiv_vfp(float64, float64); 53266314Sianfloat64 __aeabi_dmul_vfp(float64, float64); 54266314Sianfloat64 __aeabi_dsub_vfp(float64, float64); 55245655Sandrew 56266314Sian/* 57266314Sian * Depending on the target these will: 58266314Sian * On armv6 with a vfp call the above function, or 59266314Sian * Call the softfloat function in the 3rd argument. 60266314Sian */ 61266314Sianint AEABI_FUNC2(dcmpeq, float64, float64_eq) 62266314Sianint AEABI_FUNC2(dcmplt, float64, float64_lt) 63266314Sianint AEABI_FUNC2(dcmple, float64, float64_le) 64266314Sianint AEABI_FUNC2_REV(dcmpge, float64, float64_le) 65266314Sianint AEABI_FUNC2_REV(dcmpgt, float64, float64_lt) 66266314Sianint AEABI_FUNC2(dcmpun, float64, __unorddf2) 67245655Sandrew 68266314Sianint AEABI_FUNC(d2iz, float64, float64_to_int32_round_to_zero) 69266314Sianfloat32 AEABI_FUNC(d2f, float64, float64_to_float32) 70266314Sianfloat64 AEABI_FUNC(i2d, int, int32_to_float64) 71245655Sandrew 72266314Sianfloat64 AEABI_FUNC2(dadd, float64, float64_add) 73266314Sianfloat64 AEABI_FUNC2(ddiv, float64, float64_div) 74266314Sianfloat64 AEABI_FUNC2(dmul, float64, float64_mul) 75266314Sianfloat64 AEABI_FUNC2(dsub, float64, float64_sub) 76245655Sandrew 77273471Sandrewint 78273471Sandrew__aeabi_cdcmpeq_helper(float64 a, float64 b) 79273471Sandrew{ 80273471Sandrew int quiet = 0; 81273471Sandrew 82273471Sandrew /* Check if a is a NaN */ 83273471Sandrew if ((a << 1) > 0xffe0000000000000ull) { 84273471Sandrew /* If it's a signalling NaN we will always signal */ 85273471Sandrew if ((a & 0x0008000000000000ull) == 0) 86273471Sandrew return (0); 87273471Sandrew 88273471Sandrew quiet = 1; 89273471Sandrew } 90273471Sandrew 91273471Sandrew /* Check if b is a NaN */ 92273471Sandrew if ((b << 1) > 0xffe0000000000000ull) { 93273471Sandrew /* If it's a signalling NaN we will always signal */ 94273471Sandrew if ((b & 0x0008000000000000ull) == 0) 95273471Sandrew return (0); 96273471Sandrew 97273471Sandrew quiet = 1; 98273471Sandrew } 99273471Sandrew 100273471Sandrew return (quiet); 101273471Sandrew} 102