f2a5b22ca3073e3a43327e818d5059d152728dfc
[ghc.git] / includes / HaskellConstants.hs
1
2 import Data.Bits (shiftL)
3 import Data.Word
4 import Data.Int
5
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
9 -- be in trouble.
10
11 {-
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).
16 -}
17 #include "../includes/ghcautoconf.h"
18
19 #include "stg/HaskellMachRegs.h"
20
21 #include "rts/Constants.h"
22 #include "MachDeps.h"
23 #include "../includes/dist-derivedconstants/header/DerivedConstants.h"
24
25 -- import Util
26
27 -- All pretty arbitrary:
28
29 mAX_TUPLE_SIZE :: Int
30 mAX_TUPLE_SIZE = 62 -- Should really match the number
31 -- of decls in Data.Tuple
32
33 mAX_CONTEXT_REDUCTION_DEPTH :: Int
34 mAX_CONTEXT_REDUCTION_DEPTH = 200
35 -- Increase to 200; see Trac #5395
36
37 -- closure sizes: these do NOT include the header (see below for header sizes)
38 mIN_PAYLOAD_SIZE ::Int
39 mIN_PAYLOAD_SIZE = MIN_PAYLOAD_SIZE
40
41 mIN_INTLIKE, mAX_INTLIKE :: Int
42 mIN_INTLIKE = MIN_INTLIKE
43 mAX_INTLIKE = MAX_INTLIKE
44
45 mIN_CHARLIKE, mAX_CHARLIKE :: Int
46 mIN_CHARLIKE = MIN_CHARLIKE
47 mAX_CHARLIKE = MAX_CHARLIKE
48
49 mUT_ARR_PTRS_CARD_BITS :: Int
50 mUT_ARR_PTRS_CARD_BITS = MUT_ARR_PTRS_CARD_BITS
51
52 -- A section of code-generator-related MAGIC CONSTANTS.
53
54 mAX_Vanilla_REG :: Int
55 mAX_Vanilla_REG = MAX_VANILLA_REG
56
57 mAX_Float_REG :: Int
58 mAX_Float_REG = MAX_FLOAT_REG
59
60 mAX_Double_REG :: Int
61 mAX_Double_REG = MAX_DOUBLE_REG
62
63 mAX_Long_REG :: Int
64 mAX_Long_REG = MAX_LONG_REG
65
66 mAX_Real_Vanilla_REG :: Int
67 mAX_Real_Vanilla_REG = MAX_REAL_VANILLA_REG
68
69 mAX_Real_Float_REG :: Int
70 mAX_Real_Float_REG = MAX_REAL_FLOAT_REG
71
72 mAX_Real_Double_REG :: Int
73 mAX_Real_Double_REG = MAX_REAL_DOUBLE_REG
74
75 mAX_Real_Long_REG :: Int
76 #ifdef MAX_REAL_LONG_REG
77 mAX_Real_Long_REG = MAX_REAL_LONG_REG
78 #else
79 mAX_Real_Long_REG = 0
80 #endif
81
82 -- Closure header sizes.
83
84 sTD_HDR_SIZE :: Int
85 sTD_HDR_SIZE = STD_HDR_SIZE
86
87 pROF_HDR_SIZE :: Int
88 pROF_HDR_SIZE = PROF_HDR_SIZE
89
90 -- Size of a double in StgWords.
91
92 dOUBLE_SIZE :: Int
93 dOUBLE_SIZE = SIZEOF_DOUBLE
94
95 wORD64_SIZE :: Int
96 wORD64_SIZE = 8
97
98 -- This tells the native code generator the size of the spill
99 -- area is has available.
100
101 rESERVED_C_STACK_BYTES :: Int
102 rESERVED_C_STACK_BYTES = RESERVED_C_STACK_BYTES
103
104 -- The amount of (Haskell) stack to leave free for saving registers when
105 -- returning to the scheduler.
106
107 rESERVED_STACK_WORDS :: Int
108 rESERVED_STACK_WORDS = RESERVED_STACK_WORDS
109
110 -- Continuations that need more than this amount of stack should do their
111 -- own stack check (see bug #1466).
112
113 aP_STACK_SPLIM :: Int
114 aP_STACK_SPLIM = AP_STACK_SPLIM
115
116 -- Size of a word, in bytes
117
118 wORD_SIZE :: Int
119 wORD_SIZE = SIZEOF_HSWORD
120
121 wORD_SIZE_IN_BITS :: Int
122 wORD_SIZE_IN_BITS = wORD_SIZE * 8
123
124 -- Define a fixed-range integral type equivalent to the target Int/Word
125
126 #if SIZEOF_HSWORD == 4
127 type TargetInt = Int32
128 type TargetWord = Word32
129 #elif SIZEOF_HSWORD == 8
130 type TargetInt = Int64
131 type TargetWord = Word64
132 #else
133 #error unknown SIZEOF_HSWORD
134 #endif
135
136 tARGET_MIN_INT, tARGET_MAX_INT, tARGET_MAX_WORD :: Integer
137 tARGET_MIN_INT = fromIntegral (minBound :: TargetInt)
138 tARGET_MAX_INT = fromIntegral (maxBound :: TargetInt)
139 tARGET_MAX_WORD = fromIntegral (maxBound :: TargetWord)
140
141 tARGET_MAX_CHAR :: Int
142 tARGET_MAX_CHAR = 0x10ffff
143
144 -- Amount of pointer bits used for semi-tagging constructor closures
145
146 tAG_BITS :: Int
147 tAG_BITS = TAG_BITS
148
149 tAG_MASK :: Int
150 tAG_MASK = (1 `shiftL` tAG_BITS) - 1
151
152 mAX_PTR_TAG :: Int
153 mAX_PTR_TAG = tAG_MASK
154
155 -- Size of a C int, in bytes. May be smaller than wORD_SIZE.
156
157 cINT_SIZE :: Int
158 cINT_SIZE = SIZEOF_INT
159
160 cLONG_SIZE :: Int
161 cLONG_SIZE = SIZEOF_LONG
162
163 cLONG_LONG_SIZE :: Int
164 cLONG_LONG_SIZE = SIZEOF_LONG_LONG
165
166 -- Size of a storage manager block (in bytes).
167
168 bLOCK_SIZE :: Int
169 bLOCK_SIZE = BLOCK_SIZE
170 bLOCK_SIZE_W :: Int
171 bLOCK_SIZE_W = bLOCK_SIZE `quot` wORD_SIZE
172
173 -- blocks that fit in an MBlock, leaving space for the block descriptors
174
175 bLOCKS_PER_MBLOCK :: Int
176 bLOCKS_PER_MBLOCK = BLOCKS_PER_MBLOCK
177
178 -- Number of bits to shift a bitfield left by in an info table.
179
180 bITMAP_BITS_SHIFT :: Int
181 bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
182