1 /* -----------------------------------------------------------------------------
2 * $Id: TailCalls.h,v 1.2 1998/12/02 13:21:43 simonm Exp $
4 * Stuff for implementing proper tail jumps.
6 * ---------------------------------------------------------------------------*/
11 /* -----------------------------------------------------------------------------
12 Unmangled tail-jumping: use the mini interpretter.
13 -------------------------------------------------------------------------- */
15 #ifdef USE_MINIINTERPRETER
17 #define JMP_(cont) return(stgCast(StgFunPtr,cont))
23 /* -----------------------------------------------------------------------------
25 -------------------------------------------------------------------------- */
29 extern void __DISCARD__(void);
31 /* Note about discard: possibly there to fool GCC into clearing up
32 before we do the jump eg. if there are some arguments left on the C
33 stack that GCC hasn't popped yet. Also possibly to fool any
34 optimisations (a function call often acts as a barrier). Not sure
35 if any of this is necessary now -- SDM
38 /* The goto here seems to cause gcc -O2 to delete all the code after
39 it - including the FE_ marker and the epilogue code - exactly what
47 target = (void *)(cont); \
51 #endif i386_TARGET_ARCH
53 /* -----------------------------------------------------------------------------
55 -------------------------------------------------------------------------- */
57 #ifdef sparc_TARGET_ARCH
59 #define JMP_(cont) ((F_) (cont))()
60 /* Oh so happily, the above turns into a "call" instruction,
61 which, on a SPARC, is nothing but a "jmpl" with the
62 return address in %o7 [which we don't care about].
65 /* Don't need these for sparc mangling */
69 #endif sparc_TARGET_ARCH
71 /* -----------------------------------------------------------------------------
73 -------------------------------------------------------------------------- */
75 #ifdef alpha_TARGET_ARCH
77 register void *_procedure __asm__("$27");
80 do { _procedure = (void *)(cont); \
84 /* Don't need these for alpha mangling */
88 #endif alpha_TARGET_ARCH
93 These are markers indicating the start and end of Real Code in a
94 function. All instructions between the actual start and end of the
95 function and these markers is shredded by the mangler.
99 #define FB_ __asm__ volatile ("--- BEGIN ---");
103 #define FE_ __asm__ volatile ("--- END ---");
106 #endif /* !USE_MINIINTERPRETER */