Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PPC64LE] Add PPC64LE dynarec infrastructure with MOV opcodes#3592

Draft
runlevel5 wants to merge 1 commit intoptitSeb:mainfrom
runlevel5:ppc64le-pr2-dynarec-infra
Draft

[PPC64LE] Add PPC64LE dynarec infrastructure with MOV opcodes#3592
runlevel5 wants to merge 1 commit intoptitSeb:mainfrom
runlevel5:ppc64le-pr2-dynarec-infra

Conversation

@runlevel5
Copy link
Contributor

@runlevel5 runlevel5 commented Feb 28, 2026

Summary

Add the core dynarec infrastructure for PPC64LE with 3 MOV opcodes as proof the pipeline works end-to-end. Follows the incremental approach of the RV64 dynarec initial commit (5a9b896).

Depends on #3591 (platform support PR) — please merge that first.

Changes (36 files, ~9200 lines)

Core Infrastructure

  • Emitter (ppc64le_emitter.h): Instruction encoding macros for PPC64LE ISA. Argument order follows Power ISA assembly convention (Rt, offset, Ra) — documented in header comment.
  • Helper (dynarec_ppc64le_helper.h/c): STEPNAME-aliased macros and core functions (geted, move32/move64, jump_to_epilog/jump_to_next, call_c/call_n, grab_segdata, emit_pf). Displacement modes use named constants (DISP_NONE/DISP_D/DISP_DQ) and magic numbers replaced with PPC64_DISP_MAX.
  • Register mapping (ppc64le_mapping.h): x86-64 to PPC64LE register mapping, ELFv2 ABI-compliant.
  • Functions (dynarec_ppc64le_functions.c/h): fpu_reset, inst_name_pass3, updateNativeFlags, get_free_scratch, ppc64le_fast_hash, plus FPU register management stubs.
  • Architecture (dynarec_ppc64le_arch.c): CancelBlock, FillBlock, AddMarkRecursive, native address resolution, jump table support.
  • Constants (dynarec_ppc64le_consts.c/h): Constants table management (unused arrays removed per review).

Assembly

  • ppc64le_prolog.S / ppc64le_epilog.S: Dynarec entry/exit.
  • ppc64le_next.S: Block-to-block dispatcher.
  • ppc64le_lock.S/h: Atomic operations (LL/SC pairs, mutex-based 128-bit CAS).

Opcodes (3 MOV instructions in _00.c)

  • 0x89 — MOV Ed,Gd
  • 0x8B — MOV Gd,Ed
  • 0x8D — LEA Gd,Ed

Stubs

  • Printer returns "???" for all instructions (will be expanded later).
  • _66.c, _f0.c, _66f0.c contain only DEFAULT fallback.
  • FPU/SSE/AVX cache functions are empty stubs, following RV64 initial commit pattern.

Shared Dynarec Modifications

  • CMakeLists.txt, dynarec_native_pass.c, dynarec_arch.h, dynarec_helper.h, dynarec_next.h, native_lock.h, dynacache_reloc.h, dynarec.c: PPC64LE #elif branches.

Review Changes

  • Removed dynarec_ppc64le_arch.h and WIN32 guard (ptitSeb)
  • Removed unused constant arrays from dynarec_ppc64le_consts.c (ptitSeb)
  • Renamed DQ_ALIGN to DISP_NONE/DISP_D/DISP_DQ named constants (ptitSeb)
  • Replaced magic number 32768 with PPC64_DISP_MAX constant (ptitSeb)
  • Added emitter argument order convention comment (ptitSeb/classilla)
  • Removed unused GOCOND macro (~80 lines) (ptitSeb)
  • Fixed x87_get_st_empty macro bug, removed duplicate dynarec64_F0 (self-audit)
  • Removed BEQZ_safe alias no longer needed after GOCOND removal

Notes on Reviewer Feedback

Re: unused macros in helper.h (ksco): Most macros in dynarec_ppc64le_helper.h are required by the shared dynarec_native_pass.c or are building blocks used by other macros. The genuinely unused items (GOCOND, duplicate dynarec64_F0) have been removed.

Re: unused functions in functions.c (ksco): All 19 public functions are called from shared dynarec infrastructure (dynarec_native.c, dynarec_native_pass.c, dynarec_native_functions.c, dynarec.c). None can be removed without breaking compilation.

Re: ALSL/BSTRPICK_D/BSTRINS_D names (ksco): These LoongArch names do not exist in the PPC64LE code. The PPC equivalents are already named SLADDy, BF_EXTRACT, and BF_INSERT.

Re: AVX 256-bit (ksco): PPC64LE has 128-bit VSX only. The AVX macros are shared infrastructure stubs required by dynarec_native_pass.c — they don't imply 256-bit support.

Related

@runlevel5 runlevel5 marked this pull request as draft February 28, 2026 13:00
@runlevel5 runlevel5 force-pushed the ppc64le-pr2-dynarec-infra branch from d02e0ea to 9d67773 Compare February 28, 2026 14:18
@runlevel5 runlevel5 marked this pull request as ready for review February 28, 2026 14:19
@ptitSeb
Copy link
Owner

ptitSeb commented Feb 28, 2026

Sorry, but you'll have to update from main and add uint8_t is_file_mapped:1; to your dynarec_ppc64_t type for it to build.

@runlevel5 runlevel5 force-pushed the ppc64le-pr2-dynarec-infra branch 2 times, most recently from 52308d3 to 942b062 Compare February 28, 2026 20:27
@runlevel5
Copy link
Contributor Author

@ptitSeb I have addressed all your feedbacks

Copy link
Owner

@ptitSeb ptitSeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments to address, sorry.

@runlevel5 runlevel5 marked this pull request as draft March 2, 2026 03:40
Add the core dynarec infrastructure for PPC64LE, following the
incremental approach used by the RV64 dynarec (initial commit 5a9b896).

This includes:
- PPC64LE emitter macros (ppc64le_emitter.h)
- Register mapping and private types (ppc64le_mapping.h, private.h)
- Dynarec helper macros (dynarec_ppc64le_helper.h)
- Core helper functions: geted, move32/64, jump_to_epilog/next,
  call_c/call_n, grab_segdata, emit_pf, fpu_reset_cache,
  fpu_propagate_stack (dynarec_ppc64le_helper.c)
- Architecture-specific functions: dynarec_ppc64le_arch.c
- Constants table: dynarec_ppc64le_consts.c
- Functions for FPU state management (stubbed for x87/SSE/AVX,
  following RV64 precedent of empty TODO stubs)
- Stub printer (returns '???' for all instructions)
- Assembly: prolog, epilog, next dispatcher, lock primitives
- CMakeLists.txt integration for PPC64LE dynarec
- Shared dynarec infrastructure modifications for PPC64LE support
- 3 MOV opcodes in _00.c: 0x89 (MOV Ed,Gd), 0x8B (MOV Gd,Ed),
  0x8D (LEA Gd,Ed)

FPU/x87/MMX/SSE/AVX cache management functions are stubbed with empty
bodies, matching the RV64 initial commit pattern where all FPU functions
were empty TODO stubs. These will be expanded in a follow-up PR when
the first FPU opcodes are implemented.
@runlevel5 runlevel5 force-pushed the ppc64le-pr2-dynarec-infra branch from 942b062 to 4093ed9 Compare March 2, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants