Commit 983c316a authored by Ian Lynagh's avatar Ian Lynagh

Fix warnings in utils/FastTypes

Split off a FastBool module, to avoid a circular import with Panic
parent d7a89759
......@@ -41,7 +41,7 @@ import Maybes
import ErrUtils
import UniqSupply
import Outputable
import FastTypes hiding (fastOr)
import FastBool hiding ( fastOr )
import Data.List ( partition )
import Data.Maybe ( isJust )
......
......@@ -45,7 +45,7 @@ import OrdList
import Pretty
import Outputable
import FastString
import FastTypes ( isFastTrue )
import FastBool ( isFastTrue )
import Constants ( wORD_SIZE )
#ifdef DEBUG
......
......@@ -103,7 +103,7 @@ import qualified Outputable
import Unique
import UniqSet
import Constants
import FastTypes
import FastBool
import UniqFM
import GHC.Exts
......
......@@ -42,7 +42,7 @@ import MachInstrs
import MachRegs
import Outputable
import Constants ( rESERVED_C_STACK_BYTES )
import FastTypes
import FastBool
-- -----------------------------------------------------------------------------
-- RegUsage type
......
%
% (c) The University of Glasgow, 2000-2006
%
\section{Fast booleans}
\begin{code}
module FastBool (
FastBool, fastBool, isFastTrue, fastOr, fastAnd
) where
#if defined(__GLASGOW_HASKELL__)
-- Import the beggars
import GHC.Exts
( Int(..), Int#, (+#), (-#), (*#),
quotInt#, negateInt#, (==#), (<#), (<=#), (>=#), (>#)
)
import Panic
type FastBool = Int#
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
fastOr _ _ = panic# "FastTypes: fastOr"
fastAnd 0# _ = 0#
fastAnd 1# x = x
fastAnd _ _ = panic# "FastTypes: fastAnd"
#else /* ! __GLASGOW_HASKELL__ */
type FastBool = Bool
fastBool 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
#endif /* ! __GLASGOW_HASKELL__ */
fastBool :: Bool -> FastBool
isFastTrue :: FastBool -> Bool
fastOr :: FastBool -> FastBool -> FastBool
fastAnd :: FastBool -> FastBool -> FastBool
\end{code}
......@@ -4,23 +4,12 @@
\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/Commentary/CodingStyle#Warnings
-- for details
module FastTypes (
FastInt, _ILIT, iBox, iUnbox,
(+#), (-#), (*#), quotFastInt, negateFastInt,
(==#), (<#), (<=#), (>=#), (>#),
FastBool, fastBool, isFastTrue, fastOr, fastAnd
) where
#include "HsVersions.h"
#if defined(__GLASGOW_HASKELL__)
-- Import the beggars
......@@ -36,19 +25,6 @@ iUnbox (I# x) = x
quotFastInt = quotInt#
negateFastInt = negateInt#
type FastBool = Int#
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
fastAnd 0# x = 0#
fastAnd 1# x = x
#else /* ! __GLASGOW_HASKELL__ */
type FastInt = Int
......@@ -66,16 +42,6 @@ negateFastInt = negate
(>=#) = (>=)
(>#) = (>)
type FastBool = Bool
fastBool 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.
......@@ -99,9 +65,4 @@ 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}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment