module UHC.Light.Compiler.ConfigDefines
( mkB
, GCVariant (..), gcVariant
, useBoehmGC
, sizeofWord, sizeofWordInBits, sizeofWordAsInteger, sizeofWordInLog
, nodeNeedsForwarding
, magicNumberHI
, mpLib, MPLib (..)
, sizeofFloat, sizeofDouble, sizeofCInt )
where
import UHC.Light.Compiler.Opts.Base
import Data.Word
import Data.Char
magicNumberHI :: [Word8]
magicNumberHI = map (fromInteger . toInteger . fromEnum) "UHI1"
mkB :: Int -> Bool
mkB x = if x /= 0 then True else False
#define USE_BOEHM_GC 0
data GCVariant
= GCVariant_Boehm | GCVariant_Uhc
deriving Eq
gcVariant :: EHCOpts -> GCVariant
gcVariant opts | ehcOptEmitExecBytecode opts = GCVariant_Uhc
| mkB USE_BOEHM_GC = GCVariant_Boehm
| otherwise = GCVariant_Uhc
useBoehmGC :: EHCOpts -> Bool
useBoehmGC opts = gcVariant opts == GCVariant_Boehm
#define USE_LTM 1
#define USE_GMP 0
data MPLib
= MPLib_LTM | MPLib_GMP
deriving (Show,Eq)
mpLib :: MPLib
mpLib | mkB USE_GMP = MPLib_GMP
| otherwise = MPLib_LTM
#define SIZEOF_INTPTR_T 8
sizeofWord :: Int
sizeofWord = SIZEOF_INTPTR_T
sizeofWordInBits :: Int
sizeofWordInBits = sizeofWord * 8
sizeofWordInLog :: Int
sizeofWordInLog = if sizeofWord == 8 then 3 else 2
sizeofWordAsInteger :: Integer
sizeofWordAsInteger = toInteger sizeofWord
nodeNeedsForwarding :: EHCOpts -> Bool
nodeNeedsForwarding opts
= case gcVariant opts of
GCVariant_Boehm -> False
GCVariant_Uhc -> True
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_INT 4
sizeofFloat :: Int
sizeofFloat = SIZEOF_FLOAT
sizeofDouble :: Int
sizeofDouble = SIZEOF_DOUBLE
sizeofCInt :: Int
sizeofCInt = SIZEOF_INT