1 %************************************************************************
3 \section[GhcConstants]{Constants known by C code {\em and} by the compiler (hsc)}
5 %************************************************************************
7 Multi-slurp protection (start):
10 #define GHCCONSTANTS_H
17 % BECAUSE THIS FILE IS INCLUDED INTO HASKELL FILES, THERE MUST BE NO C
18 % COMMENTS IN THE ``CODE'' BITS.
20 This file defines constants that are common to diverse parts of the
21 Glasgow Haskell compilation system. For example, both the compiler
22 proper and some magic runtime-system bits need to know the minimum
23 size of an updatable closure.
25 %************************************************************************
27 \subsection[updatable-closure-size]{Size of Updatable Closures}
29 %************************************************************************
31 We define the minimum size for updatable closures. This must be at
32 least 2, to allow for cons cells and linked indirections. All updates
33 will be performed on closures of this size. For non-updatable closures
34 the minimum size is 1 to allow for a forwarding pointer.
37 #define MIN_UPD_SIZE 2
38 #define MIN_NONUPD_SIZE 1
41 ToDo: @MIN_STATIC_NONUPD_SIZE@ ???
43 %************************************************************************
45 \subsection[double-etc-size]{Sizes of various types}
47 %************************************************************************
49 The size of an StgDouble, in StgWords.
59 Sizes of gmp objects, in StgWords
62 #define MP_STRUCT_SIZE 3
63 #define MIN_MP_INT_SIZE 16
66 %************************************************************************
68 \subsection[spec-closure-constraints]{What can be declared as a @SPEC@ closure}
70 %************************************************************************
72 The following define what closure layouts can be declared as @SPEC@
76 #define MAX_SPEC_ALL_PTRS 12
77 #define MAX_SPEC_ALL_NONPTRS 5
78 #define MAX_SPEC_OTHER_SIZE 3
81 The highest-numbered selectee field that we can do magic on (i.e.,
82 do the selection at GC time):
84 #define MAX_SPEC_SELECTEE_SIZE 12
87 %************************************************************************
89 \subsection[stg-reg-counts]{How many STG registers are there}
91 %************************************************************************
94 #define MAX_VANILLA_REG 8
95 #define MAX_FLOAT_REG 4
96 #define MAX_DOUBLE_REG 2
99 %************************************************************************
101 \subsection[vectored-return]{What number of data type cases can use vectored returns}
103 %************************************************************************
105 @MAX_VECTORED_RTN@ defines the largest number of constructors that a
106 data type can have and still use a vectored return.
108 #define MAX_VECTORED_RTN 8
111 %************************************************************************
113 \subsection[intlike-range]{Range of int-like closures}
115 %************************************************************************
117 Range of built-in table of static small int-like closures.
120 #define MAX_INTLIKE (16)
121 #define MIN_INTLIKE (-16)
124 %************************************************************************
126 \subsection[string-size]{Maximum size of cost centre and description strings}
128 %************************************************************************
130 This is the maximum identifier length that can be used for a cost
131 centre or description string. It includes the terminating null
134 WDP 95/07: I think this STRING_SIZE thing is completely redundant.
136 The printf formats are here, so we are less likely to make overly-long
137 filenames (with disastrous results). No more than 128 chars, please!
140 #define STRING_SIZE 128
142 #define STATS_FILENAME_MAXLEN 128
144 #define GR_FILENAME_FMT "%0.124s.gr"
145 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.gr"
146 #define HP_FILENAME_FMT "%0.124s.hp"
147 #define LIFE_FILENAME_FMT "%0.122s.life"
148 #define PROF_FILENAME_FMT "%0.122s.prof"
149 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
150 #define QP_FILENAME_FMT "%0.124s.qp"
151 #define STAT_FILENAME_FMT "%0.122s.stat"
152 #define TICKY_FILENAME_FMT "%0.121s.ticky"
153 #define TIME_FILENAME_FMT "%0.122s.time"
154 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
157 %************************************************************************
159 \subsection[update-frame-size]{Update frame size}
161 %************************************************************************
163 The update frames are described in \tr{SMupdate.lh}. All the compiler
164 needs to ``know'' is the size of the different frames.
166 First we define update frame sizes for the compiler. These may vary at
167 runtime depending what type of code is being generated so we also
168 define the parts which can be put together.
170 ****************************************************************
171 *** NB: These update-frame sizes INCLUDE the return address. ***
172 ****************************************************************
175 The update frame sizes when cost centres are not being used are:
177 #define NOSCC_STD_UF_SIZE 4
178 #define NOSCC_CON_UF_SIZE 2
181 If cost-centres are being used we have to add to the above sizes:
183 #define SCC_STD_UF_SIZE 5
184 #define SCC_CON_UF_SIZE 3
187 If we are compiling C code the use of cost centres is determined at
188 compile time so we use conditional macro definitions.
190 #if defined(USE_COST_CENTRES)
191 #define STD_UF_SIZE SCC_STD_UF_SIZE
192 #define CON_UF_SIZE SCC_CON_UF_SIZE
194 #define STD_UF_SIZE NOSCC_STD_UF_SIZE
195 #define CON_UF_SIZE NOSCC_CON_UF_SIZE
199 Sorry. but we can't comment these if's and else's !
201 Offsets relative to a pointer to the top word (return address) of frame...
203 Notes: (1)~GC looks at the @UF_RET@ word to determine frame type. (2)
204 GC requires that @UF_SUB@ be the same offset in all frames, no matter
212 #define UF_COST_CENTRE 4
215 %************************************************************************
217 \subsection[semi-tagging-constants]{Constants for semi-tagging}
219 %************************************************************************
221 Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
222 normal-form values of algebraic data types will have tags 0, 1, ...
225 #define INFO_OTHER_TAG (-1)
226 #define INFO_IND_TAG (-1)
227 #define INFO_FIRST_TAG 0
230 %************************************************************************
232 \subsection[liveness-masks]{Liveness masks for calling GC}
234 %************************************************************************
236 We often have to tell the RTS (usually: garbage-collector) what STG
237 registers have ``followable'' pointers in them. We used to just say
238 {\em how many} there were; but this doesn't work in a semi-tagged
239 world---part of the point of semi-tagging is to avoid loading up
240 registers needlessly; but if you don't load a register and then you
241 tell the GC that it has followable contents....
243 So we use a {\em liveness mask} (one word) instead. This is probably
244 neater anyway. The layout is:
246 --------------------------
247 ... | Rn | ... | R2 | R1 |
248 --------------------------
251 The \tr{LIVENESS_<reg>} macros are used both in Haskell and C. The
252 \tr{IS_LIVE_<reg>} macros (``is this register live according to this
253 mask?'') are used only in C [obviously].
255 #define NO_LIVENESS 0
256 #define LIVENESS_R1 1
257 #define LIVENESS_R2 2
258 #define LIVENESS_R3 4
259 #define LIVENESS_R4 8
260 #define LIVENESS_R5 16
261 #define LIVENESS_R6 32
262 #define LIVENESS_R7 64
263 #define LIVENESS_R8 128
265 #define IS_LIVE_R1(mask) (((mask) & LIVENESS_R1) != 0)
266 #define IS_LIVE_R2(mask) (((mask) & LIVENESS_R2) != 0)
267 #define IS_LIVE_R3(mask) (((mask) & LIVENESS_R3) != 0)
268 #define IS_LIVE_R4(mask) (((mask) & LIVENESS_R4) != 0)
269 #define IS_LIVE_R5(mask) (((mask) & LIVENESS_R5) != 0)
270 #define IS_LIVE_R6(mask) (((mask) & LIVENESS_R6) != 0)
271 #define IS_LIVE_R7(mask) (((mask) & LIVENESS_R7) != 0)
272 #define IS_LIVE_R8(mask) (((mask) & LIVENESS_R8) != 0)
275 Some extra stuff will probably be needed for ``shift bits off the end
276 and stop when zero,'' which would be quicker. Later.
278 Multi-slurp protection (end-of-file):