Major Infrastructure Upgrade: LLVM 21, Opaque Pointers, and GUI Tooling#291
Merged
LunaStev merged 11 commits intowavefnd:masterfrom Feb 15, 2026
Conversation
…UI build tool
This commit performs a major infrastructure upgrade to the LLVM backend,
transitioning to LLVM 21 (via Inkwell 0.8.0). The primary focus is the
implementation of "Opaque Pointer" safety, requiring explicit type
tracking throughout the codegen. It also introduces a graphical build
manager for the toolchain.
Changes:
- **LLVM Backend Upgrade**:
- Upgraded Inkwell to 0.8.0 and LLVM-sys to 211.0.0.
- Migrated from typed pointers to **Opaque Pointers**.
- Updated all `build_load`, `build_store`, and `build_gep` calls to
provide explicit LLVM types, as pointers no longer carry pointee
information.
- Refactored `address.rs` and `lvalue.rs` to infer Wave-level types
during IR generation to ensure correct instruction emission.
- **Optimization & Codegen**:
- Replaced the legacy `PassManagerBuilder` with the new LLVM **PassBuilder**,
supporting modern optimization pipelines (e.g., `default<O3>`).
- Improved aggregate handling in function calls with better size-based
packing/unpacking and bitcasting.
- Adjusted IO logic (`printf`/`scanf`) to manually track C-string
status since LLVM `ptr` is now ambiguous.
- **Lexer Refactoring**:
- Modularized the lexer by splitting logic into `core`, `cursor`,
`trivia`, `literals`, `ident`, and `scan` modules.
- Cleaned up internal imports and visibility.
- **Build System & Tooling**:
- Added a Tkinter-based **GUI Build Manager** to `x.py` for managing
targets and installations visually.
- Improved cross-compilation support in `x.py` for `x86_64-pc-windows-gnu`
targets from Linux hosts using MinGW LLVM prefixes.
- Fixed target directory pathing in the backend.
- **Bug Fixes**:
- Fixed type promotion for C varargs in `printf` (e.g., promoting small
integers to `i32` and floats to `double`).
This update modernizes the compiler backend and prepares the architecture
for future LLVM versions while providing a more user-friendly build
interface.
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
Signed-off-by: LunaStev <luna@lunastev.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR represents a major leap in the Wave compiler's infrastructure. It upgrades the core backend to LLVM 21 and completes the migration to Opaque Pointers, which is now the standard in modern LLVM. Additionally, the lexer has been fully modularized, and a new graphical build manager has been added to the toolchain to improve the developer experience.
Key Changes
1. LLVM 21 & Opaque Pointer Migration
inkwellto0.8.0andllvm-systo211.0.0to support LLVM 21.i32*is now justptr), the backend has been refactored to explicitly track and provide types for all memory operations.build_load,build_store, andbuild_gepcalls project-wide to include explicit LLVM types.address.rsandlvalue.rsto ensure Wave-level type information is correctly mapped to these new opaque pointer instructions.PassManagerBuilderto the modern LLVM PassBuilder, enabling more efficient optimization passes (up toO3) and better alignment with current LLVM standards.2. Lexer Modularization
The lexer has been decomposed into specialized submodules for better maintainability:
core/cursor: Foundational types and source navigation.scan/ident: Token dispatch and keyword mapping.literals/trivia: Detailed parsing for strings/chars and whitespace/comment handling.3. GUI Build Manager & Tooling
x.pyscript. Developers can now manage build targets, installations, and configurations through a visual window.x.pylogic to support cross-compiling forx86_64-pc-windows-gnufrom Linux hosts using MinGW LLVM prefixes.target/directory structure.4. Bug Fixes & ABI Compliance
printf. Small integers are now promoted toi32and floats todouble, ensuring C ABI compliance.printfandscanflogic to manually track C-string status, as the opaqueptrtype no longer distinguishes between string buffers and other memory pointers.Example Impact
LLVM IR Change (Opaque Pointers):
Benefits