X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FFastTypes.lhs;h=ded373fd4d3c67d6fdaa2a46ca770f3da64e1824;hb=cd883e2f4dc0c37488441d18ef7b3a9ae9719b55;hp=bb92c8c02f7fc3998fe2ce8836072f2fab361c6b;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/utils/FastTypes.lhs b/compiler/utils/FastTypes.lhs index bb92c8c..ded373f 100644 --- a/compiler/utils/FastTypes.lhs +++ b/compiler/utils/FastTypes.lhs @@ -1,5 +1,5 @@ % -% (c) The University of Glasgow, 2000 +% (c) The University of Glasgow, 2000-2006 % \section{Fast integers and booleans} @@ -17,7 +17,7 @@ module FastTypes ( #if defined(__GLASGOW_HASKELL__) -- Import the beggars -import GLAEXTS +import GHC.Exts ( Int(..), Int#, (+#), (-#), (*#), quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#) ) @@ -34,6 +34,8 @@ fastBool True = 1# fastBool False = 0# isFastTrue x = x ==# 1# +-- note that fastOr and fastAnd are strict in both arguments +-- since they are unboxed fastOr 1# _ = 1# fastOr 0# x = x @@ -59,7 +61,40 @@ negateFastInt = negate type FastBool = Bool fastBool x = x -_IS_TRUE_ x = x +isFastTrue x = x +-- make sure these are as strict as the unboxed version, +-- so that the performance characteristics match +fastOr False False = False +fastOr _ _ = True +fastAnd True True = True +fastAnd _ _ = False + +--These are among the type-signatures necessary for !ghc to compile +-- but break ghc (can't give a signature for an import...) +--Note that the comparisons actually do return Bools not FastBools. +(+#) :: FastInt -> FastInt -> FastInt +(-#) :: FastInt -> FastInt -> FastInt +(*#) :: FastInt -> FastInt -> FastInt +(==#) :: FastInt -> FastInt -> Bool +(<#) :: FastInt -> FastInt -> Bool +(<=#) :: FastInt -> FastInt -> Bool +(>=#) :: FastInt -> FastInt -> Bool +(>#) :: FastInt -> FastInt -> Bool #endif /* ! __GLASGOW_HASKELL__ */ + +-- type-signatures will improve the non-ghc-specific versions +-- and keep things accurate (and ABLE to compile!) +_ILIT :: Int -> FastInt +iBox :: FastInt -> Int +iUnbox :: Int -> FastInt + +quotFastInt :: FastInt -> FastInt -> FastInt +negateFastInt :: FastInt -> FastInt + +fastBool :: Bool -> FastBool +isFastTrue :: FastBool -> Bool +fastOr :: FastBool -> FastBool -> FastBool +fastAnd :: FastBool -> FastBool -> FastBool + \end{code}