2 import Data.Bits (shiftL)
6 -- This magical #include brings in all the everybody-knows-these magic
7 -- constants unfortunately, we need to be *explicit* about which one
8 -- we want; if we just hope a -I... will get the right one, we could
12 Pull in the autoconf defines (HAVE_FOO), but don't include
13 ghcconfig.h, because that will include ghcplatform.h which has the
14 wrong platform settings for the compiler (it has the platform
15 settings for the target plat instead).
17 #include "../includes/ghcautoconf.h"
19 #include "stg/MachRegs.h"
20 #include "rts/Constants.h"
22 #include "DerivedConstants.h"
26 -- All pretty arbitrary:
29 mAX_TUPLE_SIZE = 62 -- Should really match the number
30 -- of decls in Data.Tuple
32 mAX_CONTEXT_REDUCTION_DEPTH :: Int
33 mAX_CONTEXT_REDUCTION_DEPTH = 20
36 -- specialised fun/thunk/constr closure types
37 mAX_SPEC_THUNK_SIZE :: Int
38 mAX_SPEC_THUNK_SIZE = MAX_SPEC_THUNK_SIZE
40 mAX_SPEC_FUN_SIZE :: Int
41 mAX_SPEC_FUN_SIZE = MAX_SPEC_FUN_SIZE
43 mAX_SPEC_CONSTR_SIZE :: Int
44 mAX_SPEC_CONSTR_SIZE = MAX_SPEC_CONSTR_SIZE
46 -- pre-compiled thunk types
47 mAX_SPEC_SELECTEE_SIZE :: Int
48 mAX_SPEC_SELECTEE_SIZE = MAX_SPEC_SELECTEE_SIZE
50 mAX_SPEC_AP_SIZE :: Int
51 mAX_SPEC_AP_SIZE = MAX_SPEC_AP_SIZE
53 -- closure sizes: these do NOT include the header (see below for header sizes)
54 mIN_PAYLOAD_SIZE ::Int
55 mIN_PAYLOAD_SIZE = MIN_PAYLOAD_SIZE
57 mIN_INTLIKE, mAX_INTLIKE :: Int
58 mIN_INTLIKE = MIN_INTLIKE
59 mAX_INTLIKE = MAX_INTLIKE
61 mIN_CHARLIKE, mAX_CHARLIKE :: Int
62 mIN_CHARLIKE = MIN_CHARLIKE
63 mAX_CHARLIKE = MAX_CHARLIKE
65 mUT_ARR_PTRS_CARD_BITS :: Int
66 mUT_ARR_PTRS_CARD_BITS = MUT_ARR_PTRS_CARD_BITS
68 -- A section of code-generator-related MAGIC CONSTANTS.
70 mAX_Vanilla_REG :: Int
71 mAX_Vanilla_REG = MAX_VANILLA_REG
74 mAX_Float_REG = MAX_FLOAT_REG
77 mAX_Double_REG = MAX_DOUBLE_REG
80 mAX_Long_REG = MAX_LONG_REG
82 mAX_Real_Vanilla_REG :: Int
83 mAX_Real_Vanilla_REG = MAX_REAL_VANILLA_REG
85 mAX_Real_Float_REG :: Int
86 mAX_Real_Float_REG = MAX_REAL_FLOAT_REG
88 mAX_Real_Double_REG :: Int
89 mAX_Real_Double_REG = MAX_REAL_DOUBLE_REG
91 mAX_Real_Long_REG :: Int
92 #ifdef MAX_REAL_LONG_REG
93 mAX_Real_Long_REG = MAX_REAL_LONG_REG
98 -- Closure header sizes.
101 sTD_HDR_SIZE = STD_HDR_SIZE
104 pROF_HDR_SIZE = PROF_HDR_SIZE
106 -- Size of a double in StgWords.
109 dOUBLE_SIZE = SIZEOF_DOUBLE
115 iNT64_SIZE = wORD64_SIZE
117 -- This tells the native code generator the size of the spill
118 -- area is has available.
120 rESERVED_C_STACK_BYTES :: Int
121 rESERVED_C_STACK_BYTES = RESERVED_C_STACK_BYTES
123 -- The amount of (Haskell) stack to leave free for saving registers when
124 -- returning to the scheduler.
126 rESERVED_STACK_WORDS :: Int
127 rESERVED_STACK_WORDS = RESERVED_STACK_WORDS
129 -- Continuations that need more than this amount of stack should do their
130 -- own stack check (see bug #1466).
132 aP_STACK_SPLIM :: Int
133 aP_STACK_SPLIM = AP_STACK_SPLIM
135 -- Size of a word, in bytes
138 wORD_SIZE = SIZEOF_HSWORD
140 wORD_SIZE_IN_BITS :: Int
141 wORD_SIZE_IN_BITS = wORD_SIZE * 8
143 -- Define a fixed-range integral type equivalent to the target Int/Word
145 #if SIZEOF_HSWORD == 4
146 type TargetInt = Int32
147 type TargetWord = Word32
148 #elif SIZEOF_HSWORD == 8
149 type TargetInt = Int64
150 type TargetWord = Word64
152 #error unknown SIZEOF_HSWORD
155 tARGET_MIN_INT, tARGET_MAX_INT, tARGET_MAX_WORD :: Integer
156 tARGET_MIN_INT = fromIntegral (minBound :: TargetInt)
157 tARGET_MAX_INT = fromIntegral (maxBound :: TargetInt)
158 tARGET_MAX_WORD = fromIntegral (maxBound :: TargetWord)
160 tARGET_MAX_CHAR :: Int
161 tARGET_MAX_CHAR = 0x10ffff
163 -- Amount of pointer bits used for semi-tagging constructor closures
169 tAG_MASK = (1 `shiftL` tAG_BITS) - 1
172 mAX_PTR_TAG = tAG_MASK
174 -- Size of a C int, in bytes. May be smaller than wORD_SIZE.
177 cINT_SIZE = SIZEOF_INT
179 -- Size of a storage manager block (in bytes).
182 bLOCK_SIZE = BLOCK_SIZE
184 bLOCK_SIZE_W = bLOCK_SIZE `quot` wORD_SIZE
186 -- Number of bits to shift a bitfield left by in an info table.
188 bITMAP_BITS_SHIFT :: Int
189 bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
191 -- Constants derived from headers in ghc/includes, generated by the program
192 -- ../includes/mkDerivedConstants.c.
194 #include "GHCConstants.h"