13cab2bb3Spatrick //===-- fixunsdfdi.c - Implement __fixunsdfdi -----------------------------===// 23cab2bb3Spatrick // 33cab2bb3Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 43cab2bb3Spatrick // See https://llvm.org/LICENSE.txt for license information. 53cab2bb3Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63cab2bb3Spatrick // 73cab2bb3Spatrick //===----------------------------------------------------------------------===// 83cab2bb3Spatrick 93cab2bb3Spatrick #define DOUBLE_PRECISION 103cab2bb3Spatrick #include "fp_lib.h" 113cab2bb3Spatrick 12d89ec533Spatrick #ifndef __SOFTFP__ 133cab2bb3Spatrick // Support for systems that have hardware floating-point; can set the invalid 143cab2bb3Spatrick // flag as a side-effect of computation. 153cab2bb3Spatrick __fixunsdfdi(double a)163cab2bb3SpatrickCOMPILER_RT_ABI du_int __fixunsdfdi(double a) { 173cab2bb3Spatrick if (a <= 0.0) 183cab2bb3Spatrick return 0; 193cab2bb3Spatrick su_int high = a / 4294967296.f; // a / 0x1p32f; 203cab2bb3Spatrick su_int low = a - (double)high * 4294967296.f; // high * 0x1p32f; 213cab2bb3Spatrick return ((du_int)high << 32) | low; 223cab2bb3Spatrick } 233cab2bb3Spatrick 243cab2bb3Spatrick #else 253cab2bb3Spatrick // Support for systems that don't have hardware floating-point; there are no 263cab2bb3Spatrick // flags to set, and we don't want to code-gen to an unknown soft-float 273cab2bb3Spatrick // implementation. 283cab2bb3Spatrick 293cab2bb3Spatrick typedef du_int fixuint_t; 303cab2bb3Spatrick #include "fp_fixuint_impl.inc" 313cab2bb3Spatrick __fixunsdfdi(fp_t a)323cab2bb3SpatrickCOMPILER_RT_ABI du_int __fixunsdfdi(fp_t a) { return __fixuint(a); } 333cab2bb3Spatrick 343cab2bb3Spatrick #endif 353cab2bb3Spatrick 363cab2bb3Spatrick #if defined(__ARM_EABI__) 373cab2bb3Spatrick #if defined(COMPILER_RT_ARMHF_TARGET) __aeabi_d2ulz(fp_t a)383cab2bb3SpatrickAEABI_RTABI du_int __aeabi_d2ulz(fp_t a) { return __fixunsdfdi(a); } 393cab2bb3Spatrick #else 403cab2bb3Spatrick COMPILER_RT_ALIAS(__fixunsdfdi, __aeabi_d2ulz) 413cab2bb3Spatrick #endif 423cab2bb3Spatrick #endif 43*810390e3Srobert 44*810390e3Srobert #if defined(__MINGW32__) && defined(__arm__) 45*810390e3Srobert COMPILER_RT_ALIAS(__fixunsdfdi, __dtou64) 46*810390e3Srobert #endif 47