[project @ 1999-03-26 10:29:02 by simonm]
[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         uNFOLDING_USE_THRESHOLD,
9         uNFOLDING_CREATION_THRESHOLD,
10         iNTERFACE_UNFOLD_THRESHOLD,
11         lIBERATE_CASE_THRESHOLD,
12         uNFOLDING_CHEAP_OP_COST,
13         uNFOLDING_DEAR_OP_COST,
14         uNFOLDING_NOREP_LIT_COST,
15         uNFOLDING_CON_DISCOUNT_WEIGHT,
16         uNFOLDING_KEENESS_FACTOR,
17
18         mAX_CONTEXT_REDUCTION_DEPTH,
19         mAX_TUPLE_SIZE,
20
21         mAX_SPEC_THUNK_SIZE,
22         mAX_SPEC_FUN_SIZE,
23         mAX_SPEC_CONSTR_SIZE,
24         mAX_SPEC_SELECTEE_SIZE,
25         mAX_SPEC_AP_SIZE,
26
27         tARGET_MIN_INT, tARGET_MAX_INT,
28
29         mIN_UPD_SIZE,
30         mIN_SIZE_NonUpdHeapObject,
31
32         sTD_HDR_SIZE,
33         pROF_HDR_SIZE,
34         gRAN_HDR_SIZE,
35         tICKY_HDR_SIZE,
36         aRR_HDR_SIZE,
37
38         sTD_ITBL_SIZE,
39         pROF_ITBL_SIZE,
40         gRAN_ITBL_SIZE,
41         tICKY_ITBL_SIZE,
42
43         mAX_FAMILY_SIZE_FOR_VEC_RETURNS,
44
45         uF_SIZE,
46         sCC_UF_SIZE,
47         uF_RET,
48         uF_SU,
49         uF_UPDATEE,
50         uF_CCS,
51
52         sEQ_FRAME_SIZE,
53         sCC_SEQ_FRAME_SIZE,
54
55         mAX_Vanilla_REG,
56         mAX_Float_REG,
57         mAX_Double_REG,
58         mAX_Long_REG,
59
60         mAX_Real_Vanilla_REG,
61         mAX_Real_Float_REG,
62         mAX_Real_Double_REG,
63         mAX_Real_Long_REG,
64
65         oTHER_TAG,
66
67         mAX_INTLIKE, mIN_INTLIKE,
68
69         spRelToInt,
70
71         dOUBLE_SIZE,
72         iNT64_SIZE,
73         wORD64_SIZE,
74         
75         interfaceFileFormatVersion
76
77     ) where
78
79 -- This magical #include brings in all the everybody-knows-these magic
80 -- constants unfortunately, we need to be *explicit* about which one
81 -- we want; if we just hope a -I... will get the right one, we could
82 -- be in trouble.
83
84 #include "HsVersions.h"
85 #include "../includes/config.h"
86 #include "../includes/MachRegs.h"
87 #include "../includes/Constants.h"
88
89 -- import Util
90 \end{code}
91
92 All pretty arbitrary:
93
94 \begin{code}
95 mAX_TUPLE_SIZE = (37 :: Int)
96 mAX_CONTEXT_REDUCTION_DEPTH = (20 :: Int)
97 \end{code}
98
99 \begin{code}
100 uNFOLDING_USE_THRESHOLD       = ( 8 :: Int)
101 uNFOLDING_CREATION_THRESHOLD  = (30 :: Int)     -- Discounts can be big
102 iNTERFACE_UNFOLD_THRESHOLD    = (30 :: Int)
103 lIBERATE_CASE_THRESHOLD       = (10 :: Int)
104
105 uNFOLDING_CHEAP_OP_COST       = ( 1 :: Int)
106 uNFOLDING_DEAR_OP_COST        = ( 4 :: Int)
107 uNFOLDING_NOREP_LIT_COST      = ( 20 :: Int)    -- Strings can be pretty big
108 uNFOLDING_CON_DISCOUNT_WEIGHT = ( 3 :: Int)
109 uNFOLDING_KEENESS_FACTOR      = ( 2.0 :: Float)
110 \end{code}
111
112 \begin{code}
113
114 -- specialised fun/thunk/constr closure types
115 mAX_SPEC_THUNK_SIZE   = (MAX_SPEC_THUNK_SIZE :: Int)
116 mAX_SPEC_FUN_SIZE     = (MAX_SPEC_FUN_SIZE :: Int)
117 mAX_SPEC_CONSTR_SIZE  = (MAX_SPEC_CONSTR_SIZE :: Int)
118
119 -- pre-compiled thunk types
120 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
121 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
122
123 -- closure sizes: these do NOT include the header (see below for header sizes)
124 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
125 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
126 \end{code}
127
128 If we're compiling with GHC (and we're not cross-compiling), then we
129 know that minBound and maxBound :: Int are the right values for the
130 target architecture.  Otherwise, we assume -2^31 and 2^31-1
131 respectively (which will be wrong on a 64-bit machine).
132
133 \begin{code}
134 tARGET_MIN_INT, tARGET_MAX_INT :: Integer
135 #if __GLASGOW_HASKELL__
136 tARGET_MIN_INT = toInteger (minBound :: Int)
137 tARGET_MAX_INT = toInteger (maxBound :: Int)
138 #else
139 tARGET_MIN_INT = -2147483648
140 tARGET_MAX_INT =  2147483647
141 #endif
142 \end{code}
143  
144 Constants for semi-tagging; the tags associated with the data
145 constructors will start at 0 and go up.
146
147 \begin{code}
148 oTHER_TAG = (INFO_OTHER_TAG :: Integer) -- (-1) unevaluated, probably
149 \end{code}
150
151 \begin{code}
152 mIN_INTLIKE, mAX_INTLIKE :: Integer     -- Only used to compare with (MachInt Integer)
153 mIN_INTLIKE = MIN_INTLIKE
154 mAX_INTLIKE = MAX_INTLIKE
155 \end{code}
156
157 A little function that abstracts the stack direction.  Note that most
158 of the code generator is dependent on the stack direction anyway, so
159 changing this on its own spells certain doom.  ToDo: remove?
160
161 \begin{code}
162 -- THIS IS DIRECTION SENSITIVE!
163
164 -- stack grows down, positive virtual offsets correspond to negative
165 -- additions to the stack pointer.
166
167 spRelToInt :: Int{-VirtualSpOffset-} -> Int{-VirtualSpOffset-} -> Int
168 spRelToInt sp off = sp - off
169 \end{code}
170
171 A section of code-generator-related MAGIC CONSTANTS.
172
173 \begin{code}
174 mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
175 -- If you change this, you may need to change runtimes/standard/Update.lhc
176
177 -- The update frame sizes
178 uF_SIZE = (NOSCC_UF_SIZE::Int)
179
180 -- Same again, with profiling
181 sCC_UF_SIZE = (SCC_UF_SIZE::Int)
182
183 -- Offsets in an update frame.  They don't change with profiling!
184 uF_RET         = (UF_RET::Int)
185 uF_SU          = (UF_SU::Int)
186 uF_UPDATEE     = (UF_UPDATEE::Int)
187 uF_CCS         = (UF_CCS::Int)
188 \end{code}
189
190 Seq frame sizes.
191
192 \begin{code}
193 sEQ_FRAME_SIZE = (NOSCC_SEQ_FRAME_SIZE::Int)
194 sCC_SEQ_FRAME_SIZE = (SCC_SEQ_FRAME_SIZE::Int)
195 \end{code}
196
197 \begin{code}
198 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
199 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
200 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
201 mAX_Long_REG    = (MAX_LONG_REG  :: Int)
202
203 mAX_Real_Vanilla_REG    = (MAX_REAL_VANILLA_REG :: Int)
204 mAX_Real_Float_REG      = (MAX_REAL_FLOAT_REG :: Int)
205 mAX_Real_Double_REG     = (MAX_REAL_DOUBLE_REG :: Int)
206 #ifdef MAX_REAL_LONG_REG
207 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
208 #else
209 mAX_Real_Long_REG       = (0::Int)
210 #endif
211 \end{code}
212
213 Closure header sizes.
214
215 \begin{code}
216 sTD_HDR_SIZE   = (STD_HDR_SIZE   :: Int)
217 pROF_HDR_SIZE  = (PROF_HDR_SIZE  :: Int)
218 gRAN_HDR_SIZE  = (GRAN_HDR_SIZE  :: Int)
219 tICKY_HDR_SIZE = (TICKY_HDR_SIZE :: Int)
220 aRR_HDR_SIZE   = (ARR_HDR_SIZE   :: Int)
221 \end{code}
222
223 Info Table sizes.
224
225 \begin{code}
226 sTD_ITBL_SIZE   = (STD_ITBL_SIZE   :: Int)
227 pROF_ITBL_SIZE  = (PROF_ITBL_SIZE  :: Int)
228 gRAN_ITBL_SIZE  = (GRAN_ITBL_SIZE  :: Int)
229 tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
230 \end{code}
231
232 Size of a double in StgWords.
233
234 \begin{code}
235 dOUBLE_SIZE    = (DOUBLE_SIZE   :: Int)
236 wORD64_SIZE    = (WORD64_SIZE   :: Int)
237 iNT64_SIZE     = (INT64_SIZE   :: Int)
238 \end{code}
239
240 The version of the interface file format we're
241 using:
242
243 \begin{code}
244 interfaceFileFormatVersion :: Int
245 interfaceFileFormatVersion = HscIfaceFileVersion
246 \end{code}