FreeBSD/ppc ABI

View: New views
6 Messages — Rating Filter:   Alert me  

FreeBSD/ppc ABI

by Justin Hibbits-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What's the current FreeBSD/ppc ABI register usage?  I'm writing a
proxy function that messes with some arguments before making the
target function call, and need to know which registers are free for me
to use without having to save argument registers.  From reading the
gcc source it looks like it's a strict SysV R4 ABI, leaving r0, r11,
and r12 available for me to use.  Is this the case, and are there any
others available?

Thanks,

- Justin
_______________________________________________
freebsd-ppc@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@..."

Re: FreeBSD/ppc ABI

by Rafal Jaworowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-07-07, at 15:41, Justin Hibbits wrote:

> What's the current FreeBSD/ppc ABI register usage?  I'm writing a
> proxy function that messes with some arguments before making the
> target function call, and need to know which registers are free for me
> to use without having to save argument registers.  From reading the
> gcc source it looks like it's a strict SysV R4 ABI, leaving r0, r11,
> and r12 available for me to use.  Is this the case, and are there any
> others available?

We use the plain SVR4 ABI. My understanding is R0, R11 and R12 are  
among volatile group, so you should be careful. Can you use one of the  
SPRGs (what CPU is this, do you need to do the trick in user or  
supervisor mode)?

Rafal

_______________________________________________
freebsd-ppc@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@..."

Re: FreeBSD/ppc ABI

by Justin Hibbits-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks.  The trick is only needed in user space, as a shim between two
functions, so I just need any volatile registers that I can use but
aren't function arguments.  The target is G4/G5.  I only need 3 or 4
volatile registers, but the more the better.

- Justin

On Tue, Jul 7, 2009 at 11:56 AM, Rafal Jaworowski<raj@...> wrote:

>
> On 2009-07-07, at 15:41, Justin Hibbits wrote:
>
>> What's the current FreeBSD/ppc ABI register usage?  I'm writing a
>> proxy function that messes with some arguments before making the
>> target function call, and need to know which registers are free for me
>> to use without having to save argument registers.  From reading the
>> gcc source it looks like it's a strict SysV R4 ABI, leaving r0, r11,
>> and r12 available for me to use.  Is this the case, and are there any
>> others available?
>
> We use the plain SVR4 ABI. My understanding is R0, R11 and R12 are among
> volatile group, so you should be careful. Can you use one of the SPRGs (what
> CPU is this, do you need to do the trick in user or supervisor mode)?
>
> Rafal
>
>
_______________________________________________
freebsd-ppc@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@..."

Re: FreeBSD/ppc ABI

by Peter Grehan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Justin,

> The trick is only needed in user space, as a shim between two
> functions, so I just need any volatile registers that I can use but
> aren't function arguments.  The target is G4/G5.  I only need 3 or 4
> volatile registers, but the more the better.

  You'll probably have to use the stack to spill the param register.
Have  a look at the MCOUNT macro in ppc's <machine/profile.h> for an
example of code that is an intercept between two routines and has to
assume that all param registers are used

(http://svn.freebsd.org/viewvc/base/head/sys/powerpc/include/profile.h?view=markup&pathrev=153813 
is the version that has the code fragment commented).

later,

Peter.
_______________________________________________
freebsd-ppc@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@..."

Re: FreeBSD/ppc ABI

by Justin Hibbits-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 7, 2009 at 1:52 PM, Peter Grehan<grehan@...> wrote:

> Hi Justin,
>
>> The trick is only needed in user space, as a shim between two
>> functions, so I just need any volatile registers that I can use but
>> aren't function arguments.  The target is G4/G5.  I only need 3 or 4
>> volatile registers, but the more the better.
>
>  You'll probably have to use the stack to spill the param register. Have  a
> look at the MCOUNT macro in ppc's <machine/profile.h> for an example of code
> that is an intercept between two routines and has to assume that all param
> registers are used
>
> (http://svn.freebsd.org/viewvc/base/head/sys/powerpc/include/profile.h?view=markup&pathrev=153813
> is the version that has the code fragment commented).
>
> later,
>
> Peter.
>

Thanks Peter, and Rafal,

I think this is just what I need.  I can use the 3 volatile registers,
and save the parameter registers when I need to call library
functions.  I'm doing this largely in assembly for performance
reasons, but knowing how mcount does it will help for the uncommon
case branches.

- Justin
_______________________________________________
freebsd-ppc@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@..."

Re: FreeBSD/ppc ABI

by Rafal Jaworowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-07-08, at 15:34, Justin Hibbits wrote:

> On Tue, Jul 7, 2009 at 1:52 PM, Peter Grehan<grehan@...>  
> wrote:
>> Hi Justin,
>>
>>> The trick is only needed in user space, as a shim between two
>>> functions, so I just need any volatile registers that I can use but
>>> aren't function arguments.  The target is G4/G5.  I only need 3 or 4
>>> volatile registers, but the more the better.
>>
>>  You'll probably have to use the stack to spill the param register.  
>> Have  a
>> look at the MCOUNT macro in ppc's <machine/profile.h> for an  
>> example of code
>> that is an intercept between two routines and has to assume that  
>> all param
>> registers are used
>>
>> (http://svn.freebsd.org/viewvc/base/head/sys/powerpc/include/profile.h?view=markup&pathrev=153813
>> is the version that has the code fragment commented).
>>
>> later,
>>
>> Peter.
>>
>
> Thanks Peter, and Rafal,
>
> I think this is just what I need.  I can use the 3 volatile registers,
> and save the parameter registers when I need to call library
> functions.  I'm doing this largely in assembly for performance
> reasons, but knowing how mcount does it will help for the uncommon
> case branches.

What I was trying to say is you need to be careful when messing with  
any of the volatiles: only after the caller has saved its context you  
can safely use them for your purpose.

Rafal

_______________________________________________
freebsd-ppc@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "freebsd-ppc-unsubscribe@..."