[commit: ghc] master: Move more constants to platformConstants (7ecefb6)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/7ecefb6b30c3b249bba0454586c4a008d66d567b

>---------------------------------------------------------------

commit 7ecefb6b30c3b249bba0454586c4a008d66d567b
Author: Ian Lynagh <[email protected]>
Date:   Sun Sep 16 19:42:07 2012 +0100

    Move more constants to platformConstants

>---------------------------------------------------------------

 compiler/cmm/CmmInfo.hs          |    3 +--
 compiler/cmm/PprC.hs             |   11 +++++------
 compiler/codeGen/ClosureInfo.lhs |    6 +++---
 compiler/codeGen/StgCmmLayout.hs |    4 ++--
 compiler/types/TyCon.lhs         |    2 +-
 includes/HaskellConstants.hs     |   21 ---------------------
 includes/mkDerivedConstants.c    |   11 +++++++++++
 7 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs
index 94e38ae..0735937 100644
--- a/compiler/cmm/CmmInfo.hs
+++ b/compiler/cmm/CmmInfo.hs
@@ -24,7 +24,6 @@ import qualified Stream
 import Hoopl
 
 import Maybes
-import Constants
 import DynFlags
 import Panic
 import UniqSupply
@@ -323,7 +322,7 @@ mkLivenessBits dflags liveness
                      [b] -> b
 		     _   -> panic "mkLiveness"
     bitmap_word = fromIntegral n_bits
-              .|. (small_bitmap `shiftL` bITMAP_BITS_SHIFT)
+              .|. (small_bitmap `shiftL` bITMAP_BITS_SHIFT dflags)
 
     lits = mkWordCLit dflags (fromIntegral n_bits) : map (mkWordCLit dflags) bitmap
       -- The first word is the size.  The structure must match
diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index e6c9ac3..bb2f189 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -31,7 +31,6 @@ import OldCmm
 import OldPprCmm ()
 
 -- Utils
-import Constants
 import CPrim
 import DynFlags
 import FastString
@@ -1126,11 +1125,11 @@ pprHexVal w rep
         -- times values are unsigned.  This also helps eliminate occasional
         -- warnings about integer overflow from gcc.
 
-      repsuffix W64
-       | cINT_SIZE       == 8 = char 'U'
-       | cLONG_SIZE      == 8 = ptext (sLit "UL")
-       | cLONG_LONG_SIZE == 8 = ptext (sLit "ULL")
-       | otherwise            = panic "pprHexVal: Can't find a 64-bit type"
+      repsuffix W64 = sdocWithDynFlags $ \dflags ->
+               if cINT_SIZE       dflags == 8 then char 'U'
+          else if cLONG_SIZE      dflags == 8 then ptext (sLit "UL")
+          else if cLONG_LONG_SIZE dflags == 8 then ptext (sLit "ULL")
+          else panic "pprHexVal: Can't find a 64-bit type"
       repsuffix _ = char 'U'
 
       go 0 = empty
diff --git a/compiler/codeGen/ClosureInfo.lhs b/compiler/codeGen/ClosureInfo.lhs
index 6b6bd8b..20ac63f 100644
--- a/compiler/codeGen/ClosureInfo.lhs
+++ b/compiler/codeGen/ClosureInfo.lhs
@@ -343,14 +343,14 @@ separateByPtrFollowness things
 
 \begin{code}
 cgRepSizeB :: DynFlags -> CgRep -> ByteOff
-cgRepSizeB _      DoubleArg = dOUBLE_SIZE
+cgRepSizeB dflags DoubleArg = dOUBLE_SIZE dflags
 cgRepSizeB _      LongArg   = wORD64_SIZE
 cgRepSizeB _      VoidArg   = 0
 cgRepSizeB dflags _         = wORD_SIZE dflags
 
 cgRepSizeW :: DynFlags -> CgRep -> ByteOff
-cgRepSizeW dflags DoubleArg = dOUBLE_SIZE `quot` wORD_SIZE dflags
-cgRepSizeW dflags LongArg   = wORD64_SIZE `quot` wORD_SIZE dflags
+cgRepSizeW dflags DoubleArg = dOUBLE_SIZE dflags `quot` wORD_SIZE dflags
+cgRepSizeW dflags LongArg   = wORD64_SIZE        `quot` wORD_SIZE dflags
 cgRepSizeW _      VoidArg   = 0
 cgRepSizeW _      _         = 1
 
