VirtualBox

source: vbox/trunk/src/libs/softfloat-3e/source/include/softfloat.h@ 94552

最後變更 在這個檔案從94552是 94480,由 vboxsync 提交於 3 年 前

libs/softfloat-3e: Copied from vendor branch (SoftFloat-3e.zip, md5: 7dac954ea4aed0697cbfee800ba4f492). bugref:9898

  • 屬性 svn:eol-style 設為 native
檔案大小: 17.0 KB
 
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
8University of California. All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37
38/*============================================================================
39| Note: If SoftFloat is made available as a general library for programs to
40| use, it is strongly recommended that a platform-specific version of this
41| header, "softfloat.h", be created that folds in "softfloat_types.h" and that
42| eliminates all dependencies on compile-time macros.
43*============================================================================*/
44
45
46#ifndef softfloat_h
47#define softfloat_h 1
48
49#include <stdbool.h>
50#include <stdint.h>
51#include "softfloat_types.h"
52
53#ifndef THREAD_LOCAL
54#define THREAD_LOCAL
55#endif
56
57/*----------------------------------------------------------------------------
58| Software floating-point underflow tininess-detection mode.
59*----------------------------------------------------------------------------*/
60extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
61enum {
62 softfloat_tininess_beforeRounding = 0,
63 softfloat_tininess_afterRounding = 1
64};
65
66/*----------------------------------------------------------------------------
67| Software floating-point rounding mode. (Mode "odd" is supported only if
68| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
69*----------------------------------------------------------------------------*/
70extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
71enum {
72 softfloat_round_near_even = 0,
73 softfloat_round_minMag = 1,
74 softfloat_round_min = 2,
75 softfloat_round_max = 3,
76 softfloat_round_near_maxMag = 4,
77 softfloat_round_odd = 6
78};
79
80/*----------------------------------------------------------------------------
81| Software floating-point exception flags.
82*----------------------------------------------------------------------------*/
83extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
84enum {
85 softfloat_flag_inexact = 1,
86 softfloat_flag_underflow = 2,
87 softfloat_flag_overflow = 4,
88 softfloat_flag_infinite = 8,
89 softfloat_flag_invalid = 16
90};
91
92/*----------------------------------------------------------------------------
93| Routine to raise any or all of the software floating-point exception flags.
94*----------------------------------------------------------------------------*/
95void softfloat_raiseFlags( uint_fast8_t );
96
97/*----------------------------------------------------------------------------
98| Integer-to-floating-point conversion routines.
99*----------------------------------------------------------------------------*/
100float16_t ui32_to_f16( uint32_t );
101float32_t ui32_to_f32( uint32_t );
102float64_t ui32_to_f64( uint32_t );
103#ifdef SOFTFLOAT_FAST_INT64
104extFloat80_t ui32_to_extF80( uint32_t );
105float128_t ui32_to_f128( uint32_t );
106#endif
107void ui32_to_extF80M( uint32_t, extFloat80_t * );
108void ui32_to_f128M( uint32_t, float128_t * );
109float16_t ui64_to_f16( uint64_t );
110float32_t ui64_to_f32( uint64_t );
111float64_t ui64_to_f64( uint64_t );
112#ifdef SOFTFLOAT_FAST_INT64
113extFloat80_t ui64_to_extF80( uint64_t );
114float128_t ui64_to_f128( uint64_t );
115#endif
116void ui64_to_extF80M( uint64_t, extFloat80_t * );
117void ui64_to_f128M( uint64_t, float128_t * );
118float16_t i32_to_f16( int32_t );
119float32_t i32_to_f32( int32_t );
120float64_t i32_to_f64( int32_t );
121#ifdef SOFTFLOAT_FAST_INT64
122extFloat80_t i32_to_extF80( int32_t );
123float128_t i32_to_f128( int32_t );
124#endif
125void i32_to_extF80M( int32_t, extFloat80_t * );
126void i32_to_f128M( int32_t, float128_t * );
127float16_t i64_to_f16( int64_t );
128float32_t i64_to_f32( int64_t );
129float64_t i64_to_f64( int64_t );
130#ifdef SOFTFLOAT_FAST_INT64
131extFloat80_t i64_to_extF80( int64_t );
132float128_t i64_to_f128( int64_t );
133#endif
134void i64_to_extF80M( int64_t, extFloat80_t * );
135void i64_to_f128M( int64_t, float128_t * );
136
137/*----------------------------------------------------------------------------
138| 16-bit (half-precision) floating-point operations.
139*----------------------------------------------------------------------------*/
140uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
141uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
142int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
143int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
144uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
145uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
146int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
147int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
148float32_t f16_to_f32( float16_t );
149float64_t f16_to_f64( float16_t );
150#ifdef SOFTFLOAT_FAST_INT64
151extFloat80_t f16_to_extF80( float16_t );
152float128_t f16_to_f128( float16_t );
153#endif
154void f16_to_extF80M( float16_t, extFloat80_t * );
155void f16_to_f128M( float16_t, float128_t * );
156float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
157float16_t f16_add( float16_t, float16_t );
158float16_t f16_sub( float16_t, float16_t );
159float16_t f16_mul( float16_t, float16_t );
160float16_t f16_mulAdd( float16_t, float16_t, float16_t );
161float16_t f16_div( float16_t, float16_t );
162float16_t f16_rem( float16_t, float16_t );
163float16_t f16_sqrt( float16_t );
164bool f16_eq( float16_t, float16_t );
165bool f16_le( float16_t, float16_t );
166bool f16_lt( float16_t, float16_t );
167bool f16_eq_signaling( float16_t, float16_t );
168bool f16_le_quiet( float16_t, float16_t );
169bool f16_lt_quiet( float16_t, float16_t );
170bool f16_isSignalingNaN( float16_t );
171
172/*----------------------------------------------------------------------------
173| 32-bit (single-precision) floating-point operations.
174*----------------------------------------------------------------------------*/
175uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
176uint_fast64_t f32_to_ui64( float32_t, uint_fast8_t, bool );
177int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
178int_fast64_t f32_to_i64( float32_t, uint_fast8_t, bool );
179uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
180uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
181int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
182int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
183float16_t f32_to_f16( float32_t );
184float64_t f32_to_f64( float32_t );
185#ifdef SOFTFLOAT_FAST_INT64
186extFloat80_t f32_to_extF80( float32_t );
187float128_t f32_to_f128( float32_t );
188#endif
189void f32_to_extF80M( float32_t, extFloat80_t * );
190void f32_to_f128M( float32_t, float128_t * );
191float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
192float32_t f32_add( float32_t, float32_t );
193float32_t f32_sub( float32_t, float32_t );
194float32_t f32_mul( float32_t, float32_t );
195float32_t f32_mulAdd( float32_t, float32_t, float32_t );
196float32_t f32_div( float32_t, float32_t );
197float32_t f32_rem( float32_t, float32_t );
198float32_t f32_sqrt( float32_t );
199bool f32_eq( float32_t, float32_t );
200bool f32_le( float32_t, float32_t );
201bool f32_lt( float32_t, float32_t );
202bool f32_eq_signaling( float32_t, float32_t );
203bool f32_le_quiet( float32_t, float32_t );
204bool f32_lt_quiet( float32_t, float32_t );
205bool f32_isSignalingNaN( float32_t );
206
207/*----------------------------------------------------------------------------
208| 64-bit (double-precision) floating-point operations.
209*----------------------------------------------------------------------------*/
210uint_fast32_t f64_to_ui32( float64_t, uint_fast8_t, bool );
211uint_fast64_t f64_to_ui64( float64_t, uint_fast8_t, bool );
212int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
213int_fast64_t f64_to_i64( float64_t, uint_fast8_t, bool );
214uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
215uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
216int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
217int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
218float16_t f64_to_f16( float64_t );
219float32_t f64_to_f32( float64_t );
220#ifdef SOFTFLOAT_FAST_INT64
221extFloat80_t f64_to_extF80( float64_t );
222float128_t f64_to_f128( float64_t );
223#endif
224void f64_to_extF80M( float64_t, extFloat80_t * );
225void f64_to_f128M( float64_t, float128_t * );
226float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
227float64_t f64_add( float64_t, float64_t );
228float64_t f64_sub( float64_t, float64_t );
229float64_t f64_mul( float64_t, float64_t );
230float64_t f64_mulAdd( float64_t, float64_t, float64_t );
231float64_t f64_div( float64_t, float64_t );
232float64_t f64_rem( float64_t, float64_t );
233float64_t f64_sqrt( float64_t );
234bool f64_eq( float64_t, float64_t );
235bool f64_le( float64_t, float64_t );
236bool f64_lt( float64_t, float64_t );
237bool f64_eq_signaling( float64_t, float64_t );
238bool f64_le_quiet( float64_t, float64_t );
239bool f64_lt_quiet( float64_t, float64_t );
240bool f64_isSignalingNaN( float64_t );
241
242/*----------------------------------------------------------------------------
243| Rounding precision for 80-bit extended double-precision floating-point.
244| Valid values are 32, 64, and 80.
245*----------------------------------------------------------------------------*/
246extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
247
248/*----------------------------------------------------------------------------
249| 80-bit extended double-precision floating-point operations.
250*----------------------------------------------------------------------------*/
251#ifdef SOFTFLOAT_FAST_INT64
252uint_fast32_t extF80_to_ui32( extFloat80_t, uint_fast8_t, bool );
253uint_fast64_t extF80_to_ui64( extFloat80_t, uint_fast8_t, bool );
254int_fast32_t extF80_to_i32( extFloat80_t, uint_fast8_t, bool );
255int_fast64_t extF80_to_i64( extFloat80_t, uint_fast8_t, bool );
256uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
257uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
258int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
259int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
260float16_t extF80_to_f16( extFloat80_t );
261float32_t extF80_to_f32( extFloat80_t );
262float64_t extF80_to_f64( extFloat80_t );
263float128_t extF80_to_f128( extFloat80_t );
264extFloat80_t extF80_roundToInt( extFloat80_t, uint_fast8_t, bool );
265extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
266extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
267extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
268extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
269extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
270extFloat80_t extF80_sqrt( extFloat80_t );
271bool extF80_eq( extFloat80_t, extFloat80_t );
272bool extF80_le( extFloat80_t, extFloat80_t );
273bool extF80_lt( extFloat80_t, extFloat80_t );
274bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
275bool extF80_le_quiet( extFloat80_t, extFloat80_t );
276bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
277bool extF80_isSignalingNaN( extFloat80_t );
278#endif
279uint_fast32_t extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
280uint_fast64_t extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
281int_fast32_t extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
282int_fast64_t extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
283uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
284uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
285int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
286int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
287float16_t extF80M_to_f16( const extFloat80_t * );
288float32_t extF80M_to_f32( const extFloat80_t * );
289float64_t extF80M_to_f64( const extFloat80_t * );
290void extF80M_to_f128M( const extFloat80_t *, float128_t * );
291void
292 extF80M_roundToInt(
293 const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
294void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
295void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
296void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
297void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
298void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
299void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
300bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
301bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
302bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
303bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
304bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
305bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
306bool extF80M_isSignalingNaN( const extFloat80_t * );
307
308/*----------------------------------------------------------------------------
309| 128-bit (quadruple-precision) floating-point operations.
310*----------------------------------------------------------------------------*/
311#ifdef SOFTFLOAT_FAST_INT64
312uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
313uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
314int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
315int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
316uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
317uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
318int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
319int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
320float16_t f128_to_f16( float128_t );
321float32_t f128_to_f32( float128_t );
322float64_t f128_to_f64( float128_t );
323extFloat80_t f128_to_extF80( float128_t );
324float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
325float128_t f128_add( float128_t, float128_t );
326float128_t f128_sub( float128_t, float128_t );
327float128_t f128_mul( float128_t, float128_t );
328float128_t f128_mulAdd( float128_t, float128_t, float128_t );
329float128_t f128_div( float128_t, float128_t );
330float128_t f128_rem( float128_t, float128_t );
331float128_t f128_sqrt( float128_t );
332bool f128_eq( float128_t, float128_t );
333bool f128_le( float128_t, float128_t );
334bool f128_lt( float128_t, float128_t );
335bool f128_eq_signaling( float128_t, float128_t );
336bool f128_le_quiet( float128_t, float128_t );
337bool f128_lt_quiet( float128_t, float128_t );
338bool f128_isSignalingNaN( float128_t );
339#endif
340uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
341uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
342int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );
343int_fast64_t f128M_to_i64( const float128_t *, uint_fast8_t, bool );
344uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
345uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
346int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
347int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
348float16_t f128M_to_f16( const float128_t * );
349float32_t f128M_to_f32( const float128_t * );
350float64_t f128M_to_f64( const float128_t * );
351void f128M_to_extF80M( const float128_t *, extFloat80_t * );
352void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
353void f128M_add( const float128_t *, const float128_t *, float128_t * );
354void f128M_sub( const float128_t *, const float128_t *, float128_t * );
355void f128M_mul( const float128_t *, const float128_t *, float128_t * );
356void
357 f128M_mulAdd(
358 const float128_t *, const float128_t *, const float128_t *, float128_t *
359 );
360void f128M_div( const float128_t *, const float128_t *, float128_t * );
361void f128M_rem( const float128_t *, const float128_t *, float128_t * );
362void f128M_sqrt( const float128_t *, float128_t * );
363bool f128M_eq( const float128_t *, const float128_t * );
364bool f128M_le( const float128_t *, const float128_t * );
365bool f128M_lt( const float128_t *, const float128_t * );
366bool f128M_eq_signaling( const float128_t *, const float128_t * );
367bool f128M_le_quiet( const float128_t *, const float128_t * );
368bool f128M_lt_quiet( const float128_t *, const float128_t * );
369bool f128M_isSignalingNaN( const float128_t * );
370
371#endif
372
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette