fixsfdi.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //===-- fixsfdi.c - Implement __fixsfdi -----------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #define SINGLE_PRECISION
  9. #include "fp_lib.h"
  10. #ifndef __SOFTFP__
  11. // Support for systems that have hardware floating-point; can set the invalid
  12. // flag as a side-effect of computation.
  13. COMPILER_RT_ABI du_int __fixunssfdi(float a);
  14. COMPILER_RT_ABI di_int __fixsfdi(float a) {
  15. if (a < 0.0f) {
  16. return -__fixunssfdi(-a);
  17. }
  18. return __fixunssfdi(a);
  19. }
  20. #else
  21. // Support for systems that don't have hardware floating-point; there are no
  22. // flags to set, and we don't want to code-gen to an unknown soft-float
  23. // implementation.
  24. typedef di_int fixint_t;
  25. typedef du_int fixuint_t;
  26. #include "fp_fixint_impl.inc"
  27. COMPILER_RT_ABI di_int __fixsfdi(fp_t a) { return __fixint(a); }
  28. #endif
  29. #if defined(__ARM_EABI__)
  30. #if defined(COMPILER_RT_ARMHF_TARGET)
  31. AEABI_RTABI di_int __aeabi_f2lz(fp_t a) { return __fixsfdi(a); }
  32. #else
  33. COMPILER_RT_ALIAS(__fixsfdi, __aeabi_f2lz)
  34. #endif
  35. #endif
  36. #if defined(__MINGW32__) && defined(__arm__)
  37. COMPILER_RT_ALIAS(__fixsfdi, __stoi64)
  38. #endif