X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fprelude%2Fprimops.txt.pp;h=adb2e110ff8ced4fc4348f767daa93185a37c4bf;hb=9d03becc597e5b1ab6c8466209a1263bf8ba6f29;hp=57abb7d3c76826eef26794388fa3ff08c03ccb14;hpb=493d09b47e4d4faec4f0696d071e3b7f4e7b84ea;p=ghc-hetmet.git diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp index 57abb7d..adb2e11 100644 --- a/compiler/prelude/primops.txt.pp +++ b/compiler/prelude/primops.txt.pp @@ -618,6 +618,13 @@ primop DoubleDecodeOp "decodeDouble#" GenPrimOp represent an {\tt Integer\#} holding the mantissa.} with out_of_line = True +primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp + Double# -> (# Int#, Int#, Int# #) + {Convert to arbitrary-precision integer. + First {\tt Int\#} in result is the high 32 bits of the mantissa, and the + second is the low 32. The third is the exponent.} + with out_of_line = True + ------------------------------------------------------------------------ section "Float#" {Operations on single-precision (32-bit) floating-point numbers.} @@ -724,6 +731,12 @@ primop FloatDecodeOp "decodeFloat#" GenPrimOp represent an {\tt Integer\#} holding the mantissa.} with out_of_line = True +primop FloatDecode_IntOp "decodeFloat_Int#" GenPrimOp + Float# -> (# Int#, Int# #) + {Convert to arbitrary-precision integer. + First {\tt Int\#} in result is the mantissa; second is the exponent.} + with out_of_line = True + ------------------------------------------------------------------------ section "Arrays" {Operations on {\tt Array\#}.} @@ -1795,7 +1808,14 @@ pseudoop "unsafeCoerce#" known to be empty. Also, a {\tt newtype} of a type {\tt T} has the same representation at runtime as {\tt T}. - Other uses of {\tt unsafeCoerce\#} are undefined. + Other uses of {\tt unsafeCoerce\#} are undefined. In particular, you should not use + {\tt unsafeCoerce\#} to cast a T to an algebraic data type D, unless T is also + an algebraic data type. For example, do not cast {\tt Int->Int} to {\tt Bool}, even if + you later cast that {\tt Bool} back to {\tt Int->Int} before applying it. The reasons + have to do with GHC's internal representation details (for the congnoscenti, data values + can be entered but function closures cannot). If you want a safe type to cast things + to, use {\tt Any}, which is not an algebraic data type. + } -- NB. It is tempting to think that casting a value to a type that it doesn't have is safe