Add little-endian PowerPC (ppc64le) support to VM JIT compiler#860
Open
runlevel5 wants to merge 2 commits intoioquake:mainfrom
Open
Add little-endian PowerPC (ppc64le) support to VM JIT compiler#860runlevel5 wants to merge 2 commits intoioquake:mainfrom
runlevel5 wants to merge 2 commits intoioquake:mainfrom
Conversation
Author
|
@classilla @MPC7500 I would really appreciate if you could help review this PR for me. Great thanks in advance |
The PowerPC JIT (vm_powerpc.c) was written for big-endian ppc/ppc64 only. This adds support for little-endian ppc64le (ELFv2 ABI) with the following changes: Endianness fixes: - Add SE/HI16/LO16/FPRHI/FPRLO macros for endian-independent access to union half-words and FPR double-word halves in memory - Replace big-endian byte-reversal trick for immediate decoding with portable shift-based approach (matching vm_x86.c) - Fix all union short[2] accesses and FPR store/load offsets for OP_CVIF and OP_CVFI ELFv2 ABI support: - Add ELFV1/ELFV2 detection macros using _CALL_ELF - Make OPD (Official Procedure Descriptor) conditional on ELFv1 only; ELFv2 uses direct code addresses for function pointers - Set r12 = target address before indirect calls (bctrl) as required by the ELFv2 global entry point convention - Fix entry point selection to use direct code address on ELFv2 Bug fixes (affect all PowerPC platforms): - Remove incorrect Z_Free of Hunk_Alloc'd instructionPointers, which caused 'Z_Free: freed a pointer without ZONEID' crash - Add __builtin___clear_cache() before mprotect() to synchronize split D/I caches after writing generated code Tested on ppc64le (Fedora 43, GCC 15.2.1) with full retail Quake III Arena assets: FFA, CTF, and Team Arena modes with up to 8 bots across multiple maps including 5-minute stress tests.
b8c22fe to
9278443
Compare
- Add VSX VectorArrayNormalize - Fix renderer - Fix sound
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 JIT compiler (
vm_powerpc.c) was written for big-endian ppc/ppc64 only. This patch adds support for little-endian ppc64le (ELFv2 ABI).It would also address #300
Changes
Endianness fixes
SE/HI16/LO16/FPRHI/FPRLOmacros for endian-independent access to union half-words and FPR double-word halves in memoryvm_x86.c)union short[2]accesses and FPR store/load offsets forOP_CVIFandOP_CVFIELFv2 ABI support
ELFV1/ELFV2detection macros using_CALL_ELFr12 = target addressbefore indirect calls (bctrl) as required by the ELFv2 global entry point conventionBug fixes (affect all PowerPC platforms)
Z_FreeofHunk_Alloc'dinstructionPointers, which causedZ_Free: freed a pointer without ZONEIDcrash__builtin___clear_cache()beforemprotect()to synchronize split D/I caches after writing generated codeTesting
Tested on ppc64le (Fedora 43, GCC 15.2.1) with full retail Quake III Arena assets:
Full gameplay verified: rocket/railgun kills, flag captures/returns, Quad Damage, bot team coordination, voice commands, falling deaths, bot chat. All clean shutdowns, no crashes.
Notes
code/qcommon/vm_powerpc.cSL()/SA()pattern in the fileZ_Freebug and missing I-cache flush affect big-endian PowerPC too, though they may have been masked by specific allocator/cache behavior on those platforms