Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fixunssfti.c
Go to the documentation of this file.
1
/* ===-- fixunssfti.c - Implement __fixunssfti -----------------------------===
2
*
3
* The LLVM Compiler Infrastructure
4
*
5
* This file is dual licensed under the MIT and the University of Illinois Open
6
* Source Licenses. See LICENSE.TXT for details.
7
*
8
* ===----------------------------------------------------------------------===
9
*
10
* This file implements __fixunssfti for the compiler_rt library.
11
*
12
* ===----------------------------------------------------------------------===
13
*/
14
15
#include "
fp32.h
"
16
17
typedef
unsigned
__int128
fixuint_t
;
18
19
fixuint_t
___fixunssfti
(
uint32_t
a
) {
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
}
fixuint_t
unsigned __int128 fixuint_t
Definition
fixdfti.c:14
___fixunssfti
fixuint_t ___fixunssfti(uint32_t a)
Definition
fixunssfti.c:19
rep_t
__int128 rep_t
Definition
fixunstfti.c:16
implicitBit
#define implicitBit
Definition
fp128.h:15
signBit
#define signBit
Definition
fp128.h:17
exponentBias
#define exponentBias
Definition
fp128.h:13
significandBits
#define significandBits
Definition
fp128.h:9
significandMask
#define significandMask
Definition
fp128.h:16
absMask
#define absMask
Definition
fp128.h:18
fp32.h
a
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition
pointer.h:1181
uint32_t
unsigned int uint32_t
Definition
stdint.h:126
libraries
builtins
fixunssfti.c
Generated by
1.12.0