Subject: Re: %g registers
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Urban Boquist <urban@boquist.net>
List: port-sparc
Date: 12/01/2002 00:03:49
>>>>> der Mouse writes:
der> Which %g registers can I count on not changing behind my back?
It's defined by the Sparc ABI. There is a comment in the GCC sources
describing it (src/gnu/dist/toolchain/gcc/config/sparc/sparc.h),
appended below.
However, despite that comment, I used %g5 and %g7 for a very long time
when developing a compiler for my PhD thesis, and I never saw any
problems related to that. This was pre-v9, on both NetBSD and Solaris.
YMMV... ;-)
Kind regards,
-- Urban
/* 1 for registers that have pervasive standard uses
and are not available for the register allocator.
On non-v9 systems:
g1 is free to use as temporary.
g2-g4 are reserved for applications. Gcc normally uses them as
temporaries, but this can be disabled via the -mno-app-regs option.
g5 through g7 are reserved for the operating system.
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.
g6-g7 are reserved for the operating system (or application in
embedded case).
??? Register 1 is used as a temporary by the 64 bit sethi pattern, so must
currently be a fixed register until this pattern is rewritten.
Register 1 is also used when restoring call-preserved registers in large
stack frames.
Registers fixed in arch32 and not arch64 (or vice-versa) are marked in
CONDITIONAL_REGISTER_USAGE in order to properly handle -ffixed-.
*/