diff options
author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2015-05-12 18:33:42 +0000 |
---|---|---|
committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2015-05-12 18:33:42 +0000 |
commit | d982553daf42bbedf3373c35d8db2d3fd323f9b0 (patch) | |
tree | 9faab0a3c213100c9b3c783c052601f78ae2f165 /lib/builtins/truncsfhf2.c | |
parent | 4901406799702394d9ca0b820852d850ed187f6e (diff) |
[Builtins] Implement half-precision conversions.
Mostly uninteresting, except:
- in __extendXfYf2, when checking if the number is normal, the old
code relied on the unsignedness of src_rep_t, which is a problem
when sizeof(src_rep_t) < sizeof(int): the result gets promoted to
int, the signedness of which breaks the comparison.
I added an explicit cast; it shouldn't affect other types.
- we can't pass __fp16, so src_t and src_rep_t are the same.
- the gnu_*_ieee symbols are simply duplicated definitions, as aliases
are problematic on mach-o (where only weak aliases are supported;
that's not what we want).
Differential Revision: http://reviews.llvm.org/D9693
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@237161 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/builtins/truncsfhf2.c')
-rw-r--r-- | lib/builtins/truncsfhf2.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/builtins/truncsfhf2.c b/lib/builtins/truncsfhf2.c new file mode 100644 index 000000000..a25dd83d8 --- /dev/null +++ b/lib/builtins/truncsfhf2.c @@ -0,0 +1,20 @@ +//===-- lib/truncsfhf2.c - single -> half conversion --------------*- C -*-===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#define SRC_SINGLE +#define DST_HALF +#include "fp_trunc_impl.inc" + +COMPILER_RT_ABI uint16_t __truncsfhf2(float a) { + return __truncXfYf2__(a); +} + +COMPILER_RT_ABI uint16_t __gnu_f2h_ieee(float a) { + return __truncXfYf2__(a); +} |