bf17b7e8256833dd151d7596f27ec7c7a1628518
[ghc.git] / includes / stg / Regs.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2012
4 *
5 * Registers in the STG machine.
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef REGS_H
15 #define REGS_H
16
17 /*
18 * The STG machine has a collection of "registers", each one of which
19 * may or may not correspond to an actual machine register when
20 * running code.
21 *
22 * The register set is backed by a table in memory (struct
23 * StgRegTable). If a particular STG register is not mapped to a
24 * machine register, then the appropriate slot in this table is used
25 * instead.
26 *
27 * This table is itself pointed to by another register, BaseReg. If
28 * BaseReg is not in a machine register, then the register table is
29 * used from an absolute location (MainCapability).
30 *
31 */
32
33 typedef struct {
34 StgWord stgEagerBlackholeInfo;
35 StgFunPtr stgGCEnter1;
36 StgFunPtr stgGCFun;
37 } StgFunTable;
38
39 /*
40 * Vanilla registers are given this union type, which is purely so
41 * that we can cast the vanilla reg to a variety of types with the
42 * minimum of syntax. eg. R1.w instead of (StgWord)R1.
43 */
44 typedef union {
45 StgWord w;
46 StgAddr a;
47 StgChar c;
48 StgFloat f;
49 StgInt i;
50 StgPtr p;
51 } StgUnion;
52
53 /*
54 * This is the table that holds shadow-locations for all the STG
55 * registers. The shadow locations are used when:
56 *
57 * 1) the particular register isn't mapped to a real machine
58 * register, probably because there's a shortage of real registers.
59 * 2) caller-saves registers are saved across a CCall
60 */
61 typedef struct {
62 StgUnion rR1;
63 StgUnion rR2;
64 StgUnion rR3;
65 StgUnion rR4;
66 StgUnion rR5;
67 StgUnion rR6;
68 StgUnion rR7;
69 StgUnion rR8;
70 StgUnion rR9; /* used occasionally by heap/stack checks */
71 StgUnion rR10; /* used occasionally by heap/stack checks */
72 StgFloat rF1;
73 StgFloat rF2;
74 StgFloat rF3;
75 StgFloat rF4;
76 StgDouble rD1;
77 StgDouble rD2;
78 StgWord64 rL1;
79 StgPtr rSp;
80 StgPtr rSpLim;
81 StgPtr rHp;
82 StgPtr rHpLim;
83 struct CostCentreStack_ * rCCCS; /* current cost-centre-stack */
84 struct StgTSO_ * rCurrentTSO;
85 struct nursery_ * rNursery;
86 struct bdescr_ * rCurrentNursery; /* Hp/HpLim point into this block */
87 struct bdescr_ * rCurrentAlloc; /* for allocation using allocate() */
88 StgWord rHpAlloc; /* number of *bytes* being allocated in heap */
89 StgWord rRet; /* holds the return code of the thread */
90 } StgRegTable;
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
128 #define SAVE_CurrentTSO (BaseReg->rCurrentTSO)
129 #define SAVE_CurrentNursery (BaseReg->rCurrentNursery)
130 #define SAVE_HpAlloc (BaseReg->rHpAlloc)
131
132 /* We sometimes need to save registers across a C-call, eg. if they
133 * are clobbered in the standard calling convention. We define the
134 * save locations for all registers in the register table.
135 */
136
137 #define SAVE_R1 (BaseReg->rR1)
138 #define SAVE_R2 (BaseReg->rR2)
139 #define SAVE_R3 (BaseReg->rR3)
140 #define SAVE_R4 (BaseReg->rR4)
141 #define SAVE_R5 (BaseReg->rR5)
142 #define SAVE_R6 (BaseReg->rR6)
143 #define SAVE_R7 (BaseReg->rR7)
144 #define SAVE_R8 (BaseReg->rR8)
145 #define SAVE_R9 (BaseReg->rR9)
146 #define SAVE_R10 (BaseReg->rR10)
147
148 #define SAVE_F1 (BaseReg->rF1)
149 #define SAVE_F2 (BaseReg->rF2)
150 #define SAVE_F3 (BaseReg->rF3)
151 #define SAVE_F4 (BaseReg->rF4)
152
153 #define SAVE_D1 (BaseReg->rD1)
154 #define SAVE_D2 (BaseReg->rD2)
155
156 #define SAVE_L1 (BaseReg->rL1)
157
158 /* -----------------------------------------------------------------------------
159 * Emit the GCC-specific register declarations for each machine
160 * register being used. If any STG register isn't mapped to a machine
161 * register, then map it to an offset from BaseReg.
162 *
163 * First, the general purpose registers. The idea is, if a particular
164 * general-purpose STG register can't be mapped to a real machine
165 * register, it won't be used at all. Instead, we'll use the stack.
166 *
167 * This is an improvement on the way things used to be done, when all
168 * registers were mapped to locations in the register table, and stuff
169 * was being shifted from the stack to the register table and back
170 * again for no good reason (on register-poor architectures).
171 */
172
173 /* define NO_REGS to omit register declarations - used in RTS C code
174 * that needs all the STG definitions but not the global register
175 * settings.
176 */
177 #define GLOBAL_REG_DECL(type,name,reg) register type name REG(reg);
178
179 #if defined(REG_R1) && !defined(NO_GLOBAL_REG_DECLS)
180 GLOBAL_REG_DECL(StgUnion,R1,REG_R1)
181 #else
182 # define R1 (BaseReg->rR1)
183 #endif
184
185 #if defined(REG_R2) && !defined(NO_GLOBAL_REG_DECLS)
186 GLOBAL_REG_DECL(StgUnion,R2,REG_R2)
187 #else
188 # define R2 (BaseReg->rR2)
189 #endif
190
191 #if defined(REG_R3) && !defined(NO_GLOBAL_REG_DECLS)
192 GLOBAL_REG_DECL(StgUnion,R3,REG_R3)
193 #else
194 # define R3 (BaseReg->rR3)
195 #endif
196
197 #if defined(REG_R4) && !defined(NO_GLOBAL_REG_DECLS)
198 GLOBAL_REG_DECL(StgUnion,R4,REG_R4)
199 #else
200 # define R4 (BaseReg->rR4)
201 #endif
202
203 #if defined(REG_R5) && !defined(NO_GLOBAL_REG_DECLS)
204 GLOBAL_REG_DECL(StgUnion,R5,REG_R5)
205 #else
206 # define R5 (BaseReg->rR5)
207 #endif
208
209 #if defined(REG_R6) && !defined(NO_GLOBAL_REG_DECLS)
210 GLOBAL_REG_DECL(StgUnion,R6,REG_R6)
211 #else
212 # define R6 (BaseReg->rR6)
213 #endif
214
215 #if defined(REG_R7) && !defined(NO_GLOBAL_REG_DECLS)
216 GLOBAL_REG_DECL(StgUnion,R7,REG_R7)
217 #else
218 # define R7 (BaseReg->rR7)
219 #endif
220
221 #if defined(REG_R8) && !defined(NO_GLOBAL_REG_DECLS)
222 GLOBAL_REG_DECL(StgUnion,R8,REG_R8)
223 #else
224 # define R8 (BaseReg->rR8)
225 #endif
226
227 #if defined(REG_R9) && !defined(NO_GLOBAL_REG_DECLS)
228 GLOBAL_REG_DECL(StgUnion,R9,REG_R9)
229 #else
230 # define R9 (BaseReg->rR9)
231 #endif
232
233 #if defined(REG_R10) && !defined(NO_GLOBAL_REG_DECLS)
234 GLOBAL_REG_DECL(StgUnion,R10,REG_R10)
235 #else
236 # define R10 (BaseReg->rR10)
237 #endif
238
239 #if defined(REG_F1) && !defined(NO_GLOBAL_REG_DECLS)
240 GLOBAL_REG_DECL(StgFloat,F1,REG_F1)
241 #else
242 #define F1 (BaseReg->rF1)
243 #endif
244
245 #if defined(REG_F2) && !defined(NO_GLOBAL_REG_DECLS)
246 GLOBAL_REG_DECL(StgFloat,F2,REG_F2)
247 #else
248 #define F2 (BaseReg->rF2)
249 #endif
250
251 #if defined(REG_F3) && !defined(NO_GLOBAL_REG_DECLS)
252 GLOBAL_REG_DECL(StgFloat,F3,REG_F3)
253 #else
254 #define F3 (BaseReg->rF3)
255 #endif
256
257 #if defined(REG_F4) && !defined(NO_GLOBAL_REG_DECLS)
258 GLOBAL_REG_DECL(StgFloat,F4,REG_F4)
259 #else
260 #define F4 (BaseReg->rF4)
261 #endif
262
263 #if defined(REG_D1) && !defined(NO_GLOBAL_REG_DECLS)
264 GLOBAL_REG_DECL(StgDouble,D1,REG_D1)
265 #else
266 #define D1 (BaseReg->rD1)
267 #endif
268
269 #if defined(REG_D2) && !defined(NO_GLOBAL_REG_DECLS)
270 GLOBAL_REG_DECL(StgDouble,D2,REG_D2)
271 #else
272 #define D2 (BaseReg->rD2)
273 #endif
274
275 #if defined(REG_L1) && !defined(NO_GLOBAL_REG_DECLS)
276 GLOBAL_REG_DECL(StgWord64,L1,REG_L1)
277 #else
278 #define L1 (BaseReg->rL1)
279 #endif
280
281 /*
282 * If BaseReg isn't mapped to a machine register, just use the global
283 * address of the current register table (CurrentRegTable in
284 * concurrent Haskell, MainRegTable otherwise).
285 */
286
287 /* A capability is a combination of a FunTable and a RegTable. In STG
288 * code, BaseReg normally points to the RegTable portion of this
289 * structure, so that we can index both forwards and backwards to take
290 * advantage of shorter instruction forms on some archs (eg. x86).
291 * This is a cut-down version of the Capability structure; the full
292 * version is defined in Capability.h.
293 */
294 struct PartCapability_ {
295 StgFunTable f;
296 StgRegTable r;
297 };
298
299 /* No such thing as a MainCapability under THREADED_RTS - each thread must have
300 * its own Capability.
301 */
302 #if IN_STG_CODE && !(defined(THREADED_RTS) && !defined(NOSMP))
303 extern W_ MainCapability[];
304 #endif
305
306 /*
307 * Assigning to BaseReg (the ASSIGN_BaseReg macro): this happens on
308 * return from a "safe" foreign call, when the thread might be running
309 * on a new Capability. Obviously if BaseReg is not a register, then
310 * we are restricted to a single Capability (this invariant is enforced
311 * in Capability.c:initCapabilities), and assigning to BaseReg can be omitted.
312 */
313
314 #if defined(REG_Base) && !defined(NO_GLOBAL_REG_DECLS)
315 GLOBAL_REG_DECL(StgRegTable *,BaseReg,REG_Base)
316 #define ASSIGN_BaseReg(e) (BaseReg = (e))
317 #else
318 #if defined(THREADED_RTS) && !defined(NOSMP)
319 #error BaseReg must be in a register for THREADED_RTS
320 #endif
321 #define BaseReg (&((struct PartCapability_ *)MainCapability)->r)
322 #define ASSIGN_BaseReg(e) (e)
323 #endif
324
325 #if defined(REG_Sp) && !defined(NO_GLOBAL_REG_DECLS)
326 GLOBAL_REG_DECL(P_,Sp,REG_Sp)
327 #else
328 #define Sp (BaseReg->rSp)
329 #endif
330
331 #if defined(REG_SpLim) && !defined(NO_GLOBAL_REG_DECLS)
332 GLOBAL_REG_DECL(P_,SpLim,REG_SpLim)
333 #else
334 #define SpLim (BaseReg->rSpLim)
335 #endif
336
337 #if defined(REG_Hp) && !defined(NO_GLOBAL_REG_DECLS)
338 GLOBAL_REG_DECL(P_,Hp,REG_Hp)
339 #else
340 #define Hp (BaseReg->rHp)
341 #endif
342
343 #if defined(REG_HpLim) && !defined(NO_GLOBAL_REG_DECLS)
344 #error HpLim cannot be in a register
345 #else
346 #define HpLim (BaseReg->rHpLim)
347 #endif
348
349 #if defined(REG_CCCS) && !defined(NO_GLOBAL_REG_DECLS)
350 GLOBAL_REG_DECL(struct CostCentreStack_ *,CCCS,REG_CCCS)
351 #else
352 #define CCCS (BaseReg->rCCCS)
353 #endif
354
355 #if defined(REG_CurrentTSO) && !defined(NO_GLOBAL_REG_DECLS)
356 GLOBAL_REG_DECL(struct _StgTSO *,CurrentTSO,REG_CurrentTSO)
357 #else
358 #define CurrentTSO (BaseReg->rCurrentTSO)
359 #endif
360
361 #if defined(REG_CurrentNursery) && !defined(NO_GLOBAL_REG_DECLS)
362 GLOBAL_REG_DECL(bdescr *,CurrentNursery,REG_CurrentNursery)
363 #else
364 #define CurrentNursery (BaseReg->rCurrentNursery)
365 #endif
366
367 #if defined(REG_HpAlloc) && !defined(NO_GLOBAL_REG_DECLS)
368 GLOBAL_REG_DECL(bdescr *,HpAlloc,REG_HpAlloc)
369 #else
370 #define HpAlloc (BaseReg->rHpAlloc)
371 #endif
372
373 /* -----------------------------------------------------------------------------
374 Get absolute function pointers from the register table, to save
375 code space. On x86,
376
377 jmp *-12(%ebx)
378
379 is shorter than
380
381 jmp absolute_address
382
383 as long as the offset is within the range of a signed byte
384 (-128..+127). So we pick some common absolute_addresses and put
385 them in the register table. As a bonus, linking time should also
386 be reduced.
387
388 Other possible candidates in order of importance:
389
390 stg_upd_frame_info
391 stg_CAF_BLACKHOLE_info
392 stg_IND_STATIC_info
393
394 anything else probably isn't worth the effort.
395
396 -------------------------------------------------------------------------- */
397
398
399 #define FunReg ((StgFunTable *)((void *)BaseReg - STG_FIELD_OFFSET(struct PartCapability_, r)))
400
401 #define stg_EAGER_BLACKHOLE_info (FunReg->stgEagerBlackholeInfo)
402 #define stg_gc_enter_1 (FunReg->stgGCEnter1)
403 #define stg_gc_fun (FunReg->stgGCFun)
404
405 /* -----------------------------------------------------------------------------
406 For any registers which are denoted "caller-saves" by the C calling
407 convention, we have to emit code to save and restore them across C
408 calls.
409 -------------------------------------------------------------------------- */
410
411 #ifdef CALLER_SAVES_R1
412 #define CALLER_SAVE_R1 SAVE_R1 = R1;
413 #define CALLER_RESTORE_R1 R1 = SAVE_R1;
414 #else
415 #define CALLER_SAVE_R1 /* nothing */
416 #define CALLER_RESTORE_R1 /* nothing */
417 #endif
418
419 #ifdef CALLER_SAVES_R2
420 #define CALLER_SAVE_R2 SAVE_R2 = R2;
421 #define CALLER_RESTORE_R2 R2 = SAVE_R2;
422 #else
423 #define CALLER_SAVE_R2 /* nothing */
424 #define CALLER_RESTORE_R2 /* nothing */
425 #endif
426
427 #ifdef CALLER_SAVES_R3
428 #define CALLER_SAVE_R3 SAVE_R3 = R3;
429 #define CALLER_RESTORE_R3 R3 = SAVE_R3;
430 #else
431 #define CALLER_SAVE_R3 /* nothing */
432 #define CALLER_RESTORE_R3 /* nothing */
433 #endif
434
435 #ifdef CALLER_SAVES_R4
436 #define CALLER_SAVE_R4 SAVE_R4 = R4;
437 #define CALLER_RESTORE_R4 R4 = SAVE_R4;
438 #else
439 #define CALLER_SAVE_R4 /* nothing */
440 #define CALLER_RESTORE_R4 /* nothing */
441 #endif
442
443 #ifdef CALLER_SAVES_R5
444 #define CALLER_SAVE_R5 SAVE_R5 = R5;
445 #define CALLER_RESTORE_R5 R5 = SAVE_R5;
446 #else
447 #define CALLER_SAVE_R5 /* nothing */
448 #define CALLER_RESTORE_R5 /* nothing */
449 #endif
450
451 #ifdef CALLER_SAVES_R6
452 #define CALLER_SAVE_R6 SAVE_R6 = R6;
453 #define CALLER_RESTORE_R6 R6 = SAVE_R6;
454 #else
455 #define CALLER_SAVE_R6 /* nothing */
456 #define CALLER_RESTORE_R6 /* nothing */
457 #endif
458
459 #ifdef CALLER_SAVES_R7
460 #define CALLER_SAVE_R7 SAVE_R7 = R7;
461 #define CALLER_RESTORE_R7 R7 = SAVE_R7;
462 #else
463 #define CALLER_SAVE_R7 /* nothing */
464 #define CALLER_RESTORE_R7 /* nothing */
465 #endif
466
467 #ifdef CALLER_SAVES_R8
468 #define CALLER_SAVE_R8 SAVE_R8 = R8;
469 #define CALLER_RESTORE_R8 R8 = SAVE_R8;
470 #else
471 #define CALLER_SAVE_R8 /* nothing */
472 #define CALLER_RESTORE_R8 /* nothing */
473 #endif
474
475 #ifdef CALLER_SAVES_R9
476 #define CALLER_SAVE_R9 SAVE_R9 = R9;
477 #define CALLER_RESTORE_R9 R9 = SAVE_R9;
478 #else
479 #define CALLER_SAVE_R9 /* nothing */
480 #define CALLER_RESTORE_R9 /* nothing */
481 #endif
482
483 #ifdef CALLER_SAVES_R10
484 #define CALLER_SAVE_R10 SAVE_R10 = R10;
485 #define CALLER_RESTORE_R10 R10 = SAVE_R10;
486 #else
487 #define CALLER_SAVE_R10 /* nothing */
488 #define CALLER_RESTORE_R10 /* nothing */
489 #endif
490
491 #ifdef CALLER_SAVES_F1
492 #define CALLER_SAVE_F1 SAVE_F1 = F1;
493 #define CALLER_RESTORE_F1 F1 = SAVE_F1;
494 #else
495 #define CALLER_SAVE_F1 /* nothing */
496 #define CALLER_RESTORE_F1 /* nothing */
497 #endif
498
499 #ifdef CALLER_SAVES_F2
500 #define CALLER_SAVE_F2 SAVE_F2 = F2;
501 #define CALLER_RESTORE_F2 F2 = SAVE_F2;
502 #else
503 #define CALLER_SAVE_F2 /* nothing */
504 #define CALLER_RESTORE_F2 /* nothing */
505 #endif
506
507 #ifdef CALLER_SAVES_F3
508 #define CALLER_SAVE_F3 SAVE_F3 = F3;
509 #define CALLER_RESTORE_F3 F3 = SAVE_F3;
510 #else
511 #define CALLER_SAVE_F3 /* nothing */
512 #define CALLER_RESTORE_F3 /* nothing */
513 #endif
514
515 #ifdef CALLER_SAVES_F4
516 #define CALLER_SAVE_F4 SAVE_F4 = F4;
517 #define CALLER_RESTORE_F4 F4 = SAVE_F4;
518 #else
519 #define CALLER_SAVE_F4 /* nothing */
520 #define CALLER_RESTORE_F4 /* nothing */
521 #endif
522
523 #ifdef CALLER_SAVES_D1
524 #define CALLER_SAVE_D1 SAVE_D1 = D1;
525 #define CALLER_RESTORE_D1 D1 = SAVE_D1;
526 #else
527 #define CALLER_SAVE_D1 /* nothing */
528 #define CALLER_RESTORE_D1 /* nothing */
529 #endif
530
531 #ifdef CALLER_SAVES_D2
532 #define CALLER_SAVE_D2 SAVE_D2 = D2;
533 #define CALLER_RESTORE_D2 D2 = SAVE_D2;
534 #else
535 #define CALLER_SAVE_D2 /* nothing */
536 #define CALLER_RESTORE_D2 /* nothing */
537 #endif
538
539 #ifdef CALLER_SAVES_L1
540 #define CALLER_SAVE_L1 SAVE_L1 = L1;
541 #define CALLER_RESTORE_L1 L1 = SAVE_L1;
542 #else
543 #define CALLER_SAVE_L1 /* nothing */
544 #define CALLER_RESTORE_L1 /* nothing */
545 #endif
546
547 #ifdef CALLER_SAVES_Sp
548 #define CALLER_SAVE_Sp SAVE_Sp = Sp;
549 #define CALLER_RESTORE_Sp Sp = SAVE_Sp;
550 #else
551 #define CALLER_SAVE_Sp /* nothing */
552 #define CALLER_RESTORE_Sp /* nothing */
553 #endif
554
555 #ifdef CALLER_SAVES_SpLim
556 #define CALLER_SAVE_SpLim SAVE_SpLim = SpLim;
557 #define CALLER_RESTORE_SpLim SpLim = SAVE_SpLim;
558 #else
559 #define CALLER_SAVE_SpLim /* nothing */
560 #define CALLER_RESTORE_SpLim /* nothing */
561 #endif
562
563 #ifdef CALLER_SAVES_Hp
564 #define CALLER_SAVE_Hp SAVE_Hp = Hp;
565 #define CALLER_RESTORE_Hp Hp = SAVE_Hp;
566 #else
567 #define CALLER_SAVE_Hp /* nothing */
568 #define CALLER_RESTORE_Hp /* nothing */
569 #endif
570
571 #ifdef CALLER_SAVES_Base
572 #ifdef THREADED_RTS
573 #error "Can't have caller-saved BaseReg with THREADED_RTS"
574 #endif
575 #define CALLER_SAVE_Base /* nothing */
576 #define CALLER_RESTORE_Base BaseReg = &MainRegTable;
577 #else
578 #define CALLER_SAVE_Base /* nothing */
579 #define CALLER_RESTORE_Base /* nothing */
580 #endif
581
582 #ifdef CALLER_SAVES_CurrentTSO
583 #define CALLER_SAVE_CurrentTSO SAVE_CurrentTSO = CurrentTSO;
584 #define CALLER_RESTORE_CurrentTSO CurrentTSO = SAVE_CurrentTSO;
585 #else
586 #define CALLER_SAVE_CurrentTSO /* nothing */
587 #define CALLER_RESTORE_CurrentTSO /* nothing */
588 #endif
589
590 #ifdef CALLER_SAVES_CurrentNursery
591 #define CALLER_SAVE_CurrentNursery SAVE_CurrentNursery = CurrentNursery;
592 #define CALLER_RESTORE_CurrentNursery CurrentNursery = SAVE_CurrentNursery;
593 #else
594 #define CALLER_SAVE_CurrentNursery /* nothing */
595 #define CALLER_RESTORE_CurrentNursery /* nothing */
596 #endif
597
598 #ifdef CALLER_SAVES_HpAlloc
599 #define CALLER_SAVE_HpAlloc SAVE_HpAlloc = HpAlloc;
600 #define CALLER_RESTORE_HpAlloc HpAlloc = SAVE_HpAlloc;
601 #else
602 #define CALLER_SAVE_HpAlloc /* nothing */
603 #define CALLER_RESTORE_HpAlloc /* nothing */
604 #endif
605
606 #endif /* IN_STG_CODE */
607
608 /* ----------------------------------------------------------------------------
609 Handy bunches of saves/restores
610 ------------------------------------------------------------------------ */
611
612 #if IN_STG_CODE
613
614 #define CALLER_SAVE_USER \
615 CALLER_SAVE_R1 \
616 CALLER_SAVE_R2 \
617 CALLER_SAVE_R3 \
618 CALLER_SAVE_R4 \
619 CALLER_SAVE_R5 \
620 CALLER_SAVE_R6 \
621 CALLER_SAVE_R7 \
622 CALLER_SAVE_R8 \
623 CALLER_SAVE_R9 \
624 CALLER_SAVE_R10 \
625 CALLER_SAVE_F1 \
626 CALLER_SAVE_F2 \
627 CALLER_SAVE_F3 \
628 CALLER_SAVE_F4 \
629 CALLER_SAVE_D1 \
630 CALLER_SAVE_D2 \
631 CALLER_SAVE_L1
632
633 /* Save Base last, since the others may
634 be addressed relative to it */
635 #define CALLER_SAVE_SYSTEM \
636 CALLER_SAVE_Sp \
637 CALLER_SAVE_SpLim \
638 CALLER_SAVE_Hp \
639 CALLER_SAVE_CurrentTSO \
640 CALLER_SAVE_CurrentNursery \
641 CALLER_SAVE_Base
642
643 #define CALLER_RESTORE_USER \
644 CALLER_RESTORE_R1 \
645 CALLER_RESTORE_R2 \
646 CALLER_RESTORE_R3 \
647 CALLER_RESTORE_R4 \
648 CALLER_RESTORE_R5 \
649 CALLER_RESTORE_R6 \
650 CALLER_RESTORE_R7 \
651 CALLER_RESTORE_R8 \
652 CALLER_RESTORE_R9 \
653 CALLER_RESTORE_R10 \
654 CALLER_RESTORE_F1 \
655 CALLER_RESTORE_F2 \
656 CALLER_RESTORE_F3 \
657 CALLER_RESTORE_F4 \
658 CALLER_RESTORE_D1 \
659 CALLER_RESTORE_D2 \
660 CALLER_RESTORE_L1
661
662 /* Restore Base first, since the others may
663 be addressed relative to it */
664 #define CALLER_RESTORE_SYSTEM \
665 CALLER_RESTORE_Base \
666 CALLER_RESTORE_Sp \
667 CALLER_RESTORE_SpLim \
668 CALLER_RESTORE_Hp \
669 CALLER_RESTORE_CurrentTSO \
670 CALLER_RESTORE_CurrentNursery
671
672 #else /* not IN_STG_CODE */
673
674 #define CALLER_SAVE_USER /* nothing */
675 #define CALLER_SAVE_SYSTEM /* nothing */
676 #define CALLER_RESTORE_USER /* nothing */
677 #define CALLER_RESTORE_SYSTEM /* nothing */
678
679 #endif /* IN_STG_CODE */
680 #define CALLER_SAVE_ALL \
681 CALLER_SAVE_SYSTEM \
682 CALLER_SAVE_USER
683
684 #define CALLER_RESTORE_ALL \
685 CALLER_RESTORE_SYSTEM \
686 CALLER_RESTORE_USER
687
688 #endif /* REGS_H */