LoongArch64: fix QuickCallFunctionR passing the argument in a vector register

MOVE(LoongArch64Reg::X4, arg) targets X4, which is an LASX 256-bit vector
register (0x64), not a0. The LP64D ABI puts the first integer argument in
a0, which is R4.

This is not a corner case: GenerateFixedCode uses QuickCallFunctionR for
CoreTiming::Advance, so the emitter asserted ("DJK instruction rd must be
GPR") while building the dispatcher, before a single block was compiled.
The LoongArch native JIT could not start at all.

Found by running the loongarch64 cross build under qemu-user.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-09-19 12:19:24 -06:00
1 parent 8e3b4245c2
commit 91dff7cb3f
1 file changed
+2 -1
+2 -1
View File
@@ -166,7 +166,8 @@ public:
QuickCallFunction((const u8 *)func, scratchreg);
}
void QuickCallFunctionR(const u8 *func, LoongArch64Reg arg, LoongArch64Reg scratchreg = R_RA) {
MOVE(LoongArch64Reg::X4, arg);
// The first integer argument goes in a0, which is R4 - X4 is an LASX vector register.
MOVE(LoongArch64Reg::R4, arg);
QuickJump(scratchreg, R_RA, func);
}
template <typename T>