[project @ 2004-02-12 02:04:59 by mthomas]
[ghc-hetmet.git] / ghc / includes / Regs.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Regs.h,v 1.14 2003/11/14 14:28:08 stolz Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Registers used in STG code.  Might or might not correspond to
7  * actual machine registers.
8  *
9  * ---------------------------------------------------------------------------*/
10
11 #ifndef REGS_H
12 #define REGS_H
13
14 /*
15  * This file should do the right thing if we have no machine-registers
16  * defined, i.e. everything lives in the RegTable.
17  */
18
19 /* 
20  * This is the table that holds shadow-locations for all the STG
21  * registers.  The shadow locations are used when:
22  *
23  *     1) the particular register isn't mapped to a real machine
24  *        register, probably because there's a shortage of real registers.
25  *     2) caller-saves registers are saved across a CCall
26  */
27
28 typedef struct StgSparkPool_ {
29   StgClosure **base;
30   StgClosure **lim;
31   StgClosure **hd;
32   StgClosure **tl;
33 } StgSparkPool;
34
35 typedef struct {
36   StgFunPtr      stgGCEnter1;
37   StgFunPtr      stgGCFun;
38 } StgFunTable;
39
40 typedef struct StgRegTable_ {
41   StgUnion        rR1;
42   StgUnion        rR2;
43   StgUnion        rR3;
44   StgUnion        rR4;
45   StgUnion        rR5;
46   StgUnion        rR6;
47   StgUnion        rR7;
48   StgUnion        rR8;
49   StgUnion        rR9;          // used occasionally by heap/stack checks
50   StgUnion        rR10;         // used occasionally by heap/stack checks
51   StgFloat        rF1;
52   StgFloat        rF2;
53   StgFloat        rF3;
54   StgFloat        rF4;
55   StgDouble       rD1;
56   StgDouble       rD2;
57   StgWord64       rL1;
58   StgPtr          rSp;
59   StgPtr          rSpLim;
60   StgPtr          rHp;
61   StgPtr          rHpLim;
62   StgTSO         *rCurrentTSO;
63   struct _bdescr *rNursery;
64   struct _bdescr *rCurrentNursery;
65   StgWord         rHpAlloc;     // number of words being allocated in heap 
66 #if defined(SMP) || defined(PAR)
67   StgSparkPool   rSparks;       // per-task spark pool
68 #endif
69 } StgRegTable;
70
71
72 /* A capability is a combination of a FunTable and a RegTable.  In STG
73  * code, BaseReg normally points to the RegTable portion of this
74  * structure, so that we can index both forwards and backwards to take
75  * advantage of shorter instruction forms on some archs (eg. x86).
76  */
77 typedef struct Capability_ {
78     StgFunTable f;
79     StgRegTable r;
80 #if defined(SMP)
81   struct Capability_ *link;     /* per-task register tables are linked together */
82 #endif
83 } Capability;
84
85 /* No such thing as a MainRegTable under SMP - each thread must
86  * have its own MainRegTable.
87  */
88 #ifndef SMP
89 extern DLL_IMPORT_RTS Capability  MainCapability;
90 #endif
91
92 #if IN_STG_CODE
93
94 /*
95  * Registers Hp and HpLim are global across the entire system, and are
96  * copied into the RegTable before executing a thread.
97  *
98  * Registers Sp and SpLim are saved in the TSO for the
99  * thread, but are copied into the RegTable before executing a thread.
100  *
101  * All other registers are "general purpose", and are used for passing
102  * arguments to functions, and returning values.  The code generator
103  * knows how many of these are in real registers, and avoids
104  * generating code that uses non-real registers.  General purpose
105  * registers are never saved when returning to the scheduler, instead
106  * we save whatever is live at the time on the stack, and restore it
107  * later.  This should reduce the context switch time, amongst other
108  * things.
109  *
110  * For argument passing, the stack will be used in preference to
111  * pseudo-registers if the architecture has too few general purpose
112  * registers.
113  *
114  * Some special RTS functions like newArray and the Integer primitives
115  * expect their arguments to be in registers R1-Rn, so we use these
116  * (pseudo-)registers in those cases.
117  */
118
119 /* 
120  * Locations for saving per-thread registers.
121  */
122
123 #define SAVE_Sp             (CurrentTSO->sp)
124 #define SAVE_SpLim          (CurrentTSO->splim)
125
126 #define SAVE_Hp             (BaseReg->rHp)
127 #define SAVE_HpLim          (BaseReg->rHpLim)
128
129 #define SAVE_CurrentTSO     (BaseReg->rCurrentTSO)
130 #define SAVE_CurrentNursery (BaseReg->rCurrentNursery)
131 #define SAVE_HpAlloc        (BaseReg->rHpAlloc)
132 #if defined(SMP) || defined(PAR)
133 #define SAVE_SparkHd        (BaseReg->rSparks.hd)
134 #define SAVE_SparkTl        (BaseReg->rSparks.tl)
135 #define SAVE_SparkBase      (BaseReg->rSparks.base)
136 #define SAVE_SparkLim       (BaseReg->rSparks.lim)
137 #endif
138
139 /* We sometimes need to save registers across a C-call, eg. if they
140  * are clobbered in the standard calling convention.  We define the
141  * save locations for all registers in the register table.
142  */
143
144 #define SAVE_R1             (BaseReg->rR1)
145 #define SAVE_R2             (BaseReg->rR2)
146 #define SAVE_R3             (BaseReg->rR3)
147 #define SAVE_R4             (BaseReg->rR4)
148 #define SAVE_R5             (BaseReg->rR5)
149 #define SAVE_R6             (BaseReg->rR6)
150 #define SAVE_R7             (BaseReg->rR7)
151 #define SAVE_R8             (BaseReg->rR8)
152  
153 #define SAVE_F1             (BaseReg->rF1)
154 #define SAVE_F2             (BaseReg->rF2)
155 #define SAVE_F3             (BaseReg->rF3)
156 #define SAVE_F4             (BaseReg->rF4)
157
158 #define SAVE_D1             (BaseReg->rD1)
159 #define SAVE_D2             (BaseReg->rD2)
160
161 #define SAVE_L1             (BaseReg->rL1)
162
163 /* -----------------------------------------------------------------------------
164  * Emit the GCC-specific register declarations for each machine
165  * register being used.  If any STG register isn't mapped to a machine
166  * register, then map it to an offset from BaseReg.
167  *
168  * First, the general purpose registers.  The idea is, if a particular
169  * general-purpose STG register can't be mapped to a real machine
170  * register, it won't be used at all.  Instead, we'll use the stack.
171  *
172  * This is an improvement on the way things used to be done, when all
173  * registers were mapped to locations in the register table, and stuff
174  * was being shifted from the stack to the register table and back
175  * again for no good reason (on register-poor architectures).
176  */
177
178 #define GLOBAL_REG_DECL(type,name,reg) register type name REG(reg);
179
180 #ifdef REG_R1
181 GLOBAL_REG_DECL(StgUnion,R1,REG_R1)
182 #else
183 #define R1 (BaseReg->rR1)
184 #endif
185
186 #ifdef REG_R2
187 GLOBAL_REG_DECL(StgUnion,R2,REG_R2)
188 #else
189 #define R2 (BaseReg->rR2)
190 #endif
191
192 #ifdef REG_R3
193 GLOBAL_REG_DECL(StgUnion,R3,REG_R3)
194 #else
195 # define R3 (BaseReg->rR3)
196 #endif
197
198 #ifdef REG_R4
199 GLOBAL_REG_DECL(StgUnion,R4,REG_R4)
200 #else
201 # define R4 (BaseReg->rR4)
202 #endif
203
204 #ifdef REG_R5
205 GLOBAL_REG_DECL(StgUnion,R5,REG_R5)
206 #else
207 # define R5 (BaseReg->rR5)
208 #endif
209
210 #ifdef REG_R6
211 GLOBAL_REG_DECL(StgUnion,R6,REG_R6)
212 #else
213 # define R6 (BaseReg->rR6)
214 #endif
215
216 #ifdef REG_R7
217 GLOBAL_REG_DECL(StgUnion,R7,REG_R7)
218 #else
219 # define R7 (BaseReg->rR7)
220 #endif
221
222 #ifdef REG_R8
223 GLOBAL_REG_DECL(StgUnion,R8,REG_R8)
224 #else
225 # define R8 (BaseReg->rR8)
226 #endif
227
228 #ifdef REG_R9
229 GLOBAL_REG_DECL(StgUnion,R9,REG_R9)
230 #else
231 # define R9 (BaseReg->rR9)
232 #endif
233
234 #ifdef REG_R10
235 GLOBAL_REG_DECL(StgUnion,R10,REG_R10)
236 #else
237 # define R10 (BaseReg->rR10)
238 #endif
239
240 #ifdef REG_F1
241 GLOBAL_REG_DECL(StgFloat,F1,REG_F1)
242 #else
243 #define F1 (BaseReg->rF1)
244 #endif
245
246 #ifdef REG_F2
247 GLOBAL_REG_DECL(StgFloat,F2,REG_F2)
248 #else
249 #define F2 (BaseReg->rF2)
250 #endif
251
252 #ifdef REG_F3
253 GLOBAL_REG_DECL(StgFloat,F3,REG_F3)
254 #else
255 #define F3 (BaseReg->rF3)
256 #endif
257
258 #ifdef REG_F4
259 GLOBAL_REG_DECL(StgFloat,F4,REG_F4)
260 #else
261 #define F4 (BaseReg->rF4)
262 #endif
263
264 #ifdef REG_D1
265 GLOBAL_REG_DECL(StgDouble,D1,REG_D1)
266 #else
267 #define D1 (BaseReg->rD1)
268 #endif
269
270 #ifdef REG_D2
271 GLOBAL_REG_DECL(StgDouble,D2,REG_D2)
272 #else
273 #define D2 (BaseReg->rD2)
274 #endif
275
276 #ifdef REG_L1
277 GLOBAL_REG_DECL(StgWord64,L1,REG_L1)
278 #else
279 #define L1 (BaseReg->rL1)
280 #endif
281
282 /*
283  * If BaseReg isn't mapped to a machine register, just use the global
284  * address of the current register table (CurrentRegTable in
285  * concurrent Haskell, MainRegTable otherwise).
286  */
287
288 #ifdef REG_Base
289 GLOBAL_REG_DECL(StgRegTable *,BaseReg,REG_Base)
290 #else
291 #ifdef SMP
292 #error BaseReg must be in a register for SMP
293 #endif
294 #define BaseReg (&MainCapability.r)
295 #endif
296
297 #ifdef REG_Sp
298 GLOBAL_REG_DECL(P_,Sp,REG_Sp)
299 #else
300 #define Sp (BaseReg->rSp)
301 #endif
302
303 #ifdef REG_SpLim
304 GLOBAL_REG_DECL(P_,SpLim,REG_SpLim)
305 #else
306 #define SpLim (BaseReg->rSpLim)
307 #endif
308
309 #ifdef REG_Hp
310 GLOBAL_REG_DECL(P_,Hp,REG_Hp)
311 #else
312 #define Hp (BaseReg->rHp)
313 #endif
314
315 #ifdef REG_HpLim
316 GLOBAL_REG_DECL(P_,HpLim,REG_HpLim)
317 #else
318 #define HpLim (BaseReg->rHpLim)
319 #endif
320
321 #ifdef REG_CurrentTSO
322 GLOBAL_REG_DECL(StgTSO *,CurrentTSO,REG_CurrentTSO)
323 #else
324 #define CurrentTSO (BaseReg->rCurrentTSO)
325 #endif
326
327 #ifdef REG_CurrentNursery
328 GLOBAL_REG_DECL(bdescr *,CurrentNursery,REG_CurrentNursery)
329 #else
330 #define CurrentNursery (BaseReg->rCurrentNursery)
331 #endif
332
333 #ifdef REG_HpAlloc
334 GLOBAL_REG_DECL(bdescr *,HpAlloc,REG_HpAlloc)
335 #else
336 #define HpAlloc (BaseReg->rHpAlloc)
337 #endif
338
339 #ifdef REG_SparkHd
340 GLOBAL_REG_DECL(bdescr *,SparkHd,REG_SparkHd)
341 #else
342 #define SparkHd (BaseReg->rSparks.hd)
343 #endif
344
345 #ifdef REG_SparkTl
346 GLOBAL_REG_DECL(bdescr *,SparkTl,REG_SparkTl)
347 #else
348 #define SparkTl (BaseReg->rSparks.tl)
349 #endif
350
351 #ifdef REG_SparkBase
352 GLOBAL_REG_DECL(bdescr *,SparkBase,REG_SparkBase)
353 #else
354 #define SparkBase (BaseReg->rSparks.base)
355 #endif
356
357 #ifdef REG_SparkLim
358 GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim)
359 #else
360 #define SparkLim (BaseReg->rSparks.lim)
361 #endif
362
363 /* -----------------------------------------------------------------------------
364    Get absolute function pointers from the register table, to save
365    code space.  On x86, 
366
367        jmp  *-12(%ebx)
368
369    is shorter than
370    
371        jmp absolute_address
372
373    as long as the offset is within the range of a signed byte
374    (-128..+127).  So we pick some common absolute_addresses and put
375    them in the register table.  As a bonus, linking time should also
376    be reduced.
377
378    Other possible candidates in order of importance:
379       
380      stg_upd_frame_info
381      stg_CAF_BLACKHOLE_info
382      stg_IND_STATIC_info
383
384    anything else probably isn't worth the effort.
385
386    -------------------------------------------------------------------------- */
387
388
389 #define FunReg ((StgFunTable *)((void *)BaseReg - sizeof(StgFunTable)))
390
391 #define stg_gc_enter_1     (FunReg->stgGCEnter1)
392 #define stg_gc_fun         (FunReg->stgGCFun)
393
394 /* -----------------------------------------------------------------------------
395    For any registers which are denoted "caller-saves" by the C calling
396    convention, we have to emit code to save and restore them across C
397    calls.
398    -------------------------------------------------------------------------- */
399
400 #ifdef CALLER_SAVES_R1
401 #define CALLER_SAVE_R1          SAVE_R1 = R1;
402 #define CALLER_RESTORE_R1       R1 = SAVE_R1;
403 #else
404 #define CALLER_SAVE_R1          /* nothing */
405 #define CALLER_RESTORE_R1       /* nothing */
406 #endif
407
408 #ifdef CALLER_SAVES_R2
409 #define CALLER_SAVE_R2          SAVE_R2 = R2;
410 #define CALLER_RESTORE_R2       R2 = SAVE_R2;
411 #else
412 #define CALLER_SAVE_R2          /* nothing */
413 #define CALLER_RESTORE_R2       /* nothing */
414 #endif
415
416 #ifdef CALLER_SAVES_R3
417 #define CALLER_SAVE_R3          SAVE_R3 = R3;
418 #define CALLER_RESTORE_R3       R3 = SAVE_R3;
419 #else
420 #define CALLER_SAVE_R3          /* nothing */
421 #define CALLER_RESTORE_R3       /* nothing */
422 #endif
423
424 #ifdef CALLER_SAVES_R4
425 #define CALLER_SAVE_R4          SAVE_R4 = R4;
426 #define CALLER_RESTORE_R4       R4 = SAVE_R4;
427 #else
428 #define CALLER_SAVE_R4          /* nothing */
429 #define CALLER_RESTORE_R4       /* nothing */
430 #endif
431
432 #ifdef CALLER_SAVES_R5
433 #define CALLER_SAVE_R5          SAVE_R5 = R5;
434 #define CALLER_RESTORE_R5       R5 = SAVE_R5;
435 #else
436 #define CALLER_SAVE_R5          /* nothing */
437 #define CALLER_RESTORE_R5       /* nothing */
438 #endif
439
440 #ifdef CALLER_SAVES_R6
441 #define CALLER_SAVE_R6          SAVE_R6 = R6;
442 #define CALLER_RESTORE_R6       R6 = SAVE_R6;
443 #else
444 #define CALLER_SAVE_R6          /* nothing */
445 #define CALLER_RESTORE_R6       /* nothing */
446 #endif
447
448 #ifdef CALLER_SAVES_R7
449 #define CALLER_SAVE_R7          SAVE_R7 = R7;
450 #define CALLER_RESTORE_R7       R7 = SAVE_R7;
451 #else
452 #define CALLER_SAVE_R7          /* nothing */
453 #define CALLER_RESTORE_R7       /* nothing */
454 #endif
455
456 #ifdef CALLER_SAVES_R8
457 #define CALLER_SAVE_R8          SAVE_R8 = R8;
458 #define CALLER_RESTORE_R8       R8 = SAVE_R8;
459 #else
460 #define CALLER_SAVE_R8          /* nothing */
461 #define CALLER_RESTORE_R8       /* nothing */
462 #endif
463
464 #ifdef CALLER_SAVES_R9
465 #define CALLER_SAVE_R9          SAVE_R9 = R9;
466 #define CALLER_RESTORE_R9       R9 = SAVE_R9;
467 #else
468 #define CALLER_SAVE_R9          /* nothing */
469 #define CALLER_RESTORE_R9       /* nothing */
470 #endif
471
472 #ifdef CALLER_SAVES_R10
473 #define CALLER_SAVE_R10         SAVE_R10 = R10;
474 #define CALLER_RESTORE_R10      R10 = SAVE_R10;
475 #else
476 #define CALLER_SAVE_R10         /* nothing */
477 #define CALLER_RESTORE_R10      /* nothing */
478 #endif
479
480 #ifdef CALLER_SAVES_F1
481 #define CALLER_SAVE_F1          SAVE_F1 = F1;
482 #define CALLER_RESTORE_F1       F1 = SAVE_F1;
483 #else
484 #define CALLER_SAVE_F1          /* nothing */
485 #define CALLER_RESTORE_F1       /* nothing */
486 #endif
487
488 #ifdef CALLER_SAVES_F2
489 #define CALLER_SAVE_F2          SAVE_F2 = F2;
490 #define CALLER_RESTORE_F2       F2 = SAVE_F2;
491 #else
492 #define CALLER_SAVE_F2          /* nothing */
493 #define CALLER_RESTORE_F2       /* nothing */
494 #endif
495
496 #ifdef CALLER_SAVES_F3
497 #define CALLER_SAVE_F3          SAVE_F3 = F3;
498 #define CALLER_RESTORE_F3       F3 = SAVE_F3;
499 #else
500 #define CALLER_SAVE_F3          /* nothing */
501 #define CALLER_RESTORE_F3       /* nothing */
502 #endif
503
504 #ifdef CALLER_SAVES_F4
505 #define CALLER_SAVE_F4          SAVE_F4 = F4;
506 #define CALLER_RESTORE_F4       F4 = SAVE_F4;
507 #else
508 #define CALLER_SAVE_F4          /* nothing */
509 #define CALLER_RESTORE_F4       /* nothing */
510 #endif
511
512 #ifdef CALLER_SAVES_D1
513 #define CALLER_SAVE_D1          SAVE_D1 = D1;
514 #define CALLER_RESTORE_D1       D1 = SAVE_D1;
515 #else
516 #define CALLER_SAVE_D1          /* nothing */
517 #define CALLER_RESTORE_D1       /* nothing */
518 #endif
519
520 #ifdef CALLER_SAVES_D2
521 #define CALLER_SAVE_D2          SAVE_D2 = D2;
522 #define CALLER_RESTORE_D2       D2 = SAVE_D2;
523 #else
524 #define CALLER_SAVE_D2          /* nothing */
525 #define CALLER_RESTORE_D2       /* nothing */
526 #endif
527
528 #ifdef CALLER_SAVES_L1
529 #define CALLER_SAVE_L1          SAVE_L1 = L1;
530 #define CALLER_RESTORE_L1       L1 = SAVE_L1;
531 #else
532 #define CALLER_SAVE_L1          /* nothing */
533 #define CALLER_RESTORE_L1       /* nothing */
534 #endif
535
536 #ifdef CALLER_SAVES_Sp
537 #define CALLER_SAVE_Sp          SAVE_Sp = Sp;
538 #define CALLER_RESTORE_Sp       Sp = SAVE_Sp;
539 #else
540 #define CALLER_SAVE_Sp          /* nothing */
541 #define CALLER_RESTORE_Sp       /* nothing */
542 #endif
543
544 #ifdef CALLER_SAVES_SpLim
545 #define CALLER_SAVE_SpLim       SAVE_SpLim = SpLim;
546 #define CALLER_RESTORE_SpLim    SpLim = SAVE_SpLim;
547 #else
548 #define CALLER_SAVE_SpLim       /* nothing */
549 #define CALLER_RESTORE_SpLim    /* nothing */
550 #endif
551
552 #ifdef CALLER_SAVES_Hp
553 #define CALLER_SAVE_Hp          SAVE_Hp = Hp;
554 #define CALLER_RESTORE_Hp       Hp = SAVE_Hp;
555 #else
556 #define CALLER_SAVE_Hp          /* nothing */
557 #define CALLER_RESTORE_Hp       /* nothing */
558 #endif
559
560 #ifdef CALLER_SAVES_HpLim
561 #define CALLER_SAVE_HpLim       SAVE_HpLim = HpLim;
562 #define CALLER_RESTORE_HpLim    HpLim = SAVE_HpLim;
563 #else
564 #define CALLER_SAVE_HpLim       /* nothing */
565 #define CALLER_RESTORE_HpLim    /* nothing */
566 #endif
567
568 #ifdef CALLER_SAVES_Base
569 #ifdef SMP
570 #error "Can't have caller-saved BaseReg with SMP"
571 #endif
572 #define CALLER_SAVE_Base        /* nothing */
573 #define CALLER_RESTORE_Base     BaseReg = &MainRegTable;
574 #else
575 #define CALLER_SAVE_Base        /* nothing */
576 #define CALLER_RESTORE_Base     /* nothing */
577 #endif
578
579 #ifdef CALLER_SAVES_CurrentTSO
580 #define CALLER_SAVE_CurrentTSO          SAVE_CurrentTSO = CurrentTSO;
581 #define CALLER_RESTORE_CurrentTSO       CurrentTSO = SAVE_CurrentTSO;
582 #else
583 #define CALLER_SAVE_CurrentTSO          /* nothing */
584 #define CALLER_RESTORE_CurrentTSO       /* nothing */
585 #endif
586
587 #ifdef CALLER_SAVES_CurrentNursery
588 #define CALLER_SAVE_CurrentNursery      SAVE_CurrentNursery = CurrentNursery;
589 #define CALLER_RESTORE_CurrentNursery   CurrentNursery = SAVE_CurrentNursery;
590 #else
591 #define CALLER_SAVE_CurrentNursery      /* nothing */
592 #define CALLER_RESTORE_CurrentNursery   /* nothing */
593 #endif
594
595 #ifdef CALLER_SAVES_HpAlloc
596 #define CALLER_SAVE_HpAlloc             SAVE_HpAlloc = HpAlloc;
597 #define CALLER_RESTORE_HpAlloc          HpAlloc = SAVE_HpAlloc;
598 #else
599 #define CALLER_SAVE_HpAlloc             /* nothing */
600 #define CALLER_RESTORE_HpAlloc          /* nothing */
601 #endif
602
603 #ifdef CALLER_SAVES_SparkHd
604 #define CALLER_SAVE_SparkHd             SAVE_SparkHd = SparkHd;
605 #define CALLER_RESTORE_SparkHd          SparkHd = SAVE_SparkHd;
606 #else
607 #define CALLER_SAVE_SparkHd             /* nothing */
608 #define CALLER_RESTORE_SparkHd          /* nothing */
609 #endif
610
611 #ifdef CALLER_SAVES_SparkTl
612 #define CALLER_SAVE_SparkTl             SAVE_SparkTl = SparkTl;
613 #define CALLER_RESTORE_SparkTl          SparkTl = SAVE_SparkTl;
614 #else
615 #define CALLER_SAVE_SparkTl             /* nothing */
616 #define CALLER_RESTORE_SparkTl          /* nothing */
617 #endif
618
619 #ifdef CALLER_SAVES_SparkBase
620 #define CALLER_SAVE_SparkBase           SAVE_SparkBase = SparkBase;
621 #define CALLER_RESTORE_SparkBase        SparkBase = SAVE_SparkBase;
622 #else
623 #define CALLER_SAVE_SparkBase           /* nothing */
624 #define CALLER_RESTORE_SparkBase        /* nothing */
625 #endif
626
627 #ifdef CALLER_SAVES_SparkLim
628 #define CALLER_SAVE_SparkLim            SAVE_SparkLim = SparkLim;
629 #define CALLER_RESTORE_SparkLim         SparkLim = SAVE_SparkLim;
630 #else
631 #define CALLER_SAVE_SparkLim            /* nothing */
632 #define CALLER_RESTORE_SparkLim         /* nothing */
633 #endif
634
635 #endif /* IN_STG_CODE */
636
637 /* ----------------------------------------------------------------------------
638    Handy bunches of saves/restores 
639    ------------------------------------------------------------------------  */
640
641 #if IN_STG_CODE
642
643 #define CALLER_SAVE_USER                        \
644   CALLER_SAVE_R1                                \
645   CALLER_SAVE_R2                                \
646   CALLER_SAVE_R3                                \
647   CALLER_SAVE_R4                                \
648   CALLER_SAVE_R5                                \
649   CALLER_SAVE_R6                                \
650   CALLER_SAVE_R7                                \
651   CALLER_SAVE_R8                                \
652   CALLER_SAVE_F1                                \
653   CALLER_SAVE_F2                                \
654   CALLER_SAVE_F3                                \
655   CALLER_SAVE_F4                                \
656   CALLER_SAVE_D1                                \
657   CALLER_SAVE_D2                                \
658   CALLER_SAVE_L1
659
660      /* Save Base last, since the others may
661         be addressed relative to it */
662 #define CALLER_SAVE_SYSTEM                      \
663   CALLER_SAVE_Sp                                \
664   CALLER_SAVE_SpLim                             \
665   CALLER_SAVE_Hp                                \
666   CALLER_SAVE_HpLim                             \
667   CALLER_SAVE_CurrentTSO                        \
668   CALLER_SAVE_CurrentNursery                    \
669   CALLER_SAVE_SparkHd                           \
670   CALLER_SAVE_SparkTl                           \
671   CALLER_SAVE_SparkBase                         \
672   CALLER_SAVE_SparkLim                          \
673   CALLER_SAVE_Base
674
675 #define CALLER_RESTORE_USER                     \
676   CALLER_RESTORE_R1                             \
677   CALLER_RESTORE_R2                             \
678   CALLER_RESTORE_R3                             \
679   CALLER_RESTORE_R4                             \
680   CALLER_RESTORE_R5                             \
681   CALLER_RESTORE_R6                             \
682   CALLER_RESTORE_R7                             \
683   CALLER_RESTORE_R8                             \
684   CALLER_RESTORE_F1                             \
685   CALLER_RESTORE_F2                             \
686   CALLER_RESTORE_F3                             \
687   CALLER_RESTORE_F4                             \
688   CALLER_RESTORE_D1                             \
689   CALLER_RESTORE_D2                             \
690   CALLER_RESTORE_L1
691
692      /* Restore Base first, since the others may
693         be addressed relative to it */
694 #define CALLER_RESTORE_SYSTEM                   \
695   CALLER_RESTORE_Base                           \
696   CALLER_RESTORE_Sp                             \
697   CALLER_RESTORE_SpLim                          \
698   CALLER_RESTORE_Hp                             \
699   CALLER_RESTORE_HpLim                          \
700   CALLER_RESTORE_CurrentTSO                     \
701   CALLER_RESTORE_CurrentNursery                 \
702   CALLER_RESTORE_SparkHd                        \
703   CALLER_RESTORE_SparkTl                        \
704   CALLER_RESTORE_SparkBase                      \
705   CALLER_RESTORE_SparkLim
706
707 #else /* not IN_STG_CODE */
708
709 #define CALLER_SAVE_USER       /* nothing */
710 #define CALLER_SAVE_SYSTEM     /* nothing */
711 #define CALLER_RESTORE_USER    /* nothing */
712 #define CALLER_RESTORE_SYSTEM  /* nothing */
713
714 #endif /* IN_STG_CODE */
715
716 #define CALLER_SAVE_ALL                         \
717   CALLER_SAVE_SYSTEM                            \
718   CALLER_SAVE_USER
719
720 #define CALLER_RESTORE_ALL                      \
721   CALLER_RESTORE_SYSTEM                         \
722   CALLER_RESTORE_USER
723
724 #endif /* REGS_H */
725