llvm-bleach is a tool for lifting LLVM MIR files to LLVM IR. The main feature of bleach is that it has no backends inside the tool itself. It only uses platform-independent LLVM MC library information and input configuration files (that can be modified by user). Currently bleach ships with configuration files for a subset of RISC-V instructions (rv32/64 with M extension). To add any other architecture to llvm-bleach one only needs to write a configuration file describing target platform instructions. No source modification required.
You can easily build bleach with nix:
nix build .And run:
# Generate config file (optional)
result/bin/bleach-config-gen --march rv64imdf --template-dir result/share/templates -o newconfig.yaml
# Run bleach with generated config file
result/bin/llvm-bleach path/to/program.mir --instructions=newconfig.yamlYou can fetch all the required dependencies using nix
nix develop .cmake -S . -B build
cmake --build buildllvm-bleach currently comes with documentation for all of 3 distributed tools:
- llvm-bleach - LLVM MIR to LLVM IR lifter
- mctomir - machine code to MIR lifter
- bleach-config-gen - helper tool to generate architecture configs for llvm-bleach from available templates.
Currently llvm-bleach supports rv64/rv32 basic instruction sets for I configurations. Supported extensions include:
- M - Integer multiplication and division
- F - Single-precision floating-point operations
- D - Double-precision floating-point operations
Note
mctomir tool for lifting machine code to LLVM MIR potentially supports all architectures supported by LLVM but is not yet propperly tested