--ey/N+yb7u/X9mFhi
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hello again,
It seems that I have a registerised GHC mostly working on the Alpha.
The main missing piece is createAdjustor.
My understanding of (the _ccall rather than _stdcall part of)
createAdjustor is as follows: Given "hptr" and "wptr" of types
void *hptr;
{return type} (*wptr)(void *, void *, {more arguments});
createAdjustor creates "adjustor" of the type
{return type} (*adjustor)({more arguments});
such that calling
(*adjustor)({argument values})
is equivalent to calling
(*wptr)(hptr, {undefined/ignored pointer}, {argument values}).
This goal seems difficult to achieve on the Alpha, since its
complicated calling convention puts arguments in registers, and we
don't know how many arguments there are, let alone how to adjust the
stack if needed.
But wait! There's a Sparc port of createAdjustor already, and the
Sparc passes arguments in registers too! How was that done? I pored
over the #ifdef sparc_TARGET_ARCH code in Adjustor.c, and couldn't
understand. It puts hptr in %o0 and wptr in %o1, where I assume %o0
is where the first argument is expected in _ccall, but what about
shifting over {more arguments}?
In any case, given that many architectures pass arguments in registers
nowadays, what seems like a more universally workable approach to me
is to pass hptr not as a regular function call argument but inside a
special register that the called stub function (i.e., *wptr) knows
about. This register must be caller-save and must not be involved in
the usual prologue sequence generated by gcc. I'd guess that the
following would work:
i386 %eax
alpha $0 =3D $v0
sparc %g7
This new scheme would involve changing DsForeign.lhs to output
different _ccall stub code. Would it work?
Any demystification would be greatly appreciated.
(By the way, why can't we use $0 and $1 on the Alpha? Only $2 and up
are assigned in MachRegs.h.)
--=20
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
=AB ne g=E2che pas ta vie pour leur id=E9e de patrie =BB le bouton me dit
--ey/N+yb7u/X9mFhi
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE7XkLGzjAc4f+uuBURAufzAKCEDclgId2ytWVyF99JJxybCFhaDQCg98ud
PCEgfa3UReY1IOaAlC0oYLk=
=pakl
-----END PGP SIGNATURE-----
--ey/N+yb7u/X9mFhi--