diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-08 19:47:10 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-08 19:47:10 +0000 |
commit | f4341a5a66d0fa0f3c9599ea5c5d2d7b2b240c1d (patch) | |
tree | f47eabbd2a48be6d6fec3ddeeefae5b4aeb87dbc /contrib/compiler-rt/lib/builtins/fixdfdi.c | |
parent | bbf686ed602a158a5d2fcf9dd90f4bda25feef5e (diff) | |
parent | ca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (diff) | |
download | src-f4341a5a66d0fa0f3c9599ea5c5d2d7b2b240c1d.tar.gz src-f4341a5a66d0fa0f3c9599ea5c5d2d7b2b240c1d.zip |
Update compiler-rt to trunk r224034. This brings a number of new
builtins, and also the various sanitizers. Support for these will be
added in a later commit.
Notes
Notes:
svn path=/head/; revision=276851
Diffstat (limited to 'contrib/compiler-rt/lib/builtins/fixdfdi.c')
-rw-r--r-- | contrib/compiler-rt/lib/builtins/fixdfdi.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/compiler-rt/lib/builtins/fixdfdi.c b/contrib/compiler-rt/lib/builtins/fixdfdi.c new file mode 100644 index 000000000000..86f9f6ce8db3 --- /dev/null +++ b/contrib/compiler-rt/lib/builtins/fixdfdi.c @@ -0,0 +1,45 @@ +/* ===-- fixdfdi.c - Implement __fixdfdi -----------------------------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + * + * This file implements __fixdfdi for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#include "int_lib.h" + +/* Returns: convert a to a signed long long, rounding toward zero. */ + +/* Assumption: double is a IEEE 64 bit floating point type + * su_int is a 32 bit integral type + * value in double is representable in di_int (no range checking performed) + */ + +/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ + +ARM_EABI_FNALIAS(d2lz, fixdfdi) + +COMPILER_RT_ABI di_int +__fixdfdi(double a) +{ + double_bits fb; + fb.f = a; + int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023; + if (e < 0) + return 0; + di_int s = (si_int)(fb.u.s.high & 0x80000000) >> 31; + dwords r; + r.s.high = (fb.u.s.high & 0x000FFFFF) | 0x00100000; + r.s.low = fb.u.s.low; + if (e > 52) + r.all <<= (e - 52); + else + r.all >>= (52 - e); + return (r.all ^ s) - s; +} |