This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to teach gcc, that registers are clobbered by api calls?
- From: NightStrike <nightstrike at gmail dot com>
- To: "Ross Ridge" <rridge at csclub dot uwaterloo dot ca>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 21 Apr 2008 20:07:05 -0400
- Subject: Re: How to teach gcc, that registers are clobbered by api calls?
- References: <20080421204225.0C09273DC7@caffeine.csclub.uwaterloo.ca>
On 4/21/08, Ross Ridge <rridge@csclub.uwaterloo.ca> wrote:
> H.J. Lu writes:
> >Are r10-r15 callee-saved in w64ABI?
>
> Here's what Microsoft's documentation says:
>
> Caller/Callee Saved Registers
>
> The registers RAX, RCX, RDX, R8, R9, R10, R11 are considered
> volatile and must be considered destroyed on function calls
> (unless otherwise safety-provable by analysis such as whole
> program optimization).
>
> The registers RBX, RBP, RDI, RSI, R12, R13, R14, and R15 are
> considered nonvolatile and must be saved and restored by a
> function that uses them
>
> Other parts of the documentation state that XMM0-XMM5 are volatile
> (caller-saved), while XMM6-XXM15 are non-volatile (callee-saved).
>
> Ross Ridge
>
>
Maybe this link is helpful:
http://msdn2.microsoft.com/en-us/library/9z1stfyw.aspx
Register Usage
The x64 architecture provides for 16 general-purpose registers
(hereafter referred to as integer registers) as well as 16 XMM
registers available for floating-point use. Volatile registers are
scratch registers presumed by the caller to be destroyed across a
call. Nonvolatile registers are required to retain their values across
a function call and must be saved by the callee if used.
The following table describes how each register is used across function calls:
Register
Status
Use
RAX
Volatile
Return value register
RCX
Volatile
First integer argument
RDX
Volatile
Second integer argument
R8
Volatile
Third integer argument
R9
Volatile
Fourth integer argument
R10:R11
Volatile
Must be preserved as needed by caller; used in syscall/sysret instructions
R12:R15
Nonvolatile
Must be preserved by callee
RDI
Nonvolatile
Must be preserved by callee
RSI
Nonvolatile
Must be preserved by callee
RBX
Nonvolatile
Must be preserved by callee
RBP
Nonvolatile
May be used as a frame pointer; must be preserved by callee
RSP
Nonvolatile
Stack pointer
XMM0
Volatile
First FP argument
XMM1
Volatile
Second FP argument
XMM2
Volatile
Third FP argument
XMM3
Volatile
Fourth FP argument
XMM4:XMM5
Volatile
Must be preserved as needed by caller
XMM6:XMM15
Nonvolatile
Must be preserved as needed by callee.