This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Force only register transfer calls


On Wed, 2008-09-17 at 15:52 +0200, Bernhard Poess wrote:
> Hi,
> 
> I need to prevent functions from using stack based params if the
> number of parameters exceeds 6 on x86_64.
> Is there a different calling convention I can force gcc to use?
> Basically I need one that doesn't depend on a particular order on the
> stack.
> Here is what I want in pseudo code:
> 
> cdecl stack:
> <param1>
> <param0>
> <ret> <- stack ptr
> called function knows that the next value after the ret value is the
> first param.
> 
> I need something where gcc automatically hands over a pointer like this:
> 
> <param1>
> <param0> <- stack ptr
> (...)
> different stack:
> <ret>
> called function gets stack ptr from gcc and 'knows' where to look for
> the rest of the params
> 

If I understand correctly, you simply wish to prevent the parameters
from being placed on the stack immediately after the ret address. Of
course the called function will be entered with the condition:
    <ret> <- stack ptr

Would it work for you to simply store parameters over 5 in a struct or
array, then pass the address of this list as the 6th argument (in a
register)? It looks like this would accomplish what you show in your
second diagram -- parameters 6 - n would be stored someplace on the
stack, and the called function would know that location from the 6th
argument.

This also has the advantage of not having to use any obscure gcc
options, thus making the code easier to read.

Bob



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]