9d6a7cc6384021ce2af7ded53f84d7caf1eb1a36
[ghc-hetmet.git] / ghc / compiler / main / Constants.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section[Constants]{Info about this compilation}
5
6 \begin{code}
7 module Constants (
8         mAX_CONTEXT_REDUCTION_DEPTH,
9         mAX_TUPLE_SIZE,
10
11         mAX_SPEC_THUNK_SIZE,
12         mAX_SPEC_FUN_SIZE,
13         mAX_SPEC_CONSTR_SIZE,
14         mAX_SPEC_SELECTEE_SIZE,
15         mAX_SPEC_AP_SIZE,
16
17         mIN_UPD_SIZE,
18         mIN_SIZE_NonUpdHeapObject,
19
20         sTD_HDR_SIZE,
21         pROF_HDR_SIZE,
22         gRAN_HDR_SIZE,
23         aRR_WORDS_HDR_SIZE,
24         aRR_PTRS_HDR_SIZE,
25         rESERVED_C_STACK_BYTES,
26         rESERVED_STACK_WORDS,
27
28         sTD_ITBL_SIZE,
29         rET_ITBL_SIZE,
30         pROF_ITBL_SIZE,
31         gRAN_ITBL_SIZE,
32         tICKY_ITBL_SIZE,
33
34         mAX_FAMILY_SIZE_FOR_VEC_RETURNS,
35
36         uF_SIZE,
37         pROF_UF_SIZE,
38         gRAN_UF_SIZE,  -- HWL
39         uF_RET,
40         uF_UPDATEE,
41
42         mAX_Vanilla_REG,
43         mAX_Float_REG,
44         mAX_Double_REG,
45         mAX_Long_REG,
46
47         mAX_Real_Vanilla_REG,
48         mAX_Real_Float_REG,
49         mAX_Real_Double_REG,
50         mAX_Real_Long_REG,
51
52         mAX_INTLIKE, mIN_INTLIKE,
53         mAX_CHARLIKE, mIN_CHARLIKE,
54
55         spRelToInt,
56
57         dOUBLE_SIZE,
58         iNT64_SIZE,
59         wORD64_SIZE,
60         
61         wORD_SIZE,
62         wORD_SIZE_IN_BITS,
63
64         bLOCK_SIZE,
65         bLOCK_SIZE_W,
66
67         bITMAP_BITS_SHIFT,
68     ) where
69
70 -- This magical #include brings in all the everybody-knows-these magic
71 -- constants unfortunately, we need to be *explicit* about which one
72 -- we want; if we just hope a -I... will get the right one, we could
73 -- be in trouble.
74
75 #include "HsVersions.h"
76 #include "../includes/config.h"
77 #include "../includes/MachRegs.h"
78 #include "../includes/Constants.h"
79 #include "../includes/MachDeps.h"
80 #include "../includes/DerivedConstants.h"
81
82 -- import Util
83 \end{code}
84
85 All pretty arbitrary:
86
87 \begin{code}
88 mAX_TUPLE_SIZE = (62 :: Int)    -- Should really match the number
89                                 -- of decls in Data.Tuple
90 mAX_CONTEXT_REDUCTION_DEPTH = (20 :: Int)
91 \end{code}
92
93
94 \begin{code}
95 -- specialised fun/thunk/constr closure types
96 mAX_SPEC_THUNK_SIZE   = (MAX_SPEC_THUNK_SIZE :: Int)
97 mAX_SPEC_FUN_SIZE     = (MAX_SPEC_FUN_SIZE :: Int)
98 mAX_SPEC_CONSTR_SIZE  = (MAX_SPEC_CONSTR_SIZE :: Int)
99
100 -- pre-compiled thunk types
101 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
102 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
103
104 -- closure sizes: these do NOT include the header (see below for header sizes)
105 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
106 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
107 \end{code}
108
109 \begin{code}
110 mIN_INTLIKE, mAX_INTLIKE :: Integer     -- Only used to compare with (MachInt Integer)
111 mIN_INTLIKE = MIN_INTLIKE
112 mAX_INTLIKE = MAX_INTLIKE
113
114 mIN_CHARLIKE, mAX_CHARLIKE :: Int       -- Only used to compare with (MachChar Int)
115 mIN_CHARLIKE = MIN_CHARLIKE
116 mAX_CHARLIKE = MAX_CHARLIKE
117 \end{code}
118
119 A little function that abstracts the stack direction.  Note that most
120 of the code generator is dependent on the stack direction anyway, so
121 changing this on its own spells certain doom.  ToDo: remove?
122
123 \begin{code}
124 -- THIS IS DIRECTION SENSITIVE!
125
126 -- stack grows down, positive virtual offsets correspond to negative
127 -- additions to the stack pointer.
128
129 spRelToInt :: Int{-VirtualSpOffset-} -> Int{-VirtualSpOffset-} -> Int
130 spRelToInt sp off = sp - off
131 \end{code}
132
133 A section of code-generator-related MAGIC CONSTANTS.
134
135 \begin{code}
136 mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
137 -- If you change this, you may need to change runtimes/standard/Update.lhc
138
139 -- The update frame sizes
140 uF_SIZE = (STD_UF_SIZE::Int)
141
142 -- Same again, with profiling
143 pROF_UF_SIZE = (PROF_UF_SIZE::Int)
144
145 -- Same again, with gransim
146 gRAN_UF_SIZE = (GRAN_UF_SIZE::Int)
147
148 -- Offsets in an update frame.  They don't change with profiling!
149 uF_RET         = (UF_RET::Int)
150 uF_UPDATEE     = (UF_UPDATEE::Int)
151 \end{code}
152
153 \begin{code}
154 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
155 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
156 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
157 mAX_Long_REG    = (MAX_LONG_REG  :: Int)
158
159 mAX_Real_Vanilla_REG    = (MAX_REAL_VANILLA_REG :: Int)
160 mAX_Real_Float_REG      = (MAX_REAL_FLOAT_REG :: Int)
161 mAX_Real_Double_REG     = (MAX_REAL_DOUBLE_REG :: Int)
162 #ifdef MAX_REAL_LONG_REG
163 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
164 #else
165 mAX_Real_Long_REG       = (0::Int)
166 #endif
167 \end{code}
168
169 Closure header sizes.
170
171 \begin{code}
172 sTD_HDR_SIZE       = (STD_HDR_SIZE       :: Int)
173 pROF_HDR_SIZE      = (PROF_HDR_SIZE      :: Int)
174 gRAN_HDR_SIZE      = (GRAN_HDR_SIZE      :: Int)
175 aRR_WORDS_HDR_SIZE = (ARR_WORDS_HDR_SIZE :: Int)
176 aRR_PTRS_HDR_SIZE  = (ARR_PTRS_HDR_SIZE  :: Int)
177 \end{code}
178
179 Info Table sizes.
180
181 \begin{code}
182 sTD_ITBL_SIZE   = (STD_ITBL_SIZE   :: Int)
183 rET_ITBL_SIZE   = (RET_ITBL_SIZE   :: Int)
184 pROF_ITBL_SIZE  = (PROF_ITBL_SIZE  :: Int)
185 gRAN_ITBL_SIZE  = (GRAN_ITBL_SIZE  :: Int)
186 tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
187 \end{code}
188
189 Size of a double in StgWords.
190
191 \begin{code}
192 dOUBLE_SIZE     = (SIZEOF_DOUBLE `quot` SIZEOF_HSWORD :: Int)
193 wORD64_SIZE     = (8 `quot` SIZEOF_HSWORD :: Int)
194 iNT64_SIZE      = wORD64_SIZE
195 \end{code}
196
197 This tells the native code generator the size of the spill
198 area is has available.
199
200 \begin{code}
201 rESERVED_C_STACK_BYTES = (RESERVED_C_STACK_BYTES :: Int)
202 \end{code}
203
204 The amount of (Haskell) stack to leave free for saving registers when
205 returning to the scheduler.
206
207 \begin{code}
208 rESERVED_STACK_WORDS = (RESERVED_STACK_WORDS :: Int)
209 \end{code}
210
211 Size of a word, in bytes
212
213 \begin{code}
214 wORD_SIZE = (SIZEOF_HSWORD :: Int)
215 wORD_SIZE_IN_BITS = wORD_SIZE * 8 :: Int
216 \end{code}
217
218 Size of a storage manager block (in bytes).
219
220 \begin{code}
221 bLOCK_SIZE = (BLOCK_SIZE :: Int)
222 bLOCK_SIZE_W = (bLOCK_SIZE `div` wORD_SIZE :: Int)
223 \end{code}
224
225 Number of bits to shift a bitfield left by in an info table.
226
227 \begin{code}
228 bITMAP_BITS_SHIFT = (BITMAP_BITS_SHIFT :: Int)
229 \end{code}