[project @ 2000-08-17 14:30:26 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         tICKY_HDR_SIZE,
24         aRR_WORDS_HDR_SIZE,
25         aRR_PTRS_HDR_SIZE,
26         rESERVED_C_STACK_BYTES,
27         rESERVED_STACK_WORDS,
28
29         sTD_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         sCC_UF_SIZE,
38         gRAN_UF_SIZE,  -- HWL
39         uF_RET,
40         uF_SU,
41         uF_UPDATEE,
42         uF_CCS,
43
44         sEQ_FRAME_SIZE,
45         sCC_SEQ_FRAME_SIZE,
46         gRAN_SEQ_FRAME_SIZE, -- HWL
47
48         mAX_Vanilla_REG,
49         mAX_Float_REG,
50         mAX_Double_REG,
51         mAX_Long_REG,
52
53         mAX_Real_Vanilla_REG,
54         mAX_Real_Float_REG,
55         mAX_Real_Double_REG,
56         mAX_Real_Long_REG,
57
58         oTHER_TAG,
59
60         mAX_INTLIKE, mIN_INTLIKE,
61         mAX_CHARLIKE, mIN_CHARLIKE,
62
63         spRelToInt,
64
65         dOUBLE_SIZE,
66         iNT64_SIZE,
67         wORD64_SIZE,
68         
69         wORD_SIZE,
70
71         bLOCK_SIZE,
72         bLOCK_SIZE_W,
73
74         interfaceFileFormatVersion
75
76     ) where
77
78 -- This magical #include brings in all the everybody-knows-these magic
79 -- constants unfortunately, we need to be *explicit* about which one
80 -- we want; if we just hope a -I... will get the right one, we could
81 -- be in trouble.
82
83 #include "HsVersions.h"
84 #include "../includes/config.h"
85 #include "../includes/MachRegs.h"
86 #include "../includes/Constants.h"
87
88 -- import Util
89 \end{code}
90
91 All pretty arbitrary:
92
93 \begin{code}
94 mAX_TUPLE_SIZE = (37 :: Int)
95 mAX_CONTEXT_REDUCTION_DEPTH = (20 :: Int)
96 \end{code}
97
98
99 \begin{code}
100 -- specialised fun/thunk/constr closure types
101 mAX_SPEC_THUNK_SIZE   = (MAX_SPEC_THUNK_SIZE :: Int)
102 mAX_SPEC_FUN_SIZE     = (MAX_SPEC_FUN_SIZE :: Int)
103 mAX_SPEC_CONSTR_SIZE  = (MAX_SPEC_CONSTR_SIZE :: Int)
104
105 -- pre-compiled thunk types
106 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
107 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
108
109 -- closure sizes: these do NOT include the header (see below for header sizes)
110 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
111 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
112 \end{code}
113
114 Constants for semi-tagging; the tags associated with the data
115 constructors will start at 0 and go up.
116
117 \begin{code}
118 oTHER_TAG = (INFO_OTHER_TAG :: Integer) -- (-1) unevaluated, probably
119 \end{code}
120
121 \begin{code}
122 mIN_INTLIKE, mAX_INTLIKE :: Integer     -- Only used to compare with (MachInt Integer)
123 mIN_INTLIKE = MIN_INTLIKE
124 mAX_INTLIKE = MAX_INTLIKE
125
126 mIN_CHARLIKE, mAX_CHARLIKE :: Int       -- Only used to compare with (MachChar Int)
127 mIN_CHARLIKE = MIN_CHARLIKE
128 mAX_CHARLIKE = MAX_CHARLIKE
129 \end{code}
130
131 A little function that abstracts the stack direction.  Note that most
132 of the code generator is dependent on the stack direction anyway, so
133 changing this on its own spells certain doom.  ToDo: remove?
134
135 \begin{code}
136 -- THIS IS DIRECTION SENSITIVE!
137
138 -- stack grows down, positive virtual offsets correspond to negative
139 -- additions to the stack pointer.
140
141 spRelToInt :: Int{-VirtualSpOffset-} -> Int{-VirtualSpOffset-} -> Int
142 spRelToInt sp off = sp - off
143 \end{code}
144
145 A section of code-generator-related MAGIC CONSTANTS.
146
147 \begin{code}
148 mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
149 -- If you change this, you may need to change runtimes/standard/Update.lhc
150
151 -- The update frame sizes
152 uF_SIZE = (NOSCC_UF_SIZE::Int)
153
154 -- Same again, with profiling
155 sCC_UF_SIZE = (SCC_UF_SIZE::Int)
156
157 -- Same again, with gransim
158 gRAN_UF_SIZE = (GRAN_UF_SIZE::Int)
159
160 -- Offsets in an update frame.  They don't change with profiling!
161 uF_RET         = (UF_RET::Int)
162 uF_SU          = (UF_SU::Int)
163 uF_UPDATEE     = (UF_UPDATEE::Int)
164 uF_CCS         = (UF_CCS::Int)
165 \end{code}
166
167 Seq frame sizes.
168
169 \begin{code}
170 sEQ_FRAME_SIZE = (NOSCC_SEQ_FRAME_SIZE::Int)
171 sCC_SEQ_FRAME_SIZE = (SCC_SEQ_FRAME_SIZE::Int)
172 gRAN_SEQ_FRAME_SIZE = (GRAN_SEQ_FRAME_SIZE::Int)
173 \end{code}
174
175 \begin{code}
176 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
177 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
178 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
179 mAX_Long_REG    = (MAX_LONG_REG  :: Int)
180
181 mAX_Real_Vanilla_REG    = (MAX_REAL_VANILLA_REG :: Int)
182 mAX_Real_Float_REG      = (MAX_REAL_FLOAT_REG :: Int)
183 mAX_Real_Double_REG     = (MAX_REAL_DOUBLE_REG :: Int)
184 #ifdef MAX_REAL_LONG_REG
185 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
186 #else
187 mAX_Real_Long_REG       = (0::Int)
188 #endif
189 \end{code}
190
191 Closure header sizes.
192
193 \begin{code}
194 sTD_HDR_SIZE       = (STD_HDR_SIZE       :: Int)
195 pROF_HDR_SIZE      = (PROF_HDR_SIZE      :: Int)
196 gRAN_HDR_SIZE      = (GRAN_HDR_SIZE      :: Int)
197 tICKY_HDR_SIZE     = (TICKY_HDR_SIZE     :: Int)
198 aRR_WORDS_HDR_SIZE = (ARR_WORDS_HDR_SIZE :: Int)
199 aRR_PTRS_HDR_SIZE  = (ARR_PTRS_HDR_SIZE  :: Int)
200 \end{code}
201
202 Info Table sizes.
203
204 \begin{code}
205 sTD_ITBL_SIZE   = (STD_ITBL_SIZE   :: Int)
206 pROF_ITBL_SIZE  = (PROF_ITBL_SIZE  :: Int)
207 gRAN_ITBL_SIZE  = (GRAN_ITBL_SIZE  :: Int)
208 tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
209 \end{code}
210
211 Size of a double in StgWords.
212
213 \begin{code}
214 dOUBLE_SIZE    = (DOUBLE_SIZE   :: Int)
215 wORD64_SIZE    = (WORD64_SIZE   :: Int)
216 iNT64_SIZE     = (INT64_SIZE   :: Int)
217 \end{code}
218
219 The version of the interface file format we're using.  It's propagated
220 here by a devious route from ghc/mk/version.mk.  See comments
221 there for what it means.
222
223 \begin{code}
224 interfaceFileFormatVersion :: Int
225 interfaceFileFormatVersion = HscIfaceFileVersion
226 \end{code}
227
228 This tells the native code generator the size of the spill
229 area is has available.
230
231 \begin{code}
232 rESERVED_C_STACK_BYTES = (RESERVED_C_STACK_BYTES :: Int)
233 \end{code}
234
235 The amount of (Haskell) stack to leave free for saving registers when
236 returning to the scheduler.
237
238 \begin{code}
239 rESERVED_STACK_WORDS = (RESERVED_STACK_WORDS :: Int)
240 \end{code}
241
242 Size of a word, in bytes
243
244 \begin{code}
245 wORD_SIZE = (WORD_SIZE :: Int)
246 \end{code}
247
248 Size of a storage manager block (in bytes).
249
250 \begin{code}
251 bLOCK_SIZE = (BLOCK_SIZE :: Int)
252 bLOCK_SIZE_W = (bLOCK_SIZE `div` wORD_SIZE :: Int)
253 \end{code}