Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
compiler_builtins.hpp File Reference
#include <cstdint>
#include <softfloat.hpp>
Include dependency graph for compiler_builtins.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

__int128 ___fixdfti (uint64_t)
 
__int128 ___fixsfti (uint32_t)
 
__int128 ___fixtfti (float128_t)
 
unsigned __int128 ___fixunsdfti (uint64_t)
 
unsigned __int128 ___fixunssfti (uint32_t)
 
unsigned __int128 ___fixunstfti (float128_t)
 
double ___floattidf (__int128)
 
double ___floatuntidf (unsigned __int128)
 

Function Documentation

◆ ___fixdfti()

__int128 ___fixdfti ( uint64_t a)

Definition at line 16 of file fixdfti.c.

16 {
17 const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2);
18 const fixint_t fixint_min = -fixint_max - 1;
19 // Break a into sign, exponent, significand
20 const rep_t aRep = a;
21 const rep_t aAbs = aRep & absMask;
22 const fixint_t sign = aRep & signBit ? -1 : 1;
23 const int exponent = (aAbs >> significandBits) - exponentBias;
24 const rep_t significand = (aAbs & significandMask) | implicitBit;
25
26 // If exponent is negative, the result is zero.
27 if (exponent < 0)
28 return 0;
29
30 // If the value is too large for the integer type, saturate.
31 if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT)
32 return sign == 1 ? fixint_max : fixint_min;
33
34 // If 0 <= exponent < significandBits, right shift to get the result.
35 // Otherwise, shift left.
36 if (exponent < significandBits)
37 return sign * (significand >> (significandBits - exponent));
38 else
39 return sign * ((fixint_t)significand << (exponent - significandBits));
40
41}
__int128 fixint_t
Definition fixdfti.c:13
unsigned __int128 fixuint_t
Definition fixdfti.c:14
__int128 rep_t
Definition fixunstfti.c:16
#define implicitBit
Definition fp128.h:15
#define signBit
Definition fp128.h:17
#define exponentBias
Definition fp128.h:13
#define significandBits
Definition fp128.h:9
#define significandMask
Definition fp128.h:16
#define absMask
Definition fp128.h:18
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
Here is the caller graph for this function:

◆ ___fixsfti()

__int128 ___fixsfti ( uint32_t a)

Definition at line 16 of file fixsfti.c.

16 {
17 const fixint_t fixint_max = (fixint_t)((~(fixuint_t)0) / 2);
18 const fixint_t fixint_min = -fixint_max - 1;
19 // Break a into sign, exponent, significand
20 const rep_t aRep = a;
21 const rep_t aAbs = aRep & absMask;
22 const fixint_t sign = aRep & signBit ? -1 : 1;
23 const int exponent = (aAbs >> significandBits) - exponentBias;
24 const rep_t significand = (aAbs & significandMask) | implicitBit;
25
26 // If exponent is negative, the result is zero.
27 if (exponent < 0)
28 return 0;
29
30 // If the value is too large for the integer type, saturate.
31 if ((unsigned)exponent >= sizeof(fixint_t) * CHAR_BIT)
32 return sign == 1 ? fixint_max : fixint_min;
33
34 // If 0 <= exponent < significandBits, right shift to get the result.
35 // Otherwise, shift left.
36 if (exponent < significandBits)
37 return sign * (significand >> (significandBits - exponent));
38 else
39 return sign * ((fixint_t)significand << (exponent - significandBits));
40}
Here is the caller graph for this function:

◆ ___fixtfti()

__int128 ___fixtfti ( float128_t a)

Definition at line 13 of file fixtfti.c.

13 {
14 const __int128 fixint_max = (__int128)((~(unsigned __int128)0) / 2);
15 const __int128 fixint_min = -fixint_max - 1;
16 // Break a into sign, exponent, significand
17 const __int128 aRep = toRep(a);
18 const __int128 aAbs = aRep & absMask;
19 const __int128 sign = aRep & signBit ? -1 : 1;
20 const int exponent = (aAbs >> significandBits) - exponentBias;
21 const __int128 significand = (aAbs & significandMask) | implicitBit;
22
23 // If exponent is negative, the result is zero.
24 if (exponent < 0)
25 return 0;
26
27 // If the value is too large for the integer type, saturate.
28 if ((unsigned)exponent >= sizeof(__int128) * CHAR_BIT)
29 return sign == 1 ? fixint_max : fixint_min;
30
31 // If 0 <= exponent < significandBits, right shift to get the result.
32 // Otherwise, shift left.
33 if (exponent < significandBits)
34 return sign * (significand >> (significandBits - exponent));
35 else
36 return sign * ((__int128)significand << (exponent - significandBits));
37}
Here is the caller graph for this function:

◆ ___fixunsdfti()

unsigned __int128 ___fixunsdfti ( uint64_t a)

Definition at line 15 of file fixunsdfti.c.

15 {
16 // Break a into sign, exponent, significand
17 const rep_t aRep = a;
18 const rep_t aAbs = aRep & absMask;
19 const int sign = aRep & signBit ? -1 : 1;
20 const int exponent = (aAbs >> significandBits) - exponentBias;
21 const rep_t significand = (aAbs & significandMask) | implicitBit;
22
23 // If either the value or the exponent is negative, the result is zero.
24 if (sign == -1 || exponent < 0)
25 return 0;
26
27 // If the value is too large for the integer type, saturate.
28 if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT)
29 return ~(fixuint_t)0;
30
31 // If 0 <= exponent < significandBits, right shift to get the result.
32 // Otherwise, shift left.
33 if (exponent < significandBits)
34 return significand >> (significandBits - exponent);
35 else
36 return (fixuint_t)significand << (exponent - significandBits);
37}
Here is the caller graph for this function:

