Store a destination step in the block descriptor
[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 -- A section of code-generator-related MAGIC CONSTANTS.
66
67 mAX_Vanilla_REG :: Int
68 mAX_Vanilla_REG = MAX_VANILLA_REG
69
70 mAX_Float_REG :: Int
71 mAX_Float_REG = MAX_FLOAT_REG
72
73 mAX_Double_REG :: Int
74 mAX_Double_REG = MAX_DOUBLE_REG
75
76 mAX_Long_REG :: Int
77 mAX_Long_REG = MAX_LONG_REG
78
79 mAX_Real_Vanilla_REG :: Int
80 mAX_Real_Vanilla_REG = MAX_REAL_VANILLA_REG
81
82 mAX_Real_Float_REG :: Int
83 mAX_Real_Float_REG = MAX_REAL_FLOAT_REG
84
85 mAX_Real_Double_REG :: Int
86 mAX_Real_Double_REG     = MAX_REAL_DOUBLE_REG
87
88 mAX_Real_Long_REG :: Int
89 #ifdef MAX_REAL_LONG_REG
90 mAX_Real_Long_REG = MAX_REAL_LONG_REG
91 #else
92 mAX_Real_Long_REG = 0
93 #endif
94
95 -- Closure header sizes.
96
97 sTD_HDR_SIZE :: Int
98 sTD_HDR_SIZE = STD_HDR_SIZE
99
100 pROF_HDR_SIZE :: Int
101 pROF_HDR_SIZE = PROF_HDR_SIZE
102
103 -- Size of a double in StgWords.
104
105 dOUBLE_SIZE :: Int
106 dOUBLE_SIZE = SIZEOF_DOUBLE
107
108 wORD64_SIZE :: Int
109 wORD64_SIZE = 8
110
111 iNT64_SIZE :: Int
112 iNT64_SIZE = wORD64_SIZE
113
114 -- This tells the native code generator the size of the spill
115 -- area is has available.
116
117 rESERVED_C_STACK_BYTES :: Int
118 rESERVED_C_STACK_BYTES = RESERVED_C_STACK_BYTES
119
120 -- The amount of (Haskell) stack to leave free for saving registers when
121 -- returning to the scheduler.
122
123 rESERVED_STACK_WORDS :: Int
124 rESERVED_STACK_WORDS = RESERVED_STACK_WORDS
125
126 -- Continuations that need more than this amount of stack should do their
127 -- own stack check (see bug #1466).
128
129 aP_STACK_SPLIM :: Int
130 aP_STACK_SPLIM = AP_STACK_SPLIM
131
132 -- Size of a word, in bytes
133
134 wORD_SIZE :: Int
135 wORD_SIZE = SIZEOF_HSWORD
136
137 wORD_SIZE_IN_BITS :: Int
138 wORD_SIZE_IN_BITS = wORD_SIZE * 8
139
140 -- Define a fixed-range integral type equivalent to the target Int/Word
141
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
148 #else
149 #error unknown SIZEOF_HSWORD
150 #endif
151
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)
156
157 tARGET_MAX_CHAR :: Int
158 tARGET_MAX_CHAR = 0x10ffff
159
160 -- Amount of pointer bits used for semi-tagging constructor closures
161
162 tAG_BITS :: Int
163 tAG_BITS = TAG_BITS
164
165 tAG_MASK :: Int
166 tAG_MASK = (1 `shiftL` tAG_BITS) - 1
167
168 mAX_PTR_TAG :: Int
169 mAX_PTR_TAG = tAG_MASK
170
171 -- Size of a C int, in bytes. May be smaller than wORD_SIZE.
172
173 cINT_SIZE :: Int
174 cINT_SIZE = SIZEOF_INT
175
176 -- Size of a storage manager block (in bytes).
177
178 bLOCK_SIZE :: Int
179 bLOCK_SIZE = BLOCK_SIZE
180 bLOCK_SIZE_W :: Int
181 bLOCK_SIZE_W = bLOCK_SIZE `quot` wORD_SIZE
182
183 -- Number of bits to shift a bitfield left by in an info table.
184
185 bITMAP_BITS_SHIFT :: Int
186 bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
187
188 -- Constants derived from headers in ghc/includes, generated by the program
189 -- ../includes/mkDerivedConstants.c.
190
191 #include "GHCConstants.h"
192