1 \section[COptWraps]{Wrappers for calls to ``STG C'' routines}
3 % this file is part of the C-as-assembler document
10 %************************************************************************
12 \subsection[COptWraps-portable]{Wrappers for ``portable~C''}
14 %************************************************************************
16 @STGCALL@ macros are used when we really have to be careful about saving
17 any caller-saves STG registers. @SAFESTGCALL@ macros are used
18 when the caller has previously arranged to save/restore volatile user
19 registers (vanilla, float, and double STG registers), and we only have to
20 worry about the ``system'' registers (stack and heap pointers, @STK_STUB@,
21 etc.). @STGCALL_GC@ macros are used whenever the callee is going to
22 need to access (and perhaps modify) some STG registers. @ULTRASAFESTGCALL@
23 is available for our own routines that we are absolutely certain will not
24 damage any STG registers.
28 \item @STGCALL@ saves/restores all caller-saves STG registers.
29 \item @SAFESTGCALL@ saves/restores only caller-saves STG ``system'' registers.
30 \item @ULTRASAFECALL@ is a simple call, without a wrapper.
31 \item @STGCALL_GC@ saves/restores {\em all} STG registers.
34 Several macros are provided to handle outcalls to functions requiring from
35 one to five arguments. (If we could assume GCC, we could use macro varargs,
36 but unfortunately, we have to cater to ANSI C as well.)
40 #define ULTRASAFESTGCALL0(t,p,f) f()
41 #define ULTRASAFESTGCALL1(t,p,f,a) f(a)
42 #define ULTRASAFESTGCALL2(t,p,f,a,b) f(a,b)
43 #define ULTRASAFESTGCALL3(t,p,f,a,b,c) f(a,b,c)
44 #define ULTRASAFESTGCALL4(t,p,f,a,b,c,d) f(a,b,c,d)
45 #define ULTRASAFESTGCALL5(t,p,f,a,b,c,d,e) f(a,b,c,d,e)
47 #if ! (defined(__GNUC__) && defined(__STG_GCC_REGS__))
49 #define STGCALL0(t,p,f) f()
50 #define STGCALL1(t,p,f,a) f(a)
51 #define STGCALL2(t,p,f,a,b) f(a,b)
52 #define STGCALL3(t,p,f,a,b,c) f(a,b,c)
53 #define STGCALL4(t,p,f,a,b,c,d) f(a,b,c,d)
54 #define STGCALL5(t,p,f,a,b,c,d,e) f(a,b,c,d,e)
56 #define SAFESTGCALL0(t,p,f) f()
57 #define SAFESTGCALL1(t,p,f,a) f(a)
58 #define SAFESTGCALL2(t,p,f,a,b) f(a,b)
59 #define SAFESTGCALL3(t,p,f,a,b,c) f(a,b,c)
60 #define SAFESTGCALL4(t,p,f,a,b,c,d) f(a,b,c,d)
61 #define SAFESTGCALL5(t,p,f,a,b,c,d,e) f(a,b,c,d,e)
64 * Generic call_GC wrappers have gone away in favor of these partially
69 do {SaveAllStgRegs(); PerformGC(args); RestoreAllStgRegs();} while(0)
70 #define DO_STACKOVERFLOW(headroom,args) \
71 do {SaveAllStgRegs(); StackOverflow(headroom,args); RestoreAllStgRegs();} while(0)
75 #define DO_YIELD(args) DO_GRAN_YIELD(args)
76 #define DO_GRAN_YIELD(liveness) \
77 do {SaveAllStgRegs(); Yield(liveness); RestoreAllStgRegs();} while(0)
79 #define DO_PERFORM_RESCHEDULE(liveness_mask,reenter) \
80 do {SaveAllStgRegs(); PerformReschedule(liveness_mask,reenter); RestoreAllStgRegs();} while(0)
84 #define DO_YIELD(args) \
85 do {SaveAllStgRegs(); Yield(args); RestoreAllStgRegs();} while(0)
91 %************************************************************************
93 \subsection[COptWraps-optimised]{Wrappers in ``optimised~C''}
95 %************************************************************************
97 We {\em expect} the call-wrappery to be boring---the defaults shown
98 herein will kick in--- but you never know.
100 For example: Don't try an @STGCALL6@ on a SPARC! That's because you
101 cannot pass that many arguments to \tr{f} just by heaving them into
102 \tr{%o*} registers; anything else is too painful to contemplate.
105 #else /* __GNUC__ && __STG_GCC_REGS__ */
107 #if !(defined(CALLER_SAVES_SYSTEM) || defined(CALLER_SAVES_USER))
108 #define STGCALL0(t,p,f) f()
109 #define STGCALL1(t,p,f,a) f(a)
110 #define STGCALL2(t,p,f,a,b) f(a,b)
111 #define STGCALL3(t,p,f,a,b,c) f(a,b,c)
112 #define STGCALL4(t,p,f,a,b,c,d) f(a,b,c,d)
113 #define STGCALL5(t,p,f,a,b,c,d,e) f(a,b,c,d,e)
117 extern void callWrapper(STG_NO_ARGS);
119 #define STGCALL0(t,p,f) \
120 ({t (*_w)p = (t (*)p) callWrapper; (*_w)((void *)f);})
122 #define STGCALL1(t,p,f,a) \
123 ({t (*_w)p = (t (*)p) callWrapper; (*_w)((void *)f,a);})
125 #define STGCALL2(t,p,f,a,b) \
126 ({t (*_w)p = (t (*)p) callWrapper; (*_w)((void *)f,a,b);})
128 #define STGCALL3(t,p,f,a,b,c) \
129 ({t (*_w)p = (t (*)p) callWrapper; (*_w)((void *)f,a,b,c);})
131 #define STGCALL4(t,p,f,a,b,c,d) \
132 ({t (*_w)p = (t (*)p) callWrapper; (*_w)((void *)f,a,b,c,d);})
134 #define STGCALL5(t,p,f,a,b,c,d,e) \
135 ({t (*_w)p = (t (*)p) callWrapper; (*_w)((void *)f,a,b,c,d,e);})
139 #if !defined(CALLER_SAVES_SYSTEM)
140 #define SAFESTGCALL0(t,p,f) f()
141 #define SAFESTGCALL1(t,p,f,a) f(a)
142 #define SAFESTGCALL2(t,p,f,a,b) f(a,b)
143 #define SAFESTGCALL3(t,p,f,a,b,c) f(a,b,c)
144 #define SAFESTGCALL4(t,p,f,a,b,c,d) f(a,b,c,d)
145 #define SAFESTGCALL5(t,p,f,a,b,c,d,e) f(a,b,c,d,e)
149 extern void callWrapper_safe(STG_NO_ARGS);
151 #define SAFESTGCALL0(t,p,f) \
152 ({t (*_w)p = (t (*)p) callWrapper_safe; (*_w)((void *)f);})
154 #define SAFESTGCALL1(t,p,f,a) \
155 ({t (*_w)p = (t (*)p) callWrapper_safe; (*_w)((void *)f,a);})
157 #define SAFESTGCALL2(t,p,f,a,b) \
158 ({t (*_w)p = (t (*)p) callWrapper_safe; (*_w)((void *)f,a,b);})
160 #define SAFESTGCALL3(t,p,f,a,b,c) \
161 ({t (*_w)p = (t (*)p) callWrapper_safe; (*_w)((void *)f,a,b,c);})
163 #define SAFESTGCALL4(t,p,f,a,b,c,d) \
164 ({t (*_w)p = (t (*)p) callWrapper_safe; (*_w)((void *)f,a,b,c,d);})
166 #define SAFESTGCALL5(t,p,f,a,b,c,d,e) \
167 ({t (*_w)p = (t (*)p) callWrapper_safe; (*_w)((void *)f,a,b,c,d,e);})
172 * Generic call_GC wrappers have gone away in favor of these partially
173 * evaluated versions. These are only here so that we can avoid putting
174 * all of the STG register save/restore code at each call site.
177 #ifndef CALLWRAPPER_C
179 * We may have funny declarations in CallWrapper_C, to avoid sliding the
180 * register windows and other nastiness.
182 void PerformGC_wrapper PROTO((W_));
183 void StackOverflow_wrapper PROTO((W_, W_));
184 void Yield_wrapper PROTO((W_));
186 void PerformReschedule_wrapper PROTO((W_, W_));
187 void GranSimAllocate_wrapper PROTO((I_, P_, W_));
188 void GranSimUnallocate_wrapper PROTO((I_, P_, W_));
189 void GranSimFetch_wrapper PROTO((P_));
190 void GranSimExec_wrapper PROTO((W_, W_, W_, W_, W_));
194 #define DO_GC(args) PerformGC_wrapper(args)
195 #define DO_STACKOVERFLOW(headroom,args) StackOverflow_wrapper(headroom,args)
199 #define DO_YIELD(args) DO_GRAN_YIELD(args)
200 #define DO_GRAN_YIELD(liveness) Yield_wrapper(liveness)
202 #define DO_PERFORMRESCHEDULE(liveness, always_reenter_node) PerformReschedule_wrapper(liveness, always_reenter_node)
203 #define DO_GRANSIMALLOCATE(n, node, liveness) GranSimAllocate_wrapper(n, node, liveness)
204 #define DO_GRANSIMUNALLOCATE(n, node, liveness) GranSimUnallocate_wrapper(n, node, liveness)
205 #define DO_GRANSIMFETCH(node) GranSimFetch_wrapper(node)
206 #define DO_GRANSIMEXEC(arith,branch,load,store,floats) GranSimExec_wrapper(arith,branch,load,store,floats)
210 #define DO_YIELD(args) Yield_wrapper(args)
214 #endif /* __GNUC__ && __STG_GCC_REGS__ */
217 %************************************************************************
219 \subsection[COptWraps-magic]{Magic assembly bits for call wrappers}
221 %************************************************************************
223 Call wrappers need to be able to call arbitrary functions, regardless of
224 their arguments and return types. (Okay, we actually only allow up to
225 five arguments, because on the SPARC it gets more complicated to handle
226 any more.) The nasty bit is that the return value can be in either an
227 integer register or a floating point register, and we don't know which.
228 (We {\em don't} handle structure returns, and we don't want to.)
229 Still, we have to stash the result away while we restore caller-saves
230 STG registers, and then we have to pass the result back to our caller
233 Getting this right requires three extremely @MAGIC@ macros, no doubt
234 chock full of assembly gook for the current platform. These are
235 @MAGIC_CALL_SETUP@, which gets ready for one of these magic calls,
236 @MAGIC_CALL@, which performs the call and stashes away all possible
237 results, and @MAGIC_RETURN@, which collects all possible results back
240 For example, in the SPARC version, the @SETUP@ guarantees that we
241 have enough space to store all of our argument registers for a wee
242 bit, and it gives a `C' name to the register that we're going to use
243 for the call. (It helps to do the call in actual `C' fashion, so that
244 gcc knows about register death.) It also stashes the incoming arguments
245 in the space provided. The @MAGIC_CALL@ then reloads the argument
246 registers, rotated by one, so that the function to call is in \tr{%o5},
247 calls the function in `C' fashion, and stashes away the possible return
248 values (either \tr{%o0} or \tr{%f0}) on the stack. Finally, @MAGIC_RETURN@
249 ensures that \tr{%o0} and \tr{%f0} are both set to the values we stashed
250 away. Presumably, we then fall into a return instruction and our caller
251 gets whatever it's after.
253 %************************************************************************
255 \subsubsection[alpha-magic]{Call-wrapper MAGIC for DEC Alpha}
257 %************************************************************************
261 #if defined(__GNUC__) && defined(__STG_GCC_REGS__)
263 #if alpha_TARGET_ARCH
265 #define MAGIC_CALL_SETUP \
266 long WeNeedThisSpace[7]; \
267 double AndThisSpaceToo[6]; \
268 register void (*f)() __asm__("$21");\
271 "\tstq $17,16($30)\n" \
272 "\tstq $18,24($30)\n" \
273 "\tstq $19,32($30)\n" \
274 "\tstq $20,40($30)\n" \
275 "\tstq $21,48($30)\n" \
276 "\tstt $f16,56($30)\n" \
277 "\tstt $f17,64($30)\n" \
278 "\tstt $f18,72($30)\n" \
279 "\tstt $f19,80($30)\n" \
280 "\tstt $f20,88($30)\n" \
281 "\tstt $f21,96($30)");
286 "\tldq $16,16($30)\n" \
287 "\tldq $17,24($30)\n" \
288 "\tldq $18,32($30)\n" \
289 "\tldq $19,40($30)\n" \
290 "\tldq $20,48($30)\n" \
291 "\tldt $f16,56($30)\n" \
292 "\tldt $f17,64($30)\n" \
293 "\tldt $f18,72($30)\n" \
294 "\tldt $f19,80($30)\n" \
295 "\tldt $f20,88($30)\n" \
296 "\tldt $f21,96($30)");\
300 "\tstt $f0,16($30)");
302 #define MAGIC_RETURN \
305 "\tldt $f0,16($30)");
307 #define WRAPPER_NAME(f) /* nothing */
310 Threaded code needs to be able to grab the return address, in case we have
311 an intervening context switch.
314 #define SET_RETADDR(loc) { register StgFunPtrFunPtr ra __asm__ ("$26"); loc = ra; }
316 #define WRAPPER_SETUP(f,ignore1,ignore2) SaveAllStgContext();
318 #define WRAPPER_RETURN(x) \
319 do {RestoreAllStgRegs(); if(x) JMP_(EnterNodeCode);} while(0);
321 #define SEPARATE_WRAPPER_RESTORE /* none */
327 %************************************************************************
329 \subsubsection[hppa-magic]{Call-wrapper MAGIC for HP-PA}
331 %************************************************************************
335 #if hppa1_1_TARGET_ARCH
337 #define MAGIC_CALL_SETUP \
338 long SavedIntArgRegs[4]; \
339 double SavedFltArgRegs[2]; \
340 register void (*f)() __asm__("%r28");\
343 "\tstw %r25,8(0,%r3)\n" \
344 "\tstw %r24,12(0,%r3)\n" \
345 "\tstw %r23,16(0,%r3)\n" \
346 "\tldo 40(%r3),%r19\n" \
347 "\tfstds %fr5,-16(0,%r19)\n"\
348 "\tfstds %fr7, -8(0,%r19)\n");
353 "ldw 8(0,%r3),%r26\n" \
354 "\tldw 12(0,%r3),%r25\n" \
355 "\tldw 16(0,%r3),%r24\n" \
356 "\tldw -52(0,%r3),%r23\n" \
357 "\tldw -56(0,%r3),%r19\n" \
358 "\tstw %r19,-52(0,%r30)\n" \
359 "\tldo 40(%r3),%r19\n" \
360 "\tfldds -16(0,%r19),%fr5\n"\
361 "\tfldds -8(0,%r19),%fr7\n" \
362 "\tldo -64(%r3),%r19\n" \
363 "\tldo -64(%r30),%r20\n" \
364 "\tfldds -16(0,%r19),%fr4\n"\
365 "\tfstds %fr4,-16(0,%r20)\n"\
366 "\tfldds -8(0,%r19)%fr4\n" \
367 "\tfstds %fr4,-8(0,%r19)\n" \
368 "\tfldds 0(0,%r19),%fr4\n" \
369 "\tfstds %fr4,0(0,%r19)\n" \
370 "\tfldds 8(0,%r19),%fr4\n" \
371 "\tfstds %fr4,8(0,%r19)\n");\
374 "stw %r28,8(0,%r3)\n" \
375 "\tfstds %fr4,16(0,%r3)");
377 #define MAGIC_RETURN \
379 "\tfldds 16(0,%r3),%fr4" \
380 "ldw 8(0,%r3),%r28\n");
382 #define WRAPPER_NAME(f) /* nothing */
385 Threaded code needs to be able to grab the return address, in case we have
386 an intervening context switch.
389 #define SET_RETADDR(loc) __asm__ volatile ("stw %%r2, %0" : "=m" ((void *)(loc)));
391 #define WRAPPER_SETUP(f,ignore1,ignore2) SaveAllStgContext();
393 #define WRAPPER_RETURN(x) \
394 do {RestoreAllStgRegs(); if(x) JMP_(EnterNodeCode);} while(0);
396 #define SEPARATE_WRAPPER_RESTORE /* none */
402 %************************************************************************
404 \subsubsection[iX86-magic]{Call-wrapper MAGIC for iX86}
406 %************************************************************************
411 /* modelled loosely on SPARC stuff */
413 /* NB: no MAGIC_CALL_SETUP, MAGIC_CALL, or MAGIC_RETURN! */
415 #define WRAPPER_NAME(f) /*nothing*/
417 #if defined(solaris2_TARGET_OS) || defined(linux_TARGET_OS)
418 #define REAL_NAME(f) #f
420 #define REAL_NAME(f) "_" #f
424 Threaded code needs to be able to grab the return address, in case we have
425 an intervening context switch.
428 #define SET_RETADDR(loc,val) loc = val;
430 /* the grab-%eax-quickly HACK is here because we use a VERY SPECIAL
431 calling convention on iX86 just for calling PerformGC_wrapper.
434 NB: mangler makes sure that __temp_{eax,esp} get loaded.
435 (This is about as ugly as it can get.)
438 #define WRAPPER_SETUP(f,ret_addr,args) \
440 "movl " REAL_NAME(__temp_esp) ",%%edx\n" \
441 "\tmovl (%%edx),%0\n" \
442 "\tmovl " REAL_NAME(__temp_eax) ",%1" \
443 : "=r" (ret_addr), "=r" (args) ); \
444 SaveAllStgContext(ret_addr);
446 /* Note re WRAPPER_SETUP: we have special code just for PerformGC_wrapper;
447 pls see its definition. WDP 95/09
449 Also note the EXTREMELY UGLY slamming in of an "sp_offset"; the
450 return address *is* on the stack, but it is hard to get there
451 before GCC has moved the sp pointer... WDP 95/11
454 #define WRAPPER_RETURN(x) \
455 do {RestoreAllStgRegs(); if(x) JMP_(EnterNodeCode);} while(0);
457 #define SEPARATE_WRAPPER_RESTORE /* none */
462 %************************************************************************
464 \subsubsection[m68k-magic]{Call-wrapper MAGIC for m68k}
466 %************************************************************************
472 #define MAGIC_CALL_SETUP \
473 int WeNeedThisSpace[5]; \
474 register void (*f)() __asm__("a0"); \
476 "movel a6@(8),a0\n" \
477 "\tmovel a6@(12),a6@(-20)\n" \
478 "\tmovel a6@(16),a6@(-16)\n" \
479 "\tmovel a6@(20),a6@(-12)\n" \
480 "\tmovel a6@(24),a6@(-8)\n" \
481 "\tmovel a6@(28),a6@(-4)");
489 #define MAGIC_RETURN \
494 #define WRAPPER_NAME(f) /* nothing */
496 #define WRAPPER_SETUP(f,ignore1,ignore2) SaveAllStgContext();
498 #define WRAPPER_RETURN(x) \
499 do {RestoreAllStgRegs(); if(x) JMP_(EnterNodeCode);} while(0);
501 #define SEPARATE_WRAPPER_RESTORE /* none */
503 #endif /* __mc680x0__ */
507 %************************************************************************
509 \subsubsection[mips-magic]{Call-wrapper MAGIC for MIPS}
511 %************************************************************************
514 #if mipseb_TARGET_ARCH || mipsel_TARGET_ARCH
516 /* shift 4 arg registers down one */
518 #define MAGIC_CALL_SETUP \
519 register void (*f)() __asm__("$2"); \
525 "\tlw $7,16($sp)\n" \
526 "\taddu $sp,$sp,4\n" \
533 "\ts.d $f0, -8($sp)\n" \
534 "\tsw $2, -12($sp)");
536 #define MAGIC_RETURN \
538 "l.d $f0, -8($sp)\n" \
539 "\tlw $2, -12($sp)");
541 #define WRAPPER_NAME(f) /* nothing */
543 #define WRAPPER_SETUP(f,ignore1,ignore2) SaveAllStgContext();
545 #define WRAPPER_RETURN(x) \
546 do {RestoreAllStgRegs(); if(x) JMP_(EnterNodeCode);} while(0);
548 #define SEPARATE_WRAPPER_RESTORE /* none */
553 %************************************************************************
555 \subsubsection[powerpc-magic]{Call-wrapper MAGIC for PowerPC}
557 %************************************************************************
560 #if powerpc_TARGET_ARCH
562 /* shift 4 arg registers down one */
564 #define MAGIC_CALL_SETUP \
565 register void (*f)() __asm__("$2"); \
571 "\tlw $7,16($sp)\n" \
572 "\taddu $sp,$sp,4\n" \
579 "\ts.d $f0, -8($sp)\n" \
580 "\tsw $2, -12($sp)");
582 #define MAGIC_RETURN \
584 "l.d $f0, -8($sp)\n" \
585 "\tlw $2, -12($sp)");
587 #define WRAPPER_NAME(f) /* nothing */
589 #define WRAPPER_SETUP(f,ignore1,ignore2) SaveAllStgContext();
591 /* we have to make sure the STG registers are restored.
592 GCC tries to restore the value the registers had in
593 the beginning of the current call, which we don't want.
594 We defeat it by saving the registers in the stack again. :-( */
596 #define WRAPPER_RETURN(x) \
597 do {RestoreAllStgRegs(); if(x) JMP_(EnterNodeCode);} while(0); \
600 "\tstm 13,-76(1)\n" \
603 #define SEPARATE_WRAPPER_RESTORE /* none */
608 %************************************************************************
610 \subsubsection[sparc-magic]{Call-wrapper MAGIC for SPARC}
612 %************************************************************************
615 #if sparc_TARGET_ARCH
617 #define MAGIC_CALL_SETUP \
618 int WeNeedThisSpace[6]; \
619 register void (*f)() __asm__("%o5");\
621 "std %i0,[%fp-40]\n" \
622 "\tstd %i2,[%fp-32]\n" \
623 "\tstd %i4,[%fp-24]");
625 /* Lest GCC attempt to stick something in
626 the delay slot: with compile with
627 -fno-delayed-branch. A weak solution. WDP 96/07
631 "ld [%%fp-40],%%o5\n" \
632 "\tld [%%fp-36],%%o0\n" \
633 "\tld [%%fp-32],%%o1\n" \
634 "\tld [%%fp-28],%%o2\n" \
635 "\tld [%%fp-24],%%o3\n" \
636 "\tld [%%fp-20],%%o4" \
637 : : : "%o0", "%o1", "%o2", "%o3", "%o4", "%o5");\
640 "std %f0,[%fp-40]\n" \
641 "\tstd %o0,[%fp-32]");
643 /* We leave nothing to chance here; we have seen
644 GCC stick "unwanted" code in the branch delay
645 slot, causing mischief (WDP 96/05)
647 /* the problem with this one: GCC has no way of
648 knowing there is a "call" in there, so it
649 does not do any calling-convention stuff
650 (e.g., saving used regs). WDP 96/07
654 "ld [%%fp-40],%%o5\n" \
655 "\tld [%%fp-36],%%o0\n" \
656 "\tld [%%fp-32],%%o1\n" \
657 "\tld [%%fp-28],%%o2\n" \
658 "\tld [%%fp-24],%%o3\n" \
659 "\tld [%%fp-20],%%o4\n" \
662 "\tstd %%f0,[%%fp-40]\n"\
663 "\tstd %%o0,[%%fp-32]" \
664 : : : "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", "%f0", "memory");
667 #define MAGIC_RETURN \
669 "ldd [%fp-40],%f0\n" \
670 "\tldd [%fp-32],%i0");
673 We rename the entry points for wrappers so that we can introduce a
674 new entry point after the prologue. We want to ensure that the
675 register window does not slide! However, we insert a call to
676 abort() to make gcc _believe_ that the window slid.
679 #define WRAPPER_NAME(f) __asm__("L" #f "_wrapper")
681 #ifdef solaris2_TARGET_OS
682 #define REAL_NAME(f) #f
684 #define REAL_NAME(f) "_" #f
687 #define WRAPPER_SETUP(f,ignore1,ignore2) \
689 ".global " REAL_NAME(f) "_wrapper\n"\
690 REAL_NAME(f) "_wrapper:\n" \
691 "\tstd %o0,[%sp-24]\n" \
693 SaveAllStgContext(); \
695 "ldd [%sp-24],%i0\n" \
699 * In the above, we want to ensure that the arguments are both in the
700 * %i registers and the %o registers, with the assumption that gcc
701 * will expect them now to be in one or the other. This is a terrible
706 Threaded code needs to be able to grab the return address, in case
707 we have an intervening context switch. Note that we want the
708 address of the next instruction to be executed, so we add 8 to the
712 #define SET_RETADDR(loc) \
714 "add %%i7,8,%%o7\n" \
716 : "=m" (loc) : : "%o7");
719 #define WRAPPER_RETURN(x) \
721 "call Lwrapper_restore" #x "\n" \
726 The sparc is a big nuisance. We use a separate function for
727 restoring STG registers so that gcc won't try to leave anything
728 (like the address of MainRegTable) in the stack frame that we
729 didn't build. We also use a leaf return in a format that allows us
730 to pass %o7 in as an argument known to gcc, in the hope that its
731 value will be preserved during the reloading of STG registers.
732 Note that the current gcc (2.5.6) does not use the delay slot
733 here (%#), but perhaps future versions will.
736 #if defined(CONCURRENT)
737 #define WRAPPER_REENTER \
738 void wrapper_restore_and_reenter_node(STG_NO_ARGS) \
740 __asm__("Lwrapper_restore1:"); \
741 RestoreAllStgRegs(); \
742 JMP_(EnterNodeCode); \
745 #define WRAPPER_REENTER
748 #define SEPARATE_WRAPPER_RESTORE \
749 void wrapper_restore(STG_NO_ARGS) \
751 register void *o7 __asm__("%o7"); \
753 "Lwrapper_restore0:\n" \
754 "\tmov %%i7,%0" : "=r" (o7)); \
755 RestoreAllStgRegs(); \
756 __asm__ volatile ("jmp %0+8%#" : : "r" (o7)); \
760 #endif /* __sparc__ */
762 #endif /* __GNUC__ && __STG_GCC_REGS__ */
768 #endif /* ! COPTWRAPS_H */