floatundidf.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //===-- floatundidf.S - Implement __floatundidf for x86_64 ----------------===//
  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. //
  9. // This file implements __floatundidf for the compiler_rt library.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "../assembly.h"
  13. // double __floatundidf(du_int a);
  14. #ifdef __x86_64__
  15. CONST_SECTION
  16. .balign 16
  17. twop52:
  18. .quad 0x4330000000000000
  19. .balign 16
  20. twop84_plus_twop52:
  21. .quad 0x4530000000100000
  22. .balign 16
  23. twop84:
  24. .quad 0x4530000000000000
  25. #define REL_ADDR(_a) (_a)(%rip)
  26. .text
  27. .balign 4
  28. DEFINE_COMPILERRT_FUNCTION(__floatundidf)
  29. movd %edi, %xmm0 // low 32 bits of a
  30. shrq $32, %rdi // high 32 bits of a
  31. orq REL_ADDR(twop84), %rdi // 0x1p84 + a_hi (no rounding occurs)
  32. orpd REL_ADDR(twop52), %xmm0 // 0x1p52 + a_lo (no rounding occurs)
  33. movd %rdi, %xmm1
  34. subsd REL_ADDR(twop84_plus_twop52), %xmm1 // a_hi - 0x1p52 (no rounding occurs)
  35. addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here)
  36. ret
  37. END_COMPILERRT_FUNCTION(__floatundidf)
  38. #endif // __x86_64__
  39. NO_EXEC_STACK_DIRECTIVE