recompile-tests command generates Catch2 test cases from PowerPC assembly source files with embedded test specifications. This is used for validating the recompiler’s correctness.
This command is primarily for ReXGlue SDK development and testing the recompiler itself. End-user projects typically don’t need this command.
Usage
Required Flags
Directory containing linked
.bin and .map filesThese are PowerPC binaries linked at address 0x82010000 (matching the -Ttext linker flag).Directory containing
.s assembly source filesAssembly files must include test specification comments (#_REGISTER_IN, #_REGISTER_OUT, etc.).Output directory for generated test codeThe command generates:
ppc_config.h- Test memory layout configurationppc_test_functions.cpp- Recompiled PPC functionsppc_test_cases.cpp- Catch2 test casesppc_test_decls.h- Function declarations
Test Specification Format
Assembly files use special comments to specify test cases:Supported Test Directives
#_REGISTER_IN <reg> <value>- Set register before function call#_REGISTER_OUT <reg> <value>- Assert register after function call#_MEMORY_IN <addr> <hex bytes>- Initialize memory before function call#_MEMORY_OUT <addr> <hex bytes>- Assert memory after function call
Register Types
- General purpose:
r0-r31(64-bit integer values) - Floating point:
f0-f31(64-bit floating point, use decimal notation) - Vector:
v0-v127(128-bit, four 32-bit values in[w3, w2, w1, w0]order) - Condition register:
cr(32-bit combined condition flags)
Examples
Basic Test Generation
Generated Output
ppc_config.h
Defines the memory layout for test execution:ppc_test_functions.cpp
Contains recompiled PPC functions:ppc_test_cases.cpp
Generated Catch2 test cases:ppc_test_decls.h
Function declarations for test cases:Building Test Binaries
The.bin and .map files are typically generated from assembly sources using a PowerPC cross-compiler:
Running Generated Tests
The generated test files integrate with Catch2:Test Categories
Tests are automatically tagged based on file naming:| File Pattern | Category | Description |
|---|---|---|
*add*, *sub*, *mul*, *div* | arithmetic | Integer arithmetic |
*cmp* | comparison | Comparison operations |
*and*, *or*, *xor*, *rl* | logical | Logical and rotate |
f*, *_f* | floating_point | Floating point operations |
v*, *_v* | vector | VMX/AltiVec vector operations |
l*, st* | memory | Load/store operations |
| Other | misc | Miscellaneous instructions |
Common Errors
Missing Required Flags
No Symbols in Map File
nm format with symbols at the correct base address.
Test Recompilation Failed
Limitations
- Fixed base address: Tests must be linked at
0x82010000 - No imports: Test functions cannot call external libraries
- Single module: All test functions must be self-contained
- No OS calls: Tests run in isolated memory without kernel/OS support
Use Cases
- Recompiler validation - Ensure instructions are recompiled correctly
- Regression testing - Catch recompiler bugs during development
- Instruction coverage - Track which PPC instructions are implemented
- Accuracy testing - Verify edge cases and corner conditions
Next Steps
- Review Recompiler Architecture
- Learn about PPC Instruction Set
- Understand Testing Strategy