Rosetta 2 part by part, applied to ScarletNX (5)

ScarletNX now. FP runs on the host's IEEE unit only behind guards that prove the result and the cumulative flags equal the soft-float helper's, and the helper runs otherwise (sg_fp_fast_binary, sg_fp_fast_sqrt and sg_fp_fast_fma in tools/sailgen/llvm.h). The helpers follow the Arm ARM for NaN propagation, the default NaN, flush to zero and every rounding mode (src/common/cpu/aarch64/helpers/fp.c), and no FP group differs from QEMU (tests/native_qemu_expected.txt). A directed rounding mode sends every operation to a helper. The FMA fast path waits until FPSR.IXC is set and needs a host FMA. Halves, scalar FRINT* and FJCVTZS always call helpers. The fpsr_flags setting (default 1) keeps FPSR exact.

On each host. The guards are host-generic, because each proves the host result equal to the helper's whatever the host's own rules are. That covers RISC-V, which never propagates a NaN payload, since the fast paths never produce a NaN. Only ties-away rounding (FRINTA, FCVTA*) has a fast path limited to AArch64 hosts, which have that rounding instruction (tools/sailgen/llvm.h). An AArch64 host can drop the guards altogether, as Rosetta's hardware mode lets it (I12).

I11 More guarded FP paths
I12 Native FP on AArch64 hosts

Exclusives and atomics

Rosetta 2. x86's locked instructions become Arm atomics. The direction is the reverse here.

ScarletNX now. The Switch's Cortex-A57 has no LSE atomics, so compiled code builds every atomic from LDXR/STXR loops. LDXR arms four monitor fields in CPU. STXR loads them, does a locked compare and swap and clears the monitor (ir_ldst.c, ir_helpers.c). The monitor compares values, so it cannot see ABA, as in Dynarmic.

On each host. LLVM lowers a compare and swap to lock cmpxchg on x86-64, to LSE or an exclusive loop on AArch64, and to reservation loops on PowerPC64, RISC-V and LoongArch. A 16-byte compare and swap goes through RtAPI.cas128 on RISC-V and LoongArch (docs/hosts/riscv-loongarch.md).

I13 Exclusive loops as single host atomics

Native code for library routines (beyond Rosetta)

Rosetta translates the x86-64 system libraries too. Windows on Arm goes further with ARM64EC, which lets native code run inside an x64 process, and Box64 runs whole native host libraries in place of translated ones.

I14 Native versions of hot SDK routines

Made from docs/layers/cpu/plan.md at 69237645142c. GPL-3.0-or-later.