Re: SPARC Solaris global (g2-g4) register preservation question

fjh@cs.mu.OZ.AU (Fergus Henderson)
15 Feb 2001 00:28:12 -0500

          From comp.compilers

Related articles
SPARC Solaris global (g2-g4) register preservation question stonybrk@ix.netcom.com (Norman Black) (2001-02-12)
Re: SPARC Solaris global (g2-g4) register preservation question fjh@cs.mu.OZ.AU (2001-02-15)
| List of all articles for this month |

From: fjh@cs.mu.OZ.AU (Fergus Henderson)
Newsgroups: comp.compilers
Date: 15 Feb 2001 00:28:12 -0500
Organization: Computer Science, University of Melbourne
References: 01-02-050
Keywords: sparc, registers
Posted-Date: 15 Feb 2001 00:28:12 EST

"Norman Black" <stonybrk@ix.netcom.com> writes:


>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.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.