1 1.1 joerg /* ===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------=== 2 1.1 joerg * 3 1.1 joerg * The LLVM Compiler Infrastructure 4 1.1 joerg * 5 1.1 joerg * This file is dual licensed under the MIT and the University of Illinois Open 6 1.1 joerg * Source Licenses. See LICENSE.TXT for details. 7 1.1 joerg * 8 1.1 joerg * ===----------------------------------------------------------------------=== 9 1.1 joerg */ 10 1.1 joerg 11 1.2 rin #define DOUBLE_PRECISION 12 1.2 rin #include "fp_lib.h" 13 1.1 joerg 14 1.2 rin #ifndef __SOFT_FP__ 15 1.2 rin /* Support for systems that have hardware floating-point; can set the invalid 16 1.2 rin * flag as a side-effect of computation. 17 1.1 joerg */ 18 1.1 joerg 19 1.2 rin COMPILER_RT_ABI du_int 20 1.2 rin __fixunsdfdi(double a) 21 1.2 rin { 22 1.2 rin if (a <= 0.0) return 0; 23 1.2 rin su_int high = a / 4294967296.f; /* a / 0x1p32f; */ 24 1.2 rin su_int low = a - (double)high * 4294967296.f; /* high * 0x1p32f; */ 25 1.2 rin return ((du_int)high << 32) | low; 26 1.2 rin } 27 1.2 rin 28 1.2 rin #else 29 1.2 rin /* Support for systems that don't have hardware floating-point; there are no 30 1.2 rin * flags to set, and we don't want to code-gen to an unknown soft-float 31 1.2 rin * implementation. 32 1.1 joerg */ 33 1.1 joerg 34 1.2 rin typedef du_int fixuint_t; 35 1.2 rin #include "fp_fixuint_impl.inc" 36 1.2 rin 37 1.2 rin COMPILER_RT_ABI du_int 38 1.2 rin __fixunsdfdi(fp_t a) { 39 1.2 rin return __fixuint(a); 40 1.2 rin } 41 1.1 joerg 42 1.2 rin #endif 43 1.1 joerg 44 1.2 rin #if defined(__ARM_EABI__) 45 1.3 rin #if defined(COMPILER_RT_ARMHF_TARGET) 46 1.3 rin AEABI_RTABI du_int __aeabi_d2ulz(fp_t a) { 47 1.3 rin return __fixunsdfdi(a); 48 1.3 rin } 49 1.2 rin #else 50 1.3 rin AEABI_RTABI du_int __aeabi_d2ulz(fp_t a) COMPILER_RT_ALIAS(__fixunsdfdi); 51 1.2 rin #endif 52 1.2 rin #endif 53