>I am porting our Modula-2 compiler (the others get a free ride) to>SPARC Solaris from the Intel world. I wonder if anyone has information>on the preservation of the application reserved global registers>g2-g4.>>The ABI states preserved across procedure calls. Another document I>saw said preserved across system calls.

GCC treats these registers as scratch registers (caller-save) by
default. So if you want to interoperate with code compiled with GCC,
you can't assume that they will be preserved across procedure calls.

The comments in the gcc source code (gcc/config/sparc/sparc.h) give
some additional information:

| On non-v9 systems:
...
| g2-g4 are reserved for applications. Gcc normally uses them as
| temporaries, but this can be disabled via the -mno-app-regs option.
...
| On v9 systems:
| g1,g5 are free to use as temporaries, and are free to use between calls
| if the call is to an external function via the PLT.
| g4 is free to use as a temporary in the non-embedded case.
| g4 is reserved in the embedded case.
| g2-g3 are reserved for applications. Gcc normally uses them as
| temporaries, but this can be disabled via the -mno-app-regs option.
...

--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.