[project @ 2000-01-31 18:11:50 by sewardj]
[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         tARGET_MIN_INT, tARGET_MAX_INT,
18
19         mIN_UPD_SIZE,
20         mIN_SIZE_NonUpdHeapObject,
21
22         sTD_HDR_SIZE,
23         pROF_HDR_SIZE,
24         gRAN_HDR_SIZE,
25         tICKY_HDR_SIZE,
26         aRR_WORDS_HDR_SIZE,
27         aRR_PTRS_HDR_SIZE,
28         rESERVED_C_STACK_BYTES,
29
30         sTD_ITBL_SIZE,
31         pROF_ITBL_SIZE,
32         gRAN_ITBL_SIZE,
33         tICKY_ITBL_SIZE,
34
35         mAX_FAMILY_SIZE_FOR_VEC_RETURNS,
36
37         uF_SIZE,
38         sCC_UF_SIZE,
39         gRAN_UF_SIZE,  -- HWL
40         uF_RET,
41         uF_SU,
42         uF_UPDATEE,
43         uF_CCS,
44
45         sEQ_FRAME_SIZE,
46         sCC_SEQ_FRAME_SIZE,
47         gRAN_SEQ_FRAME_SIZE, -- HWL
48
49         mAX_Vanilla_REG,
50         mAX_Float_REG,
51         mAX_Double_REG,
52         mAX_Long_REG,
53
54         mAX_Real_Vanilla_REG,
55         mAX_Real_Float_REG,
56         mAX_Real_Double_REG,
57         mAX_Real_Long_REG,
58
59         oTHER_TAG,
60
61         mAX_INTLIKE, mIN_INTLIKE,
62
63         spRelToInt,
64
65         dOUBLE_SIZE,
66         iNT64_SIZE,
67         wORD64_SIZE,
68         
69         interfaceFileFormatVersion
70
71     ) where
72
73 -- This magical #include brings in all the everybody-knows-these magic
74 -- constants unfortunately, we need to be *explicit* about which one
75 -- we want; if we just hope a -I... will get the right one, we could
76 -- be in trouble.
77
78 #include "HsVersions.h"
79 #include "../includes/config.h"
80 #include "../includes/MachRegs.h"
81 #include "../includes/Constants.h"
82
83 -- import Util
84 \end{code}
85
86 All pretty arbitrary:
87
88 \begin{code}
89 mAX_TUPLE_SIZE = (37 :: Int)
90 mAX_CONTEXT_REDUCTION_DEPTH = (20 :: Int)
91 \end{code}
92
93
94 \begin{code}
95 -- specialised fun/thunk/constr closure types
96 mAX_SPEC_THUNK_SIZE   = (MAX_SPEC_THUNK_SIZE :: Int)
97 mAX_SPEC_FUN_SIZE     = (MAX_SPEC_FUN_SIZE :: Int)
98 mAX_SPEC_CONSTR_SIZE  = (MAX_SPEC_CONSTR_SIZE :: Int)
99
100 -- pre-compiled thunk types
101 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
102 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
103
104 -- closure sizes: these do NOT include the header (see below for header sizes)
105 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
106 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
107 \end{code}
108
109 If we're compiling with GHC (and we're not cross-compiling), then we
110 know that minBound and maxBound :: Int are the right values for the
111 target architecture.  Otherwise, we assume -2^31 and 2^31-1
112 respectively (which will be wrong on a 64-bit machine).
113
114 \begin{code}
115 tARGET_MIN_INT, tARGET_MAX_INT :: Integer
116 #if __GLASGOW_HASKELL__
117 tARGET_MIN_INT = toInteger (minBound :: Int)
118 tARGET_MAX_INT = toInteger (maxBound :: Int)
119 #else
120 tARGET_MIN_INT = -2147483648
121 tARGET_MAX_INT =  2147483647
122 #endif
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 -- Same again, with gransim
165 gRAN_UF_SIZE = (GRAN_UF_SIZE::Int)
166
167 -- Offsets in an update frame.  They don't change with profiling!
168 uF_RET         = (UF_RET::Int)
169 uF_SU          = (UF_SU::Int)
170 uF_UPDATEE     = (UF_UPDATEE::Int)
171 uF_CCS         = (UF_CCS::Int)
172 \end{code}
173
174 Seq frame sizes.
175
176 \begin{code}
177 sEQ_FRAME_SIZE = (NOSCC_SEQ_FRAME_SIZE::Int)
178 sCC_SEQ_FRAME_SIZE = (SCC_SEQ_FRAME_SIZE::Int)
179 gRAN_SEQ_FRAME_SIZE = (GRAN_SEQ_FRAME_SIZE::Int)
180 \end{code}
181
182 \begin{code}
183 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
184 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
185 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
186 mAX_Long_REG    = (MAX_LONG_REG  :: Int)
187
188 mAX_Real_Vanilla_REG    = (MAX_REAL_VANILLA_REG :: Int)
189 mAX_Real_Float_REG      = (MAX_REAL_FLOAT_REG :: Int)
190 mAX_Real_Double_REG     = (MAX_REAL_DOUBLE_REG :: Int)
191 #ifdef MAX_REAL_LONG_REG
192 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
193 #else
194 mAX_Real_Long_REG       = (0::Int)
195 #endif
196 \end{code}
197
198 Closure header sizes.
199
200 \begin{code}
201 sTD_HDR_SIZE       = (STD_HDR_SIZE       :: Int)
202 pROF_HDR_SIZE      = (PROF_HDR_SIZE      :: Int)
203 gRAN_HDR_SIZE      = (GRAN_HDR_SIZE      :: Int)
204 tICKY_HDR_SIZE     = (TICKY_HDR_SIZE     :: Int)
205 aRR_WORDS_HDR_SIZE = (ARR_WORDS_HDR_SIZE :: Int)
206 aRR_PTRS_HDR_SIZE  = (ARR_PTRS_HDR_SIZE  :: Int)
207 \end{code}
208
209 Info Table sizes.
210
211 \begin{code}
212 sTD_ITBL_SIZE   = (STD_ITBL_SIZE   :: Int)
213 pROF_ITBL_SIZE  = (PROF_ITBL_SIZE  :: Int)
214 gRAN_ITBL_SIZE  = (GRAN_ITBL_SIZE  :: Int)
215 tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
216 \end{code}
217
218 Size of a double in StgWords.
219
220 \begin{code}
221 dOUBLE_SIZE    = (DOUBLE_SIZE   :: Int)
222 wORD64_SIZE    = (WORD64_SIZE   :: Int)
223 iNT64_SIZE     = (INT64_SIZE   :: Int)
224 \end{code}
225
226 The version of the interface file format we're
227 using:
228
229 \begin{code}
230 interfaceFileFormatVersion :: Int
231 interfaceFileFormatVersion = HscIfaceFileVersion
232 \end{code}
233
234 This tells the native code generator the size of the spill
235 area is has available.
236
237 \begin{code}
238 rESERVED_C_STACK_BYTES = (RESERVED_C_STACK_BYTES :: Int)
239 \end{code}