Regs.h 18.8 KB
Newer Older
1
/* -----------------------------------------------------------------------------
2
 *
3
 * (c) The GHC Team, 1998-2004
4
 *
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 * Registers in the STG machine.
 *
 * The STG machine has a collection of "registers", each one of which
 * may or may not correspond to an actual machine register when
 * running code.  
 *
 * The register set is backed by a table in memory (struct
 * StgRegTable).  If a particular STG register is not mapped to a
 * machine register, then the apprpriate slot in this table is used
 * instead.  
 *
 * This table is itself pointed to by another register, BaseReg.  If
 * BaseReg is not in a machine register, then the register table is
 * used from an absolute location (MainCapability).
19
20
21
22
23
24
 *
 * ---------------------------------------------------------------------------*/

#ifndef REGS_H
#define REGS_H

25
typedef struct {
26
  StgWord        stgEagerBlackholeInfo;
27
  StgFunPtr      stgGCEnter1;
28
  StgFunPtr      stgGCFun;
29
30
} StgFunTable;

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Vanilla registers are given this union type, which is purely so
 * that we can cast the vanilla reg to a variety of types with the
 * minimum of syntax.  eg.  R1.w instead of (StgWord)R1.
 */
typedef union {
    StgWord        w;
    StgAddr        a;
    StgChar        c;
    StgInt8        i8;
    StgFloat       f;
    StgInt         i;
    StgPtr         p;
    StgClosurePtr  cl;
    StgStackOffset offset;	/* unused? */
    StgByteArray   b;
    StgTSOPtr      t;
} StgUnion;

50
51
52
53
54
55
56
57
/* 
 * This is the table that holds shadow-locations for all the STG
 * registers.  The shadow locations are used when:
 *
 *     1) the particular register isn't mapped to a real machine
 *        register, probably because there's a shortage of real registers.
 *     2) caller-saves registers are saved across a CCall
 */
58
typedef struct StgRegTable_ {
59
60
61
62
63
64
65
66
  StgUnion 	  rR1;
  StgUnion   	  rR2;
  StgUnion   	  rR3;
  StgUnion   	  rR4;
  StgUnion   	  rR5;
  StgUnion   	  rR6;
  StgUnion   	  rR7;
  StgUnion   	  rR8;
67
68
  StgUnion   	  rR9;		/* used occasionally by heap/stack checks */
  StgUnion   	  rR10;		/* used occasionally by heap/stack checks */
69
70
71
72
73
74
  StgFloat 	  rF1;
  StgFloat 	  rF2;
  StgFloat 	  rF3;
  StgFloat 	  rF4;
  StgDouble 	  rD1;
  StgDouble 	  rD2;
sof's avatar
sof committed
75
  StgWord64       rL1;
76
77
78
79
  StgPtr 	  rSp;
  StgPtr 	  rSpLim;
  StgPtr 	  rHp;
  StgPtr 	  rHpLim;
80
  struct StgTSO_ *rCurrentTSO;
81
  struct step_   *rNursery;
82
83
  struct bdescr_ *rCurrentNursery; /* Hp/HpLim point into this block */
  struct bdescr_ *rCurrentAlloc;   /* for allocation using allocate() */
84
  StgWord         rHpAlloc;	/* number of *bytes* being allocated in heap */
85
  StgWord         rRet;  // holds the return code of the thread
86
87
} StgRegTable;

88
#if IN_STG_CODE
89
90
91
92
93

/*
 * Registers Hp and HpLim are global across the entire system, and are
 * copied into the RegTable before executing a thread.
 *
94
 * Registers Sp and SpLim are saved in the TSO for the
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 * thread, but are copied into the RegTable before executing a thread.
 *
 * All other registers are "general purpose", and are used for passing
 * arguments to functions, and returning values.  The code generator
 * knows how many of these are in real registers, and avoids
 * generating code that uses non-real registers.  General purpose
 * registers are never saved when returning to the scheduler, instead
 * we save whatever is live at the time on the stack, and restore it
 * later.  This should reduce the context switch time, amongst other
 * things.
 *
 * For argument passing, the stack will be used in preference to
 * pseudo-registers if the architecture has too few general purpose
 * registers.
 *
 * Some special RTS functions like newArray and the Integer primitives
 * expect their arguments to be in registers R1-Rn, so we use these
 * (pseudo-)registers in those cases.
 */

