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