Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
softfloat.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <softfloat_types.h>
4
5#ifndef THREAD_LOCAL
6#define THREAD_LOCAL __thread
7#endif
8extern "C" {
9/*----------------------------------------------------------------------------
10| Integer-to-floating-point conversion routines.
11*----------------------------------------------------------------------------*/
32
33/*----------------------------------------------------------------------------
34| 16-bit (half-precision) floating-point operations.
35*----------------------------------------------------------------------------*/
63
64/*----------------------------------------------------------------------------
65| 32-bit (single-precision) floating-point operations.
66*----------------------------------------------------------------------------*/
78
95
96/*----------------------------------------------------------------------------
97| 64-bit (double-precision) floating-point operations.
98*----------------------------------------------------------------------------*/
119bool f64_eq( float64_t, float64_t );
120bool f64_le( float64_t, float64_t );
121bool f64_lt( float64_t, float64_t );
126
127/*----------------------------------------------------------------------------
128| 128-bit (quadruple-precision) floating-point operations.
129*----------------------------------------------------------------------------*/
156
157void f128M_to_extF80M( const float128_t *, extFloat80_t * );
169void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
170void f128M_add( const float128_t *, const float128_t *, float128_t * );
171void f128M_sub( const float128_t *, const float128_t *, float128_t * );
172void f128M_mul( const float128_t *, const float128_t *, float128_t * );
173void
175 const float128_t *, const float128_t *, const float128_t *, float128_t *
176 );
177void f128M_div( const float128_t *, const float128_t *, float128_t * );
178void f128M_rem( const float128_t *, const float128_t *, float128_t * );
179void f128M_sqrt( const float128_t *, float128_t * );
180bool f128M_eq( const float128_t *, const float128_t * );
181bool f128M_le( const float128_t *, const float128_t * );
182bool f128M_lt( const float128_t *, const float128_t * );
183bool f128M_eq_signaling( const float128_t *, const float128_t * );
184bool f128M_le_quiet( const float128_t *, const float128_t * );
185bool f128M_lt_quiet( const float128_t *, const float128_t * );
186bool f128M_isSignalingNaN( const float128_t * );
187bool isNaNF128( const float128_t * );
188};
189
190inline bool operator == (const float32_t& lhs, const float32_t& rhs) {
191 return f32_eq(lhs, rhs);
192}
193
194inline bool operator != (const float32_t& lhs, const float32_t& rhs) {
195 return !f32_eq(lhs, rhs);
196}
197
198inline bool operator < (const float32_t& lhs, const float32_t& rhs) {
199 return f32_lt(lhs, rhs);
200}
201
202inline bool operator > (const float32_t& lhs, const float32_t& rhs) {
203 return f32_lt(rhs, lhs);
204}
205
206inline bool operator <= (const float32_t& lhs, const float32_t& rhs) {
207 return f32_le(lhs, rhs);
208}
209
210inline bool operator >= (const float32_t& lhs, const float32_t& rhs) {
211 return f32_le(rhs, lhs);
212}
213
214inline bool operator == (const float64_t& lhs, const float64_t& rhs) {
215 return f64_eq(lhs, rhs);
216}
217
218inline bool operator != (const float64_t& lhs, const float64_t& rhs) {
219 return !f64_eq(lhs, rhs);
220}
221
222inline bool operator < (const float64_t& lhs, const float64_t& rhs) {
223 return f64_lt(lhs, rhs);
224}
225
226inline bool operator > (const float64_t& lhs, const float64_t& rhs) {
227 return f64_lt(rhs, lhs);
228}
229
230inline bool operator <= (const float64_t& lhs, const float64_t& rhs) {
231 return f64_le(lhs, rhs);
232}
233
234inline bool operator >= (const float64_t& lhs, const float64_t& rhs) {
235 return f64_le(rhs, lhs);
236}
237
238inline bool operator == (const float128_t& lhs, const float128_t& rhs) {
239 return f128_eq(lhs, rhs);
240}
241
242inline bool operator != (const float128_t& lhs, const float128_t& rhs) {
243 return !f128_eq(lhs, rhs);
244}
245
246inline bool operator < (const float128_t& lhs, const float128_t& rhs) {
247 return f128_lt(lhs, rhs);
248}
249
250inline bool operator > (const float128_t& lhs, const float128_t& rhs) {
251 return f128_lt(rhs, lhs);
252}
253
254inline bool operator <= (const float128_t& lhs, const float128_t& rhs) {
255 return f128_le(lhs, rhs);
256}
257
258inline bool operator >= (const float128_t& lhs, const float128_t& rhs) {
259 return f128_le(rhs, lhs);
260}
261
262inline bool f32_sign_bit( float32_t f ) { return f.v >> 31; }
263inline bool f64_sign_bit( float64_t f ) { return f.v >> 63; }
264inline bool f128_sign_bit( float128_t f ) { return f.v[1] >> 63; }
265
266inline bool f32_is_nan( const float32_t f ) {
267 return ((f.v & 0x7FFFFFFF) > 0x7F800000);
268}
269inline bool f64_is_nan( const float64_t f ) {
270 return ((f.v & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000);
271}
272inline bool f128_is_nan( const float128_t& f ) {
273 return (((~(f.v[1]) & uint64_t( 0x7FFF000000000000 )) == 0) && (f.v[0] || ((f.v[1]) & uint64_t( 0x0000FFFFFFFFFFFF ))));
274}
275
277 return {0xff800000ul};
278}
280 return {0x7f800000ul};
281}
283 return {0xfff0000000000000ull};
284}
286 return {0x7ff0000000000000ull};
287}
289 return {{0x0ull, 0xffff000000000000ull}};
290}
292 return {{0x0ull, 0x7fff000000000000ull}};
293}
294
295inline float32_t to_softfloat32( float f ) {
296 float32_t x;
297 memcpy(&x, &f, sizeof(f));
298 return x;
299}
300inline float64_t to_softfloat64( double d ) {
301 float64_t x;
302 memcpy(&x, &d, sizeof(d));
303 return x;
304}
305inline float from_softfloat32( float32_t f ) {
306 float x;
307 memcpy(&x, &f, sizeof(f));
308 return x;
309}
310inline double from_softfloat64( float64_t d ) {
311 double x;
312 memcpy(&x, &d, sizeof(d));
313 return x;
314}
int_fast32_t f128M_to_i32_r_minMag(const float128_t *, bool)
int_fast32_t f128_to_i32(float128_t, uint_fast8_t, bool)
Definition f128_to_i32.c:44
bool f32_isSignalingNaN(float32_t)
float128_t f128_div(float128_t, float128_t)
Definition f128_div.c:44
float16_t f16_roundToInt(float16_t, uint_fast8_t, bool)
float128_t f128_positive_infinity()
bool f128M_lt(const float128_t *, const float128_t *)
Definition f128M_lt.c:54
float16_t f128M_to_f16(const float128_t *)
float64_t i32_to_f64(int32_t)
Definition i32_to_f64.c:43
float128_t f128_sqrt(float128_t)
Definition f128_sqrt.c:44
float32_t to_softfloat32(float f)
bool f128_eq_signaling(float128_t, float128_t)
uint_fast64_t f128_to_ui64(float128_t, uint_fast8_t, bool)
float128_t f64_to_f128(float64_t)
Definition f64_to_f128.c:44
bool f32_le_quiet(float32_t, float32_t)
bool f128_lt_quiet(float128_t, float128_t)
float16_t f16_mulAdd(float16_t, float16_t, float16_t)
Definition f16_mulAdd.c:42
float64_t f128_to_f64(float128_t)
Definition f128_to_f64.c:44
float64_t f64_add(float64_t, float64_t)
Definition f64_add.c:43
bool f128_isSignalingNaN(float128_t)
float16_t f16_mul(float16_t, float16_t)
Definition f16_mul.c:44
float16_t f16_sub(float16_t, float16_t)
Definition f16_sub.c:43
float32_t f32_sub(float32_t, float32_t)
Definition f32_sub.c:43
bool f128M_le(const float128_t *, const float128_t *)
Definition f128M_le.c:54
uint_fast32_t f32_to_ui32_r_minMag(float32_t, bool)
float128_t f128_mul(float128_t, float128_t)
Definition f128_mul.c:44
bool f128_sign_bit(float128_t f)
int_fast32_t f16_to_i32_r_minMag(float16_t, bool)
uint_fast64_t f16_to_ui64(float16_t, uint_fast8_t, bool)
Definition f16_to_ui64.c:44
float16_t f16_rem(float16_t, float16_t)
Definition f16_rem.c:44
float128_t ui32_to_f128(uint32_t)
bool f128_is_nan(const float128_t &f)
float32_t f16_to_f32(float16_t)
Definition f16_to_f32.c:44
bool f64_is_nan(const float64_t f)
bool operator!=(const float32_t &lhs, const float32_t &rhs)
float32_t f32_positive_infinity()
bool f64_lt(float64_t, float64_t)
Definition f64_lt.c:43
void f128M_to_extF80M(const float128_t *, extFloat80_t *)
float64_t ui64_to_f64(uint64_t)
Definition ui64_to_f64.c:42
uint_fast32_t f128_to_ui32(float128_t, uint_fast8_t, bool)
bool f16_le_quiet(float16_t, float16_t)
bool f128M_lt_quiet(const float128_t *, const float128_t *)
int_fast32_t f128_to_i32_r_minMag(float128_t, bool)
float128_t f128_sub(float128_t, float128_t)
Definition f128_sub.c:43
float64_t f64_mul(float64_t, float64_t)
Definition f64_mul.c:44
int_fast64_t f128M_to_i64(const float128_t *, uint_fast8_t, bool)
uint_fast64_t f128M_to_ui64_r_minMag(const float128_t *, bool)
bool f16_eq(float16_t, float16_t)
Definition f16_eq.c:44
bool operator==(const float32_t &lhs, const float32_t &rhs)
float32_t ui32_to_f32(uint32_t)
Definition ui32_to_f32.c:42
int_fast64_t f128_to_i64(float128_t, uint_fast8_t, bool)
Definition f128_to_i64.c:44
void f128M_add(const float128_t *, const float128_t *, float128_t *)
Definition f128M_add.c:84
void f32_to_f128M(float32_t, float128_t *)
bool operator>=(const float32_t &lhs, const float32_t &rhs)
float16_t i32_to_f16(int32_t)
Definition i32_to_f16.c:43
float128_t f128_roundToInt(float128_t, uint_fast8_t, bool)
int_fast64_t f64_to_i64(float64_t, uint_fast8_t, bool)
Definition f64_to_i64.c:44
float32_t f128M_to_f32(const float128_t *)
float16_t ui64_to_f16(uint64_t)
Definition ui64_to_f16.c:42
bool f16_lt(float16_t, float16_t)
Definition f16_lt.c:43
void ui32_to_f128M(uint32_t, float128_t *)
int_fast64_t f128_to_i64_r_minMag(float128_t, bool)
float128_t f128_add(float128_t, float128_t)
Definition f128_add.c:43
float16_t f64_to_f16(float64_t)
Definition f64_to_f16.c:44
float64_t f64_sub(float64_t, float64_t)
Definition f64_sub.c:43
double from_softfloat64(float64_t d)
bool f32_lt(float32_t, float32_t)
Definition f32_lt.c:43
uint_fast64_t f128_to_ui64_r_minMag(float128_t, bool)
float32_t f32_sqrt(float32_t)
Definition f32_sqrt.c:44
bool f64_sign_bit(float64_t f)
void f64_to_f128M(float64_t, float128_t *)
bool f128_le(float128_t, float128_t)
Definition f128_le.c:43
void f128M_mulAdd(const float128_t *, const float128_t *, const float128_t *, float128_t *)
void f128M_roundToInt(const float128_t *, uint_fast8_t, bool, float128_t *)
float32_t f32_div(float32_t, float32_t)
Definition f32_div.c:44
float32_t f64_to_f32(float64_t)
Definition f64_to_f32.c:44
float32_t f128_to_f32(float128_t)
Definition f128_to_f32.c:44
bool f32_lt_quiet(float32_t, float32_t)
bool f16_lt_quiet(float16_t, float16_t)
float64_t f64_positive_infinity()
float32_t ui64_to_f32(uint64_t)
Definition ui64_to_f32.c:42
float64_t f16_to_f64(float16_t)
Definition f16_to_f64.c:44
float16_t ui32_to_f16(uint32_t)
Definition ui32_to_f16.c:42
float16_t f128_to_f16(float128_t)
Definition f128_to_f16.c:44
int_fast64_t f64_to_i64_r_minMag(float64_t, bool)
float64_t f64_rem(float64_t, float64_t)
Definition f64_rem.c:44
uint_fast32_t f16_to_ui32_r_minMag(float16_t, bool)
bool f32_sign_bit(float32_t f)
bool f64_le(float64_t, float64_t)
Definition f64_le.c:43
uint_fast64_t f128M_to_ui64(const float128_t *, uint_fast8_t, bool)
int_fast32_t f16_to_i32(float16_t, uint_fast8_t, bool)
Definition f16_to_i32.c:44
float64_t f32_to_f64(float32_t)
Definition f32_to_f64.c:44
bool f16_isSignalingNaN(float16_t)
bool f32_eq_signaling(float32_t, float32_t)
bool f64_isSignalingNaN(float64_t)
bool f128M_eq(const float128_t *, const float128_t *)
Definition f128M_eq.c:55
bool operator>(const float32_t &lhs, const float32_t &rhs)
bool operator<(const float32_t &lhs, const float32_t &rhs)
float64_t f64_mulAdd(float64_t, float64_t, float64_t)
Definition f64_mulAdd.c:42
uint_fast64_t f16_to_ui64_r_minMag(float16_t, bool)
float64_t i64_to_f64(int64_t)
Definition i64_to_f64.c:43
float64_t to_softfloat64(double d)
float64_t f64_negative_infinity()
void ui64_to_f128M(uint64_t, float128_t *)
bool f16_eq_signaling(float16_t, float16_t)
float64_t f64_sqrt(float64_t)
Definition f64_sqrt.c:44
float128_t i32_to_f128(int32_t)
Definition i32_to_f128.c:42
int_fast32_t f32_to_i32_r_minMag(float32_t, bool)
int_fast64_t f16_to_i64(float16_t, uint_fast8_t, bool)
Definition f16_to_i64.c:44
float128_t f16_to_f128(float16_t)
Definition f16_to_f128.c:44
bool f128_lt(float128_t, float128_t)
Definition f128_lt.c:43
uint_fast32_t f32_to_ui32(float32_t, uint_fast8_t, bool)
Definition f32_to_ui32.c:44
float32_t f32_mulAdd(float32_t, float32_t, float32_t)
Definition f32_mulAdd.c:42
float from_softfloat32(float32_t f)
float128_t f128_mulAdd(float128_t, float128_t, float128_t)
Definition f128_mulAdd.c:42
uint_fast64_t f32_to_ui64_r_minMag(float32_t, bool)
float16_t f16_add(float16_t, float16_t)
Definition f16_add.c:43
uint_fast32_t f64_to_ui32_r_minMag(float64_t, bool)
bool isNaNF128(const float128_t *)
Definition f128_isnan.c:4
void i64_to_f128M(int64_t, float128_t *)
float32_t f32_roundToInt(float32_t, uint_fast8_t, bool)
float32_t f32_negative_infinity()
float64_t f64_div(float64_t, float64_t)
Definition f64_div.c:44
float32_t i64_to_f32(int64_t)
Definition i64_to_f32.c:43
bool f64_eq(float64_t, float64_t)
Definition f64_eq.c:44
bool f128_le_quiet(float128_t, float128_t)
float128_t i64_to_f128(int64_t)
Definition i64_to_f128.c:42
void f128M_sub(const float128_t *, const float128_t *, float128_t *)
Definition f128M_sub.c:84
void f128M_div(const float128_t *, const float128_t *, float128_t *)
Definition f128M_div.c:57
void i32_to_f128M(int32_t, float128_t *)
uint_fast64_t f64_to_ui64_r_minMag(float64_t, bool)
float32_t i32_to_f32(int32_t)
Definition i32_to_f32.c:43
float16_t f32_to_f16(float32_t)
Definition f32_to_f16.c:44
float64_t f128M_to_f64(const float128_t *)
uint_fast32_t f128M_to_ui32_r_minMag(const float128_t *, bool)
float32_t f32_rem(float32_t, float32_t)
Definition f32_rem.c:44
bool f16_le(float16_t, float16_t)
Definition f16_le.c:43
bool f128_eq(float128_t, float128_t)
Definition f128_eq.c:44
uint_fast64_t f32_to_ui64(float32_t, uint_fast8_t, bool)
Definition f32_to_ui64.c:44
bool f32_is_nan(const float32_t f)
float128_t f128_rem(float128_t, float128_t)
Definition f128_rem.c:44
int_fast32_t f128M_to_i32(const float128_t *, uint_fast8_t, bool)
bool f64_lt_quiet(float64_t, float64_t)
float128_t f32_to_f128(float32_t)
Definition f32_to_f128.c:44
float128_t ui64_to_f128(uint64_t)
void f16_to_f128M(float16_t, float128_t *)
int_fast32_t f64_to_i32_r_minMag(float64_t, bool)
bool f128M_le_quiet(const float128_t *, const float128_t *)
uint_fast32_t f16_to_ui32(float16_t, uint_fast8_t, bool)
Definition f16_to_ui32.c:44
float128_t f128_negative_infinity()
bool f128M_isSignalingNaN(const float128_t *)
uint_fast32_t f128M_to_ui32(const float128_t *, uint_fast8_t, bool)
int_fast64_t f32_to_i64(float32_t, uint_fast8_t, bool)
Definition f32_to_i64.c:44
int_fast32_t f32_to_i32(float32_t, uint_fast8_t, bool)
Definition f32_to_i32.c:44
bool f32_le(float32_t, float32_t)
Definition f32_le.c:43
bool f32_eq(float32_t, float32_t)
Definition f32_eq.c:44
bool operator<=(const float32_t &lhs, const float32_t &rhs)
float64_t ui32_to_f64(uint32_t)
Definition ui32_to_f64.c:42
float32_t f32_add(float32_t, float32_t)
Definition f32_add.c:43
float64_t f64_roundToInt(float64_t, uint_fast8_t, bool)
uint_fast32_t f128_to_ui32_r_minMag(float128_t, bool)
float16_t f16_sqrt(float16_t)
Definition f16_sqrt.c:47
void f128M_sqrt(const float128_t *, float128_t *)
Definition f128M_sqrt.c:55
float16_t i64_to_f16(int64_t)
Definition i64_to_f16.c:43
void f128M_mul(const float128_t *, const float128_t *, float128_t *)
Definition f128M_mul.c:57
float16_t f16_div(float16_t, float16_t)
Definition f16_div.c:47
uint_fast32_t f64_to_ui32(float64_t, uint_fast8_t, bool)
Definition f64_to_ui32.c:44
uint_fast64_t f64_to_ui64(float64_t, uint_fast8_t, bool)
Definition f64_to_ui64.c:44
int_fast64_t f32_to_i64_r_minMag(float32_t, bool)
bool f128M_eq_signaling(const float128_t *, const float128_t *)
bool f64_eq_signaling(float64_t, float64_t)
void f128M_rem(const float128_t *, const float128_t *, float128_t *)
Definition f128M_rem.c:57
float32_t f32_mul(float32_t, float32_t)
Definition f32_mul.c:44
int_fast64_t f128M_to_i64_r_minMag(const float128_t *, bool)
int_fast32_t f64_to_i32(float64_t, uint_fast8_t, bool)
Definition f64_to_i32.c:44
int_fast64_t f16_to_i64_r_minMag(float16_t, bool)
bool f64_le_quiet(float64_t, float64_t)
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
uint64_t uint_fast64_t
Definition stdint.h:157
uint32_t uint_fast32_t
Definition stdint.h:156
int32_t int_fast32_t
Definition stdint.h:152
signed int int32_t
Definition stdint.h:123
uint8_t uint_fast8_t
Definition stdint.h:154
unsigned __int64 uint64_t
Definition stdint.h:136
int64_t int_fast64_t
Definition stdint.h:153
CK_ULONG d
memcpy((char *) pInfo->slotDescription, s, l)