Skip to content

Commit 47538d5

Browse files
committed
Document ABI registers
1 parent 175acc6 commit 47538d5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/ABIStabilityManifesto.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,22 @@ Having the call context register be callee-saved is advantageous. It keeps the r
337337

338338
Throwing functions communicate error values to their callers through the *error* register on some platforms. The error register holds a pointer to the error value if an error occurred, otherwise 0. The caller of a throwing function is expected to quickly check for 0 before continuing on with non-error code, otherwise branching to code to handle or propagate the error. Using a callee-saved register for the error register enables free conversion from non-throwing to throwing functions, which is required to honor the subtyping relationship.
339339

340+
### Register Allocations
341+
342+
From Swift 5, the register allocation for 64 architectures is as follows:
343+
344+
| Register Purpose | ARM64 | x86_64 |
345+
| ------------- |:-------------:| ----- |
346+
| Context register (self) | x20 | r13 |
347+
| Error return register | x21 | r12 |
348+
| Struct return pointer | x8 | rax |
349+
| Float call arguments | d0 - d7 | xmm0 - xmm7 |
350+
| Integer call arguments | x0 - x7 | rdi, rsi, rdx, rcx, r8, r9 |
351+
| Float return | d0, d1 | xmm0, xmm1 |
352+
| Integer return | x1, x2 | rax, rbx |
353+
354+
For more detail consult the specifications linked at the end of this document.
355+
340356
### <a name="function-signature-lowering"></a>Function Signature Lowering
341357

342358
Function signature lowering is the mapping of a function's source-language type, which includes formal parameters and results, all the way down to a physical convention, which dictates what values are stored in what registers and what values to pass on the stack.

0 commit comments

Comments
 (0)