diff options
author | Alexey Samsonov <samsonov@google.com> | 2014-02-14 09:20:33 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2014-02-14 09:20:33 +0000 |
commit | a6b264b51d4fa786d9df659621fc1ffad1fdc5d0 (patch) | |
tree | 416fdf341f03ee1f373907f65ce054afc40d7ab1 /compiler-rt/lib/builtins/floatundixf.c | |
parent | 0b28ea9c471308faf04b4b6695c9f016aabea49a (diff) | |
download | bcm5719-llvm-a6b264b51d4fa786d9df659621fc1ffad1fdc5d0.tar.gz bcm5719-llvm-a6b264b51d4fa786d9df659621fc1ffad1fdc5d0.zip |
Move original compiler-rt functions (libgcc replacement) to lib/builtins directory
llvm-svn: 201393
Diffstat (limited to 'compiler-rt/lib/builtins/floatundixf.c')
-rw-r--r-- | compiler-rt/lib/builtins/floatundixf.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/compiler-rt/lib/builtins/floatundixf.c b/compiler-rt/lib/builtins/floatundixf.c new file mode 100644 index 00000000000..64f7662d952 --- /dev/null +++ b/compiler-rt/lib/builtins/floatundixf.c @@ -0,0 +1,42 @@ +/* ===-- floatundixf.c - Implement __floatundixf ---------------------------=== + * + * 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 __floatundixf for the compiler_rt library. + * + * ===----------------------------------------------------------------------=== + */ + +#if !_ARCH_PPC + +#include "int_lib.h" + +/* Returns: convert a to a long double, rounding toward even. */ + +/* Assumption: long double is a IEEE 80 bit floating point type padded to 128 bits + * du_int is a 64 bit integral type + */ + +/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee | + * 1mmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm + */ +long double +__floatundixf(du_int a) +{ + if (a == 0) + return 0.0; + const unsigned N = sizeof(du_int) * CHAR_BIT; + int clz = __builtin_clzll(a); + int e = (N - 1) - clz ; /* exponent */ + long_double_bits fb; + fb.u.high.s.low = (e + 16383); /* exponent */ + fb.u.low.all = a << clz; /* mantissa */ + return fb.f; +} + +#endif /* _ARCH_PPC */ |