Make Constants shareable with the base package
[ghc-hetmet.git] / includes / HaskellConstants.hs
1
2 import Data.Bits (shiftL)
3
4 -- This magical #include brings in all the everybody-knows-these magic
5 -- constants unfortunately, we need to be *explicit* about which one
6 -- we want; if we just hope a -I... will get the right one, we could
7 -- be in trouble.
8
9 {-
10 Pull in the autoconf defines (HAVE_FOO), but don't include
11 ghcconfig.h, because that will include ghcplatform.h which has the
12 wrong platform settings for the compiler (it has the platform
13 settings for the target plat instead).
14 -}
15 #include "../includes/ghcautoconf.h"
16
17 #include "stg/MachRegs.h"
18 #include "rts/Constants.h"
19 #include "MachDeps.h"
20 #include "DerivedConstants.h"
21
22 -- import Util
23
24 -- All pretty arbitrary:
25
26 mAX_TUPLE_SIZE :: Int
27 mAX_TUPLE_SIZE = 62 -- Should really match the number
28                     -- of decls in Data.Tuple
29
30 mAX_CONTEXT_REDUCTION_DEPTH :: Int
31 mAX_CONTEXT_REDUCTION_DEPTH = 20
32
33
34 -- specialised fun/thunk/constr closure types
35 mAX_SPEC_THUNK_SIZE :: Int
36 mAX_SPEC_THUNK_SIZE = MAX_SPEC_THUNK_SIZE
37
38 mAX_SPEC_FUN_SIZE :: Int
39 mAX_SPEC_FUN_SIZE = MAX_SPEC_FUN_SIZE
40
41 mAX_SPEC_CONSTR_SIZE :: Int
42 mAX_SPEC_CONSTR_SIZE = MAX_SPEC_CONSTR_SIZE
43
44 -- pre-compiled thunk types
45 mAX_SPEC_SELECTEE_SIZE :: Int
46 mAX_SPEC_SELECTEE_SIZE = MAX_SPEC_SELECTEE_SIZE
47
48 mAX_SPEC_AP_SIZE :: Int
49 mAX_SPEC_AP_SIZE = MAX_SPEC_AP_SIZE
50
51 -- closure sizes: these do NOT include the header (see below for header sizes)
52 mIN_PAYLOAD_SIZE ::Int
53 mIN_PAYLOAD_SIZE = MIN_PAYLOAD_SIZE
54
55 mIN_INTLIKE, mAX_INTLIKE :: Int 
56 mIN_INTLIKE = MIN_INTLIKE
57 mAX_INTLIKE = MAX_INTLIKE
58
59 mIN_CHARLIKE, mAX_CHARLIKE :: Int
60 mIN_CHARLIKE = MIN_CHARLIKE
61 mAX_CHARLIKE = MAX_CHARLIKE
62
63 -- A section of code-generator-related MAGIC CONSTANTS.
64
65 mAX_Vanilla_REG :: Int
66 mAX_Vanilla_REG = MAX_VANILLA_REG
67
68 mAX_Float_REG :: Int
69 mAX_Float_REG = MAX_FLOAT_REG
70
71 mAX_Double_REG :: Int
72 mAX_Double_REG = MAX_DOUBLE_REG
73
74 mAX_Long_REG :: Int
75 mAX_Long_REG = MAX_LONG_REG
76
77 mAX_Real_Vanilla_REG :: Int
78 mAX_Real_Vanilla_REG = MAX_REAL_VANILLA_REG
79
80 mAX_Real_Float_REG :: Int
81 mAX_Real_Float_REG = MAX_REAL_FLOAT_REG
82
83 mAX_Real_Double_REG :: Int
84 mAX_Real_Double_REG     = MAX_REAL_DOUBLE_REG
85
86 mAX_Real_Long_REG :: Int
87 #ifdef MAX_REAL_LONG_REG
88 mAX_Real_Long_REG = MAX_REAL_LONG_REG
89 #else
90 mAX_Real_Long_REG = 0
91 #endif
92
93 -- Closure header sizes.
94
95 sTD_HDR_SIZE :: Int
96 sTD_HDR_SIZE = STD_HDR_SIZE
97
98 pROF_HDR_SIZE :: Int
99 pROF_HDR_SIZE = PROF_HDR_SIZE
100
101 -- Size of a double in StgWords.
102
103 dOUBLE_SIZE :: Int
104 dOUBLE_SIZE = SIZEOF_DOUBLE
105
106 wORD64_SIZE :: Int
107 wORD64_SIZE = 8
108
109 iNT64_SIZE :: Int
110 iNT64_SIZE = wORD64_SIZE
111
112 -- This tells the native code generator the size of the spill
113 -- area is has available.
114
115 rESERVED_C_STACK_BYTES :: Int
116 rESERVED_C_STACK_BYTES = RESERVED_C_STACK_BYTES
117
118 -- The amount of (Haskell) stack to leave free for saving registers when
119 -- returning to the scheduler.
120
121 rESERVED_STACK_WORDS :: Int
122 rESERVED_STACK_WORDS = RESERVED_STACK_WORDS
123
124 -- Continuations that need more than this amount of stack should do their
125 -- own stack check (see bug #1466).
126
127 aP_STACK_SPLIM :: Int
128 aP_STACK_SPLIM = AP_STACK_SPLIM
129
130 -- Size of a word, in bytes
131
132 wORD_SIZE :: Int
133 wORD_SIZE = SIZEOF_HSWORD
134
135 wORD_SIZE_IN_BITS :: Int
136 wORD_SIZE_IN_BITS = wORD_SIZE * 8
137
138 -- Amount of pointer bits used for semi-tagging constructor closures
139
140 tAG_BITS :: Int
141 tAG_BITS = TAG_BITS
142
143 tAG_MASK :: Int
144 tAG_MASK = (1 `shiftL` tAG_BITS) - 1
145
146 mAX_PTR_TAG :: Int
147 mAX_PTR_TAG = tAG_MASK
148
149 -- Size of a C int, in bytes. May be smaller than wORD_SIZE.
150
151 cINT_SIZE :: Int
152 cINT_SIZE = SIZEOF_INT
153
154 -- Size of a storage manager block (in bytes).
155
156 bLOCK_SIZE :: Int
157 bLOCK_SIZE = BLOCK_SIZE
158 bLOCK_SIZE_W :: Int
159 bLOCK_SIZE_W = bLOCK_SIZE `quot` wORD_SIZE
160
161 -- Number of bits to shift a bitfield left by in an info table.
162
163 bITMAP_BITS_SHIFT :: Int
164 bITMAP_BITS_SHIFT = BITMAP_BITS_SHIFT
165
166 -- Constants derived from headers in ghc/includes, generated by the program
167 -- ../includes/mkDerivedConstants.c.
168
169 #include "GHCConstants.h"
170