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 -- A section of code-generator-related MAGIC CONSTANTS.
67 mAX_Vanilla_REG :: Int
68 mAX_Vanilla_REG = MAX_VANILLA_REG
71 mAX_Float_REG = MAX_FLOAT_REG
74 mAX_Double_REG = MAX_DOUBLE_REG
77 mAX_Long_REG = MAX_LONG_REG
79 mAX_Real_Vanilla_REG :: Int
80 mAX_Real_Vanilla_REG = MAX_REAL_VANILLA_REG
82 mAX_Real_Float_REG :: Int
83 mAX_Real_Float_REG = MAX_REAL_FLOAT_REG
85 mAX_Real_Double_REG :: Int
86 mAX_Real_Double_REG = MAX_REAL_DOUBLE_REG
88 mAX_Real_Long_REG :: Int
89 #ifdef MAX_REAL_LONG_REG
90 mAX_Real_Long_REG = MAX_REAL_LONG_REG
95 -- Closure header sizes.
98 sTD_HDR_SIZE = STD_HDR_SIZE
101 pROF_HDR_SIZE = PROF_HDR_SIZE
103 -- Size of a double in StgWords.
106 dOUBLE_SIZE = SIZEOF_DOUBLE
112 iNT64_SIZE = wORD64_SIZE
114 -- This tells the native code generator the size of the spill
115 -- area is has available.
117 rESERVED_C_STACK_BYTES :: Int
118 rESERVED_C_STACK_BYTES = RESERVED_C_STACK_BYTES
120 -- The amount of (Haskell) stack to leave free for saving registers when
121 -- returning to the scheduler.
123 rESERVED_STACK_WORDS :: Int
124 rESERVED_STACK_WORDS = RESERVED_STACK_WORDS
126 -- Continuations that need more than this amount of stack should do their
127 -- own stack check (see bug #1466).
129 aP_STACK_SPLIM :: Int
130 aP_STACK_SPLIM = AP_STACK_SPLIM
132 -- Size of a word, in bytes
135 wORD_SIZE = SIZEOF_HSWORD
137 wORD_SIZE_IN_BITS :: Int
138 wORD_SIZE_IN_BITS = wORD_SIZE * 8
140 -- Define a fixed-range integral type equivalent to the target Int/Word
142 #if SIZEOF_HSWORD == 4
143 type TargetInt = Int32
144 type TargetWord = Word32
145 #elif SIZEOF_HSWORD == 8
146 type TargetInt = Int64
147 type TargetWord = Word64
149 #error unknown SIZEOF_HSWORD
152 tARGET_MIN_INT, tARGET_MAX_INT, tARGET_MAX_WORD :: Integer
153 tARGET_MIN_INT = fromIntegral (minBound :: TargetInt)
154 tARGET_MAX_INT = fromIntegral (maxBound :: TargetInt)
155 tARGET_MAX_WORD = fromIntegral (maxBound :: TargetWord)
157 tARGET_MAX_CHAR :: Int
158 tARGET_MAX_CHAR = 0x10ffff
160 -- Amount of pointer bits used for semi-tagging constructor closures
166 tAG_MASK = (1 `shiftL` tAG_BITS) - 1
169 mAX_PTR_TAG = tAG_MASK
171 -- Size of a C int, in bytes. May be smaller than wORD_SIZE.
174 cINT_SIZE = SIZEOF_INT
176 -- Size of a storage manager block (in bytes).
179 bLOCK_SIZE = BLOCK_SIZE
181 bLOCK_SIZE_W = bLOCK_SIZE `quot` wORD_SIZE
183 -- Number of bits to shift a bitfield left by in an info table.
185 bITMAP_BITS_SHIFT :: Int
186 bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
188 -- Constants derived from headers in ghc/includes, generated by the program
189 -- ../includes/mkDerivedConstants.c.
191 #include "GHCConstants.h"