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
39long long
40xfixdfdi(double a)
41{
42	return (long long)a;
43}
44
45int
46xfixdfsi(double a)
47{
48	return (int)a;
49}
50
51unsigned long long
52xfixunsdfdi(double a)
53{
54	return (unsigned long long)a;
55}
56
57unsigned int
58xfixunsdfsi(double a)
59{
60	return (unsigned int)a;
61}
62
63double
64xfloatundidf(unsigned long long a)
65{
66	return (double) a;
67}
68
69double
70xfloatunsidf(unsigned int a)
71{
72	return (double) a;
73}
74
75double
76xfloatdidf(long long a)
77{
78	return (double) a;
79}
80
81double
82xfloatsidf(int a)
83{
84	return (double) a;
85}
86
87double
88xextendsfdf2(float a)
89{
90	return (double) a;
91}
92
93int
94xeqdf2(double a, double b)
95{
96	return a == b;
97}
98
99int
100xnedf2(double a, double b)
101{
102	return a != b;
103}
104
105int
106xledf2(double a, double b)
107{
108	return a <= b;
109}
110
111int
112xgtdf2(double a, double b)
113{
114	return a > b;
115}
116
117int
118xltdf2(double a, double b)
119{
120	return a < b;
121}
122
123int
124xgedf2(double a, double b)
125{
126	return a >= b;
127}
128
129long long
130xfixsfdi(float a)
131{
132	return (long long)a;
133}
134
135int
136xfixsfsi(float a)
137{
138	return (int)a;
139}
140
141unsigned long long
142xfixunssfdi(float a)
143{
144	return (unsigned long long)a;
145}
146
147unsigned int
148xfixunssfsi(float a)
149{
150	return (unsigned int)a;
151}
152
153float
154xfloatundisf(unsigned long long a)
155{
156	return (float) a;
157}
158
159float
160xfloatunsisf(unsigned int a)
161{
162	return (float) a;
163}
164
165float
166xfloatdisf(long long a)
167{
168	return (float) a;
169}
170
171float
172xfloatsisf(int a)
173{
174	return (float) a;
175}
176
177float
178xtruncdfsf2(double a)
179{
180	return (float) a;
181}
182
183int
184xeqsf2(float a, float b)
185{
186	return a == b;
187}
188
189int
190xnesf2(float a, float b)
191{
192	return a != b;
193}
194
195int
196xlesf2(float a, float b)
197{
198	return a <= b;
199}
200
201int
202xgtsf2(float a, float b)
203{
204	return a > b;
205}
206
207int
208xltsf2(float a, float b)
209{
210	return a < b;
211}
212
213int
214xgesf2(float a, float b)
215{
216	return a >= b;
217}
218