PowerPC Architecture
The emulated CPUs are 32-bit RISC processors:| Feature | GameCube (Gekko) | Wii (Broadway) |
|---|---|---|
| Clock Speed | 486 MHz | 729 MHz |
| Architecture | PowerPC 750CL | PowerPC 750CL-based |
| L1 Cache | 32 KB I + 32 KB D | 32 KB I + 32 KB D |
| L2 Cache | 256 KB | 512 KB |
| Paired Singles | Yes | Yes |
| SIMD | Limited | Limited |
Source/Core/Core/PowerPC/
Execution Backends
Dolphin offers multiple CPU emulation modes inPowerPC/:
- JIT (x86-64)
- JIT (ARM64)
- Cached Interpreter
- Interpreter
Location: The JIT handles:
PowerPC/Jit64/Default on x86-64 platforms. Compiles PowerPC code to native x86-64:- Block-level compilation with register allocation
- Fastmem for direct memory access (when MMU allows)
- Paired-single optimization using SSE/AVX
- Fastest execution (5-10x interpreter speed)
- Branch folding and block linking
- Constant propagation
- Register caching across instructions
- Special handling for common idioms
JIT Compilation Process
The JIT operates on blocks of PowerPC code:Block Discovery
Identify a basic block starting at PC
- Follow instructions until branch/return
- Respect block size limits
- Check for compiled block in cache
Analysis
Analyze PowerPC instructionsFile:
PowerPC/PPCAnalyst.cpp- Detect register usage
- Find memory access patterns
- Identify idle loops (for skip-idle optimization)
- Determine instruction dependencies
Compilation
Generate native code
- Allocate registers for PowerPC GPRs/FPRs
- Emit x86-64/ARM64 instructions
- Insert memory access trampolines
- Add exception handling
Register Mapping
PowerPC has extensive register state:r1(stack pointer) → native register when possibler13(small data area) → cachedf0-f31→ x87/SSE registers or stack
Memory Management Unit
Location:PowerPC/MMU.cpp
Translates virtual addresses to physical:
Address Translation
Address Translation
PowerPC uses segmented memory model:
- Segment lookup: Translate EA (effective address) to VA (virtual address)
- Page table lookup: Translate VA to PA (physical address)
- TLB caching: Translation Lookaside Buffer speeds up lookups
Fastmem
Fastmem
On x86-64/ARM64 with MMU disabled or known-safe access:
- Direct pointer to emulated RAM
- No translation overhead
- Trap SIGSEGV/EXCEPTION_ACCESS_VIOLATION for bounds checking
- 10x faster than full MMU emulation
BAT Registers
BAT Registers
Block Address Translation for large mappings:
- 4 instruction BATs (IBAT0-3)
- 4 data BATs (DBAT0-3)
- Map large regions (128 KB - 256 MB)
- Used by games for main RAM, I/O
Paired Singles
GameCube/Wii extension for SIMD floating-point:ps_add,ps_sub,ps_mul- Paired arithmeticpsq_l,psq_st- Quantized loads/storesps_merge00,ps_merge01- Shuffle operations
- x86-64: SSE instructions (2x floats per XMM register)
- ARM64: NEON instructions (2x floats per vector)
Gekko/Broadway Differences
Wii (Broadway) is mostly identical to GameCube (Gekko):| Feature | Gekko | Broadway |
|---|---|---|
| Base ISA | PowerPC 750CL | PowerPC 750CL |
| Extensions | Paired singles | Paired singles |
| Clock | 486 MHz | 729 MHz (1.5x) |
| Cache | 256 KB L2 | 512 KB L2 (2x) |
The main difference is clock speed and cache size. No new instructions were added.
Performance Optimization
Idle Skipping
Detect idle loops waiting for interrupts:- Skip ahead to next event
- Save thousands of CPU cycles
- Enabled with
SkipIdle = True
Branch Following
Compile through unconditional branches:Register Allocation
Keep PowerPC registers in native registers:- Avoid memory loads/stores
- Track liveness across block
- Spill least-used registers
Debugging CPU Emulation
Tools for CPU debugging:- Set breakpoints on PowerPC addresses
- Step through PowerPC instructions
- Inspect GPR/FPR register values
- View disassembly
Source/Core/Core/Debugger/