]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/fixunssfdi.c
Merge clang, llvm, lld, lldb, compiler-rt and libc++ 5.0.0 release.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / fixunssfdi.c
1 /* ===-- fixunssfdi.c - Implement __fixunssfdi -----------------------------===
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 #define SINGLE_PRECISION
12 #include "fp_lib.h"
13
14 #ifndef __SOFT_FP__
15 /* Support for systems that have hardware floating-point; can set the invalid
16  * flag as a side-effect of computation.
17  */
18
19 COMPILER_RT_ABI du_int
20 __fixunssfdi(float a)
21 {
22     if (a <= 0.0f) return 0;
23     double da = a;
24     su_int high = da / 4294967296.f;               /* da / 0x1p32f; */
25     su_int low = da - (double)high * 4294967296.f; /* high * 0x1p32f; */
26     return ((du_int)high << 32) | low;
27 }
28
29 #else
30 /* Support for systems that don't have hardware floating-point; there are no
31  * flags to set, and we don't want to code-gen to an unknown soft-float
32  * implementation.
33  */
34
35 typedef du_int fixuint_t;
36 #include "fp_fixuint_impl.inc"
37
38 COMPILER_RT_ABI du_int
39 __fixunssfdi(fp_t a) {
40     return __fixuint(a);
41 }
42
43 #endif
44
45 #if defined(__ARM_EABI__)
46 AEABI_RTABI du_int
47 #if defined(__SOFT_FP__)
48 __aeabi_f2ulz(fp_t a) {
49 #else
50 __aeabi_f2ulz(float a) {
51 #endif
52   return __fixunssfdi(a);
53 }
54 #endif
55