gcc-softfloat.c revision 1.1
11.1Smatt/* $NetBSD: gcc-softfloat.c,v 1.1 2016/07/14 01:59:18 matt Exp $ */ 21.1Smatt/*- 31.1Smatt * Copyright (c) 2016 The NetBSD Foundation, Inc. 41.1Smatt * All rights reserved. 51.1Smatt * 61.1Smatt * This code is derived from software contributed to The NetBSD Foundation 71.1Smatt * by Matt Thomas of 3am Software Foundry. 81.1Smatt * 91.1Smatt * Redistribution and use in source and binary forms, with or without 101.1Smatt * modification, are permitted provided that the following conditions 111.1Smatt * are met: 121.1Smatt * 1. Redistributions of source code must retain the above copyright 131.1Smatt * notice, this list of conditions and the following disclaimer. 141.1Smatt * 2. Redistributions in binary form must reproduce the above copyright 151.1Smatt * notice, this list of conditions and the following disclaimer in the 161.1Smatt * documentation and/or other materials provided with the distribution. 171.1Smatt * 181.1Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 191.1Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 201.1Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 211.1Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 221.1Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 231.1Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 241.1Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 251.1Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 261.1Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 271.1Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 281.1Smatt * POSSIBILITY OF SUCH DAMAGE. 291.1Smatt */ 301.1Smatt 311.1Smatt/* 321.1Smatt * This contain the softfloat primitives used by GCC. 331.1Smatt * It can be used to verify the functions invoked by tGCC to do softfloat. 341.1Smatt * It can also be used to what FP instructions GCC generates to implement the 351.1Smatt * various primitives. Your arch-dependent code should provide all of these 361.1Smatt * that are easy to implement. 371.1Smatt */ 381.1Smatt 391.1Smattlong long 401.1Smattxfixdfdi(double a) 411.1Smatt{ 421.1Smatt return (long long)a; 431.1Smatt} 441.1Smatt 451.1Smattint 461.1Smattxfixdfsi(double a) 471.1Smatt{ 481.1Smatt return (int)a; 491.1Smatt} 501.1Smatt 511.1Smattunsigned long long 521.1Smattxfixunsdfdi(double a) 531.1Smatt{ 541.1Smatt return (unsigned long long)a; 551.1Smatt} 561.1Smatt 571.1Smattunsigned int 581.1Smattxfixunsdfsi(double a) 591.1Smatt{ 601.1Smatt return (unsigned int)a; 611.1Smatt} 621.1Smatt 631.1Smattdouble 641.1Smattxfloatundidf(unsigned long long a) 651.1Smatt{ 661.1Smatt return (double) a; 671.1Smatt} 681.1Smatt 691.1Smattdouble 701.1Smattxfloatunsidf(unsigned int a) 711.1Smatt{ 721.1Smatt return (double) a; 731.1Smatt} 741.1Smatt 751.1Smattdouble 761.1Smattxfloatdidf(long long a) 771.1Smatt{ 781.1Smatt return (double) a; 791.1Smatt} 801.1Smatt 811.1Smattdouble 821.1Smattxfloatsidf(int a) 831.1Smatt{ 841.1Smatt return (double) a; 851.1Smatt} 861.1Smatt 871.1Smattdouble 881.1Smattxextendsfdf2(float a) 891.1Smatt{ 901.1Smatt return (double) a; 911.1Smatt} 921.1Smatt 931.1Smattint 941.1Smattxeqdf2(double a, double b) 951.1Smatt{ 961.1Smatt return a == b; 971.1Smatt} 981.1Smatt 991.1Smattint 1001.1Smattxnedf2(double a, double b) 1011.1Smatt{ 1021.1Smatt return a != b; 1031.1Smatt} 1041.1Smatt 1051.1Smattint 1061.1Smattxledf2(double a, double b) 1071.1Smatt{ 1081.1Smatt return a <= b; 1091.1Smatt} 1101.1Smatt 1111.1Smattint 1121.1Smattxgtdf2(double a, double b) 1131.1Smatt{ 1141.1Smatt return a > b; 1151.1Smatt} 1161.1Smatt 1171.1Smattint 1181.1Smattxltdf2(double a, double b) 1191.1Smatt{ 1201.1Smatt return a < b; 1211.1Smatt} 1221.1Smatt 1231.1Smattint 1241.1Smattxgedf2(double a, double b) 1251.1Smatt{ 1261.1Smatt return a >= b; 1271.1Smatt} 1281.1Smatt 1291.1Smattlong long 1301.1Smattxfixsfdi(float a) 1311.1Smatt{ 1321.1Smatt return (long long)a; 1331.1Smatt} 1341.1Smatt 1351.1Smattint 1361.1Smattxfixsfsi(float a) 1371.1Smatt{ 1381.1Smatt return (int)a; 1391.1Smatt} 1401.1Smatt 1411.1Smattunsigned long long 1421.1Smattxfixunssfdi(float a) 1431.1Smatt{ 1441.1Smatt return (unsigned long long)a; 1451.1Smatt} 1461.1Smatt 1471.1Smattunsigned int 1481.1Smattxfixunssfsi(float a) 1491.1Smatt{ 1501.1Smatt return (unsigned int)a; 1511.1Smatt} 1521.1Smatt 1531.1Smattfloat 1541.1Smattxfloatundisf(unsigned long long a) 1551.1Smatt{ 1561.1Smatt return (float) a; 1571.1Smatt} 1581.1Smatt 1591.1Smattfloat 1601.1Smattxfloatunsisf(unsigned int a) 1611.1Smatt{ 1621.1Smatt return (float) a; 1631.1Smatt} 1641.1Smatt 1651.1Smattfloat 1661.1Smattxfloatdisf(long long a) 1671.1Smatt{ 1681.1Smatt return (float) a; 1691.1Smatt} 1701.1Smatt 1711.1Smattfloat 1721.1Smattxfloatsisf(int a) 1731.1Smatt{ 1741.1Smatt return (float) a; 1751.1Smatt} 1761.1Smatt 1771.1Smattfloat 1781.1Smattxtruncdfsf2(double a) 1791.1Smatt{ 1801.1Smatt return (float) a; 1811.1Smatt} 1821.1Smatt 1831.1Smattint 1841.1Smattxeqsf2(float a, float b) 1851.1Smatt{ 1861.1Smatt return a == b; 1871.1Smatt} 1881.1Smatt 1891.1Smattint 1901.1Smattxnesf2(float a, float b) 1911.1Smatt{ 1921.1Smatt return a != b; 1931.1Smatt} 1941.1Smatt 1951.1Smattint 1961.1Smattxlesf2(float a, float b) 1971.1Smatt{ 1981.1Smatt return a <= b; 1991.1Smatt} 2001.1Smatt 2011.1Smattint 2021.1Smattxgtsf2(float a, float b) 2031.1Smatt{ 2041.1Smatt return a > b; 2051.1Smatt} 2061.1Smatt 2071.1Smattint 2081.1Smattxltsf2(float a, float b) 2091.1Smatt{ 2101.1Smatt return a < b; 2111.1Smatt} 2121.1Smatt 2131.1Smattint 2141.1Smattxgesf2(float a, float b) 2151.1Smatt{ 2161.1Smatt return a >= b; 2171.1Smatt} 218