/* 
 * Locations for saving per-thread registers.
 */

#define SAVE_Sp    	    (CurrentTSO->sp)
#define SAVE_SpLim    	    (CurrentTSO->splim)

122
123
124
125
#define SAVE_Hp	    	    (BaseReg->rHp)

#define SAVE_CurrentTSO     (BaseReg->rCurrentTSO)
#define SAVE_CurrentNursery (BaseReg->rCurrentNursery)
126
#define SAVE_HpAlloc        (BaseReg->rHpAlloc)
127
128
129
130
131
132

/* We sometimes need to save registers across a C-call, eg. if they
 * are clobbered in the standard calling convention.  We define the
 * save locations for all registers in the register table.
 */

133
134
135
136
137
138
139
140
#define SAVE_R1             (BaseReg->rR1)
#define SAVE_R2             (BaseReg->rR2)
#define SAVE_R3             (BaseReg->rR3)
#define SAVE_R4             (BaseReg->rR4)
#define SAVE_R5             (BaseReg->rR5)
#define SAVE_R6             (BaseReg->rR6)
#define SAVE_R7             (BaseReg->rR7)
#define SAVE_R8             (BaseReg->rR8)
141
 
142
143
144
145
#define SAVE_F1             (BaseReg->rF1)
#define SAVE_F2             (BaseReg->rF2)
#define SAVE_F3             (BaseReg->rF3)
#define SAVE_F4             (BaseReg->rF4)
146

147
148
#define SAVE_D1             (BaseReg->rD1)
#define SAVE_D2             (BaseReg->rD2)
149

150
#define SAVE_L1             (BaseReg->rL1)
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

/* -----------------------------------------------------------------------------
 * Emit the GCC-specific register declarations for each machine
 * register being used.  If any STG register isn't mapped to a machine
 * register, then map it to an offset from BaseReg.
 *
 * First, the general purpose registers.  The idea is, if a particular
 * general-purpose STG register can't be mapped to a real machine
 * register, it won't be used at all.  Instead, we'll use the stack.
 *
 * This is an improvement on the way things used to be done, when all
 * registers were mapped to locations in the register table, and stuff
 * was being shifted from the stack to the register table and back
 * again for no good reason (on register-poor architectures).
 */

167
168
169
170
/* define NO_REGS to omit register declarations - used in RTS C code
 * that needs all the STG definitions but not the global register 
 * settings.
 */
171
172
#define GLOBAL_REG_DECL(type,name,reg) register type name REG(reg);

173
#if defined(REG_R1) && !defined(NO_GLOBAL_REG_DECLS)
174
175
GLOBAL_REG_DECL(StgUnion,R1,REG_R1)
#else
176
# define R1 (BaseReg->rR1)
177
178
#endif

179
#if defined(REG_R2) && !defined(NO_GLOBAL_REG_DECLS)
180
181
GLOBAL_REG_DECL(StgUnion,R2,REG_R2)
#else
182
# define R2 (BaseReg->rR2)
183
184
#endif

185
#if defined(REG_R3) && !defined(NO_GLOBAL_REG_DECLS)
186
187
188
189
190
GLOBAL_REG_DECL(StgUnion,R3,REG_R3)
#else
# define R3 (BaseReg->rR3)
#endif

191
#if defined(REG_R4) && !defined(NO_GLOBAL_REG_DECLS)
192
193
194
195
196
GLOBAL_REG_DECL(StgUnion,R4,REG_R4)
#else
# define R4 (BaseReg->rR4)
#endif

197
#if defined(REG_R5) && !defined(NO_GLOBAL_REG_DECLS)
198
199
200
201
202
GLOBAL_REG_DECL(StgUnion,R5,REG_R5)
#else
# define R5 (BaseReg->rR5)
#endif

