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