10b57cec5SDimitry Andric //===-- fixunssfdi.c - Implement __fixunssfdi -----------------------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #define SINGLE_PRECISION 100b57cec5SDimitry Andric #include "fp_lib.h" 110b57cec5SDimitry Andric 12fe6060f1SDimitry Andric #ifndef __SOFTFP__ 130b57cec5SDimitry Andric // Support for systems that have hardware floating-point; can set the invalid 140b57cec5SDimitry Andric // flag as a side-effect of computation. 150b57cec5SDimitry Andric __fixunssfdi(float a)160b57cec5SDimitry AndricCOMPILER_RT_ABI du_int __fixunssfdi(float a) { 170b57cec5SDimitry Andric if (a <= 0.0f) 180b57cec5SDimitry Andric return 0; 190b57cec5SDimitry Andric double da = a; 200b57cec5SDimitry Andric su_int high = da / 4294967296.f; // da / 0x1p32f; 210b57cec5SDimitry Andric su_int low = da - (double)high * 4294967296.f; // high * 0x1p32f; 220b57cec5SDimitry Andric return ((du_int)high << 32) | low; 230b57cec5SDimitry Andric } 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric #else 260b57cec5SDimitry Andric // Support for systems that don't have hardware floating-point; there are no 270b57cec5SDimitry Andric // flags to set, and we don't want to code-gen to an unknown soft-float 280b57cec5SDimitry Andric // implementation. 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric typedef du_int fixuint_t; 310b57cec5SDimitry Andric #include "fp_fixuint_impl.inc" 320b57cec5SDimitry Andric __fixunssfdi(fp_t a)330b57cec5SDimitry AndricCOMPILER_RT_ABI du_int __fixunssfdi(fp_t a) { return __fixuint(a); } 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric #endif 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric #if defined(__ARM_EABI__) 380b57cec5SDimitry Andric #if defined(COMPILER_RT_ARMHF_TARGET) __aeabi_f2ulz(fp_t a)390b57cec5SDimitry AndricAEABI_RTABI du_int __aeabi_f2ulz(fp_t a) { return __fixunssfdi(a); } 400b57cec5SDimitry Andric #else 410b57cec5SDimitry Andric COMPILER_RT_ALIAS(__fixunssfdi, __aeabi_f2ulz) 420b57cec5SDimitry Andric #endif 430b57cec5SDimitry Andric #endif 44*349cc55cSDimitry Andric 45*349cc55cSDimitry Andric #if defined(__MINGW32__) && defined(__arm__) 46*349cc55cSDimitry Andric COMPILER_RT_ALIAS(__fixunssfdi, __stou64) 47*349cc55cSDimitry Andric #endif 48