eca728d3c3fa24dfb548c56bbc5ef7fc58da404e
[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
54         mAX_Vanilla_REG,
55         mAX_Float_REG,
56         mAX_Double_REG,
57         mAX_Long_REG,
58
59         mAX_Real_Vanilla_REG,
60         mAX_Real_Float_REG,
61         mAX_Real_Double_REG,
62         mAX_Real_Long_REG,
63
64         oTHER_TAG,
65
66         mAX_INTLIKE, mIN_INTLIKE,
67
68         spRelToInt,
69
70         dOUBLE_SIZE,
71         iNT64_SIZE,
72         wORD64_SIZE,
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 \begin{code}
99 uNFOLDING_USE_THRESHOLD       = ( 8 :: Int)
100 uNFOLDING_CREATION_THRESHOLD  = (30 :: Int)     -- Discounts can be big
101 iNTERFACE_UNFOLD_THRESHOLD    = (30 :: Int)
102 lIBERATE_CASE_THRESHOLD       = (10 :: Int)
103
104 uNFOLDING_CHEAP_OP_COST       = ( 1 :: Int)
105 uNFOLDING_DEAR_OP_COST        = ( 4 :: Int)
106 uNFOLDING_NOREP_LIT_COST      = ( 20 :: Int)    -- Strings can be pretty big
107 uNFOLDING_CON_DISCOUNT_WEIGHT = ( 3 :: Int)
108 uNFOLDING_KEENESS_FACTOR      = ( 2.0 :: Float)
109 \end{code}
110
111 \begin{code}
112
113 -- specialised fun/thunk/constr closure types
114 mAX_SPEC_THUNK_SIZE   = (MAX_SPEC_THUNK_SIZE :: Int)
115 mAX_SPEC_FUN_SIZE     = (MAX_SPEC_FUN_SIZE :: Int)
116 mAX_SPEC_CONSTR_SIZE  = (MAX_SPEC_CONSTR_SIZE :: Int)
117
118 -- pre-compiled thunk types
119 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
120 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
121
122 -- closure sizes: these do NOT include the header (see below for header sizes)
123 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
124 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
125 \end{code}
126
127 If we're compiling with GHC (and we're not cross-compiling), then we
128 know that minBound and maxBound :: Int are the right values for the
129 target architecture.  Otherwise, we assume -2^31 and 2^31-1
130 respectively (which will be wrong on a 64-bit machine).
131
132 \begin{code}
133 tARGET_MIN_INT, tARGET_MAX_INT :: Integer
134 #if __GLASGOW_HASKELL__
135 tARGET_MIN_INT = toInteger (minBound :: Int)
136 tARGET_MAX_INT = toInteger (maxBound :: Int)
137 #else
138 tARGET_MIN_INT = -2147483648
139 tARGET_MAX_INT =  2147483647
140 #endif
141 \end{code}
142  
143 Constants for semi-tagging; the tags associated with the data
144 constructors will start at 0 and go up.
145
146 \begin{code}
147 oTHER_TAG = (INFO_OTHER_TAG :: Integer) -- (-1) unevaluated, probably
148 \end{code}
149
150 \begin{code}
151 mIN_INTLIKE, mAX_INTLIKE :: Integer     -- Only used to compare with (MachInt Integer)
152 mIN_INTLIKE = MIN_INTLIKE
153 mAX_INTLIKE = MAX_INTLIKE
154 \end{code}
155
156 A little function that abstracts the stack direction.  Note that most
157 of the code generator is dependent on the stack direction anyway, so
158 changing this on its own spells certain doom.  ToDo: remove?
159
160 \begin{code}
161 -- THIS IS DIRECTION SENSITIVE!
162
163 -- stack grows down, positive virtual offsets correspond to negative
164 -- additions to the stack pointer.
165
166 spRelToInt :: Int{-VirtualSpOffset-} -> Int{-VirtualSpOffset-} -> Int
167 spRelToInt sp off = sp - off
168 \end{code}
169
170 A section of code-generator-related MAGIC CONSTANTS.
171
172 \begin{code}
173 mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
174 -- If you change this, you may need to change runtimes/standard/Update.lhc
175
176 -- The update frame sizes
177 uF_SIZE = (NOSCC_UF_SIZE::Int)
178
179 -- Same again, with profiling
180 sCC_UF_SIZE = (SCC_UF_SIZE::Int)
181
182 -- Offsets in an update frame.  They don't change with profiling!
183 uF_RET         = (UF_RET::Int)
184 uF_SU          = (UF_SU::Int)
185 uF_UPDATEE     = (UF_UPDATEE::Int)
186 uF_CCS         = (UF_CCS::Int)
187 \end{code}
188
189 \begin{code}
190 sEQ_FRAME_SIZE = (SEQ_FRAME_SIZE::Int)
191 \end{code}
192
193 \begin{code}
194 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
195 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
196 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
197 mAX_Long_REG    = (MAX_LONG_REG  :: Int)
198
199 mAX_Real_Vanilla_REG    = (MAX_REAL_VANILLA_REG :: Int)
200 mAX_Real_Float_REG      = (MAX_REAL_FLOAT_REG :: Int)
201 mAX_Real_Double_REG     = (MAX_REAL_DOUBLE_REG :: Int)
202 #ifdef MAX_REAL_LONG_REG
203 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
204 #else
205 mAX_Real_Long_REG       = (0::Int)
206 #endif
207 \end{code}
208
209 Closure header sizes.
210
211 \begin{code}
212 sTD_HDR_SIZE   = (STD_HDR_SIZE   :: Int)
213 pROF_HDR_SIZE  = (PROF_HDR_SIZE  :: Int)
214 gRAN_HDR_SIZE  = (GRAN_HDR_SIZE  :: Int)
215 tICKY_HDR_SIZE = (TICKY_HDR_SIZE :: Int)
216 aRR_HDR_SIZE   = (ARR_HDR_SIZE   :: Int)
217 \end{code}
218
219 Info Table sizes.
220
221 \begin{code}
222 sTD_ITBL_SIZE   = (STD_ITBL_SIZE   :: Int)
223 pROF_ITBL_SIZE  = (PROF_ITBL_SIZE  :: Int)
224 gRAN_ITBL_SIZE  = (GRAN_ITBL_SIZE  :: Int)
225 tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
226 \end{code}
227
228 Size of a double in StgWords.
229
230 \begin{code}
231 dOUBLE_SIZE    = (DOUBLE_SIZE   :: Int)
232 wORD64_SIZE    = (WORD64_SIZE   :: Int)
233 iNT64_SIZE     = (INT64_SIZE   :: Int)
234 \end{code}
235
236 The version of the interface file format we're
237 using:
238
239 \begin{code}
240 interfaceFileFormatVersion :: Int
241 interfaceFileFormatVersion = HscIfaceFileVersion
242 \end{code}