Skip to content

Commit 966c3d0

Browse files
authored
Merge pull request #476 from rustcoreutils/updates
[cc] update docs
2 parents 67ed41f + 57a24b7 commit 966c3d0

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

cc/doc/TODO.md

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
- [Technical Debt](#technical-debt)
66
- [R10 reserved globally for division scratch](#r10-reserved-globally-for-division-scratch)
7-
- [XMM register save area for variadic functions](#xmm-register-save-area-for-variadic-functions-x86-64)
87
- [Future Features](#future-features)
98
- [C11 Atomics (`_Atomic`)](#c11-atomics-_atomic-implementation)
109
- [C11 Alignment Specifiers (`_Alignas`, `_Alignof`)](#c11-alignment-specifiers-_alignas-_alignof)
@@ -25,7 +24,7 @@
2524

2625
### R10 reserved globally for division scratch
2726

28-
**Location**: `arch/x86_64/codegen.rs` lines 160-179
27+
**Location**: `arch/x86_64/regalloc.rs` lines 187-208
2928

3029
**Issue**: R10 is permanently excluded from the allocatable register pool because x86-64 `div`/`idiv` instructions clobber RAX (quotient) and RDX (remainder). When the divisor operand happens to be in RAX or RDX, we need a scratch register to hold it during the division.
3130

@@ -45,27 +44,6 @@
4544

4645
Production compilers (GCC, LLVM) use approaches 2-4. The current approach is simple and correct but sacrifices some optimization potential.
4746

48-
### XMM register save area for variadic functions (x86-64)
49-
50-
**Location**: `arch/x86_64/codegen.rs` lines 1012-1015
51-
52-
**Issue**: On x86-64 SysV ABI, variadic functions that receive floating-point arguments via XMM0-XMM7 should save those registers in the register save area during the prologue. This allows `va_arg(ap, double)` to retrieve FP arguments passed in registers.
53-
54-
**Current state**: The compiler correctly:
55-
- Passes FP arguments to variadic functions (caller side) in XMM registers
56-
- Sets AL to the count of XMM registers used for variadic calls
57-
- Saves GP registers (RDI, RSI, RDX, RCX, R8, R9) in the register save area
58-
59-
However, XMM registers are not saved, so user-defined variadic functions cannot use `va_arg` to retrieve `double` arguments.
60-
61-
**Impact**: Low. Most POSIX variadic functions (printf, sprintf, scanf, etc.) are provided by libc and work correctly. This only affects user-defined variadic functions that accept floating-point variadic arguments.
62-
63-
**Solution**: In the function prologue for variadic functions:
64-
1. Allocate additional space in the register save area (8 XMM regs × 16 bytes = 128 bytes)
65-
2. Use `movaps` to save XMM0-XMM7 at their ABI-specified offsets
66-
3. Update `va_start` to initialize the FP register save area pointer correctly
67-
4. Update `va_arg` to read from XMM save area when extracting FP types
68-
6947
---
7048

7149
## Future Features

0 commit comments

Comments
 (0)