203
#if defined(REG_R6) && !defined(NO_GLOBAL_REG_DECLS)
204
205
206
207
208
GLOBAL_REG_DECL(StgUnion,R6,REG_R6)
#else
# define R6 (BaseReg->rR6)
#endif

209
#if defined(REG_R7) && !defined(NO_GLOBAL_REG_DECLS)
210
211
212
213
214
GLOBAL_REG_DECL(StgUnion,R7,REG_R7)
#else
# define R7 (BaseReg->rR7)
#endif

215
#if defined(REG_R8) && !defined(NO_GLOBAL_REG_DECLS)
216
217
218
219
220
GLOBAL_REG_DECL(StgUnion,R8,REG_R8)
#else
# define R8 (BaseReg->rR8)
#endif

221
#if defined(REG_R9) && !defined(NO_GLOBAL_REG_DECLS)
222
223
224
225
226
GLOBAL_REG_DECL(StgUnion,R9,REG_R9)
#else
# define R9 (BaseReg->rR9)
#endif

227
#if defined(REG_R10) && !defined(NO_GLOBAL_REG_DECLS)
228
229
230
231
232
GLOBAL_REG_DECL(StgUnion,R10,REG_R10)
#else
# define R10 (BaseReg->rR10)
#endif

233
#if defined(REG_F1) && !defined(NO_GLOBAL_REG_DECLS)
234
235
236
237
238
GLOBAL_REG_DECL(StgFloat,F1,REG_F1)
#else
#define F1 (BaseReg->rF1)
#endif

239
#if defined(REG_F2) && !defined(NO_GLOBAL_REG_DECLS)
240
241
242
243
244
GLOBAL_REG_DECL(StgFloat,F2,REG_F2)
#else
#define F2 (BaseReg->rF2)
#endif

245
#if defined(REG_F3) && !defined(NO_GLOBAL_REG_DECLS)
246
247
248
249
250
GLOBAL_REG_DECL(StgFloat,F3,REG_F3)
#else
#define F3 (BaseReg->rF3)
#endif

251
#if defined(REG_F4) && !defined(NO_GLOBAL_REG_DECLS)
252
253
254
255
256
GLOBAL_REG_DECL(StgFloat,F4,REG_F4)
#else
#define F4 (BaseReg->rF4)
#endif

257
#if defined(REG_D1) && !defined(NO_GLOBAL_REG_DECLS)
258
259
260
261
262
GLOBAL_REG_DECL(StgDouble,D1,REG_D1)
#else
#define D1 (BaseReg->rD1)
#endif

263
#if defined(REG_D2) && !defined(NO_GLOBAL_REG_DECLS)
264
265
266
267
268
GLOBAL_REG_DECL(StgDouble,D2,REG_D2)
#else
#define D2 (BaseReg->rD2)
#endif

269
#if defined(REG_L1) && !defined(NO_GLOBAL_REG_DECLS)
sof's avatar
sof committed
270
GLOBAL_REG_DECL(StgWord64,L1,REG_L1)
271
272
273
274
275
276
277
278
279
280
#else
#define L1 (BaseReg->rL1)
#endif

/*
 * If BaseReg isn't mapped to a machine register, just use the global
 * address of the current register table (CurrentRegTable in
 * concurrent Haskell, MainRegTable otherwise).
 */

281
282
283
284
285
286
287
288
289
290
291
292
/* A capability is a combination of a FunTable and a RegTable.  In STG
 * code, BaseReg normally points to the RegTable portion of this
 * structure, so that we can index both forwards and backwards to take
 * advantage of shorter instruction forms on some archs (eg. x86).
 * This is a cut-down version of the Capability structure; the full
 * version is defined in Capability.h.
 */
struct PartCapability_ {
    StgFunTable f;
    StgRegTable r;
};

293
/* No such thing as a MainCapability under THREADED_RTS - each thread must have
294
295
 * its own Capability.
 */
