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