1 /* --------------------------------------------------------------------------
2 * $Id: mkNativeHdr.c,v 1.12 2003/03/21 15:48:06 sof Exp $
4 * (c) The GHC Team, 1992-1998
6 * Generate a header for the native code generator
8 * ------------------------------------------------------------------------*/
14 #define OFFSET(table, x) ((StgUnion *) &(x) - (StgUnion *) (&table))
16 #define OFFSET_R1 OFFSET(RegTable, RegTable.rR1)
17 #define OFFSET_R2 OFFSET(RegTable, RegTable.rR2)
18 #define OFFSET_R3 OFFSET(RegTable, RegTable.rR3)
19 #define OFFSET_R4 OFFSET(RegTable, RegTable.rR4)
20 #define OFFSET_R5 OFFSET(RegTable, RegTable.rR5)
21 #define OFFSET_R6 OFFSET(RegTable, RegTable.rR6)
22 #define OFFSET_R7 OFFSET(RegTable, RegTable.rR7)
23 #define OFFSET_R8 OFFSET(RegTable, RegTable.rR8)
24 #define OFFSET_R9 OFFSET(RegTable, RegTable.rR9)
25 #define OFFSET_R10 OFFSET(RegTable, RegTable.rR10)
26 #define OFFSET_F1 OFFSET(RegTable, RegTable.rF1)
27 #define OFFSET_F2 OFFSET(RegTable, RegTable.rF2)
28 #define OFFSET_F3 OFFSET(RegTable, RegTable.rF3)
29 #define OFFSET_F4 OFFSET(RegTable, RegTable.rF4)
30 #define OFFSET_D1 OFFSET(RegTable, RegTable.rD1)
31 #define OFFSET_D2 OFFSET(RegTable, RegTable.rD2)
32 #define OFFSET_L1 OFFSET(RegTable, RegTable.rL1)
33 #define OFFSET_Sp OFFSET(RegTable, RegTable.rSp)
34 #define OFFSET_SpLim OFFSET(RegTable, RegTable.rSpLim)
35 #define OFFSET_Hp OFFSET(RegTable, RegTable.rHp)
36 #define OFFSET_HpLim OFFSET(RegTable, RegTable.rHpLim)
37 #define OFFSET_CurrentTSO OFFSET(RegTable, RegTable.rCurrentTSO)
38 #define OFFSET_CurrentNursery OFFSET(RegTable, RegTable.rCurrentNursery)
39 #define OFFSET_HpAlloc OFFSET(RegTable, RegTable.rHpAlloc)
41 #define FUN_OFFSET(sym) ((StgPtr)&cap.f.sym - (StgPtr)&cap.r)
43 #define OFFSET_stgGCEnter1 FUN_OFFSET(stgGCEnter1)
44 #define OFFSET_stgGCFun FUN_OFFSET(stgGCFun)
46 #define OFFW_Capability_r OFFSET(cap, cap.r)
48 #define TSO_SP OFFSET(tso, tso.sp)
49 #define TSO_STACK OFFSET(tso, tso.stack)
51 #define BDESCR_START OFFSET(bd, bd.start)
52 #define BDESCR_FREE OFFSET(bd, bd.free)
53 #define BDESCR_BLOCKS OFFSET(bd, bd.blocks)
65 printf("-- This file is created automatically. Do not edit by hand.\n\n");
67 printf("\n-- Base table offsets for the Native Code Generator\n");
69 printf("#define OFFSET_R1 %d\n", OFFSET_R1);
70 printf("#define OFFSET_R2 %d\n", OFFSET_R2);
71 printf("#define OFFSET_R3 %d\n", OFFSET_R3);
72 printf("#define OFFSET_R4 %d\n", OFFSET_R4);
73 printf("#define OFFSET_R5 %d\n", OFFSET_R5);
74 printf("#define OFFSET_R6 %d\n", OFFSET_R6);
75 printf("#define OFFSET_R7 %d\n", OFFSET_R7);
76 printf("#define OFFSET_R8 %d\n", OFFSET_R8);
77 printf("#define OFFSET_R9 %d\n", OFFSET_R9);
78 printf("#define OFFSET_R10 %d\n", OFFSET_R10);
79 printf("#define OFFSET_F1 %d\n", OFFSET_F1);
80 printf("#define OFFSET_F2 %d\n", OFFSET_F2);
81 printf("#define OFFSET_F3 %d\n", OFFSET_F3);
82 printf("#define OFFSET_F4 %d\n", OFFSET_F4);
83 printf("#define OFFSET_D1 %d\n", OFFSET_D1);
84 printf("#define OFFSET_D2 %d\n", OFFSET_D2);
85 #ifdef SUPPORT_LONG_LONGS
86 printf("#define OFFSET_L1 %d\n", OFFSET_L1);
88 printf("#define OFFSET_Sp %d\n", OFFSET_Sp);
89 printf("#define OFFSET_SpLim %d\n", OFFSET_SpLim);
90 printf("#define OFFSET_Hp %d\n", OFFSET_Hp);
91 printf("#define OFFSET_HpLim %d\n", OFFSET_HpLim);
92 printf("#define OFFSET_CurrentTSO %d\n", OFFSET_CurrentTSO);
93 printf("#define OFFSET_CurrentNursery %d\n", OFFSET_CurrentNursery);
94 printf("#define OFFSET_HpAlloc %d\n", OFFSET_HpAlloc);
96 printf("#define OFFSET_stgGCEnter1 (%d)\n", OFFSET_stgGCEnter1);
97 printf("#define OFFSET_stgGCFun (%d)\n", OFFSET_stgGCFun);
99 printf("\n-- Offset of the .r (StgRegTable) field in a Capability\n");
101 printf("#define OFFW_Capability_r (%d)\n", OFFW_Capability_r);
103 printf("\n-- Storage Manager offsets for the Native Code Generator\n");
105 printf("\n-- TSO offsets for the Native Code Generator\n");
107 printf("#define TSO_SP %d\n", TSO_SP);
108 printf("#define TSO_STACK %d\n", TSO_STACK);
110 printf("\n-- Block descriptor offsets for the Native Code Generator\n");
112 printf("#define BDESCR_START %d\n", BDESCR_START);
113 printf("#define BDESCR_FREE %d\n", BDESCR_FREE);
114 printf("#define BDESCR_BLOCKS %d\n", BDESCR_BLOCKS);