[M3devel] a trouble with passing records by value..
Jay K
jay.krell at cornell.edu
Wed Sep 1 01:13:04 CEST 2010
Another change we need is to check that the backend and frontend agree on the sizes and alignments of types.
gcc does have a "packed" notion. It might be useful, like if it lets us set size/alignment and impedes repeat computation.
It might also be good to have the backend feed its computed sizes/alignments back to the front end.
It'd be via more files.
- Jay
----------------------------------------
> From: jay.krell at cornell.edu
> To: hosking at cs.purdue.edu
> Date: Tue, 31 Aug 2010 23:09:56 +0000
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] a trouble with passing records by value..
>
>
> I'm possibly going to try changing the target-specific code in gcc to never pass structs in registers.
> Yucky.
>
> I'm also going to try giving temporaries types.
> Another m3cg change like pop_struct.
> Given the latest internal error I saw.
> Maybe review m3cg for more missing type information.
>
> - Jay
>
> ----------------------------------------
> > From: jay.krell at cornell.edu
> > To: hosking at cs.purdue.edu
> > CC: m3devel at elegosoft.com
> > Subject: RE: [M3devel] a trouble with passing records by value..
> > Date: Tue, 31 Aug 2010 23:05:08 +0000
> >
> >
> > t1 must still be passed in registers. The ABI can't be changed by that.
> >
> > - Jay
> >
> > ----------------------------------------
> > > From: hosking at cs.purdue.edu
> > > Date: Tue, 31 Aug 2010 09:15:32 -0400
> > > To: jay.krell at cornell.edu
> > > CC: m3devel at elegosoft.com
> > > Subject: Re: [M3devel] a trouble with passing records by value..
> > >
> > > What happens if you take the address of t inside ActionLookup?
> > > What happens if you take the address of t1 inside main?
> > >
> > > On 31 Aug 2010, at 07:25, Jay K wrote:
> > >
> > > >
> > > > Given something like this:
> > > >
> > > > jbook2:p247 jay$ more 1.c
> > > > #include
> > > >
> > > > typedef struct { long code; long value; } T1;
> > > >
> > > > void ActionLookup(T1 t, long code, long value);
> > > >
> > > > void ActionLookup(T1 t, long code, long value)
> > > > {
> > > > assert(t.code == code);
> > > > assert(t.value == value);
> > > > }
> > > >
> > > > int main()
> > > > {
> > > > T1 t1 = {2,2};
> > > > ActionLookup(t1, 2, 2);
> > > > return 0;
> > > > }
> > > > j
> > > >
> > > >
> > > > on some platforms, such as AMD64_DARWIN, T1 is passed in registers. Good.
> > > >
> > > >
> > > > However, one of the unfortunate aspects of our Modula-3 system is that when you reference e.g. t1.value,
> > > > the backend isn't told you are accessing the "value" "field" of "t1", and it figures out where that is,
> > > > but rather 64bits at offset 64bits into t1. Therefore t1 must have an address. Therefore it can't be in registers.
> > > > Darn.
> > > >
> > > >
> > > > If m3cg were higher level this could be better.
> > > >
> > > >
> > > > There should be a viable compromise where the parameter is passed in registers, and only "homed"
> > > > to some stack location if its address is used -- e.g. to pass unused parameters in registers.
> > > > But given the inefficiency of field accesses, I'm not sure it is worth trying?
> > > >
> > > >
> > > > Maybe we should have M3CG include field references?
> > > >
> > > >
> > > > There is this basic problem that the interface between m3front and m3cc isn't really at the
> > > > right level for m3cc. But it is probably for m3front. m3front wants a lower level code generator.
> > > >
> > > >
> > > > - Jay
> > > >
> > >
> >
>
More information about the M3devel
mailing list