Conversation
Author
|
@classilla @MPC7500 I would really appreciate if you could help review this PR for me. Great thanks in advance |
runlevel5
force-pushed
the
ppc64le-jit-support
branch
from
March 31, 2026 10:01
b8c22fe to
9278443
Compare
Make the JIT endian-independent, detect ELFv1/ELFv2 via _CALL_ELF and follow each ABI's calling convention, fix a Z_Free of hunk memory and a missing I-cache flush, add VSX variants of the AltiVec renderer and sound paths, and fix two long-standing big-endian AltiVec bugs.
runlevel5
force-pushed
the
ppc64le-jit-support
branch
from
August 14, 2026 07:36
2d8227a to
ade8709
Compare
When built with -mcpu=power8 or newer, emit mtvsrwa+fcfids for OP_CVIF and fctiwz+mfvsrwz for OP_CVFI instead of the classic double-magic sequences, removing the stack round-trips. Add a PPC64LE_CPU cmake option (power8/power9/power10/native) and schedule for POWER9 by default while keeping the POWER8 baseline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The PowerPC VM JIT (
vm_powerpc.c) was written for big-endian ppc/ppc64 only. This adds little-endian ppc64le support and fixes a few bugs that affect all PowerPC platforms. Addresses #300.JIT (
vm_powerpc.c)HI16/LO16,FPRHI/FPRLO)_CALL_ELF: ELFv1 keeps the OPD, ELFv2 uses direct code addresses and setsr12before indirect callsintargs); 32-bit is untouchedZ_FreeofHunk_Alloc'd memory (crashed on VM reload) and added__builtin___clear_cache()beforemprotect()for the split D/I cachesRenderer / sound
vec_lvslalignment trick is big-endian only. The VMX paths are kept for G4/G5 and thealtivec.hinclude stays gated for Apple PPCRB_CalcDiffuseColor_altivecrotated every normal after the first (stalevec_lvsl(12)from a 12-byte-stride layout), and the sound mixer read a stale sample block wheneversampleOffsetwas 16-byte alignedBuild
-mcpu=power8(the ppc64le baseline); big-endian ppc64 keeps the compiler default so pre-POWER8 CPUs (970/G5, POWER5–7) still workPPC64LE_CPUcmake option (power8default,power9,power10,native) raises the baseline for machine-specific builds — worth ~2% server CPU on a POWER9 in my benchmarksPOWER8+ JIT conversions
On
-mcpu=power8or newer builds,OP_CVIF/OP_CVFIuse direct GPR↔FPR moves (mtvsrwa+fcfids,fctiwz+mfvsrwz) instead of the classic 0x4330-magic sequences and their stack round-trips. Results are bit-identical (verified against the old sequences across NaN/∞/saturation edge cases on both endians) and the generated code shrinks ~1%. Pre-POWER8 builds keep the original sequences.Testing
All with retail Quake III data, dedicated server with bots on
q3dm17plus the JIT (vm_game 2):-mcpu=970builds)I also unit-tested the VSX and VMX vector paths (sound mixer, diffuse lighting, mesh lerp, normalize) against scalar references on both endians — that's how the two big-endian AltiVec bugs above were caught.