Overview
Therex::codegen::Recompiler class is the main interface for converting PowerPC binary code to C++ source code. It manages the recompilation process, output buffering, and file generation.
Class Definition
Public Members
Runtime environment for executing recompiled code
Non-owning pointer to the code generation context
Output buffer accumulating generated C++ code
Counter for generating unique C++ file names
Deferred file writes buffered until validation passes. Each pair contains (filename, content).
Tracks if validation failed during analysis
Methods
print()
Append formatted text to the output buffer.Format string using syntax
Variadic arguments to format
println()
Append formatted text with a newline to the output buffer.Format string using syntax
Variadic arguments to format
recompile() - Single Instruction
Recompile a single PowerPC instruction (internal use).Function node containing the instruction
Base address for the instruction
PowerPC instruction to recompile
Pointer to instruction data
Iterator to current jump table (if any)
Tracks which registers are used as local variables
Current control/status register state (FPU or VMX)
true on success, false on error
recompile() - Single Function
Recompile an entire function (internal use).Function node to recompile
true on success, false on error
recompile() - All Functions
Recompile all functions and write output files.If
true, generate output even if validation errors occur. If false, validation errors block code generation.true if output was generated, false if blocked due to errors
Generated code includes SDK headers (
rexglue/runtime/ppc_context.h) and follows the configured code generation options from RecompilerConfig.SaveCurrentOutData()
Save the current output buffer to pending writes.Optional custom filename. If empty, uses auto-generated name based on
cppFileIndex.FlushPendingWrites()
Write all pending files to disk. Called after validation passes.Related Types
RecompilerLocalVariables
Tracks which PowerPC registers are allocated as C++ local variables during recompilation.Bit mask where bit N indicates rN contains an MMIO base address. Set when
lis loads a value with upper 16 bits >= 0x7F00 (address >= 0x7F000000) or when oris sets upper bits >= 0xC800 (address >= 0xC8000000).CSRState
Tracks the current control/status register mode.Status register mode is unknown
Floating-point unit mode
Vector/SIMD (AltiVec) mode
Constants
Encoded instruction value for PowerPC EIEIO (Enforce In-order Execution of I/O) instruction.
See Also
- RecompilerConfig - Configuration structure
- FunctionConfig - Per-function configuration