summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-16 19:42:07 +0100
committerIan Lynagh <ian@well-typed.com>2012-09-16 19:42:07 +0100
commit7ecefb6b30c3b249bba0454586c4a008d66d567b (patch)
tree14f9c6c425ba9b0dbeeff024c3546ebc906f9ca3
parent17910899dacc892fd652d9206340d2bc2b2c5fc1 (diff)
downloadhaskell-7ecefb6b30c3b249bba0454586c4a008d66d567b.tar.gz
Move more constants to platformConstants
-rw-r--r--compiler/cmm/CmmInfo.hs3
-rw-r--r--compiler/cmm/PprC.hs11
-rw-r--r--compiler/codeGen/ClosureInfo.lhs6
-rw-r--r--compiler/codeGen/StgCmmLayout.hs4
-rw-r--r--compiler/types/TyCon.lhs2
-rw-r--r--includes/HaskellConstants.hs21
-rw-r--r--includes/mkDerivedConstants.c11
7 files changed, 23 insertions, 35 deletions
diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs
index 94e38ae071..0735937754 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 e6c9ac3a15..bb2f189e14 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 6b6bd8b294..20ac63f6d2 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 8e4d21e352..142100e109 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 05c0ae5be3..06fef36102 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 5b9a5ba1ac..e692a723d0 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 a6d2230d6e..86bf63e5fd 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");