296
#if IN_STG_CODE && !(defined(THREADED_RTS) && !defined(NOSMP))
297
298
299
extern W_ MainCapability[];
#endif

Simon Marlow's avatar
Simon Marlow committed
300
301
302
303
304
305
306
307
/*
 * Assigning to BaseReg (the ASSIGN_BaseReg macro): this happens on
 * return from a "safe" foreign call, when the thread might be running
 * on a new Capability.  Obviously if BaseReg is not a register, then
 * we are restricted to a single Capability (this invariant is enforced
 * in Capability.c:initCapabilities), and assigning to BaseReg can be omitted.
 */

308
#if defined(REG_Base) && !defined(NO_GLOBAL_REG_DECLS)
309
GLOBAL_REG_DECL(StgRegTable *,BaseReg,REG_Base)
Simon Marlow's avatar
Simon Marlow committed
310
#define ASSIGN_BaseReg(e) (BaseReg = (e))
311
#else
312
#if defined(THREADED_RTS) && !defined(NOSMP)
313
#error BaseReg must be in a register for THREADED_RTS
314
#endif
315
#define BaseReg (&((struct PartCapability_ *)MainCapability)->r)
316
#define ASSIGN_BaseReg(e) (e)
317
318
#endif

319
#if defined(REG_Sp) && !defined(NO_GLOBAL_REG_DECLS)
320
321
322
323
324
GLOBAL_REG_DECL(P_,Sp,REG_Sp)
#else
#define Sp (BaseReg->rSp)
#endif

325
#if defined(REG_SpLim) && !defined(NO_GLOBAL_REG_DECLS)
326
327
328
329
330
GLOBAL_REG_DECL(P_,SpLim,REG_SpLim)
#else
#define SpLim (BaseReg->rSpLim)
#endif

331
#if defined(REG_Hp) && !defined(NO_GLOBAL_REG_DECLS)
332
333
334
335
336
GLOBAL_REG_DECL(P_,Hp,REG_Hp)
#else
#define Hp (BaseReg->rHp)
#endif

337
#if defined(REG_HpLim) && !defined(NO_GLOBAL_REG_DECLS)
338
#error HpLim cannot be in a register
339
340
341
342
#else
#define HpLim (BaseReg->rHpLim)
#endif

343
#if defined(REG_CurrentTSO) && !defined(NO_GLOBAL_REG_DECLS)
344
GLOBAL_REG_DECL(struct _StgTSO *,CurrentTSO,REG_CurrentTSO)
345
346
347
348
#else
#define CurrentTSO (BaseReg->rCurrentTSO)
#endif

349
#if defined(REG_CurrentNursery) && !defined(NO_GLOBAL_REG_DECLS)
350
351
352
353
354
GLOBAL_REG_DECL(bdescr *,CurrentNursery,REG_CurrentNursery)
#else
#define CurrentNursery (BaseReg->rCurrentNursery)
#endif

355
#if defined(REG_HpAlloc) && !defined(NO_GLOBAL_REG_DECLS)
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
GLOBAL_REG_DECL(bdescr *,HpAlloc,REG_HpAlloc)
#else
#define HpAlloc (BaseReg->rHpAlloc)
#endif

/* -----------------------------------------------------------------------------
   Get absolute function pointers from the register table, to save
   code space.  On x86, 

       jmp  *-12(%ebx)

   is shorter than
   
       jmp absolute_address

   as long as the offset is within the range of a signed byte
   (-128..+127).  So we pick some common absolute_addresses and put
   them in the register table.  As a bonus, linking time should also
   be reduced.

   Other possible candidates in order of importance:
      
     stg_upd_frame_info
     stg_CAF_BLACKHOLE_info
     stg_IND_STATIC_info

   anything else probably isn't worth the effort.

   -------------------------------------------------------------------------- */


Ian Lynagh's avatar
Ian Lynagh committed
387
#define FunReg ((StgFunTable *)((void *)BaseReg - STG_FIELD_OFFSET(struct PartCapability_, r)))
388

