1 /* ----------------------------------------------------------------------------
2 * $Id: InfoMacros.h,v 1.8 1999/11/30 11:44:32 simonmar 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 #define CONSTR_INFO(type_,tag_) \
28 #ifdef USE_MINIINTERPRETER
29 #define INIT_VECTOR {}
34 /* function/thunk info tables --------------------------------------------- */
37 INFO_TABLE_SRT(info, /* info-table label */ \
38 entry, /* entry code label */ \
39 ptrs, nptrs, /* closure layout info */\
40 srt_, srt_off_, srt_len_, /* SRT info */ \
41 type, /* closure type */ \
42 info_class, entry_class, /* C storage classes */ \
43 prof_descr, prof_type) /* profiling info */ \
45 info_class INFO_TBL_CONST StgInfoTable info = { \
46 layout : { payload : {ptrs,nptrs} }, \
47 SRT_INFO(type,srt_,srt_off_,srt_len_), \
53 /* direct-return address info tables --------------------------------------*/
56 INFO_TABLE_SRT_BITMAP(info, entry, bitmap_, srt_, srt_off_, srt_len_, \
57 type, info_class, entry_class, \
58 prof_descr, prof_type) \
60 info_class INFO_TBL_CONST StgInfoTable info = { \
61 layout : { bitmap : (StgWord32)bitmap_ }, \
62 SRT_INFO(type,srt_,srt_off_,srt_len_), \
67 /* info-table without an SRT -----------------------------------------------*/
70 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class, \
71 entry_class, prof_descr, prof_type) \
73 info_class INFO_TBL_CONST StgInfoTable info = { \
74 layout : { payload : {ptrs,nptrs} }, \
80 /* special selector-thunk info table ---------------------------------------*/
83 INFO_TABLE_SELECTOR(info, entry, offset, info_class, \
84 entry_class, prof_descr, prof_type) \
86 info_class INFO_TBL_CONST StgInfoTable info = { \
87 layout : { selector_offset : offset }, \
88 STD_INFO(THUNK_SELECTOR), \
93 /* constructor info table --------------------------------------------------*/
96 INFO_TABLE_CONSTR(info, entry, ptrs, nptrs, tag_,type_,info_class, \
97 entry_class, prof_descr, prof_type) \
99 info_class INFO_TBL_CONST StgInfoTable info = { \
100 layout : { payload : {ptrs,nptrs} }, \
101 CONSTR_INFO(type_,tag_), \
106 #define constrTag(con) (get_itbl(con)->srt_len)
108 /* return-vectors ----------------------------------------------------------*/
110 /* vectored-return info tables have the vector slammed up against the
111 * start of the info table.
113 * A vectored-return address always has an SRT and a bitmap-style
114 * layout field, so we only need one macro for these.
117 #ifdef TABLES_NEXT_TO_CODE
154 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_len_, \
157 info_class INFO_TBL_CONST vec_info_2 info = { \
160 layout : { bitmap : (StgWord32)bitmap_ }, \
161 SRT_INFO(type,srt_,srt_off_,srt_len_) \
165 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_len_, \
167 alt_1, alt_2, alt_3 \
169 info_class INFO_TBL_CONST vec_info_3 info = { \
170 { alt_3, alt_2, alt_1 }, \
172 layout : { bitmap : (StgWord32)bitmap_ }, \
173 SRT_INFO(type,srt_,srt_off_,srt_len_) \
177 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_len_, \
179 alt_1, alt_2, alt_3, alt_4 \
181 info_class INFO_TBL_CONST vec_info_4 info = { \
182 { alt_4, alt_3, alt_2, alt_1 }, \
184 layout : { bitmap : (StgWord32)bitmap_ }, \
185 SRT_INFO(type,srt_,srt_off_,srt_len_) \
189 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_len_, \
191 alt_1, alt_2, alt_3, alt_4, \
194 info_class INFO_TBL_CONST vec_info_5 info = { \
195 { alt_5, alt_4, alt_3, alt_2, \
198 layout : { bitmap : (StgWord32)bitmap_ }, \
199 SRT_INFO(type,srt_,srt_off_,srt_len_) \
203 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_len_, \
205 alt_1, alt_2, alt_3, alt_4, \
208 info_class INFO_TBL_CONST vec_info_6 info = { \
209 { alt_6, alt_5, alt_4, alt_3, \
212 layout : { bitmap : (StgWord32)bitmap_ }, \
213 SRT_INFO(type,srt_,srt_off_,srt_len_) \
217 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_len_, \
219 alt_1, alt_2, alt_3, alt_4, \
220 alt_5, alt_6, alt_7 \
222 info_class INFO_TBL_CONST vec_info_7 info = { \
223 { alt_7, alt_6, alt_5, alt_4, \
224 alt_3, alt_2, alt_1 }, \
226 layout : { bitmap : (StgWord32)bitmap_ }, \
227 SRT_INFO(type,srt_,srt_off_,srt_len_) \
231 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_len_, \
233 alt_1, alt_2, alt_3, alt_4, \
234 alt_5, alt_6, alt_7, alt_8 \
236 info_class INFO_TBL_CONST vec_info_8 info = { \
237 { alt_8, alt_7, alt_6, alt_5, \
238 alt_4, alt_3, alt_2, alt_1 }, \
240 layout : { bitmap : (StgWord32)bitmap_ }, \
241 SRT_INFO(type,srt_,srt_off_,srt_len_) \
248 /* We have to define these structure to work around a bug in gcc: if we
249 * try to initialise the vector directly (it's defined as a zero-length
250 * array tacked on the end of the info table structor), then gcc silently
251 * throws away our vector table sometimes.
289 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_len_, \
292 info_class INFO_TBL_CONST vec_info_2 info = { \
293 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
294 SRT_INFO(type,srt_,srt_off_,srt_len_), \
297 vec : { alt_1, alt_2 } \
300 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_len_, \
302 alt_1, alt_2, alt_3 \
304 info_class INFO_TBL_CONST vec_info_3 info = { \
305 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
306 SRT_INFO(type,srt_,srt_off_,srt_len_), \
309 vec : { alt_1, alt_2, alt_3 } \
312 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_len_, \
314 alt_1, alt_2, alt_3, alt_4 \
316 info_class INFO_TBL_CONST vec_info_4 info = { \
317 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
318 SRT_INFO(type,srt_,srt_off_,srt_len_), \
321 vec : { alt_1, alt_2, alt_3, alt_4 } \
324 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_len_, \
326 alt_1, alt_2, alt_3, alt_4, \
329 info_class INFO_TBL_CONST vec_info_5 info = { \
330 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
331 SRT_INFO(type,srt_,srt_off_,srt_len_), \
334 vec : { alt_1, alt_2, alt_3, alt_4, \
338 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_len_, \
340 alt_1, alt_2, alt_3, alt_4, \
343 info_class INFO_TBL_CONST vec_info_6 info = { \
344 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
345 SRT_INFO(type,srt_,srt_off_,srt_len_), \
348 vec : { alt_1, alt_2, alt_3, alt_4, \
352 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_len_, \
354 alt_1, alt_2, alt_3, alt_4, \
355 alt_5, alt_6, alt_7 \
357 info_class INFO_TBL_CONST vec_info_7 info = { \
358 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
359 SRT_INFO(type,srt_,srt_off_,srt_len_), \
362 vec : { alt_1, alt_2, alt_3, alt_4, \
363 alt_5, alt_6, alt_7 } \
366 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_len_, \
368 alt_1, alt_2, alt_3, alt_4, \
369 alt_5, alt_6, alt_7, alt_8 \
371 info_class INFO_TBL_CONST vec_info_8 info = { \
372 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
373 SRT_INFO(type,srt_,srt_off_,srt_len_), \
376 vec : { alt_1, alt_2, alt_3, alt_4, \
377 alt_5, alt_6, alt_7, alt_8 } \
380 #endif /* TABLES_NEXT_TO_CODE */
382 /* For polymorphic activation records, we need both a direct return
383 * address and a return vector:
386 typedef vec_info_8 StgPolyInfoTable;
388 #ifndef TABLES_NEXT_TO_CODE
390 #define VEC_POLY_INFO_TABLE(nm, bitmap_, \
391 srt_, srt_off_, srt_len_, \
392 type, info_class, entry_class \
394 info_class INFO_TBL_CONST vec_info_8 nm##_info = { \
395 i : { layout : { bitmap : (StgWord32)bitmap_ }, \
396 SRT_INFO(type,srt_,srt_off_,srt_len_), \
397 INIT_ENTRY(nm##_entry), \
413 #define VEC_POLY_INFO_TABLE(nm, bitmap_, \
414 srt_, srt_off_, srt_len_, \
415 type, info_class, entry_class \
417 info_class INFO_TBL_CONST vec_info_8 nm##_info = { \
429 layout : { bitmap : (StgWord32)bitmap_ }, \
430 SRT_INFO(type,srt_,srt_off_,srt_len_), \
431 INIT_ENTRY(nm##_entry) \
438 static const StgSRT lbl = {
440 #define BITMAP(lbl,size) \
441 static const StgLargeBitmap lbl = { size, {
443 /* DLL_SRT_ENTRY is used on the Win32 side when filling initialising
444 an entry in an SRT table with a reference to a closure that's
445 living in a DLL. See elsewhere for reasons as to why we need
446 to distinguish these kinds of references.
447 (ToDo: fill in a more precise href.)
449 #ifdef HAVE_WIN32_DLL_SUPPORT
450 #define DLL_SRT_ENTRY(x) ((StgClosure*)(((char*)&DLL_IMPORT_DATA_VAR(x)) + 1))
452 #define DLL_SRT_ENTRY(x) no-can-do
455 #endif /* INFOMACROS_H */