* ppc405gp and GCC register usage
@ 2003-07-15 10:24 Juergen Beisert
2003-07-15 10:40 ` Wolfgang Denk
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Juergen Beisert @ 2003-07-15 10:24 UTC (permalink / raw)
To: linuxppc-embedded
Hello all,
does someone know, which register I can use in my own assembler routines
without disturbing code generated by gcc (in kernel space)? I did not found
any spec which registers gcc use, yet. Is such a document available?
-- JB
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ppc405gp and GCC register usage
2003-07-15 10:24 ppc405gp and GCC register usage Juergen Beisert
@ 2003-07-15 10:40 ` Wolfgang Denk
2003-07-15 10:42 ` Vladimir A. Gurevich
2003-07-15 10:51 ` Paul Mackerras
2 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2003-07-15 10:40 UTC (permalink / raw)
To: jbeisert; +Cc: linuxppc-embedded
In message <200307151224.04020.jbeisert@eurodsn.de> you wrote:
>
> does someone know, which register I can use in my own assembler routines
> without disturbing code generated by gcc (in kernel space)? I did not found
> any spec which registers gcc use, yet. Is such a document available?
See the (E)ABI specifications for the PowerPC architecture, and GCC
source code.
For PowerPC, the following registers have specific use:
R1: stack pointer
R2: TOC pointer
R3-R4: parameter passing and return values
R5-R10: parameter passing
R13: small data area pointer
R30: GOT pointer
R31: frame pointer
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
Life would be so much easier if we could just look at the source
code. -- Dave Olson
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ppc405gp and GCC register usage
2003-07-15 10:24 ppc405gp and GCC register usage Juergen Beisert
2003-07-15 10:40 ` Wolfgang Denk
@ 2003-07-15 10:42 ` Vladimir A. Gurevich
2003-07-15 11:31 ` Juergen Beisert
2003-07-15 10:51 ` Paul Mackerras
2 siblings, 1 reply; 5+ messages in thread
From: Vladimir A. Gurevich @ 2003-07-15 10:42 UTC (permalink / raw)
To: jbeisert; +Cc: linuxppc-embedded
Hi Juergen,
There is a standard, called ABI (Application Binary Interface) that
defines this.
ABIs are, obviuosly, CPU-specific. Compilers tend to respect ABI that
is defined for the CPU they generate code for.
The best documents specifying PPC ABI can be found on IBM's website:
PowerPC Compiler Writer's Guide
http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF7785256996007558C6/$file/cwg.pdf
Developing PowerPC Embedded Application Binary Interface (EABI)
Compliant Programs
http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF77852569970071B0D6/$file/eabi_app.pdf
They not only describe register usage, but stack layout, parameter
passing and many
other things. There are a couple of slightly different ABI's for
PowerPC, that differ
with regards to R2 and R13 usage to access the so-called small data
sections.
Also, depending on what you are doing you have 2 options:
-- do the whole function in assembly. You are free to do whatever (as
long as you
obey the ABI), but you've got to watch register allocation
yourself (among other
thing)
-- Use __asm__ in your C code. Then the compiler will do most of the
register
allocation for you and will help you with ABI issues as well.
Happy Hacking,
Vladimir
Juergen Beisert wrote:
>Hello all,
>
>does someone know, which register I can use in my own assembler routines
>without disturbing code generated by gcc (in kernel space)? I did not found
>any spec which registers gcc use, yet. Is such a document available?
>
>-- JB
>
>
>
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ppc405gp and GCC register usage
2003-07-15 10:24 ppc405gp and GCC register usage Juergen Beisert
2003-07-15 10:40 ` Wolfgang Denk
2003-07-15 10:42 ` Vladimir A. Gurevich
@ 2003-07-15 10:51 ` Paul Mackerras
2 siblings, 0 replies; 5+ messages in thread
From: Paul Mackerras @ 2003-07-15 10:51 UTC (permalink / raw)
To: jbeisert; +Cc: linuxppc-embedded
Juergen Beisert writes:
> does someone know, which register I can use in my own assembler routines
> without disturbing code generated by gcc (in kernel space)? I did not found
> any spec which registers gcc use, yet. Is such a document available?
It's defined in the PowerPC ELF ABI document. Basically a procedure
can use r0 and r3 - r12 without saving and restoring them. r1 is the
stack pointer, r2 is used by the kernel to hold the pointer to the
task_struct for the current task. r13 - r31 have to be preserved so
your procedure has to save and restore them if it wants to use them.
Similarly your procedure has to preserve cr2 - cr4 but can use cr0,
cr1, cr5 - cr7, lr, ctr, xer without saving & restoring them.
Unfortunately the PowerPC ELF ABI specification doesn't really have
anyone looking after it at the moment, so I don't know of a public
site where you can get it. I could send you the pdf if you are
interested.
Paul.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ppc405gp and GCC register usage
2003-07-15 10:42 ` Vladimir A. Gurevich
@ 2003-07-15 11:31 ` Juergen Beisert
0 siblings, 0 replies; 5+ messages in thread
From: Juergen Beisert @ 2003-07-15 11:31 UTC (permalink / raw)
To: Vladimir A. Gurevich; +Cc: linuxppc-embedded
Am Dienstag, 15. Juli 2003 12:42 schrieb Vladimir A. Gurevich:
> Hi Juergen,
>
> PowerPC Compiler Writer's Guide
> http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF77852
>56996007558C6/$file/cwg.pdf
>
> Developing PowerPC Embedded Application Binary Interface (EABI)
> Compliant Programs
> http://www-3.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF77852
>569970071B0D6/$file/eabi_app.pdf
Thank you very,very much. That's what I'm searching for.
Best regards,
Juergen Beisert
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-07-15 11:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-15 10:24 ppc405gp and GCC register usage Juergen Beisert
2003-07-15 10:40 ` Wolfgang Denk
2003-07-15 10:42 ` Vladimir A. Gurevich
2003-07-15 11:31 ` Juergen Beisert
2003-07-15 10:51 ` Paul Mackerras
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.