[M3devel] a trouble with passing records by value..
Rodney M. Bates
rodney_bates at lcwb.coop
Thu Sep 2 16:39:12 CEST 2010
Jay K wrote:
> > Date: Tue, 31 Aug 2010 21:24:07 -0500
> > From: rodney_bates@
> >
> > If the writers of an ABI actually *required* that small
> structs/records be
> > passed in registers
>
>
> Yes, they have. The rules are hard for me to understand. It isn't just
> based on size.
>
>
> > then they have made a big blunder.
>
>
> No they have not. They know what they are doing.
When the ABI requires a compiler to do it wrong for the language semantics,
which it must then compensate for at a place that's outside the jurisdiction
of the ABI, the ABI has a design bug. At least when the language in question
is one of those the ABI designers considered, which has to be the case
with C.
>
>
> > Thus taking their address must always be possible,
>
>
> If they have to be in memory, then they will be put in memory, at or before
> the address is taken. That doesn't mean the parameters have to be passed
> in memory.
>
>
> > 1) Declare that language semantics trump ABI requirements and defy
> the ABI.
>
> Not necessary.
> Granted, we don't have to follow the ABI. The ABI is for
> interoperability with C.
> I'm plenty willing to say you can't pass records by value between C and
> Modula-3.
>
>
>
> > 2) Pass them in registers at the time of control transfer, but store them
> > in memory in the prologue, then access them from memory thereafter.
>
>
> The backend does that as needed for C already.
>
>
> Data can live in multiple places.
> Just that there can be only be one mutable location at a time.
>
>
> Look at the code generated Tony asked about, add like
> printr("%p\n", &t);
>
>
> you'll see the registers get written to the stack.
>
>
> - Jay
More information about the M3devel
mailing list