Jan Kort <[EMAIL PROTECTED]> writes:
> It looks like I'm either missing more code, or I'm on the wrong
> track. I can't find the powerpc assembly code for "JMP_" (should
> be in ghc/includes/TailCalls.h), "StgRun" (should be in
> ghc/rts/StgCRun.c) and for "StgReturn" (should be in ghc/rts/StgRun.S).
> I also tried to compile with USE_MINIINTERPRETER set to 1, but this
> led to having to set INTERPRETER_ONLY to 1 as well,
> otherwise Hugs_CONSTR_entry would be undefined. I asume that
> "INTERPRETER_ONLY" means no compiler ?
This is because I haven't done a powerpc of the new RTS yet. You've
spotted the bits that are missing - mostly these can be filled in by
looking at the relevant bits in the old RTS (from 3.02).
> In case I'm not missing code and I have to write it myself, if
> I don't use native code generation, can I do:
>
> #ifdef powerpc_TARGET_ARCH
>
> StgThreadReturnCode
> StgRun(StgFunPtr f) {
> f();
> return (StgThreadReturnCode)R1.i;
> }
>
> #endif
You need some hackery to save/restore callee-saves registers around
the call to 'f'. The following is a complete guess, based on the old
RTS code:
StgThreadReturnCode
StgRun(StgFunPtr f)
{
StgChar space[RESERVED_C_STACK_BYTES+6*sizeof(double)+19*sizeof(long)];
__asm__ volatile ("stm 13,-176(1)\n"
"\tstfd 14,-200(1)\n"
"\tstfd 15,-208(1)\n"
"\tstfd 16,-216(1)\n"
"\tstfd 17,-224(1)\n"
"\tstfd 18,-232(1)\n"
"\tstfd 19,-240(1)\n"
: : "I" (RESERVED_C_STACK_BYTES+16) : "1" );
f();
__asm__ volatile (".align 3\n"
".globl " STG_RETURN "\n"
STG_RETURN ":\n"
"\tlm 13,-176(1)\n"
"\tlfd 14,-200(1)\n"
"\tlfd 15,-208(1)\n"
"\tlfd 16,-216(1)\n"
"\tlfd 17,-224(1)\n"
"\tlfd 18,-232(1)\n"
"\tlfd 19,-240(1)\n"
: : "I" (RESERVED_C_STACK_BYTES+16) : "1" );
return (StgThreadReturnCode)R1.i;
}
> And for the "JMP_":
>
> #if powerpc_TARGET_ARCH
>
> #define JMP_(cont) \
> { \
> goto (void *)(cont); \
> }
>
> #endif powerpc_TARGET_ARCH
Yep, this *should* work.
> I don't know what to do about StgReturn in ghc/rts/StgRun.S,
> judging from the ifdef, the StgReturn is only valid for 386
> architectures, so where is it defined on a sparc or an alpha ?
You don't need to worry about StgRun.S (the glue code is *either*
defined in StgRun.S or StgCRun.c, depending on whether you feel like
writing it in assembler or C...)
A small warning: the assembly manger (in ghc/driver/ghc-asm.lprl) may
need a bit of tweaking for powerpc.
Thanks for giving this a go... it shouldn't be too much work to get it
all working.
Cheers,
Simon
--
Simon Marlow [EMAIL PROTECTED]
University of Glasgow http://www.dcs.gla.ac.uk/~simonm/
finger for PGP public key