diff --git a/compiler/codeGen/StgCmmLayout.hs b/compiler/codeGen/StgCmmLayout.hs
index 8e4d21e..142100e 100644
--- a/compiler/codeGen/StgCmmLayout.hs
+++ b/compiler/codeGen/StgCmmLayout.hs
@@ -387,8 +387,8 @@ argRepSizeW :: DynFlags -> ArgRep -> WordOff                -- Size in words
 argRepSizeW _      N = 1
 argRepSizeW _      P = 1
 argRepSizeW _      F = 1
-argRepSizeW dflags L = wORD64_SIZE `quot` wORD_SIZE dflags
-argRepSizeW dflags D = dOUBLE_SIZE `quot` wORD_SIZE dflags
+argRepSizeW dflags L = wORD64_SIZE        `quot` wORD_SIZE dflags
+argRepSizeW dflags D = dOUBLE_SIZE dflags `quot` wORD_SIZE dflags
 argRepSizeW _      V = 0
 
 idArgRep :: Id -> ArgRep
diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs
index 05c0ae5..06fef36 100644
--- a/compiler/types/TyCon.lhs
+++ b/compiler/types/TyCon.lhs
@@ -784,7 +784,7 @@ primRepSizeW _      WordRep  = 1
 primRepSizeW dflags Int64Rep = wORD64_SIZE `quot` wORD_SIZE dflags
 primRepSizeW dflags Word64Rep= wORD64_SIZE `quot` wORD_SIZE dflags
 primRepSizeW _      FloatRep = 1    -- NB. might not take a full word
-primRepSizeW dflags DoubleRep= dOUBLE_SIZE `quot` wORD_SIZE dflags
+primRepSizeW dflags DoubleRep= dOUBLE_SIZE dflags `quot` wORD_SIZE dflags
 primRepSizeW _      AddrRep  = 1
 primRepSizeW _      PtrRep   = 1
 primRepSizeW _      VoidRep  = 0
diff --git a/includes/HaskellConstants.hs b/includes/HaskellConstants.hs
index 5b9a5ba..e692a72 100644
--- a/includes/HaskellConstants.hs
+++ b/includes/HaskellConstants.hs
@@ -34,11 +34,6 @@ mAX_CONTEXT_REDUCTION_DEPTH :: Int
 mAX_CONTEXT_REDUCTION_DEPTH = 200
   -- Increase to 200; see Trac #5395
 
--- Size of a double in StgWords.
-
-dOUBLE_SIZE :: Int
-dOUBLE_SIZE = SIZEOF_DOUBLE
-
 wORD64_SIZE :: Int
 wORD64_SIZE = 8
 
@@ -73,19 +68,3 @@ tAG_MASK = (1 `shiftL` tAG_BITS) - 1
 mAX_PTR_TAG :: Int
 mAX_PTR_TAG = tAG_MASK
 
--- Size of a C int, in bytes. May be smaller than wORD_SIZE.
-
-cINT_SIZE :: Int
-cINT_SIZE = SIZEOF_INT
-
-cLONG_SIZE :: Int
-cLONG_SIZE = SIZEOF_LONG
-
-cLONG_LONG_SIZE :: Int
-cLONG_LONG_SIZE = SIZEOF_LONG_LONG
-
--- Number of bits to shift a bitfield left by in an info table.
-
-bITMAP_BITS_SHIFT :: Int
-bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
-
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
index a6d2230..86bf63e 100644
--- a/includes/mkDerivedConstants.c
+++ b/includes/mkDerivedConstants.c
@@ -686,6 +686,17 @@ main(int argc, char *argv[])
     // Size of a word, in bytes
     constantInt("wORD_SIZE", SIZEOF_HSWORD);
 
+    // Size of a double in StgWords.
+    constantInt("dOUBLE_SIZE", SIZEOF_DOUBLE);
+
+    // Size of a C int, in bytes. May be smaller than wORD_SIZE.
+    constantInt("cINT_SIZE", SIZEOF_INT);
+    constantInt("cLONG_SIZE", SIZEOF_LONG);
+    constantInt("cLONG_LONG_SIZE", SIZEOF_LONG_LONG);
+
+    // Number of bits to shift a bitfield left by in an info table.
+    constantInt("bITMAP_BITS_SHIFT", BITMAP_BITS_SHIFT);
+
     switch (mode) {
     case Gen_Haskell_Type:
         printf("  } deriving (Read, Show)\n");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.