LLVM-Z80 offers a powerful LLVM fork tailored for Zilog Z80 microprocessors, bringing modern capabilities to vintage hardware. Although still experimental, it focuses on optimized code generation, supporting a range of Z80 and compatible CPUs. This project is a unique opportunity to leverage LLVM's potential in resource-constrained environments.
LLVM-Z80 is an innovative fork of the LLVM compiler infrastructure specifically designed to support the Zilog Z80 microprocessors and their related architectures. Recognized for its high-performance features, LLVM-Z80 offers a rich set of capabilities aimed at developers looking to harness the power of modern compilation techniques for retro computing.
Key Features
- Multi-width Integer Arithmetic: Provides support for integer types up to 128 bits, facilitating complex calculations with ease.
- Floating-Point Compliance: Features half and single-precision floating-point arithmetic that adheres to the IEEE 754 standard, ensuring accurate computations.
- Dual Toolchain Support: Choose between the default ELF path using an integrated assembler and
ld.lldlinker or use the SDCC toolchain with sdasz80 and sdldz80 for other assembly requirements. - Cross-linking Capability: Allows seamless integration with SDCC-compiled code via specialized converters.
- Optimizations: Includes standard LLVM optimizations such as constant folding and dead code elimination, enhancing the performance of the generated code.
Target Platforms
LLVM-Z80 is compatible with a variety of binary-compatible CPUs including:
- Z80, Z180, eZ80
- R800, μPD780, LH0080
- SM83 (Game Boy)
- Analogue Pocket (AP)
Frontend Integration
Developers can leverage LLVM-Z80 with several programming languages:
- C/C++: Supported via Clang included in the repository (C++ support is experimental).
- Rust: Integration through llvm-z80/rust-z80.
- Potential for More: Future support anticipated for other LLVM-based languages like Zig and TinyGo.
Usage Examples
ELF Toolchain (Default):
clang --target=z80 -O1 input.c -o output.elf
llvm-objcopy -O binary output.elf output.bin
z88dk-ticks -trace output.bin
SDCC Toolchain:
clang --target=z80-unknown-none-sdcc -O1 input.c -o output.ihx
# Execute with z88dk-ticks for simulation
makebin output.ihx output.bin
z88dk-ticks -trace output.bin
These simple commands illustrate how to compile Z80 applications using LLVM-Z80, empowering developers to create efficient programs for legacy systems.
Experimental Stage
It is important to note that LLVM-Z80 is currently in an experimental phase and may not be suitable for production environments at this time. Developers seeking a stable Z80 C compiler for production purposes are advised to consider the Small Device C Compiler (SDCC).
Further resources and documentation can be found within the repository, including details on tests, utilities, and FAQs for a clearer understanding.
This project is not officially affiliated with or endorsed by the LLVM Foundation or the LLVM project, positioning itself as a community-driven effort aimed at enhancing Z80 programming.
No comments yet.
Sign in to be the first to comment.