1 /* ----------------------------------------------------------------------------
2 * $Id: InfoMacros.h,v 1.6 1999/05/13 17:31:06 simonm Exp $
4 * (c) The GHC Team, 1998-1999
6 * Macros for building and deconstructing info tables.
8 * -------------------------------------------------------------------------- */
13 #define STD_INFO(type_) \
18 #define SRT_INFO(type_,srt_,srt_off_,srt_len_) \
19 srt : (StgSRT *)((StgClosure **)srt_+srt_off_), \
23 #ifdef USE_MINIINTERPRETER
24 #define INIT_VECTOR {}
29 /* function/thunk info tables --------------------------------------------- */
32 INFO_TABLE_SRT(info, /* info-table label */ \
33 entry, /* entry code label */ \
34 ptrs, nptrs, /* closure layout info */\
35 srt_, srt_off_, srt_len_, /* SRT info */ \
36 type, /* closure type */ \
37 info_class, entry_class, /* C storage classes */ \
38 prof_descr, prof_type) /* profiling info */ \
40 info_class INFO_TBL_CONST StgInfoTable info = { \
41 layout : { payload : {ptrs,nptrs} }, \
42 SRT_INFO(type,srt_,srt_off_,srt_len_), \
48 /* direct-return address info tables --------------------------------------*/
51 INFO_TABLE_SRT_BITMAP(info, entry, bitmap_, srt_, srt_off_, srt_len_, \
52 type, info_class, entry_class, \
53 prof_descr, prof_type) \
55 info_class INFO_TBL_CONST StgInfoTable info = { \
56 layout : { bitmap : (StgWord32)bitmap_ }, \
57 SRT_INFO(type,srt_,srt_off_,srt_len_), \
62 /* info-table without an SRT -----------------------------------------------*/
65 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class, \
66 entry_class, prof_descr, prof_type) \
68 info_class INFO_TBL_CONST StgInfoTable info = { \
69 layout : { payload : {ptrs,nptrs} }, \
75 /* special selector-thunk info table ---------------------------------------*/
78 INFO_TABLE_SELECTOR(info, entry, offset, info_class, \
79 entry_class, prof_descr, prof_type) \
81 info_class INFO_TBL_CONST StgInfoTable info = { \
82 layout : { selector_offset : offset }, \
83 STD_INFO(THUNK_SELECTOR), \
88 /* constructor info table --------------------------------------------------*/
91 INFO_TABLE_CONSTR(info, entry, ptrs, nptrs, tag_,type_,info_class, \
92 entry_class, prof_descr, prof_type) \
94 info_class INFO_TBL_CONST StgInfoTable info = { \
95 layout : { payload : {ptrs,nptrs} }, \
102 #define constrTag(con) (get_itbl(con)->srt_len)
104 /* return-vectors ----------------------------------------------------------*/
106 /* vectored-return info tables have the vector slammed up against the
107 * start of the info table.
109 * A vectored-return address always has an SRT and a bitmap-style
110 * layout field, so we only need one macro for these.
113 #ifndef USE_MINIINTERPRETER
150 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_len_, \
153 info_class INFO_TBL_CONST vec_info_2 info = { \
156 layout : { bitmap : (StgWord32)bitmap_ }, \
157 SRT_INFO(type,srt_,srt_off_,srt_len_) \
161 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_len_, \
163 alt_1, alt_2, alt_3 \
165 info_class INFO_TBL_CONST vec_info_3 info = { \
166 { alt_3, alt_2, alt_1 }, \
168 layout : { bitmap : (StgWord32)bitmap_ }, \
169 SRT_INFO(type,srt_,srt_off_,srt_len_) \
173 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_len_, \
175 alt_1, alt_2, alt_3, alt_4 \
177 info_class INFO_TBL_CONST vec_info_4 info = { \
178 { alt_4, alt_3, alt_2, alt_1 }, \
180 layout : { bitmap : (StgWord32)bitmap_ }, \
181 SRT_INFO(type,srt_,srt_off_,srt_len_) \
185 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_len_, \
187 alt_1, alt_2, alt_3, alt_4, \
190 info_class INFO_TBL_CONST vec_info_5 info = { \
191 { alt_5, alt_4, alt_3, alt_2, \
194 layout : { bitmap : (StgWord32)bitmap_ }, \
195 SRT_INFO(type,srt_,srt_off_,srt_len_) \
199 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_len_, \
201 alt_1, alt_2, alt_3, alt_4, \
204 info_class INFO_TBL_CONST vec_info_6 info = { \
205 { alt_6, alt_5, alt_4, alt_3, \
208 layout : { bitmap : (StgWord32)bitmap_ }, \
209 SRT_INFO(type,srt_,srt_off_,srt_len_) \
213 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_len_, \
215 alt_1, alt_2, alt_3, alt_4, \
216 alt_5, alt_6, alt_7 \
218 info_class INFO_TBL_CONST vec_info_7 info = { \
219 { alt_7, alt_6, alt_5, alt_4, \
220 alt_3, alt_2, alt_1 }, \
222 layout : { bitmap : (StgWord32)bitmap_ }, \
223 SRT_INFO(type,srt_,srt_off_,srt_len_) \
227 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_len_, \
229 alt_1, alt_2, alt_3, alt_4, \
230 alt_5, alt_6, alt_7, alt_8 \
232 info_class INFO_TBL_CONST vec_info_8 info = { \
233 { alt_8, alt_7, alt_6, alt_5, \
234 alt_4, alt_3, alt_2, alt_1 }, \
236 layout : { bitmap : (StgWord32)bitmap_ }, \
237 SRT_INFO(type,srt_,srt_off_,srt_len_) \
244 /* We have to define these structure to work around a bug in gcc: if we
245 * try to initialise the vector directly (it's defined as a zero-length
246 * array tacked on the end of the info table structor), then gcc silently
247 * throws away our vector table sometimes.
285 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_len_, \
288 info_class INFO_TBL_CONST vec_info_2 info = { \
289 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
290 SRT_INFO(type,srt_,srt_off_,srt_len_), \
293 vec : { alt_1, alt_2 } \
296 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_len_, \
298 alt_1, alt_2, alt_3 \
300 info_class INFO_TBL_CONST vec_info_3 info = { \
301 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
302 SRT_INFO(type,srt_,srt_off_,srt_len_), \
305 vec : { alt_1, alt_2, alt_3 } \
308 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_len_, \
310 alt_1, alt_2, alt_3, alt_4 \
312 info_class INFO_TBL_CONST vec_info_4 info = { \
313 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
314 SRT_INFO(type,srt_,srt_off_,srt_len_), \
317 vec : { alt_1, alt_2, alt_3, alt_4 } \
320 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_len_, \
322 alt_1, alt_2, alt_3, alt_4, \
325 info_class INFO_TBL_CONST vec_info_5 info = { \
326 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
327 SRT_INFO(type,srt_,srt_off_,srt_len_), \
330 vec : { alt_1, alt_2, alt_3, alt_4, \
334 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_len_, \
336 alt_1, alt_2, alt_3, alt_4, \
339 info_class INFO_TBL_CONST vec_info_6 info = { \
340 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
341 SRT_INFO(type,srt_,srt_off_,srt_len_), \
344 vec : { alt_1, alt_2, alt_3, alt_4, \
348 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_len_, \
350 alt_1, alt_2, alt_3, alt_4, \
351 alt_5, alt_6, alt_7 \
353 info_class INFO_TBL_CONST vec_info_7 info = { \
354 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
355 SRT_INFO(type,srt_,srt_off_,srt_len_), \
358 vec : { alt_1, alt_2, alt_3, alt_4, \
359 alt_5, alt_6, alt_7 } \
362 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_len_, \
364 alt_1, alt_2, alt_3, alt_4, \
365 alt_5, alt_6, alt_7, alt_8 \
367 info_class INFO_TBL_CONST vec_info_8 info = { \
368 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
369 SRT_INFO(type,srt_,srt_off_,srt_len_), \
372 vec : { alt_1, alt_2, alt_3, alt_4, \
373 alt_5, alt_6, alt_7, alt_8 } \
376 #endif /* MINI_INTERPRETER */
378 /* For polymorphic activation records, we need both a direct return
379 * address and a return vector:
382 typedef vec_info_8 StgPolyInfoTable;
384 #ifdef USE_MINIINTERPRETER
386 #define VEC_POLY_INFO_TABLE(nm, bitmap_, \
387 srt_, srt_off_, srt_len_, \
388 type, info_class, entry_class \
390 info_class INFO_TBL_CONST vec_info_8 nm##_info = { \
391 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
392 SRT_INFO(type,srt_,srt_off_,srt_len_), \
393 INIT_ENTRY(nm##_entry), \
409 #define VEC_POLY_INFO_TABLE(nm, bitmap_, \
410 srt_, srt_off_, srt_len_, \
411 type, info_class, entry_class \
413 info_class INFO_TBL_CONST vec_info_8 nm##_info = { \
425 layout : { bitmap : (StgWord32)bitmap_ }, \
426 SRT_INFO(type,srt_,srt_off_,srt_len_), \
427 INIT_ENTRY(nm##_entry) \
434 static const StgSRT lbl = {
436 #define BITMAP(lbl,size) \
437 static const StgLargeBitmap lbl = { size, {
439 /* DLL_SRT_ENTRY is used on the Win32 side when filling initialising
440 an entry in an SRT table with a reference to a closure that's
441 living in a DLL. See elsewhere for reasons as to why we need
442 to distinguish these kinds of references.
443 (ToDo: fill in a more precise href.)
445 #ifdef HAVE_WIN32_DLL_SUPPORT
446 #define DLL_SRT_ENTRY(x) ((StgClosure*)(((char*)&DLL_IMPORT_DATA_VAR(x)) + 1))
448 #define DLL_SRT_ENTRY(x) no-can-do
451 #endif /* INFOMACROS_H */