389
390
391
#define stg_EAGER_BLACKHOLE_info  (FunReg->stgEagerBlackholeInfo)
#define stg_gc_enter_1            (FunReg->stgGCEnter1)
#define stg_gc_fun                (FunReg->stgGCFun)
392

393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
/* -----------------------------------------------------------------------------
   For any registers which are denoted "caller-saves" by the C calling
   convention, we have to emit code to save and restore them across C
   calls.
   -------------------------------------------------------------------------- */

#ifdef CALLER_SAVES_R1
#define CALLER_SAVE_R1    	SAVE_R1 = R1;
#define CALLER_RESTORE_R1 	R1 = SAVE_R1;
#else
#define CALLER_SAVE_R1      	/* nothing */
#define CALLER_RESTORE_R1    	/* nothing */
#endif

#ifdef CALLER_SAVES_R2
#define CALLER_SAVE_R2    	SAVE_R2 = R2;
#define CALLER_RESTORE_R2 	R2 = SAVE_R2;
#else
#define CALLER_SAVE_R2      	/* nothing */
#define CALLER_RESTORE_R2    	/* nothing */
#endif

#ifdef CALLER_SAVES_R3
#define CALLER_SAVE_R3    	SAVE_R3 = R3;
#define CALLER_RESTORE_R3 	R3 = SAVE_R3;
#else
#define CALLER_SAVE_R3      	/* nothing */
#define CALLER_RESTORE_R3    	/* nothing */
#endif

#ifdef CALLER_SAVES_R4
#define CALLER_SAVE_R4    	SAVE_R4 = R4;
#define CALLER_RESTORE_R4 	R4 = SAVE_R4;
#else
#define CALLER_SAVE_R4      	/* nothing */
#define CALLER_RESTORE_R4    	/* nothing */
#endif

#ifdef CALLER_SAVES_R5
#define CALLER_SAVE_R5    	SAVE_R5 = R5;
#define CALLER_RESTORE_R5 	R5 = SAVE_R5;
#else
#define CALLER_SAVE_R5      	/* nothing */
#define CALLER_RESTORE_R5    	/* nothing */
#endif

#ifdef CALLER_SAVES_R6
#define CALLER_SAVE_R6    	SAVE_R6 = R6;
#define CALLER_RESTORE_R6 	R6 = SAVE_R6;
#else
#define CALLER_SAVE_R6      	/* nothing */
#define CALLER_RESTORE_R6    	/* nothing */
#endif

#ifdef CALLER_SAVES_R7
#define CALLER_SAVE_R7    	SAVE_R7 = R7;
#define CALLER_RESTORE_R7 	R7 = SAVE_R7;
#else
#define CALLER_SAVE_R7      	/* nothing */
#define CALLER_RESTORE_R7    	/* nothing */
#endif

#ifdef CALLER_SAVES_R8
#define CALLER_SAVE_R8    	SAVE_R8 = R8;
#define CALLER_RESTORE_R8 	R8 = SAVE_R8;
#else
#define CALLER_SAVE_R8      	/* nothing */
#define CALLER_RESTORE_R8    	/* nothing */
#endif

#ifdef CALLER_SAVES_R9
#define CALLER_SAVE_R9    	SAVE_R9 = R9;
#define CALLER_RESTORE_R9 	R9 = SAVE_R9;
#else
#define CALLER_SAVE_R9      	/* nothing */
#define CALLER_RESTORE_R9    	/* nothing */
#endif

#ifdef CALLER_SAVES_R10
#define CALLER_SAVE_R10    	SAVE_R10 = R10;
#define CALLER_RESTORE_R10 	R10 = SAVE_R10;
#else
#define CALLER_SAVE_R10      	/* nothing */
#define CALLER_RESTORE_R10    	/* nothing */
#endif

#ifdef CALLER_SAVES_F1
#define CALLER_SAVE_F1    	SAVE_F1 = F1;
#define CALLER_RESTORE_F1 	F1 = SAVE_F1;
#else
#define CALLER_SAVE_F1    	/* nothing */
#define CALLER_RESTORE_F1 	/* nothing */
#endif

