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
14ARM_EABI_FNALIAS(f2ulz, fixunssfdi)
15
16#ifndef __SOFT_FP__
17/* Support for systems that have hardware floating-point; can set the invalid
18 * flag as a side-effect of computation.
19 */
20
21COMPILER_RT_ABI du_int
22__fixunssfdi(float a)
23{
24    if (a <= 0.0f) return 0;
25    double da = a;
26    su_int high = da / 4294967296.f;               /* da / 0x1p32f; */
27    su_int low = da - (double)high * 4294967296.f; /* high * 0x1p32f; */
28    return ((du_int)high << 32) | low;
29}
30
31#else
32/* Support for systems that don't have hardware floating-point; there are no
33 * flags to set, and we don't want to code-gen to an unknown soft-float
34 * implementation.
35 */
36
37typedef du_int fixuint_t;
38#include "fp_fixuint_impl.inc"
39
40COMPILER_RT_ABI du_int
41__fixunssfdi(fp_t a) {
42    return __fixuint(a);
43}
44
45#endif
46