5aa4835eaf8b4f4bd8e227ec800fea67547eb9f7
[ghc-hetmet.git] / ghc / includes / InfoMacros.h
1 /* ----------------------------------------------------------------------------
2  * $Id: InfoMacros.h,v 1.22 2003/05/14 09:14:01 simonmar Exp $
3  * 
4  * (c) The GHC Team, 1998-2002
5  *
6  * Macros for building and deconstructing info tables.
7  *
8  * -------------------------------------------------------------------------- */
9
10 #ifndef INFOMACROS_H
11 #define INFOMACROS_H
12
13 #define STD_INFO(srt_bitmap_, type_)            \
14                 srt_bitmap : srt_bitmap_,               \
15                 type : type_
16
17 #define THUNK_INFO(srt_, srt_off_)                      \
18                 srt : (StgSRT *)((StgClosure **)srt_+srt_off_)
19
20 #define FUN_GEN_INFO(srt_, srt_off_, fun_type_, arity_, bitmap_, slow_apply_) \
21
22 #define RET_INFO(srt_, srt_off_)                                \
23                 srt : (StgSRT *)((StgClosure **)srt_+srt_off_)
24
25 #ifdef PROFILING
26 #define PROF_INFO(type_str, desc_str)           \
27                 prof: {                         \
28                    closure_type: type_str,      \
29                    closure_desc: desc_str,      \
30                 },
31 #else
32 #define PROF_INFO(type_str, desc_str)
33 #endif
34
35 /*
36   On the GranSim/GUM specific parts of the InfoTables (GRAN/PAR):
37
38   In both GranSim and GUM we use revertible black holes (RBH) when putting
39   an updatable closure into a packet for communication. The entry code for
40   an RBH performs standard blocking (as with any kind of BH). The info
41   table for the RBH resides just before the one for the std info
42   table. (NB: there is one RBH ITBL for every ITBL of an updatable
43   closure.) The @rbh_infoptr@ field in the ITBL points from the std ITBL to
44   the RBH ITBL and vice versa. This is used by the RBH_INFOPTR and
45   REVERT_INFOPTR macros to turn an updatable node into an RBH and vice
46   versa. Note, that the only case where we have to revert the RBH in its
47   original form is when a packet is sent back because of garbage collection
48   on another PE. In the RTS for GdH we will use this reversion mechanism in 
49   order to deal with faults in the system. 
50   ToDo: Check that RBHs are needed for all the info tables below. From a quick
51   check of the macros generated in the libs it seems that all of them are used
52   for generating THUNKs.
53   Possible optimisation: Note that any RBH ITBL is a fixed distance away from 
54   the actual ITBL. We could inline this offset as a constant into the RTS and
55   avoid the rbh_infoptr fields altogether (Jim did that in the old RTS).
56   -- HWL
57 */
58
59
60 /* function/thunk info tables --------------------------------------------- */
61
62 #if defined(GRAN) || defined(PAR)
63
64 #define \
65 INFO_TABLE_THUNK(info,                          /* info-table label */  \
66                entry,                           /* entry code label */  \
67                ptrs, nptrs,                     /* closure layout info */\
68                srt_, srt_off_, srt_bitmap_,     /* SRT info */          \
69                type,                            /* closure type */      \
70                info_class, entry_class,         /* C storage classes */ \
71                prof_descr, prof_type)           /* profiling info */    \
72         entry_class(stg_RBH_##entry);                                           \
73         entry_class(entry);                                             \
74         ED_RO_ StgInfoTable info;                                       \
75         info_class const StgInfoTable stg_RBH_##info = {                \
76                 layout : { payload : {ptrs,nptrs} },                    \
77                 PROF_INFO(prof_type, prof_descr)                        \
78                 SRT_INFO(RBH,srt_,srt_off_,srt_bitmap_),                        \
79                 INCLUDE_RBH_INFO(info),                                 \
80                 INIT_ENTRY(stg_RBH_##entry)                             \
81         } ;                                                             \
82         StgFunPtr stg_RBH_##entry (void) {                                  \
83           FB_                                                           \
84             JMP_(stg_RBH_entry);                                            \
85           FE_                                                           \
86         } ;                                                             \
87         info_class const StgInfoTable info = {                  \
88                 layout : { payload : {ptrs,nptrs} },                    \
89                 PROF_INFO(prof_type, prof_descr)                        \
90                 SRT_INFO(type,srt_,srt_off_,srt_bitmap_),                       \
91                 INCLUDE_RBH_INFO(stg_RBH_##info),                       \
92                 INIT_ENTRY(entry)                                       \
93         }
94
95 #else
96
97 #define \
98 INFO_TABLE_THUNK(info,                          /* info-table label */  \
99                entry,                           /* entry code label */  \
100                ptrs, nptrs,                     /* closure layout info */\
101                srt_, srt_off_, srt_bitmap_,     /* SRT info */          \
102                type_,                           /* closure type */      \
103                info_class, entry_class,         /* C storage classes */ \
104                prof_descr, prof_type)           /* profiling info */    \
105         entry_class(entry);                                             \
106         info_class const StgThunkInfoTable info = {             \
107                 i : {                                                   \
108                   layout : { payload : {ptrs,nptrs} },                  \
109                   PROF_INFO(prof_type, prof_descr)                      \
110                   STD_INFO(srt_bitmap_, type_),                         \
111                   INIT_ENTRY(entry)                                     \
112                 },                                                      \
113                 THUNK_INFO(srt_,srt_off_),                              \
114         }
115
116 #endif
117
118 /* direct-return address info tables  --------------------------------------*/
119
120 #if defined(GRAN) || defined(PAR)
121
122 #define                                                                 \
123 INFO_TABLE_RET(info, entry, bitmap_, srt_, srt_off_, srt_bitmap_,               \
124                       type, info_class, entry_class,                    \
125                       prof_descr, prof_type)                            \
126         entry_class(stg_RBH_##entry);                                   \
127         entry_class(entry);                                             \
128         ED_RO_ StgInfoTable info;                                       \
129         info_class const StgInfoTable stg_RBH_##info = {        \
130                 layout : { bitmap : (StgWord)bitmap_ },                 \
131                 PROF_INFO(prof_type, prof_descr)                        \
132                 SRT_INFO(RBH,srt_,srt_off_,srt_bitmap_),                        \
133                 INCLUDE_RBH_INFO(info),                                 \
134                 INIT_ENTRY(stg_RBH_##entry)                             \
135         };                                                              \
136         StgFunPtr stg_RBH_##entry (void) {                              \
137           FB_                                                           \
138             JMP_(stg_RBH_entry);                                        \
139           FE_                                                           \
140         } ;                                                             \
141         info_class const StgInfoTable info = {                  \
142                 layout : { bitmap : (StgWord)bitmap_ },                 \
143                 PROF_INFO(prof_type, prof_descr)                        \
144                 SRT_INFO(type,srt_,srt_off_,srt_bitmap_),                       \
145                 INCLUDE_RBH_INFO(stg_RBH_##info),                       \
146                 INIT_ENTRY(entry)                                       \
147         }
148
149 #else
150
151 #define                                                                 \
152 INFO_TABLE_RET(info, entry, bitmap_, srt_, srt_off_, srt_bitmap_,               \
153                       type_, info_class, entry_class,                   \
154                       prof_descr, prof_type)                            \
155         entry_class(entry);                                             \
156         info_class const StgRetInfoTable info = {               \
157                 i : {                                                   \
158                     layout : { bitmap : (StgWord)bitmap_ },             \
159                     PROF_INFO(prof_type, prof_descr)                    \
160                     STD_INFO(srt_bitmap_,type_),                                \
161                     INIT_ENTRY(entry)                                   \
162                 },                                                      \
163                 RET_INFO(srt_,srt_off_)                                 \
164         }
165 #endif
166
167 /* info-table without an SRT -----------------------------------------------*/
168
169 #if defined(GRAN) || defined(PAR)
170
171 #define                                                         \
172 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class,          \
173            entry_class, prof_descr, prof_type)                  \
174         entry_class(stg_RBH_##entry);                           \
175         entry_class(entry);                                     \
176         ED_ StgInfoTable info;                          \
177         info_class const StgInfoTable stg_RBH_##info = {        \
178                 layout : { payload : {ptrs,nptrs} },            \
179                 PROF_INFO(prof_type, prof_descr)                \
180                 STD_INFO(RBH),                                  \
181                 INCLUDE_RBH_INFO(info),                         \
182                 INIT_ENTRY(stg_RBH_##entry)                     \
183         } ;                                                     \
184         StgFunPtr stg_RBH_##entry (void) {                      \
185           FB_                                                   \
186             JMP_(stg_RBH_entry);                                \
187           FE_                                                   \
188         } ;                                                     \
189         info_class const StgInfoTable info = {  \
190                 layout : { payload : {ptrs,nptrs} },            \
191                 PROF_INFO(prof_type, prof_descr)                \
192                 STD_INFO(type),                                 \
193                 INCLUDE_RBH_INFO(stg_RBH_##info),               \
194                 INIT_ENTRY(entry)                               \
195         }
196
197 #else
198
199 #define                                                 \
200 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class,  \
201            entry_class, prof_descr, prof_type)          \
202         entry_class(entry);                             \
203         info_class const StgInfoTable info = {  \
204                 layout : { payload : {ptrs,nptrs} },    \
205                 PROF_INFO(prof_type, prof_descr)        \
206                 STD_INFO(0, type),                      \
207                 INIT_ENTRY(entry)                       \
208         }
209
210 #endif
211
212 /* special selector-thunk info table ---------------------------------------*/
213
214 #if defined(GRAN) || defined(PAR)
215
216 #define                                                         \
217 INFO_TABLE_SELECTOR(info, entry, offset, info_class,            \
218                     entry_class, prof_descr, prof_type)         \
219         entry_class(stg_RBH_##entry);                           \
220         entry_class(entry);                                     \
221         ED_RO_ StgInfoTable info;                               \
222         info_class const StgInfoTable stg_RBH_##info = {        \
223                 layout : { selector_offset : offset },          \
224                 PROF_INFO(prof_type, prof_descr)                \
225                 STD_INFO(RBH),                                  \
226                 INCLUDE_RBH_INFO(info),                         \
227                 INIT_ENTRY(stg_RBH_##entry)                     \
228         };                                                      \
229         StgFunPtr stg_RBH_##entry (void) {                          \
230           FB_                                                   \
231             JMP_(stg_RBH_entry);                                    \
232           FE_                                                   \
233         } ;                                                     \
234         info_class const StgInfoTable info = {          \
235                 layout : { selector_offset : offset },          \
236                 PROF_INFO(prof_type, prof_descr)                \
237                 STD_INFO(THUNK_SELECTOR),                       \
238                 INCLUDE_RBH_INFO(stg_RBH_##info),                       \
239                 INIT_ENTRY(entry)                               \
240         }
241
242 #else
243
244 #define                                                 \
245 INFO_TABLE_SELECTOR(info, entry, offset, info_class,    \
246                     entry_class, prof_descr, prof_type) \
247         entry_class(entry);                             \
248         info_class const StgInfoTable info = {  \
249                 layout : { selector_offset : offset },  \
250                 PROF_INFO(prof_type, prof_descr)        \
251                 STD_INFO(0,THUNK_SELECTOR),             \
252                 INIT_ENTRY(entry)                       \
253         }
254
255 #endif
256
257 /* constructor info table --------------------------------------------------*/
258
259 #define                                                                 \
260 INFO_TABLE_CONSTR(info, entry, ptrs, nptrs, tag_,type_,info_class,      \
261                   entry_class, prof_descr, prof_type)                   \
262         entry_class(entry);                                             \
263         info_class const StgInfoTable info = {                  \
264                 layout : { payload : {ptrs,nptrs} },                    \
265                 PROF_INFO(prof_type, prof_descr)                        \
266                 STD_INFO(tag_, type_),                                  \
267                 INIT_ENTRY(entry)                                       \
268         }
269
270 #define constrTag(con) (get_itbl(con)->srt_bitmap)
271
272 /* function info table -----------------------------------------------------*/
273
274 #define                                                                 \
275 INFO_TABLE_FUN_GEN(info,                        /* info-table label */  \
276                entry,                           /* entry code label */  \
277                ptrs, nptrs,                     /* closure layout info */\
278                srt_, srt_off_, srt_bitmap_,     /* SRT info */          \
279                fun_type_, arity_, bitmap_, slow_apply_,                 \
280                                                 /* Function info */     \
281                type_,                           /* closure type */      \
282                info_class, entry_class,         /* C storage classes */ \
283                prof_descr, prof_type)           /* profiling info */    \
284         entry_class(entry);                                             \
285         info_class const StgFunInfoTable info = {               \
286                 i : {                                                   \
287                    layout : { payload : {ptrs,nptrs} },                 \
288                    PROF_INFO(prof_type, prof_descr)                     \
289                    STD_INFO(srt_bitmap_,type_),                         \
290                    INIT_ENTRY(entry)                                    \
291                 },                                                      \
292                 srt : (StgSRT *)((StgClosure **)srt_+srt_off_),         \
293                 arity : arity_,                                         \
294                 fun_type : fun_type_,                                   \
295                 bitmap : (W_)bitmap_,                                   \
296                 slow_apply : slow_apply_                                \
297         }
298
299 /* return-vectors ----------------------------------------------------------*/
300
301 /* vectored-return info tables have the vector slammed up against the
302  * start of the info table.
303  *
304  * A vectored-return address always has an SRT and a bitmap-style
305  * layout field, so we only need one macro for these.
306  */
307
308 #ifdef TABLES_NEXT_TO_CODE
309
310 typedef struct {
311   StgFunPtr vec[2];
312   StgRetInfoTable i;
313 } vec_info_2;
314
315 typedef struct {
316   StgFunPtr vec[3];
317   StgRetInfoTable i;
318 } vec_info_3;
319
320 typedef struct {
321   StgFunPtr vec[4];
322   StgRetInfoTable i;
323 } vec_info_4;
324
325 typedef struct {
326   StgFunPtr vec[5];
327   StgRetInfoTable i;
328 } vec_info_5;
329
330 typedef struct {
331   StgFunPtr vec[6];
332   StgRetInfoTable i;
333 } vec_info_6;
334
335 typedef struct {
336   StgFunPtr vec[7];
337   StgRetInfoTable i;
338 } vec_info_7;
339
340 typedef struct {
341   StgFunPtr vec[8];
342   StgRetInfoTable i;
343 } vec_info_8;
344
345 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
346                    type_, info_class,                           \
347                    alt_1, alt_2)                                \
348         info_class const vec_info_2 info = {            \
349                 { alt_2, alt_1 },                               \
350                 i : {                                           \
351                    i : {                                        \
352                       layout : { bitmap : (StgWord)bitmap_ },   \
353                       STD_INFO(srt_bitmap_,type_)                       \
354                    },                                           \
355                    RET_INFO(srt_,srt_off_)                      \
356                 }                                               \
357         }
358
359 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
360                    type_, info_class,                           \
361                    alt_1, alt_2, alt_3                          \
362                   )                                             \
363         info_class const vec_info_3 info = {            \
364                 { alt_3, alt_2, alt_1 },                        \
365                 i : {                                           \
366                    i : {                                        \
367                       layout : { bitmap : (StgWord)bitmap_ },   \
368                       STD_INFO(srt_bitmap_,type_)                       \
369                    },                                           \
370                    RET_INFO(srt_,srt_off_)                      \
371                 }                                               \
372         }
373
374 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
375                    type_, info_class,                           \
376                    alt_1, alt_2, alt_3, alt_4                   \
377                   )                                             \
378         info_class const vec_info_4 info = {            \
379                 { alt_4, alt_3, alt_2, alt_1 },                 \
380                 i : {                                           \
381                    i : {                                        \
382                       layout : { bitmap : (StgWord)bitmap_ },   \
383                       STD_INFO(srt_bitmap_,type_)                       \
384                    },                                           \
385                    RET_INFO(srt_,srt_off_)                      \
386                 }                                               \
387         }
388
389 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
390                    type_, info_class,                           \
391                    alt_1, alt_2, alt_3, alt_4,                  \
392                    alt_5                                        \
393                   )                                             \
394         info_class const vec_info_5 info = {            \
395                 { alt_5, alt_4, alt_3, alt_2,                   \
396                   alt_1 },                                      \
397                 i : {                                           \
398                    i : {                                        \
399                       layout : { bitmap : (StgWord)bitmap_ },   \
400                       STD_INFO(srt_bitmap_,type_)                       \
401                    },                                           \
402                    RET_INFO(srt_,srt_off_)                      \
403                 }                                               \
404         }
405
406 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
407                    type_, info_class,                           \
408                    alt_1, alt_2, alt_3, alt_4,                  \
409                    alt_5, alt_6                                 \
410                   )                                             \
411         info_class const vec_info_6 info = {            \
412                 { alt_6, alt_5, alt_4, alt_3,                   \
413                   alt_2, alt_1 },                               \
414                 i : {                                           \
415                    i : {                                        \
416                       layout : { bitmap : (StgWord)bitmap_ },   \
417                       STD_INFO(srt_bitmap_,type_)                       \
418                    },                                           \
419                    RET_INFO(srt_,srt_off_)                      \
420                 }                                               \
421         }
422
423 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
424                    type_, info_class,                           \
425                    alt_1, alt_2, alt_3, alt_4,                  \
426                    alt_5, alt_6, alt_7                          \
427                   )                                             \
428         info_class const vec_info_7 info = {            \
429                 { alt_7, alt_6, alt_5, alt_4,                   \
430                   alt_3, alt_2, alt_1 },                        \
431                 i : {                                           \
432                    i : {                                        \
433                       layout : { bitmap : (StgWord)bitmap_ },   \
434                       STD_INFO(srt_bitmap_,type_)                       \
435                    },                                           \
436                    RET_INFO(srt_,srt_off_)                      \
437                 }                                               \
438         }
439
440 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
441                    type_, info_class,                           \
442                    alt_1, alt_2, alt_3, alt_4,                  \
443                    alt_5, alt_6, alt_7, alt_8                   \
444                   )                                             \
445         info_class const vec_info_8 info = {            \
446                 { alt_8, alt_7, alt_6, alt_5,                   \
447                   alt_4, alt_3, alt_2, alt_1 },                 \
448                 i : {                                           \
449                    i : {                                        \
450                       layout : { bitmap : (StgWord)bitmap_ },   \
451                       STD_INFO(srt_bitmap_,type_)                       \
452                    },                                           \
453                    RET_INFO(srt_,srt_off_)                      \
454                 }                                               \
455         }
456
457
458 #else
459
460 /* We have to define these structure to work around a bug in gcc: if we
461  * try to initialise the vector directly (it's defined as a zero-length
462  * array tacked on the end of the info table structor), then gcc silently
463  * throws away our vector table sometimes.
464  */
465
466 typedef struct {
467   StgRetInfoTable i;
468   StgFunPtr vec[2];
469 } vec_info_2;
470
471 typedef struct {
472   StgRetInfoTable i;
473   StgFunPtr vec[3];
474 } vec_info_3;
475
476 typedef struct {
477   StgRetInfoTable i;
478   StgFunPtr vec[4];
479 } vec_info_4;
480
481 typedef struct {
482   StgRetInfoTable i;
483   StgFunPtr vec[5];
484 } vec_info_5;
485
486 typedef struct {
487   StgRetInfoTable i;
488   StgFunPtr vec[6];
489 } vec_info_6;
490
491 typedef struct {
492   StgRetInfoTable i;
493   StgFunPtr vec[7];
494 } vec_info_7;
495
496 typedef struct {
497   StgRetInfoTable i;
498   StgFunPtr vec[8];
499 } vec_info_8;
500
501 #define VEC_INFO_2(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
502                    type_, info_class,                           \
503                    alt_1, alt_2)                                \
504         info_class const vec_info_2 info = {            \
505                 i : {                                           \
506                    i : {                                        \
507                       layout : { bitmap : (StgWord)bitmap_ },   \
508                       STD_INFO(srt_bitmap_,type_)                       \
509                    },                                           \
510                    RET_INFO(srt_,srt_off_)                      \
511                 }                                               \
512         }
513
514 #define VEC_INFO_3(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
515                    type_, info_class,                           \
516                    alt_1, alt_2, alt_3                          \
517                   )                                             \
518         info_class const vec_info_3 info = {            \
519                 i : {                                           \
520                    i : {                                        \
521                       layout : { bitmap : (StgWord)bitmap_ },   \
522                       STD_INFO(srt_bitmap_,type_)                       \
523                    },                                           \
524                    RET_INFO(srt_,srt_off_)                      \
525                 },                                              \
526                 vec : { alt_1, alt_2, alt_3 }                   \
527         }
528
529 #define VEC_INFO_4(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
530                    type_, info_class,                           \
531                    alt_1, alt_2, alt_3, alt_4                   \
532                   )                                             \
533         info_class const vec_info_4 info = {            \
534                 i : {                                           \
535                    i : {                                        \
536                       layout : { bitmap : (StgWord)bitmap_ },   \
537                       STD_INFO(srt_bitmap_,type_)                       \
538                    },                                           \
539                    RET_INFO(srt_,srt_off_)                      \
540                 },                                              \
541                 vec : { alt_1, alt_2, alt_3, alt_4 }            \
542         }
543
544 #define VEC_INFO_5(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
545                    type_, info_class,                           \
546                    alt_1, alt_2, alt_3, alt_4,                  \
547                    alt_5                                        \
548                   )                                             \
549         info_class const vec_info_5 info = {            \
550                 i : {                                           \
551                    i : {                                        \
552                       layout : { bitmap : (StgWord)bitmap_ },   \
553                       STD_INFO(srt_bitmap_,type_)                       \
554                    },                                           \
555                    RET_INFO(srt_,srt_off_)                      \
556                 },                                              \
557                 vec : { alt_1, alt_2, alt_3, alt_4,             \
558                         alt_5 }                                 \
559         }
560
561 #define VEC_INFO_6(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
562                    type_, info_class,                           \
563                    alt_1, alt_2, alt_3, alt_4,                  \
564                    alt_5, alt_6                                 \
565                   )                                             \
566         info_class const vec_info_6 info = {            \
567                 i : {                                           \
568                    i : {                                        \
569                       layout : { bitmap : (StgWord)bitmap_ },   \
570                       STD_INFO(srt_bitmap_,type_)                       \
571                    },                                           \
572                    RET_INFO(srt_,srt_off_)                      \
573                 },                                              \
574                 vec : { alt_1, alt_2, alt_3, alt_4,             \
575                         alt_5, alt_6 }                          \
576         }
577
578 #define VEC_INFO_7(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
579                    type_, info_class,                           \
580                    alt_1, alt_2, alt_3, alt_4,                  \
581                    alt_5, alt_6, alt_7                          \
582                   )                                             \
583         info_class const vec_info_7 info = {            \
584                 i : {                                           \
585                    i : {                                        \
586                       layout : { bitmap : (StgWord)bitmap_ },   \
587                       STD_INFO(srt_bitmap_,type_)                       \
588                    },                                           \
589                    RET_INFO(srt_,srt_off_)                      \
590                 },                                              \
591                 vec : { alt_1, alt_2, alt_3, alt_4,             \
592                         alt_5, alt_6, alt_7 }                   \
593         }
594
595 #define VEC_INFO_8(info,bitmap_,srt_,srt_off_,srt_bitmap_,              \
596                    type_, info_class,                           \
597                    alt_1, alt_2, alt_3, alt_4,                  \
598                    alt_5, alt_6, alt_7, alt_8                   \
599                   )                                             \
600         info_class const vec_info_8 info = {            \
601                 i : {                                           \
602                    i : {                                        \
603                       layout : { bitmap : (StgWord)bitmap_ },   \
604                       STD_INFO(srt_bitmap_,type_)                       \
605                    },                                           \
606                    RET_INFO(srt_,srt_off_)                      \
607                 },                                              \
608                 vec : { alt_1, alt_2, alt_3, alt_4,             \
609                         alt_5, alt_6, alt_7, alt_8 }            \
610         }
611
612 #endif /* TABLES_NEXT_TO_CODE */
613
614 /* For polymorphic activation records, we need both a direct return
615  * address and a return vector:
616  */
617
618 typedef vec_info_8 StgPolyInfoTable;
619
620 #ifndef TABLES_NEXT_TO_CODE
621
622 #define VEC_POLY_INFO_TABLE(nm, bitmap_,                        \
623                            srt_, srt_off_, srt_bitmap_,         \
624                            type_, info_class, entry_class       \
625                            )                                    \
626   info_class const vec_info_8 nm##_info = {                     \
627                 i : {                                           \
628                     i : {                                       \
629                         layout : {                              \
630                         bitmap : (StgWord)bitmap_ },            \
631                         STD_INFO(srt_bitmap_, type_),           \
632                         INIT_ENTRY(nm##_ret)                    \
633                     },                                          \
634                     RET_INFO(srt_,srt_off_)                     \
635                 },                                              \
636                 vec : {                                         \
637                         (F_) nm##_0_ret,                        \
638                         (F_) nm##_1_ret,                        \
639                         (F_) nm##_2_ret,                        \
640                         (F_) nm##_3_ret,                        \
641                         (F_) nm##_4_ret,                        \
642                         (F_) nm##_5_ret,                        \
643                         (F_) nm##_6_ret,                        \
644                         (F_) nm##_7_ret                         \
645                 }                                               \
646             }
647 #else
648
649 #define VEC_POLY_INFO_TABLE(nm, bitmap_,                        \
650                            srt_, srt_off_, srt_bitmap_,         \
651                            type_, info_class, entry_class       \
652                            )                                    \
653         info_class const vec_info_8 nm##_info = {       \
654                 {                                               \
655                         (F_) nm##_7_ret,                        \
656                         (F_) nm##_6_ret,                        \
657                         (F_) nm##_5_ret,                        \
658                         (F_) nm##_4_ret,                        \
659                         (F_) nm##_3_ret,                        \
660                         (F_) nm##_2_ret,                        \
661                         (F_) nm##_1_ret,                        \
662                         (F_) nm##_0_ret                 \
663                 },                                              \
664                 i : {                                           \
665                     i : {                                       \
666                         layout : {                              \
667                         bitmap : (StgWord)bitmap_ },            \
668                         STD_INFO(srt_bitmap_, type_),           \
669                         INIT_ENTRY(nm##_ret)                    \
670                     },                                          \
671                     RET_INFO(srt_,srt_off_)                     \
672                 }                                               \
673         }
674
675 #endif
676
677 #define SRT(lbl) \
678   static const StgSRT lbl = {
679
680 /* DLL_SRT_ENTRY is used on the Win32 side when filling initialising
681    an entry in an SRT table with a reference to a closure that's
682    living in a DLL. See elsewhere for reasons as to why we need
683    to distinguish these kinds of references.
684    (ToDo: fill in a more precise href.)
685 */
686 #ifdef ENABLE_WIN32_DLL_SUPPORT /* mingw DietHEP doesn't seem to care either way */
687 #define DLL_SRT_ENTRY(x) ((StgClosure*)(((char*)&DLL_IMPORT_DATA_VAR(x)) + 1))
688 #else
689 #define DLL_SRT_ENTRY(x) no-can-do
690 #endif
691
692 #endif /* INFOMACROS_H */