[project @ 2003-09-24 11:06:51 by simonmar]
[ghc-hetmet.git] / ghc / includes / TailCalls.h
index 2dbd99c..05dc852 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: TailCalls.h,v 1.9 2002/05/28 09:22:08 wolfgang Exp $
+ * $Id: TailCalls.h,v 1.14 2003/09/21 13:22:02 igloo Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -51,15 +51,30 @@ extern void __DISCARD__(void);
 
 #define JMP_(cont)                     \
     {                                  \
-      void *target;                    \
+      void *__target;                  \
       __DISCARD__();                   \
-      target = (void *)(cont);         \
-      goto *target;                    \
+      __target = (void *)(cont);       \
+      goto *__target;                  \
     }
 
 #endif /* i386_TARGET_ARCH */
 
 /* -----------------------------------------------------------------------------
+   Tail calling on x86_64
+   -------------------------------------------------------------------------- */
+
+#if x86_64_TARGET_ARCH
+
+#define JMP_(cont)                     \
+    {                                  \
+      void *__target;                  \
+      __target = (void *)(cont);       \
+      goto *__target;                  \
+    }
+
+#endif /* x86_64_TARGET_ARCH */
+
+/* -----------------------------------------------------------------------------
    Tail calling on Sparc
    -------------------------------------------------------------------------- */
 
@@ -83,11 +98,14 @@ extern void __DISCARD__(void);
 
 #ifdef alpha_TARGET_ARCH
 
+#ifdef IN_STG_CODE
 register void *_procedure __asm__("$27");
+#endif
 
-#define JMP_(cont)                             \
-    do { _procedure = (void *)(cont);          \
-         goto *_procedure;                     \
+#define JMP_(cont)                             \
+    do { _procedure = (void *)(cont);          \
+         __DISCARD__();                                \
+         goto *_procedure;                     \
        } while(0)
 
 /* Don't need these for alpha mangling */
@@ -186,6 +204,21 @@ but uses $$dyncall if necessary to cope, just in case you aren't.
 #endif /* powerpc_TARGET_ARCH */
 
 /* -----------------------------------------------------------------------------
+   Tail calling on IA64
+   -------------------------------------------------------------------------- */
+
+#ifdef ia64_TARGET_ARCH
+
+/* The compiler can more intelligently decide how to do this.  We therefore
+ * implement it as a call and optimise to a jump at mangle time. */
+#define JMP_(cont)     ((F_) (cont))(); __asm__ volatile ("--- TAILCALL ---");
+
+/* Don't emit calls to __DISCARD__ as this causes hassles */
+#define __DISCARD__()
+
+#endif
+
+/* -----------------------------------------------------------------------------
   FUNBEGIN and FUNEND.
 
   These are markers indicating the start and end of Real Code in a