X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=includes%2FTailCalls.h;h=854c7b4b186830d5edba146c435626cd804c3143;hp=670da9546f75de9df447311bef7f9edbfd293f0e;hb=65ff44face84ae30f1ddf7d009d51c1778f8c7d3;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1 diff --git a/includes/TailCalls.h b/includes/TailCalls.h index 670da95..854c7b4 100644 --- a/includes/TailCalls.h +++ b/includes/TailCalls.h @@ -233,8 +233,17 @@ but uses $$dyncall if necessary to cope, just in case you aren't. #ifdef ia64_HOST_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 ---"); + * implement it as a call and optimise to a jump at mangle time. + * + * Sometimes GCC likes to move instructions between the function call and + * the "--- TAILCALL ---". To stop it from finding instructions to put + * there, we insert a jump to the end of the function after the TAILCALL. */ +#define JMP_(cont) \ + ((F_) (cont))(); \ + __asm__ volatile ("--- TAILCALL ---"); \ + goto _function_end; + +#define FE_ _function_end: __asm__ volatile ("--- END ---"); /* Don't emit calls to __DISCARD__ as this causes hassles */ #define __DISCARD__() @@ -242,6 +251,29 @@ but uses $$dyncall if necessary to cope, just in case you aren't. #endif /* ----------------------------------------------------------------------------- + Tail calling on MIPS + -------------------------------------------------------------------------- */ + +#ifdef mips_HOST_ARCH + +#if IN_STG_CODE +register void *_procedure __asm__("$25"); +#endif + +#define JMP_(cont) \ + { \ + _procedure = (void *)(cont); \ + __DISCARD__(); \ + goto *_procedure; \ + } + +/* Don't need these for MIPS mangling */ +#define FB_ +#define FE_ + +#endif /* mips_HOST_ARCH */ + +/* ----------------------------------------------------------------------------- FUNBEGIN and FUNEND. These are markers indicating the start and end of Real Code in a