[A64] Dedicate x19 as backend context pointer

Reserves x19 to permanently hold the A64BackendContext pointer
(x20 - sizeof(A64BackendContext)), set once in the HostToGuestThunk.
Since x19 is AAPCS64 callee-saved, it survives all host calls for free.

Eliminates repeated 2-instruction mov+sub sequences in stackpoint
push/pop, stack synchronization, FPCR management, and reserved
load/store paths.

Reduces allocatable GPRs from 8 to 7 (like on x64).
This commit is contained in:
Herman S.
2026-03-24 14:23:31 +09:00
parent cfc1e4d069
commit 756ae7a558
6 changed files with 88 additions and 94 deletions

View File

@@ -71,10 +71,10 @@ class A64Emitter : public Xbyak_aarch64::CodeGenerator {
std::vector<SourceMapEntry>* out_source_map);
public:
// Reserved: sp, x20 (context), x21 (membase)
// Reserved: sp, x19 (backend context), x20 (context), x21 (membase)
// Scratch: x0-x18 (caller-saved), v0-v3
// Available GPRs for register allocator: x19, x22-x28
static constexpr int GPR_COUNT = 8;
// Available GPRs for register allocator: x22-x28
static constexpr int GPR_COUNT = 7;
// Available VEC regs: v4-v7, v16-v31
static constexpr int VEC_COUNT = 20;
static constexpr size_t kStashOffset = 32;
@@ -122,6 +122,9 @@ class A64Emitter : public Xbyak_aarch64::CodeGenerator {
void CallNativeSafe(void* fn);
void SetReturnAddress(uint64_t value);
// Backend context register = x19.
// Points to A64BackendContext (immediately before PPCContext in memory).
const Xbyak_aarch64::XReg& GetBackendCtxReg() const { return x19; }
// Context register = x20.
const Xbyak_aarch64::XReg& GetContextReg() const { return x20; }
// Memory base register = x21.