From: Ian Lynagh Date: Sun, 13 Jan 2008 14:16:12 +0000 (+0000) Subject: Fix warnings in utils/FastTypes X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=983c316af4654b6532909a0e85dec175e808401a Fix warnings in utils/FastTypes Split off a FastBool module, to avoid a circular import with Panic --- diff --git a/compiler/main/TidyPgm.lhs b/compiler/main/TidyPgm.lhs index fc951cc..2189f85 100644 --- a/compiler/main/TidyPgm.lhs +++ b/compiler/main/TidyPgm.lhs @@ -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 ) diff --git a/compiler/nativeGen/MachCodeGen.hs b/compiler/nativeGen/MachCodeGen.hs index 8f6cfcb..10f6655 100644 --- a/compiler/nativeGen/MachCodeGen.hs +++ b/compiler/nativeGen/MachCodeGen.hs @@ -45,7 +45,7 @@ import OrdList import Pretty import Outputable import FastString -import FastTypes ( isFastTrue ) +import FastBool ( isFastTrue ) import Constants ( wORD_SIZE ) #ifdef DEBUG diff --git a/compiler/nativeGen/MachRegs.lhs b/compiler/nativeGen/MachRegs.lhs index 2205ce0..522f715 100644 --- a/compiler/nativeGen/MachRegs.lhs +++ b/compiler/nativeGen/MachRegs.lhs @@ -103,7 +103,7 @@ import qualified Outputable import Unique import UniqSet import Constants -import FastTypes +import FastBool import UniqFM import GHC.Exts diff --git a/compiler/nativeGen/RegAllocInfo.hs b/compiler/nativeGen/RegAllocInfo.hs index 4b975af..b6b2a73 100644 --- a/compiler/nativeGen/RegAllocInfo.hs +++ b/compiler/nativeGen/RegAllocInfo.hs @@ -42,7 +42,7 @@ import MachInstrs import MachRegs import Outputable import Constants ( rESERVED_C_STACK_BYTES ) -import FastTypes +import FastBool -- ----------------------------------------------------------------------------- -- RegUsage type diff --git a/compiler/utils/FastBool.lhs b/compiler/utils/FastBool.lhs new file mode 100644 index 0000000..d7776e4 --- /dev/null +++ b/compiler/utils/FastBool.lhs @@ -0,0 +1,54 @@ +% +% (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} diff --git a/compiler/utils/FastTypes.lhs b/compiler/utils/FastTypes.lhs index ab5ae46..bce98f4 100644 --- a/compiler/utils/FastTypes.lhs +++ b/compiler/utils/FastTypes.lhs @@ -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}