floatdidf.S 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  2. // See https://llvm.org/LICENSE.txt for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "../assembly.h"
  5. // double __floatdidf(du_int a);
  6. #ifdef __i386__
  7. CONST_SECTION
  8. .balign 16
  9. twop52:
  10. .quad 0x4330000000000000
  11. .balign 16
  12. twop32:
  13. .quad 0x41f0000000000000
  14. #define REL_ADDR(_a) (_a)-0b(%eax)
  15. .text
  16. .balign 4
  17. DEFINE_COMPILERRT_FUNCTION(__floatdidf)
  18. cvtsi2sd 8(%esp), %xmm1
  19. movss 4(%esp), %xmm0 // low 32 bits of a
  20. calll 0f
  21. 0: popl %eax
  22. mulsd REL_ADDR(twop32), %xmm1 // a_hi as a double (without rounding)
  23. movsd REL_ADDR(twop52), %xmm2 // 0x1.0p52
  24. subsd %xmm2, %xmm1 // a_hi - 0x1p52 (no rounding occurs)
  25. orpd %xmm2, %xmm0 // 0x1p52 + a_lo (no rounding occurs)
  26. addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here)
  27. movsd %xmm0, 4(%esp)
  28. fldl 4(%esp)
  29. ret
  30. END_COMPILERRT_FUNCTION(__floatdidf)
  31. #endif // __i386__
  32. NO_EXEC_STACK_DIRECTIVE