Home | History | Annotate | Line # | Download | only in libc_fp
      1 /* $NetBSD: gcc-softfloat.c,v 1.1 2016/07/14 01:59:18 matt Exp $ */
      2 /*-
      3  * Copyright (c) 2016 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by Matt Thomas of 3am Software Foundry.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  * POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 /*
     32  * This contain the softfloat primitives used by GCC.
     33  * It can be used to verify the functions invoked by tGCC to do softfloat.
     34  * It can also be used to what FP instructions GCC generates to implement the
     35  * various primitives.  Your arch-dependent code should provide all of these
     36  * that are easy to implement.
     37  */
     38 
     39 long long
     40 xfixdfdi(double a)
     41 {
     42 	return (long long)a;
     43 }
     44 
     45 int
     46 xfixdfsi(double a)
     47 {
     48 	return (int)a;
     49 }
     50 
     51 unsigned long long
     52 xfixunsdfdi(double a)
     53 {
     54 	return (unsigned long long)a;
     55 }
     56 
     57 unsigned int
     58 xfixunsdfsi(double a)
     59 {
     60 	return (unsigned int)a;
     61 }
     62 
     63 double
     64 xfloatundidf(unsigned long long a)
     65 {
     66 	return (double) a;
     67 }
     68 
     69 double
     70 xfloatunsidf(unsigned int a)
     71 {
     72 	return (double) a;
     73 }
     74 
     75 double
     76 xfloatdidf(long long a)
     77 {
     78 	return (double) a;
     79 }
     80 
     81 double
     82 xfloatsidf(int a)
     83 {
     84 	return (double) a;
     85 }
     86 
     87 double
     88 xextendsfdf2(float a)
     89 {
     90 	return (double) a;
     91 }
     92 
     93 int
     94 xeqdf2(double a, double b)
     95 {
     96 	return a == b;
     97 }
     98 
     99 int
    100 xnedf2(double a, double b)
    101 {
    102 	return a != b;
    103 }
    104 
    105 int
    106 xledf2(double a, double b)
    107 {
    108 	return a <= b;
    109 }
    110 
    111 int
    112 xgtdf2(double a, double b)
    113 {
    114 	return a > b;
    115 }
    116 
    117 int
    118 xltdf2(double a, double b)
    119 {
    120 	return a < b;
    121 }
    122 
    123 int
    124 xgedf2(double a, double b)
    125 {
    126 	return a >= b;
    127 }
    128 
    129 long long
    130 xfixsfdi(float a)
    131 {
    132 	return (long long)a;
    133 }
    134 
    135 int
    136 xfixsfsi(float a)
    137 {
    138 	return (int)a;
    139 }
    140 
    141 unsigned long long
    142 xfixunssfdi(float a)
    143 {
    144 	return (unsigned long long)a;
    145 }
    146 
    147 unsigned int
    148 xfixunssfsi(float a)
    149 {
    150 	return (unsigned int)a;
    151 }
    152 
    153 float
    154 xfloatundisf(unsigned long long a)
    155 {
    156 	return (float) a;
    157 }
    158 
    159 float
    160 xfloatunsisf(unsigned int a)
    161 {
    162 	return (float) a;
    163 }
    164 
    165 float
    166 xfloatdisf(long long a)
    167 {
    168 	return (float) a;
    169 }
    170 
    171 float
    172 xfloatsisf(int a)
    173 {
    174 	return (float) a;
    175 }
    176 
    177 float
    178 xtruncdfsf2(double a)
    179 {
    180 	return (float) a;
    181 }
    182 
    183 int
    184 xeqsf2(float a, float b)
    185 {
    186 	return a == b;
    187 }
    188 
    189 int
    190 xnesf2(float a, float b)
    191 {
    192 	return a != b;
    193 }
    194 
    195 int
    196 xlesf2(float a, float b)
    197 {
    198 	return a <= b;
    199 }
    200 
    201 int
    202 xgtsf2(float a, float b)
    203 {
    204 	return a > b;
    205 }
    206 
    207 int
    208 xltsf2(float a, float b)
    209 {
    210 	return a < b;
    211 }
    212 
    213 int
    214 xgesf2(float a, float b)
    215 {
    216 	return a >= b;
    217 }
    218