#ifdef CALLER_SAVES_F2
#define CALLER_SAVE_F2    	SAVE_F2 = F2;
#define CALLER_RESTORE_F2 	F2 = SAVE_F2;
#else
#define CALLER_SAVE_F2    	/* nothing */
#define CALLER_RESTORE_F2 	/* nothing */
#endif

#ifdef CALLER_SAVES_F3
#define CALLER_SAVE_F3    	SAVE_F3 = F3;
#define CALLER_RESTORE_F3 	F3 = SAVE_F3;
#else
#define CALLER_SAVE_F3    	/* nothing */
#define CALLER_RESTORE_F3 	/* nothing */
#endif

#ifdef CALLER_SAVES_F4
#define CALLER_SAVE_F4    	SAVE_F4 = F4;
#define CALLER_RESTORE_F4 	F4 = SAVE_F4;
#else
#define CALLER_SAVE_F4    	/* nothing */
#define CALLER_RESTORE_F4 	/* nothing */
#endif

#ifdef CALLER_SAVES_D1
#define CALLER_SAVE_D1    	SAVE_D1 = D1;
#define CALLER_RESTORE_D1 	D1 = SAVE_D1;
#else
#define CALLER_SAVE_D1    	/* nothing */
#define CALLER_RESTORE_D1 	/* nothing */
#endif

#ifdef CALLER_SAVES_D2
#define CALLER_SAVE_D2    	SAVE_D2 = D2;
#define CALLER_RESTORE_D2 	D2 = SAVE_D2;
#else
#define CALLER_SAVE_D2    	/* nothing */
#define CALLER_RESTORE_D2 	/* nothing */
#endif

#ifdef CALLER_SAVES_L1
#define CALLER_SAVE_L1    	SAVE_L1 = L1;
#define CALLER_RESTORE_L1 	L1 = SAVE_L1;
#else
#define CALLER_SAVE_L1    	/* nothing */
#define CALLER_RESTORE_L1 	/* nothing */
#endif

#ifdef CALLER_SAVES_Sp
#define CALLER_SAVE_Sp	    	SAVE_Sp = Sp;
#define CALLER_RESTORE_Sp  	Sp = SAVE_Sp;
#else
#define CALLER_SAVE_Sp	    	/* nothing */
#define CALLER_RESTORE_Sp	/* nothing */
#endif

#ifdef CALLER_SAVES_SpLim
#define CALLER_SAVE_SpLim    	SAVE_SpLim = SpLim;
#define CALLER_RESTORE_SpLim  	SpLim = SAVE_SpLim;
#else
#define CALLER_SAVE_SpLim    	/* nothing */
#define CALLER_RESTORE_SpLim	/* nothing */
#endif

#ifdef CALLER_SAVES_Hp
#define CALLER_SAVE_Hp	    	SAVE_Hp = Hp;
#define CALLER_RESTORE_Hp   	Hp = SAVE_Hp;
#else
#define CALLER_SAVE_Hp	    	/* nothing */
#define CALLER_RESTORE_Hp	/* nothing */
#endif

#ifdef CALLER_SAVES_Base
560
561
#ifdef THREADED_RTS
#error "Can't have caller-saved BaseReg with THREADED_RTS"
562
#endif
563
564
565
566
567
568
569
#define CALLER_SAVE_Base	/* nothing */
#define CALLER_RESTORE_Base	BaseReg = &MainRegTable;
#else
#define CALLER_SAVE_Base	/* nothing */
#define CALLER_RESTORE_Base	/* nothing */
#endif

570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
#ifdef CALLER_SAVES_CurrentTSO
#define CALLER_SAVE_CurrentTSO   	SAVE_CurrentTSO = CurrentTSO;
#define CALLER_RESTORE_CurrentTSO	CurrentTSO = SAVE_CurrentTSO;
#else
#define CALLER_SAVE_CurrentTSO   	/* nothing */
#define CALLER_RESTORE_CurrentTSO   	/* nothing */
#endif

