Re: x86-64 and calling conventions

Dave Parker <daveparker@flamingthunder.com>
Mon, 12 May 2008 20:10:58 -0700 (PDT)

          From comp.compilers

Related articles
x86-64 and calling conventions cr88192@hotmail.com (cr88192) (2008-05-12)
Re: x86-64 and calling conventions cr88192@hotmail.com (cr88192) (2008-05-12)
Re: x86-64 and calling conventions james.harris.1@googlemail.com (James Harris) (2008-05-12)
Re: x86-64 and calling conventions vidar.hokstad@gmail.com (Vidar Hokstad) (2008-05-12)
Re: x86-64 and calling conventions daveparker@flamingthunder.com (Dave Parker) (2008-05-12)
Re: x86-64 and calling conventions cr88192@hotmail.com (cr88192) (2008-05-13)
Re: x86-64 and calling conventions cr88192@hotmail.com (cr88192) (2008-05-13)
Re: x86-64 and calling conventions gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-05-13)
Re: x86-64 and calling conventions james.harris.1@googlemail.com (James Harris) (2008-05-14)
Re: x86-64 and calling conventions vidar.hokstad@gmail.com (Vidar Hokstad) (2008-05-14)
Re: x86-64 and calling conventions james.harris.1@googlemail.com (James Harris) (2008-05-14)
[6 later articles]
| List of all articles for this month |
From: Dave Parker <daveparker@flamingthunder.com>
Newsgroups: comp.compilers
Date: Mon, 12 May 2008 20:10:58 -0700 (PDT)
Organization: Compilers Central
References: 08-05-031
Keywords: C, registers
Posted-Date: 12 May 2008 23:28:23 EDT

On May 11, 5:44 pm, "cr88192" <cr88...@hotmail.com> wrote:
> now, what kind of convention would I be imagining:
> well, basically, it would be a hybrid of the existing conventions, and the
> good old 32-bit x86 convention.
>
> in particular, arguments would be passed on the stack (in good old linear
> right-to-left ordering).


That's kind of what I did in the Flaming Thunder compiler (which
supports the x86 and x86-64 versions of FreeBSD, Linux, Mac OS X and
Windows).


Some differences:


The calling convention is left-to-right (since I was making my own
calling convention, I figured I might as well fix the old right-to-
left holdover and use the stack the way the stack should be used ---
left-to-right). Left-to-right means the arguments are evaluated in
the order that users expect them to be. If the function is vararg,
then I push the argument count on the stack last.


When I need to access a system service, I translate my stack layout to
the Windows/Mac/Linux/FreeBSD/32/64 layout, then call the system.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.