◆ ___fixunssfti()

unsigned __int128 ___fixunssfti ( uint32_t a)

Definition at line 19 of file fixunssfti.c.

19 {
20 // Break a into sign, exponent, significand
21 const rep_t aRep = a;
22 const rep_t aAbs = aRep & absMask;
23 const int sign = aRep & signBit ? -1 : 1;
24 const int exponent = (aAbs >> significandBits) - exponentBias;
25 const rep_t significand = (aAbs & significandMask) | implicitBit;
26
27 // If either the value or the exponent is negative, the result is zero.
28 if (sign == -1 || exponent < 0)
29 return 0;
30
31 // If the value is too large for the integer type, saturate.
32 if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT)
33 return ~(fixuint_t)0;
34
35 // If 0 <= exponent < significandBits, right shift to get the result.
36 // Otherwise, shift left.
37 if (exponent < significandBits)
38 return significand >> (significandBits - exponent);
39 else
40 return (fixuint_t)significand << (exponent - significandBits);
41}
Here is the caller graph for this function:

◆ ___fixunstfti()

unsigned __int128 ___fixunstfti ( float128_t a)

Definition at line 18 of file fixunstfti.c.

18 {
19 // Break a into sign, exponent, significand
20 const rep_t aRep = toRep(a);
21 const rep_t aAbs = aRep & absMask;
22 const int sign = aRep & signBit ? -1 : 1;
23 const int exponent = (aAbs >> significandBits) - exponentBias;
24 const rep_t significand = (aAbs & significandMask) | implicitBit;
25
26 // If either the value or the exponent is negative, the result is zero.
27 if (sign == -1 || exponent < 0)
28 return 0;
29
30 // If the value is too large for the integer type, saturate.
31 if ((unsigned)exponent >= sizeof(fixuint_t) * CHAR_BIT)
32 return ~(fixuint_t)0;
33
34 // If 0 <= exponent < significandBits, right shift to get the result.
35 // Otherwise, shift left.
36 if (exponent < significandBits)
37 return significand >> (significandBits - exponent);
38 else
39 return (fixuint_t)significand << (exponent - significandBits);
40}
Here is the caller graph for this function:

◆ ___floattidf()

double ___floattidf ( __int128 a)

Definition at line 26 of file floattidf.c.

27{
28 if (a == 0)
29 return 0.0;
30 const unsigned N = sizeof(ti_int) * CHAR_BIT;
31 const ti_int s = a >> (N-1);
32 a = (a ^ s) - s;
33 int sd = N - __clzti2(a); /* number of significant digits */
34 int e = sd - 1; /* exponent */
35 if (sd > DBL_MANT_DIG)
36 {
37 /* start: 0000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQxxxxxxxxxxxxxxxxxx
38 * finish: 000000000000000000000000000000000000001xxxxxxxxxxxxxxxxxxxxxxPQR
39 * 12345678901234567890123456
40 * 1 = msb 1 bit
41 * P = bit DBL_MANT_DIG-1 bits to the right of 1
42 * Q = bit DBL_MANT_DIG bits to the right of 1
43 * R = "or" of all bits to the right of Q
44 */
45 switch (sd)
46 {
47 case DBL_MANT_DIG + 1:
48 a <<= 1;
49 break;
50 case DBL_MANT_DIG + 2:
51 break;
52 default:
53 a = ((tu_int)a >> (sd - (DBL_MANT_DIG+2))) |
54 ((a & ((tu_int)(-1) >> ((N + DBL_MANT_DIG+2) - sd))) != 0);
55 };
56 /* finish: */
57 a |= (a & 4) != 0; /* Or P into R */
58 ++a; /* round - this step may add a significant bit */
59 a >>= 2; /* dump Q and R */
60 /* a is now rounded to DBL_MANT_DIG or DBL_MANT_DIG+1 bits */
61 if (a & ((tu_int)1 << DBL_MANT_DIG))
62 {
63 a >>= 1;
64 ++e;
65 }
66 /* a is now rounded to DBL_MANT_DIG bits */
67 }
68 else
69 {
70 a <<= (DBL_MANT_DIG - sd);
71 /* a is now rounded to DBL_MANT_DIG bits */
72 }
73 double_bits fb;
74 fb.u.s.high = ((uint32_t)s & 0x80000000) | /* sign */
75 ((e + 1023) << 20) | /* exponent */
76 ((uint32_t)(a >> 32) & 0x000FFFFF); /* mantissa-high */
77 fb.u.s.low = (uint32_t)a; /* mantissa-low */
78 return fb.f;
79}
unsigned __int128 tu_int
Definition fixunstfti.c:15
__int128 __clzti2(__int128 a)
Definition int_t.h:45
__int128 ti_int
Definition int_t.h:43
const int N
Definition quantize.cpp:54
unsigned int uint32_t
Definition stdint.h:126
double f
Definition int_t.h:39
udwords u
Definition int_t.h:38
struct udwords::@2 s
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ___floatuntidf()

double ___floatuntidf ( unsigned __int128)
Here is the caller graph for this function: