add support for flattening recursive-let
[ghc-hetmet.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/MachRegs.h"
20 #include "rts/Constants.h"
21 #include "MachDeps.h"
22 #include "DerivedConstants.h"
23
24 -- import Util
25
26 -- All pretty arbitrary:
27
28 mAX_TUPLE_SIZE :: Int
29 mAX_TUPLE_SIZE = 62 -- Should really match the number
30                     -- of decls in Data.Tuple
31
32 mAX_CONTEXT_REDUCTION_DEPTH :: Int
33 mAX_CONTEXT_REDUCTION_DEPTH = 20
34
35
36 -- specialised fun/thunk/constr closure types
37 mAX_SPEC_THUNK_SIZE :: Int
38 mAX_SPEC_THUNK_SIZE = MAX_SPEC_THUNK_SIZE
39
40 mAX_SPEC_FUN_SIZE :: Int
41 mAX_SPEC_FUN_SIZE = MAX_SPEC_FUN_SIZE
42
43 mAX_SPEC_CONSTR_SIZE :: Int
44 mAX_SPEC_CONSTR_SIZE = MAX_SPEC_CONSTR_SIZE
45
46 -- pre-compiled thunk types
47 mAX_SPEC_SELECTEE_SIZE :: Int
48 mAX_SPEC_SELECTEE_SIZE = MAX_SPEC_SELECTEE_SIZE
49
50 mAX_SPEC_AP_SIZE :: Int
51 mAX_SPEC_AP_SIZE = MAX_SPEC_AP_SIZE
52
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
56
57 mIN_INTLIKE, mAX_INTLIKE :: Int 
58 mIN_INTLIKE = MIN_INTLIKE
59 mAX_INTLIKE = MAX_INTLIKE
60
61 mIN_CHARLIKE, mAX_CHARLIKE :: Int
62 mIN_CHARLIKE = MIN_CHARLIKE
63 mAX_CHARLIKE = MAX_CHARLIKE
64
65 mUT_ARR_PTRS_CARD_BITS :: Int
66 mUT_ARR_PTRS_CARD_BITS = MUT_ARR_PTRS_CARD_BITS
67
68 -- A section of code-generator-related MAGIC CONSTANTS.
69
70 mAX_Vanilla_REG :: Int
71 mAX_Vanilla_REG = MAX_VANILLA_REG
72
73 mAX_Float_REG :: Int
74 mAX_Float_REG = MAX_FLOAT_REG
75
76 mAX_Double_REG :: Int
77 mAX_Double_REG = MAX_DOUBLE_REG
78
79 mAX_Long_REG :: Int
80 mAX_Long_REG = MAX_LONG_REG
81
82 mAX_Real_Vanilla_REG :: Int
83 mAX_Real_Vanilla_REG = MAX_REAL_VANILLA_REG
84
85 mAX_Real_Float_REG :: Int
86 mAX_Real_Float_REG = MAX_REAL_FLOAT_REG
87
88 mAX_Real_Double_REG :: Int
89 mAX_Real_Double_REG     = MAX_REAL_DOUBLE_REG
90
91 mAX_Real_Long_REG :: Int
92 #ifdef MAX_REAL_LONG_REG
93 mAX_Real_Long_REG = MAX_REAL_LONG_REG
94 #else
95 mAX_Real_Long_REG = 0
96 #endif
97
98 -- Closure header sizes.
99
100 sTD_HDR_SIZE :: Int
101 sTD_HDR_SIZE = STD_HDR_SIZE
102
103 pROF_HDR_SIZE :: Int
104 pROF_HDR_SIZE = PROF_HDR_SIZE
105
106 -- Size of a double in StgWords.
107
108 dOUBLE_SIZE :: Int
109 dOUBLE_SIZE = SIZEOF_DOUBLE
110
111 wORD64_SIZE :: Int
112 wORD64_SIZE = 8
113
114 iNT64_SIZE :: Int
115 iNT64_SIZE = wORD64_SIZE
116
117 -- This tells the native code generator the size of the spill
118 -- area is has available.
119
120 rESERVED_C_STACK_BYTES :: Int
121 rESERVED_C_STACK_BYTES = RESERVED_C_STACK_BYTES
122
123 -- The amount of (Haskell) stack to leave free for saving registers when
124 -- returning to the scheduler.
125
126 rESERVED_STACK_WORDS :: Int
127 rESERVED_STACK_WORDS = RESERVED_STACK_WORDS
128
129 -- Continuations that need more than this amount of stack should do their
130 -- own stack check (see bug #1466).
131
132 aP_STACK_SPLIM :: Int
133 aP_STACK_SPLIM = AP_STACK_SPLIM
134
135 -- Size of a word, in bytes
136
137 wORD_SIZE :: Int
138 wORD_SIZE = SIZEOF_HSWORD
139
140 wORD_SIZE_IN_BITS :: Int
141 wORD_SIZE_IN_BITS = wORD_SIZE * 8
142
143 -- Define a fixed-range integral type equivalent to the target Int/Word
144
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
151 #else
152 #error unknown SIZEOF_HSWORD
153 #endif
154
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)
159
160 tARGET_MAX_CHAR :: Int
161 tARGET_MAX_CHAR = 0x10ffff
162
163 -- Amount of pointer bits used for semi-tagging constructor closures
164
165 tAG_BITS :: Int
166 tAG_BITS = TAG_BITS
167
168 tAG_MASK :: Int
169 tAG_MASK = (1 `shiftL` tAG_BITS) - 1
170
171 mAX_PTR_TAG :: Int
172 mAX_PTR_TAG = tAG_MASK
173
174 -- Size of a C int, in bytes. May be smaller than wORD_SIZE.
175
176 cINT_SIZE :: Int
177 cINT_SIZE = SIZEOF_INT
178
179 -- Size of a storage manager block (in bytes).
180
181 bLOCK_SIZE :: Int
182 bLOCK_SIZE = BLOCK_SIZE
183 bLOCK_SIZE_W :: Int
184 bLOCK_SIZE_W = bLOCK_SIZE `quot` wORD_SIZE
185
186 -- blocks that fit in an MBlock, leaving space for the block descriptors
187
188 bLOCKS_PER_MBLOCK :: Int
189 bLOCKS_PER_MBLOCK = BLOCKS_PER_MBLOCK
190
191 -- Number of bits to shift a bitfield left by in an info table.
192
193 bITMAP_BITS_SHIFT :: Int
194 bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
195
196 -- Constants derived from headers in ghc/includes, generated by the program
197 -- ../includes/mkDerivedConstants.c.
198
199 #include "GHCConstants.h"
200