blob: 1be553b7d1e0d4c70869990d1d87f29079ef584b [file] [log] [blame]
Daniel Dunbar51c80cc2009-10-27 17:49:19 +00001//===-- floatundidf.S - Implement __floatundidf for x86_64 ----------------===//
Daniel Dunbarb3a69012009-06-26 16:47:03 +00002//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant9ad441f2010-11-16 22:13:33 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Daniel Dunbarb3a69012009-06-26 16:47:03 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements __floatundidf for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
Daniel Dunbar19336a22009-10-27 17:49:50 +000014#include "../assembly.h"
15
Daniel Dunbarb3a69012009-06-26 16:47:03 +000016// double __floatundidf(du_int a);
17
18#ifdef __x86_64__
19
Edward O'Callaghaneed13002009-11-04 23:52:51 +000020#ifndef __ELF__
Daniel Dunbarb3a69012009-06-26 16:47:03 +000021.const
Edward O'Callaghaneed13002009-11-04 23:52:51 +000022#endif
Daniel Dunbarb3a69012009-06-26 16:47:03 +000023.align 4
24twop52: .quad 0x4330000000000000
25twop84_plus_twop52:
26 .quad 0x4530000000100000
27twop84: .quad 0x4530000000000000
28
29#define REL_ADDR(_a) (_a)(%rip)
30
31.text
32.align 4
Daniel Dunbarb4b1e8c2009-10-27 17:50:21 +000033DEFINE_COMPILERRT_FUNCTION(__floatundidf)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000034 movd %edi, %xmm0 // low 32 bits of a
35 shrq $32, %rdi // high 32 bits of a
36 orq REL_ADDR(twop84), %rdi // 0x1p84 + a_hi (no rounding occurs)
37 orpd REL_ADDR(twop52), %xmm0 // 0x1p52 + a_lo (no rounding occurs)
38 movd %rdi, %xmm1
39 subsd REL_ADDR(twop84_plus_twop52), %xmm1 // a_hi - 0x1p52 (no rounding occurs)
40 addsd %xmm1, %xmm0 // a_hi + a_lo (round happens here)
41 ret
42
Edward O'Callaghaneed13002009-11-04 23:52:51 +000043#endif // __x86_64__