#ifdef CALLER_SAVES_CurrentNursery
#define CALLER_SAVE_CurrentNursery   	SAVE_CurrentNursery = CurrentNursery;
#define CALLER_RESTORE_CurrentNursery	CurrentNursery = SAVE_CurrentNursery;
#else
#define CALLER_SAVE_CurrentNursery   	/* nothing */
#define CALLER_RESTORE_CurrentNursery   /* nothing */
#endif

586
587
588
589
590
591
592
593
#ifdef CALLER_SAVES_HpAlloc
#define CALLER_SAVE_HpAlloc   		SAVE_HpAlloc = HpAlloc;
#define CALLER_RESTORE_HpAlloc		HpAlloc = SAVE_HpAlloc;
#else
#define CALLER_SAVE_HpAlloc   		/* nothing */
#define CALLER_RESTORE_HpAlloc   	/* nothing */
#endif

594
595
#endif /* IN_STG_CODE */

596
597
598
599
/* ----------------------------------------------------------------------------
   Handy bunches of saves/restores 
   ------------------------------------------------------------------------  */

600
#if IN_STG_CODE
601

602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#define CALLER_SAVE_USER			\
  CALLER_SAVE_R1				\
  CALLER_SAVE_R2				\
  CALLER_SAVE_R3				\
  CALLER_SAVE_R4				\
  CALLER_SAVE_R5				\
  CALLER_SAVE_R6				\
  CALLER_SAVE_R7				\
  CALLER_SAVE_R8				\
  CALLER_SAVE_F1				\
  CALLER_SAVE_F2				\
  CALLER_SAVE_F3				\
  CALLER_SAVE_F4				\
  CALLER_SAVE_D1				\
  CALLER_SAVE_D2				\
  CALLER_SAVE_L1

619
620
     /* Save Base last, since the others may
	be addressed relative to it */
621
622
623
624
#define CALLER_SAVE_SYSTEM			\
  CALLER_SAVE_Sp				\
  CALLER_SAVE_SpLim				\
  CALLER_SAVE_Hp				\
625
  CALLER_SAVE_CurrentTSO			\
626
  CALLER_SAVE_CurrentNursery			\
627
  CALLER_SAVE_Base
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645

#define CALLER_RESTORE_USER			\
  CALLER_RESTORE_R1				\
  CALLER_RESTORE_R2				\
  CALLER_RESTORE_R3				\
  CALLER_RESTORE_R4				\
  CALLER_RESTORE_R5				\
  CALLER_RESTORE_R6				\
  CALLER_RESTORE_R7				\
  CALLER_RESTORE_R8				\
  CALLER_RESTORE_F1				\
  CALLER_RESTORE_F2				\
  CALLER_RESTORE_F3				\
  CALLER_RESTORE_F4				\
  CALLER_RESTORE_D1				\
  CALLER_RESTORE_D2				\
  CALLER_RESTORE_L1

646
647
     /* Restore Base first, since the others may
	be addressed relative to it */
648
649
650
651
652
#define CALLER_RESTORE_SYSTEM			\
  CALLER_RESTORE_Base				\
  CALLER_RESTORE_Sp				\
  CALLER_RESTORE_SpLim				\
  CALLER_RESTORE_Hp				\
653
  CALLER_RESTORE_CurrentTSO			\
654
  CALLER_RESTORE_CurrentNursery
655
656
657
658
659
660
661
662
663

#else /* not IN_STG_CODE */

#define CALLER_SAVE_USER       /* nothing */
#define CALLER_SAVE_SYSTEM     /* nothing */
#define CALLER_RESTORE_USER    /* nothing */
#define CALLER_RESTORE_SYSTEM  /* nothing */

#endif /* IN_STG_CODE */
664
665
666
667
668
669
670
671
672
#define CALLER_SAVE_ALL				\
  CALLER_SAVE_SYSTEM				\
  CALLER_SAVE_USER

#define CALLER_RESTORE_ALL			\
  CALLER_RESTORE_SYSTEM				\
  CALLER_RESTORE_USER

#endif /* REGS_H */