diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-09-17 17:54:20 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-09-17 17:55:37 +0200 |
commit | b62bd5ecf3be421778e4835010b6b334e95c5a56 (patch) | |
tree | e19e2efc012ec3940c4b4c739f0b1e8bcfed3eaf /rts/PrimOps.cmm | |
parent | 3c2829017943522a946e7ae0560034c7d28d96ce (diff) | |
download | haskell-b62bd5ecf3be421778e4835010b6b334e95c5a56.tar.gz |
Implement `decodeDouble_Int64#` primop
The existing `decodeDouble_2Int#` primop is rather inconvenient to use
(and in fact is not even used by `integer-gmp`) as the mantissa is split
into 3 components which would actually fit in an `Int64#` value.
However, `decodeDouble_Int64#` is to be used by the new `integer-gmp2`
re-implementation (see #9281).
Moreover, `decodeDouble_2Int#` performs direct bit-wise operations on the
IEEE representation which can be replaced by a combination of the
portable standard C99 `scalbn(3)` and `frexp(3)` functions.
Differential Revision: https://phabricator.haskell.org/D160
Diffstat (limited to 'rts/PrimOps.cmm')
-rw-r--r-- | rts/PrimOps.cmm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index ee50f7fed5..cb4cd5e9fa 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -22,6 +22,7 @@ * ---------------------------------------------------------------------------*/ #include "Cmm.h" +#include "MachDeps.h" #ifdef __PIC__ import pthread_mutex_lock; @@ -807,6 +808,22 @@ stg_decodeDoublezu2Intzh ( D_ arg ) return (r1, r2, r3, r4); } +/* Double# -> (# Int64#, Int# #) */ +stg_decodeDoublezuInt64zh ( D_ arg ) +{ + CInt exp; + I64 mant; + W_ mant_ptr; + + STK_CHK_GEN_N (SIZEOF_INT64); + reserve BYTES_TO_WDS(SIZEOF_INT64) = mant_ptr { + (exp) = ccall __decodeDouble_Int64(mant_ptr "ptr", arg); + mant = I64[mant_ptr]; + } + + return (mant, TO_W_(exp)); +} + /* ----------------------------------------------------------------------------- * Concurrency primitives * -------------------------------------------------------------------------- */ |