[m-dev.] Re: fastcall for the x86

Peter Ross peter.ross at miscrit.be
Sat Nov 25 03:54:29 AEDT 2000


On Sat, Nov 25, 2000 at 03:01:16AM +1100, Fergus Henderson wrote:
> On 17-Nov-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 17-Nov-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > > I was chatting to Pete on the phone and we got into a discussion of
> > > using fastcall convention on the x86 in hlc grade.
> > > gcc has a similar calling convention that can be enabled using the
> > > regparm(X) attribute.  It might be worth trying this out in hlc.gc
> > > for non-exported functions.
> > 
> > That won't work, since we take the address of non-exported functions
> > and pass them to other modules.
> > 
> > But we could do it for all Mercury-generated functions
> > (and for functions in the Mercury runtime or standard library that
> > implement builtin unification/compare or Mercury procedures declared
> > `:- external').
> 
> I tried this out.  But both the `regparm' and `stdcall' attributes are
> broken in both gcc 2.95.2 and egcs 1.1.2 (in slightly different ways).
> The symptoms include (1) silently ignoring such attributes when they
> occur in function pointer type casts (and thus generating code which
> crashes, due to mismatches with the places where the attributes are
> not ignored); (2) gcc internal compiler errors; and (3) segmentation
> fauls ("fatal signal 11") in cc1.  I just sent off three bug reports
> against gcc 2.95.2.
> 
> The following diff has my efforts towards exploiting such attributes.
> They may be useful for __fastcall with MSVC.  But they're not yet
> useful for gcc, and I haven't been able to test them properly, so I
> don't plan to commit this.  Pete, you might want to take this diff,
> review it carefully for bugs (no doubt there are some ;-), and then
> use it to try out __fastcall with MSVC.
> 
Thanks for the diff!

The first problem with this diff is that the MR_CALL macro is in the
wrong spot for MSVC, it needs to come after the return type :(. eg.

void MR_CALL function(int arg);

I guess the easiest (only?) solution would be to change MR_CALL to be a
macro which takes one argument, the return type.

MR_CALL(void) function(int arg);

I will look into this more and try to get it working.

Pete
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list