Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fixunstfti.c
Go to the documentation of this file.
1/* ===-- fixunstfsi.c - Implement __fixunstfsi -----------------------------===
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
11#include "fp128.h"
12
14typedef unsigned __int128 fixuint_t;
15typedef unsigned __int128 tu_int;
16typedef __int128 rep_t;
17
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}
unsigned __int128 fixuint_t
Definition fixdfti.c:14
unsigned __int128 tu_int
Definition fixunstfti.c:15
__int128 rep_t
Definition fixunstfti.c:16
tu_int ___fixunstfti(fp_t a)
Definition fixunstfti.c:18
float128_t fp_t
Definition fixunstfti.c:13
#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