Commit 7ecefb6b authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Move more constants to platformConstants

parent 17910899
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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");
......
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