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