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