diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2014-09-16 20:34:41 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2014-09-16 20:34:41 +0000 |
commit | 086f46a9b87b17d36de8cc7e7f4b5a7469161cca (patch) | |
tree | 056ad3a0cb3ff7b3670b81ef8270426e9a9e33c8 /test/builtins/Unit/floatunsitf_test.c | |
parent | 48d5c81378502ac2f26565f76caec9601e702e6a (diff) |
Implement floatsitf, floatunstfsi, which perform
(signed/unsigned)integer to quad-precision conversion.
Submitted by GuanHong Liu.
Differential Revision: http://reviews.llvm.org/D2805
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217901 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/builtins/Unit/floatunsitf_test.c')
-rw-r--r-- | test/builtins/Unit/floatunsitf_test.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/builtins/Unit/floatunsitf_test.c b/test/builtins/Unit/floatunsitf_test.c new file mode 100644 index 000000000..1af72d246 --- /dev/null +++ b/test/builtins/Unit/floatunsitf_test.c @@ -0,0 +1,55 @@ +//===--------------- floatunsitf_test.c - Test __floatunsitf --------------===// +// +// 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 tests __floatunsitf for the compiler_rt library. +// +//===----------------------------------------------------------------------===// + +#include <stdio.h> + +#if __LDBL_MANT_DIG__ == 113 + +#include "fp_test.h" + +long double __floatunsitf(unsigned int a); + +int test__floatunsitf(unsigned int a, uint64_t expectedHi, uint64_t expectedLo) +{ + long double x = __floatunsitf(a); + int ret = compareResultLD(x, expectedHi, expectedLo); + + if (ret){ + printf("error in test__floatunsitf(%u) = %.20Lf, " + "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo)); + } + return ret; +} + +char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; + +#endif + +int main() +{ +#if __LDBL_MANT_DIG__ == 113 + if (test__floatunsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0))) + return 1; + if (test__floatunsitf(0, UINT64_C(0x0), UINT64_C(0x0))) + return 1; + if (test__floatunsitf(0xffffffff, UINT64_C(0x401efffffffe0000), UINT64_C(0x0))) + return 1; + if (test__floatunsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0))) + return 1; + +#else + printf("skipped\n"); + +#endif + return 0; +} |