X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=compiler%2Futils%2FFastTypes.lhs;h=dc4357440ca675dc43606a4ed32d231ee5d7a919;hb=ad94d40948668032189ad22a0ad741ac1f645f50;hp=c58346d3f8890c1ece64052eb49b1d48324efcc4;hpb=046ee54f048ddd721dcee41916d6a6f68db3b15b;p=ghc-hetmet.git diff --git a/compiler/utils/FastTypes.lhs b/compiler/utils/FastTypes.lhs index c58346d..dc43574 100644 --- a/compiler/utils/FastTypes.lhs +++ b/compiler/utils/FastTypes.lhs @@ -4,6 +4,13 @@ \section{Fast integers and booleans} \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings +-- for details + module FastTypes ( FastInt, _ILIT, iBox, iUnbox, (+#), (-#), (*#), quotFastInt, negateFastInt, @@ -34,6 +41,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 +68,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}