Megumin is a super-optimizer targeting AArch64 assemblies.
Currently it only supports integral instructions and floating point instructions (partly).
See megumin/3rd for all third-party dependencies
| Dependency | Description |
|---|---|
| Z3 | Symbolic execution |
| thread-pool | Parallel optimization |
| argparse | Parsing user arguments |
| Catch2 | Unit tests |
| keystone | Compile AArch64 assembilies to machine code |
| abseil | Large integer arithmetic |
git clone https://github.com/wormtql/megumin.git --recursive
cd meguminmkdir z3_build
mkdir z3_install
cd z3_build
cmake -DCMAKE_BUILD_TYPE=Release ../3rd/z3
cmake --build .
cmake -DCMAKE_INSTALL_PREFIX=<path_to_z3_install> -P cmake_install.cmake./build_keystone.shmkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .Same as Linux
- Download Z3 binaries
- Extract to
z3_install
- Download binary distributions from keystone
- Extract to
keystone_install - Make sure the
keystone.dlllies inkeystone_install/keystone.dll
use either cmake or Visual Studio or CLion or VS Code to build
Use xxx.exe --help to see options
Optimize a single file assemblies
| Parameter | Description |
|---|---|
| --input-file | Assembly file to be optimized |
| --correct-file | Store the optimize results |
| --error-file | Store errors |
| --time-per-opt | Time spent per basic block per launch (ms) |
| --thread-count | Specify how many threads to use |
Apply optimize result to original assembly file
| Parameter | Description |
|---|---|
| --source-file | The original assembly file |
| --output-file | The output assembly file |
| --optimizations | The optimize result, should be the output of auto-opt |