Fix warnings in utils/FastTypes
authorIan Lynagh <igloo@earth.li>
Sun, 13 Jan 2008 14:16:12 +0000 (14:16 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 13 Jan 2008 14:16:12 +0000 (14:16 +0000)
Split off a FastBool module, to avoid a circular import with Panic

compiler/main/TidyPgm.lhs
compiler/nativeGen/MachCodeGen.hs
compiler/nativeGen/MachRegs.lhs
compiler/nativeGen/RegAllocInfo.hs
compiler/utils/FastBool.lhs [new file with mode: 0644]
compiler/utils/FastTypes.lhs

index fc951cc..2189f85 100644 (file)
@@ -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 )
index 8f6cfcb..10f6655 100644 (file)
@@ -45,7 +45,7 @@ import OrdList
 import Pretty
 import Outputable
 import FastString
-import FastTypes       ( isFastTrue )
+import FastBool                ( isFastTrue )
 import Constants       ( wORD_SIZE )
 
 #ifdef DEBUG
index 2205ce0..522f715 100644 (file)
@@ -103,7 +103,7 @@ import qualified Outputable
 import Unique
 import UniqSet
 import Constants
-import FastTypes
+import FastBool
 import UniqFM
 
 import GHC.Exts
index 4b975af..b6b2a73 100644 (file)
@@ -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 (file)
index 0000000..d7776e4
--- /dev/null
@@ -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}
index ab5ae46..bce98f4 100644 (file)
@@ -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}