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/fp_trunc.h | |
parent | 4901406799702394d9ca0b820852d850ed187f6e (diff) | |
download | compiler-rt-d982553daf42bbedf3373c35d8db2d3fd323f9b0.tar.gz |
[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/fp_trunc.h')
-rw-r--r-- | lib/builtins/fp_trunc.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/builtins/fp_trunc.h b/lib/builtins/fp_trunc.h index 49a9aebbc..373ba1b04 100644 --- a/lib/builtins/fp_trunc.h +++ b/lib/builtins/fp_trunc.h @@ -16,7 +16,13 @@ #include "int_lib.h" -#if defined SRC_DOUBLE +#if defined SRC_SINGLE +typedef float src_t; +typedef uint32_t src_rep_t; +#define SRC_REP_C UINT32_C +static const int srcSigBits = 23; + +#elif defined SRC_DOUBLE typedef double src_t; typedef uint64_t src_rep_t; #define SRC_REP_C UINT64_C @@ -44,6 +50,12 @@ typedef uint32_t dst_rep_t; #define DST_REP_C UINT32_C static const int dstSigBits = 23; +#elif defined DST_HALF +typedef uint16_t dst_t; +typedef uint16_t dst_rep_t; +#define DST_REP_C UINT16_C +static const int dstSigBits = 10; + #else #error Destination should be single precision or double precision! #endif //end destination precision |