[project @ 1999-01-18 14:31:50 by sof]
[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_SELECTEE_SIZE,
22         mAX_SPEC_AP_SIZE,
23
24         tARGET_MIN_INT, tARGET_MAX_INT,
25
26         mIN_UPD_SIZE,
27         mIN_SIZE_NonUpdHeapObject,
28
29         sTD_HDR_SIZE,
30         pROF_HDR_SIZE,
31         gRAN_HDR_SIZE,
32         tICKY_HDR_SIZE,
33         aRR_HDR_SIZE,
34
35         sTD_ITBL_SIZE,
36         pROF_ITBL_SIZE,
37         gRAN_ITBL_SIZE,
38         tICKY_ITBL_SIZE,
39
40         mAX_FAMILY_SIZE_FOR_VEC_RETURNS,
41
42         uF_SIZE,
43         sCC_UF_SIZE,
44         uF_RET,
45         uF_SU,
46         uF_UPDATEE,
47         uF_CCS,
48
49         sEQ_FRAME_SIZE,
50
51         mAX_Vanilla_REG,
52         mAX_Float_REG,
53         mAX_Double_REG,
54         mAX_Long_REG,
55
56         mAX_Real_Vanilla_REG,
57         mAX_Real_Float_REG,
58         mAX_Real_Double_REG,
59         mAX_Real_Long_REG,
60
61         oTHER_TAG,
62
63         mAX_INTLIKE, mIN_INTLIKE,
64
65         spRelToInt,
66
67         dOUBLE_SIZE,
68         iNT64_SIZE,
69         wORD64_SIZE,
70         
71         interfaceFileFormatVersion
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 \begin{code}
96 uNFOLDING_USE_THRESHOLD       = ( 8 :: Int)
97 uNFOLDING_CREATION_THRESHOLD  = (30 :: Int)     -- Discounts can be big
98 iNTERFACE_UNFOLD_THRESHOLD    = (30 :: Int)
99 lIBERATE_CASE_THRESHOLD       = (10 :: Int)
100
101 uNFOLDING_CHEAP_OP_COST       = ( 1 :: Int)
102 uNFOLDING_DEAR_OP_COST        = ( 4 :: Int)
103 uNFOLDING_NOREP_LIT_COST      = ( 20 :: Int)    -- Strings can be pretty big
104 uNFOLDING_CON_DISCOUNT_WEIGHT = ( 3 :: Int)
105 uNFOLDING_KEENESS_FACTOR      = ( 2.0 :: Float)
106 \end{code}
107
108 \begin{code}
109
110 -- pre-compiled thunk types
111 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
112 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
113
114 -- closure sizes: these do NOT include the header (see below for header sizes)
115 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
116 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
117 \end{code}
118
119 \begin{code}
120 tARGET_MIN_INT, tARGET_MAX_INT :: Integer
121 tARGET_MIN_INT = -536870912
122 tARGET_MAX_INT =  536870912
123 \end{code}
124  
125 Constants for semi-tagging; the tags associated with the data
126 constructors will start at 0 and go up.
127
128 \begin{code}
129 oTHER_TAG = (INFO_OTHER_TAG :: Integer) -- (-1) unevaluated, probably
130 \end{code}
131
132 \begin{code}
133 mIN_INTLIKE, mAX_INTLIKE :: Integer     -- Only used to compare with (MachInt Integer)
134 mIN_INTLIKE = MIN_INTLIKE
135 mAX_INTLIKE = MAX_INTLIKE
136 \end{code}
137
138 A little function that abstracts the stack direction.  Note that most
139 of the code generator is dependent on the stack direction anyway, so
140 changing this on its own spells certain doom.  ToDo: remove?
141
142 \begin{code}
143 -- THIS IS DIRECTION SENSITIVE!
144
145 -- stack grows down, positive virtual offsets correspond to negative
146 -- additions to the stack pointer.
147
148 spRelToInt :: Int{-VirtualSpOffset-} -> Int{-VirtualSpOffset-} -> Int
149 spRelToInt sp off = sp - off
150 \end{code}
151
152 A section of code-generator-related MAGIC CONSTANTS.
153
154 \begin{code}
155 mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
156 -- If you change this, you may need to change runtimes/standard/Update.lhc
157
158 -- The update frame sizes
159 uF_SIZE = (NOSCC_UF_SIZE::Int)
160
161 -- Same again, with profiling
162 sCC_UF_SIZE = (SCC_UF_SIZE::Int)
163
164 -- Offsets in an update frame.  They don't change with profiling!
165 uF_RET         = (UF_RET::Int)
166 uF_SU          = (UF_SU::Int)
167 uF_UPDATEE     = (UF_UPDATEE::Int)
168 uF_CCS         = (UF_CCS::Int)
169 \end{code}
170
171 \begin{code}
172 sEQ_FRAME_SIZE = (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 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
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_HDR_SIZE   = (ARR_HDR_SIZE   :: Int)
195 \end{code}
196
197 Info Table sizes.
198
199 \begin{code}
200 sTD_ITBL_SIZE   = (STD_ITBL_SIZE   :: Int)
201 pROF_ITBL_SIZE  = (PROF_ITBL_SIZE  :: Int)
202 gRAN_ITBL_SIZE  = (GRAN_ITBL_SIZE  :: Int)
203 tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
204 \end{code}
205
206 Size of a double in StgWords.
207
208 \begin{code}
209 dOUBLE_SIZE    = (DOUBLE_SIZE   :: Int)
210 wORD64_SIZE    = (WORD64_SIZE   :: Int)
211 iNT64_SIZE     = (INT64_SIZE   :: Int)
212 \end{code}
213
214 The version of the interface file format we're
215 using:
216
217 \begin{code}
218 interfaceFileFormatVersion = HscIfaceFileVersion
219 \end{code}